13b3a8eb9SGleb Smirnoff /* $OpenBSD: pfctl_parser.h,v 1.86 2006/10/31 23:46:25 mcbride Exp $ */ 23b3a8eb9SGleb Smirnoff 31de7b4b8SPedro F. Giffuni /*- 41de7b4b8SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause 51de7b4b8SPedro F. Giffuni * 63b3a8eb9SGleb Smirnoff * Copyright (c) 2001 Daniel Hartmeier 73b3a8eb9SGleb Smirnoff * All rights reserved. 83b3a8eb9SGleb Smirnoff * 93b3a8eb9SGleb Smirnoff * Redistribution and use in source and binary forms, with or without 103b3a8eb9SGleb Smirnoff * modification, are permitted provided that the following conditions 113b3a8eb9SGleb Smirnoff * are met: 123b3a8eb9SGleb Smirnoff * 133b3a8eb9SGleb Smirnoff * - Redistributions of source code must retain the above copyright 143b3a8eb9SGleb Smirnoff * notice, this list of conditions and the following disclaimer. 153b3a8eb9SGleb Smirnoff * - Redistributions in binary form must reproduce the above 163b3a8eb9SGleb Smirnoff * copyright notice, this list of conditions and the following 173b3a8eb9SGleb Smirnoff * disclaimer in the documentation and/or other materials provided 183b3a8eb9SGleb Smirnoff * with the distribution. 193b3a8eb9SGleb Smirnoff * 203b3a8eb9SGleb Smirnoff * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 213b3a8eb9SGleb Smirnoff * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 223b3a8eb9SGleb Smirnoff * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 233b3a8eb9SGleb Smirnoff * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 243b3a8eb9SGleb Smirnoff * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 253b3a8eb9SGleb Smirnoff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 263b3a8eb9SGleb Smirnoff * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 273b3a8eb9SGleb Smirnoff * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 283b3a8eb9SGleb Smirnoff * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 293b3a8eb9SGleb Smirnoff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 303b3a8eb9SGleb Smirnoff * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 313b3a8eb9SGleb Smirnoff * POSSIBILITY OF SUCH DAMAGE. 323b3a8eb9SGleb Smirnoff */ 333b3a8eb9SGleb Smirnoff 343b3a8eb9SGleb Smirnoff #ifndef _PFCTL_PARSER_H_ 353b3a8eb9SGleb Smirnoff #define _PFCTL_PARSER_H_ 363b3a8eb9SGleb Smirnoff 37e9eb0941SKristof Provost #include <libpfctl.h> 38e9eb0941SKristof Provost 393b3a8eb9SGleb Smirnoff #define PF_OSFP_FILE "/etc/pf.os" 403b3a8eb9SGleb Smirnoff 413b3a8eb9SGleb Smirnoff #define PF_OPT_DISABLE 0x0001 423b3a8eb9SGleb Smirnoff #define PF_OPT_ENABLE 0x0002 433b3a8eb9SGleb Smirnoff #define PF_OPT_VERBOSE 0x0004 443b3a8eb9SGleb Smirnoff #define PF_OPT_NOACTION 0x0008 453b3a8eb9SGleb Smirnoff #define PF_OPT_QUIET 0x0010 463b3a8eb9SGleb Smirnoff #define PF_OPT_CLRRULECTRS 0x0020 473b3a8eb9SGleb Smirnoff #define PF_OPT_USEDNS 0x0040 483b3a8eb9SGleb Smirnoff #define PF_OPT_VERBOSE2 0x0080 493b3a8eb9SGleb Smirnoff #define PF_OPT_DUMMYACTION 0x0100 503b3a8eb9SGleb Smirnoff #define PF_OPT_DEBUG 0x0200 513b3a8eb9SGleb Smirnoff #define PF_OPT_SHOWALL 0x0400 523b3a8eb9SGleb Smirnoff #define PF_OPT_OPTIMIZE 0x0800 533b3a8eb9SGleb Smirnoff #define PF_OPT_NUMERIC 0x1000 543b3a8eb9SGleb Smirnoff #define PF_OPT_MERGE 0x2000 553b3a8eb9SGleb Smirnoff #define PF_OPT_RECURSE 0x4000 5693abcf17SKristof Provost #define PF_OPT_KILLMATCH 0x8000 573b3a8eb9SGleb Smirnoff 583b3a8eb9SGleb Smirnoff #define PF_NAT_PROXY_PORT_LOW 50001 593b3a8eb9SGleb Smirnoff #define PF_NAT_PROXY_PORT_HIGH 65535 603b3a8eb9SGleb Smirnoff 613b3a8eb9SGleb Smirnoff #define PF_OPTIMIZE_BASIC 0x0001 623b3a8eb9SGleb Smirnoff #define PF_OPTIMIZE_PROFILE 0x0002 633b3a8eb9SGleb Smirnoff 643b3a8eb9SGleb Smirnoff #define FCNT_NAMES { \ 653b3a8eb9SGleb Smirnoff "searches", \ 663b3a8eb9SGleb Smirnoff "inserts", \ 673b3a8eb9SGleb Smirnoff "removals", \ 683b3a8eb9SGleb Smirnoff NULL \ 693b3a8eb9SGleb Smirnoff } 703b3a8eb9SGleb Smirnoff 713b3a8eb9SGleb Smirnoff struct pfr_buffer; /* forward definition */ 723b3a8eb9SGleb Smirnoff 733b3a8eb9SGleb Smirnoff 743b3a8eb9SGleb Smirnoff struct pfctl { 753b3a8eb9SGleb Smirnoff int dev; 76f1612e70SKristof Provost struct pfctl_handle *h; 773b3a8eb9SGleb Smirnoff int opts; 783b3a8eb9SGleb Smirnoff int optimize; 793b3a8eb9SGleb Smirnoff int loadopt; 803b3a8eb9SGleb Smirnoff int asd; /* anchor stack depth */ 813b3a8eb9SGleb Smirnoff int bn; /* brace number */ 823b3a8eb9SGleb Smirnoff int tdirty; /* kernel dirty */ 833b3a8eb9SGleb Smirnoff #define PFCTL_ANCHOR_STACK_DEPTH 64 84e9eb0941SKristof Provost struct pfctl_anchor *astack[PFCTL_ANCHOR_STACK_DEPTH]; 853b3a8eb9SGleb Smirnoff struct pfioc_pooladdr paddr; 863b3a8eb9SGleb Smirnoff struct pfioc_altq *paltq; 873b3a8eb9SGleb Smirnoff struct pfioc_queue *pqueue; 883b3a8eb9SGleb Smirnoff struct pfr_buffer *trans; 89e9eb0941SKristof Provost struct pfctl_anchor *anchor, *alast; 902b29ceb8SKristof Provost int eth_nr; 91c5131afeSKristof Provost struct pfctl_eth_anchor *eanchor, *ealast; 92c5131afeSKristof Provost struct pfctl_eth_anchor *eastack[PFCTL_ANCHOR_STACK_DEPTH]; 932b29ceb8SKristof Provost u_int32_t eth_ticket; 943b3a8eb9SGleb Smirnoff const char *ruleset; 953b3a8eb9SGleb Smirnoff 963b3a8eb9SGleb Smirnoff /* 'set foo' options */ 973b3a8eb9SGleb Smirnoff u_int32_t timeout[PFTM_MAX]; 983b3a8eb9SGleb Smirnoff u_int32_t limit[PF_LIMIT_MAX]; 993b3a8eb9SGleb Smirnoff u_int32_t debug; 1003b3a8eb9SGleb Smirnoff u_int32_t hostid; 10139282ef3SKajetan Staszkiewicz u_int32_t reassemble; 1023b3a8eb9SGleb Smirnoff char *ifname; 10342ec75f8SKristof Provost bool keep_counters; 104c69121c4SKristof Provost u_int8_t syncookies; 1055062afffSKristof Provost u_int8_t syncookieswat[2]; /* lowat, highwat, in % */ 1065062afffSKristof Provost u_int8_t syncookieswat_set; 1073b3a8eb9SGleb Smirnoff 1083b3a8eb9SGleb Smirnoff u_int8_t timeout_set[PFTM_MAX]; 1093b3a8eb9SGleb Smirnoff u_int8_t limit_set[PF_LIMIT_MAX]; 1103b3a8eb9SGleb Smirnoff u_int8_t debug_set; 1113b3a8eb9SGleb Smirnoff u_int8_t hostid_set; 1123b3a8eb9SGleb Smirnoff u_int8_t ifname_set; 11339282ef3SKajetan Staszkiewicz u_int8_t reass_set; 1143b3a8eb9SGleb Smirnoff }; 1153b3a8eb9SGleb Smirnoff 1163b3a8eb9SGleb Smirnoff struct node_if { 1173b3a8eb9SGleb Smirnoff char ifname[IFNAMSIZ]; 1183b3a8eb9SGleb Smirnoff u_int8_t not; 1193b3a8eb9SGleb Smirnoff u_int8_t dynamic; /* antispoof */ 1203b3a8eb9SGleb Smirnoff u_int ifa_flags; 1213b3a8eb9SGleb Smirnoff struct node_if *next; 1223b3a8eb9SGleb Smirnoff struct node_if *tail; 1233b3a8eb9SGleb Smirnoff }; 1243b3a8eb9SGleb Smirnoff 1253b3a8eb9SGleb Smirnoff struct node_host { 1263b3a8eb9SGleb Smirnoff struct pf_addr_wrap addr; 1273b3a8eb9SGleb Smirnoff struct pf_addr bcast; 1283b3a8eb9SGleb Smirnoff struct pf_addr peer; 1293b3a8eb9SGleb Smirnoff sa_family_t af; 1303b3a8eb9SGleb Smirnoff u_int8_t not; 1313b3a8eb9SGleb Smirnoff u_int32_t ifindex; /* link-local IPv6 addrs */ 1323b3a8eb9SGleb Smirnoff char *ifname; 1333b3a8eb9SGleb Smirnoff u_int ifa_flags; 1343b3a8eb9SGleb Smirnoff struct node_host *next; 1353b3a8eb9SGleb Smirnoff struct node_host *tail; 1363b3a8eb9SGleb Smirnoff }; 1373b3a8eb9SGleb Smirnoff 138637d81c5SKristof Provost void freehostlist(struct node_host *); 139637d81c5SKristof Provost 14087a89d6eSKristof Provost struct node_mac { 14187a89d6eSKristof Provost u_int8_t mac[ETHER_ADDR_LEN]; 142b590f17aSKristof Provost u_int8_t mask[ETHER_ADDR_LEN]; 14387a89d6eSKristof Provost bool neg; 144c32cd180SKristof Provost bool isset; 14587a89d6eSKristof Provost struct node_mac *next; 14687a89d6eSKristof Provost struct node_mac *tail; 14787a89d6eSKristof Provost }; 14887a89d6eSKristof Provost 1493b3a8eb9SGleb Smirnoff struct node_os { 1503b3a8eb9SGleb Smirnoff char *os; 1513b3a8eb9SGleb Smirnoff pf_osfp_t fingerprint; 1523b3a8eb9SGleb Smirnoff struct node_os *next; 1533b3a8eb9SGleb Smirnoff struct node_os *tail; 1543b3a8eb9SGleb Smirnoff }; 1553b3a8eb9SGleb Smirnoff 1563b3a8eb9SGleb Smirnoff struct node_queue_bw { 157249cc75fSPatrick Kelsey u_int64_t bw_absolute; 1583b3a8eb9SGleb Smirnoff u_int16_t bw_percent; 1593b3a8eb9SGleb Smirnoff }; 1603b3a8eb9SGleb Smirnoff 1613b3a8eb9SGleb Smirnoff struct node_hfsc_sc { 1623b3a8eb9SGleb Smirnoff struct node_queue_bw m1; /* slope of 1st segment; bps */ 1633b3a8eb9SGleb Smirnoff u_int d; /* x-projection of m1; msec */ 1643b3a8eb9SGleb Smirnoff struct node_queue_bw m2; /* slope of 2nd segment; bps */ 1653b3a8eb9SGleb Smirnoff u_int8_t used; 1663b3a8eb9SGleb Smirnoff }; 1673b3a8eb9SGleb Smirnoff 1683b3a8eb9SGleb Smirnoff struct node_hfsc_opts { 1693b3a8eb9SGleb Smirnoff struct node_hfsc_sc realtime; 1703b3a8eb9SGleb Smirnoff struct node_hfsc_sc linkshare; 1713b3a8eb9SGleb Smirnoff struct node_hfsc_sc upperlimit; 1723b3a8eb9SGleb Smirnoff int flags; 1733b3a8eb9SGleb Smirnoff }; 1743b3a8eb9SGleb Smirnoff 175a5b789f6SErmal Luçi struct node_fairq_sc { 176a5b789f6SErmal Luçi struct node_queue_bw m1; /* slope of 1st segment; bps */ 177a5b789f6SErmal Luçi u_int d; /* x-projection of m1; msec */ 178a5b789f6SErmal Luçi struct node_queue_bw m2; /* slope of 2nd segment; bps */ 179a5b789f6SErmal Luçi u_int8_t used; 180a5b789f6SErmal Luçi }; 181a5b789f6SErmal Luçi 182a5b789f6SErmal Luçi struct node_fairq_opts { 183a5b789f6SErmal Luçi struct node_fairq_sc linkshare; 184a5b789f6SErmal Luçi struct node_queue_bw hogs_bw; 185a5b789f6SErmal Luçi u_int nbuckets; 186a5b789f6SErmal Luçi int flags; 187a5b789f6SErmal Luçi }; 188a5b789f6SErmal Luçi 1893b3a8eb9SGleb Smirnoff struct node_queue_opt { 1903b3a8eb9SGleb Smirnoff int qtype; 1913b3a8eb9SGleb Smirnoff union { 1923b3a8eb9SGleb Smirnoff struct cbq_opts cbq_opts; 1930a70aaf8SLuiz Otavio O Souza struct codel_opts codel_opts; 1943b3a8eb9SGleb Smirnoff struct priq_opts priq_opts; 1953b3a8eb9SGleb Smirnoff struct node_hfsc_opts hfsc_opts; 196a5b789f6SErmal Luçi struct node_fairq_opts fairq_opts; 1973b3a8eb9SGleb Smirnoff } data; 1983b3a8eb9SGleb Smirnoff }; 1993b3a8eb9SGleb Smirnoff 2001d34c9daSPatrick Kelsey #define QPRI_BITSET_SIZE 256 2015e04571cSStefan Eßer __BITSET_DEFINE(qpri_bitset, QPRI_BITSET_SIZE); 2021d34c9daSPatrick Kelsey LIST_HEAD(gen_sc, segment); 2031d34c9daSPatrick Kelsey 2041d34c9daSPatrick Kelsey struct pfctl_altq { 2051d34c9daSPatrick Kelsey struct pf_altq pa; 2061d34c9daSPatrick Kelsey struct { 2071d34c9daSPatrick Kelsey STAILQ_ENTRY(pfctl_altq) link; 2081d34c9daSPatrick Kelsey u_int64_t bwsum; 2091d34c9daSPatrick Kelsey struct qpri_bitset qpris; 2101d34c9daSPatrick Kelsey int children; 2111d34c9daSPatrick Kelsey int root_classes; 2121d34c9daSPatrick Kelsey int default_classes; 2131d34c9daSPatrick Kelsey struct gen_sc lssc; 2141d34c9daSPatrick Kelsey struct gen_sc rtsc; 2151d34c9daSPatrick Kelsey } meta; 2161d34c9daSPatrick Kelsey }; 2171d34c9daSPatrick Kelsey 2185062afffSKristof Provost struct pfctl_watermarks { 2195062afffSKristof Provost uint32_t hi; 2205062afffSKristof Provost uint32_t lo; 2215062afffSKristof Provost }; 2225062afffSKristof Provost 2233b3a8eb9SGleb Smirnoff #ifdef __FreeBSD__ 2243b3a8eb9SGleb Smirnoff /* 2253b3a8eb9SGleb Smirnoff * XXX 2263b3a8eb9SGleb Smirnoff * Absolutely this is not correct location to define this. 2273b3a8eb9SGleb Smirnoff * Should we use an another sperate header file? 2283b3a8eb9SGleb Smirnoff */ 2293b3a8eb9SGleb Smirnoff #define SIMPLEQ_HEAD STAILQ_HEAD 2303b3a8eb9SGleb Smirnoff #define SIMPLEQ_HEAD_INITIALIZER STAILQ_HEAD_INITIALIZER 2313b3a8eb9SGleb Smirnoff #define SIMPLEQ_ENTRY STAILQ_ENTRY 2323b3a8eb9SGleb Smirnoff #define SIMPLEQ_FIRST STAILQ_FIRST 2333b3a8eb9SGleb Smirnoff #define SIMPLEQ_END(head) NULL 2343b3a8eb9SGleb Smirnoff #define SIMPLEQ_EMPTY STAILQ_EMPTY 2353b3a8eb9SGleb Smirnoff #define SIMPLEQ_NEXT STAILQ_NEXT 2363b3a8eb9SGleb Smirnoff /*#define SIMPLEQ_FOREACH STAILQ_FOREACH*/ 2373b3a8eb9SGleb Smirnoff #define SIMPLEQ_FOREACH(var, head, field) \ 2383b3a8eb9SGleb Smirnoff for((var) = SIMPLEQ_FIRST(head); \ 2393b3a8eb9SGleb Smirnoff (var) != SIMPLEQ_END(head); \ 2403b3a8eb9SGleb Smirnoff (var) = SIMPLEQ_NEXT(var, field)) 2413b3a8eb9SGleb Smirnoff #define SIMPLEQ_INIT STAILQ_INIT 2423b3a8eb9SGleb Smirnoff #define SIMPLEQ_INSERT_HEAD STAILQ_INSERT_HEAD 2433b3a8eb9SGleb Smirnoff #define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL 2443b3a8eb9SGleb Smirnoff #define SIMPLEQ_INSERT_AFTER STAILQ_INSERT_AFTER 2453b3a8eb9SGleb Smirnoff #define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD 2463b3a8eb9SGleb Smirnoff #endif 2473b3a8eb9SGleb Smirnoff SIMPLEQ_HEAD(node_tinithead, node_tinit); 2483b3a8eb9SGleb Smirnoff struct node_tinit { /* table initializer */ 2493b3a8eb9SGleb Smirnoff SIMPLEQ_ENTRY(node_tinit) entries; 2503b3a8eb9SGleb Smirnoff struct node_host *host; 2513b3a8eb9SGleb Smirnoff char *file; 2523b3a8eb9SGleb Smirnoff }; 2533b3a8eb9SGleb Smirnoff 2543b3a8eb9SGleb Smirnoff 2553b3a8eb9SGleb Smirnoff /* optimizer created tables */ 2563b3a8eb9SGleb Smirnoff struct pf_opt_tbl { 2573b3a8eb9SGleb Smirnoff char pt_name[PF_TABLE_NAME_SIZE]; 2583b3a8eb9SGleb Smirnoff int pt_rulecount; 2593b3a8eb9SGleb Smirnoff int pt_generated; 2603b3a8eb9SGleb Smirnoff struct node_tinithead pt_nodes; 2613b3a8eb9SGleb Smirnoff struct pfr_buffer *pt_buf; 2623b3a8eb9SGleb Smirnoff }; 2633b3a8eb9SGleb Smirnoff #define PF_OPT_TABLE_PREFIX "__automatic_" 2643b3a8eb9SGleb Smirnoff 2653b3a8eb9SGleb Smirnoff /* optimizer pf_rule container */ 2663b3a8eb9SGleb Smirnoff struct pf_opt_rule { 267e9eb0941SKristof Provost struct pfctl_rule por_rule; 2683b3a8eb9SGleb Smirnoff struct pf_opt_tbl *por_src_tbl; 2693b3a8eb9SGleb Smirnoff struct pf_opt_tbl *por_dst_tbl; 2703b3a8eb9SGleb Smirnoff u_int64_t por_profile_count; 2713b3a8eb9SGleb Smirnoff TAILQ_ENTRY(pf_opt_rule) por_entry; 2723b3a8eb9SGleb Smirnoff TAILQ_ENTRY(pf_opt_rule) por_skip_entry[PF_SKIP_COUNT]; 2733b3a8eb9SGleb Smirnoff }; 2743b3a8eb9SGleb Smirnoff 2753b3a8eb9SGleb Smirnoff TAILQ_HEAD(pf_opt_queue, pf_opt_rule); 2763b3a8eb9SGleb Smirnoff 2773b3a8eb9SGleb Smirnoff int pfctl_rules(int, char *, int, int, char *, struct pfr_buffer *); 278e9eb0941SKristof Provost int pfctl_optimize_ruleset(struct pfctl *, struct pfctl_ruleset *); 2793b3a8eb9SGleb Smirnoff 280*aeddee83SKajetan Staszkiewicz void pfctl_init_rule(struct pfctl_rule *r); 281e9eb0941SKristof Provost int pfctl_append_rule(struct pfctl *, struct pfctl_rule *, const char *); 282c5131afeSKristof Provost int pfctl_append_eth_rule(struct pfctl *, struct pfctl_eth_rule *, 283c5131afeSKristof Provost const char *); 2843b3a8eb9SGleb Smirnoff int pfctl_add_altq(struct pfctl *, struct pf_altq *); 285e11dacbfSKristof Provost int pfctl_add_pool(struct pfctl *, struct pfctl_pool *, sa_family_t, int); 286600bd6ceSKurosawa Takahiro void pfctl_move_pool(struct pfctl_pool *, struct pfctl_pool *); 287600bd6ceSKurosawa Takahiro void pfctl_clear_pool(struct pfctl_pool *); 2883b3a8eb9SGleb Smirnoff 28930bad751SKristof Provost int pfctl_apply_timeout(struct pfctl *, const char *, int, int); 29039282ef3SKajetan Staszkiewicz int pfctl_set_reassembly(struct pfctl *, int, int); 2913b3a8eb9SGleb Smirnoff int pfctl_set_optimization(struct pfctl *, const char *); 292d9ab8999SKristof Provost int pfctl_apply_limit(struct pfctl *, const char *, unsigned int); 2933b3a8eb9SGleb Smirnoff int pfctl_set_logif(struct pfctl *, char *); 2944aafc73dSKristof Provost void pfctl_set_hostid(struct pfctl *, u_int32_t); 295c36c90a2SKristof Provost int pfctl_do_set_debug(struct pfctl *, char *); 2963b3a8eb9SGleb Smirnoff int pfctl_set_interface_flags(struct pfctl *, char *, int, int); 2975062afffSKristof Provost int pfctl_cfg_syncookies(struct pfctl *, uint8_t, struct pfctl_watermarks *); 2983b3a8eb9SGleb Smirnoff 2993b3a8eb9SGleb Smirnoff int parse_config(char *, struct pfctl *); 3003b3a8eb9SGleb Smirnoff int parse_flags(char *); 3013b3a8eb9SGleb Smirnoff int pfctl_load_anchors(int, struct pfctl *, struct pfr_buffer *); 3023b3a8eb9SGleb Smirnoff 303600bd6ceSKurosawa Takahiro void print_pool(struct pfctl_pool *, u_int16_t, u_int16_t, sa_family_t, int); 3049c125336SKristof Provost void print_src_node(struct pfctl_src_node *, int); 305c5131afeSKristof Provost void print_eth_rule(struct pfctl_eth_rule *, const char *, int); 306e9eb0941SKristof Provost void print_rule(struct pfctl_rule *, const char *, int, int); 3073b3a8eb9SGleb Smirnoff void print_tabledef(const char *, int, int, struct node_tinithead *); 30880078d9dSKristof Provost void print_status(struct pfctl_status *, struct pfctl_syncookies *, int); 30980078d9dSKristof Provost void print_running(struct pfctl_status *); 3103b3a8eb9SGleb Smirnoff 3113b3a8eb9SGleb Smirnoff int eval_pfaltq(struct pfctl *, struct pf_altq *, struct node_queue_bw *, 3123b3a8eb9SGleb Smirnoff struct node_queue_opt *); 3133b3a8eb9SGleb Smirnoff int eval_pfqueue(struct pfctl *, struct pf_altq *, struct node_queue_bw *, 3143b3a8eb9SGleb Smirnoff struct node_queue_opt *); 3153b3a8eb9SGleb Smirnoff 3163b3a8eb9SGleb Smirnoff void print_altq(const struct pf_altq *, unsigned, struct node_queue_bw *, 3173b3a8eb9SGleb Smirnoff struct node_queue_opt *); 3183b3a8eb9SGleb Smirnoff void print_queue(const struct pf_altq *, unsigned, struct node_queue_bw *, 3193b3a8eb9SGleb Smirnoff int, struct node_queue_opt *); 3203b3a8eb9SGleb Smirnoff 3213b3a8eb9SGleb Smirnoff int pfctl_define_table(char *, int, int, const char *, struct pfr_buffer *, 3223b3a8eb9SGleb Smirnoff u_int32_t); 3233b3a8eb9SGleb Smirnoff 3243b3a8eb9SGleb Smirnoff void pfctl_clear_fingerprints(int, int); 3253b3a8eb9SGleb Smirnoff int pfctl_file_fingerprints(int, int, const char *); 3263b3a8eb9SGleb Smirnoff pf_osfp_t pfctl_get_fingerprint(const char *); 3273b3a8eb9SGleb Smirnoff int pfctl_load_fingerprints(int, int); 3283b3a8eb9SGleb Smirnoff char *pfctl_lookup_fingerprint(pf_osfp_t, char *, size_t); 3293b3a8eb9SGleb Smirnoff void pfctl_show_fingerprints(int); 3303b3a8eb9SGleb Smirnoff 3313b3a8eb9SGleb Smirnoff 3323b3a8eb9SGleb Smirnoff struct icmptypeent { 3333b3a8eb9SGleb Smirnoff const char *name; 3343b3a8eb9SGleb Smirnoff u_int8_t type; 3353b3a8eb9SGleb Smirnoff }; 3363b3a8eb9SGleb Smirnoff 3373b3a8eb9SGleb Smirnoff struct icmpcodeent { 3383b3a8eb9SGleb Smirnoff const char *name; 3393b3a8eb9SGleb Smirnoff u_int8_t type; 3403b3a8eb9SGleb Smirnoff u_int8_t code; 3413b3a8eb9SGleb Smirnoff }; 3423b3a8eb9SGleb Smirnoff 343dbce131bSKristof Provost const struct icmptypeent *geticmptypebynumber(u_int8_t, sa_family_t); 344dbce131bSKristof Provost const struct icmptypeent *geticmptypebyname(char *, sa_family_t); 345dbce131bSKristof Provost const struct icmpcodeent *geticmpcodebynumber(u_int8_t, u_int8_t, sa_family_t); 346dbce131bSKristof Provost const struct icmpcodeent *geticmpcodebyname(u_long, char *, sa_family_t); 3473b3a8eb9SGleb Smirnoff 3483b3a8eb9SGleb Smirnoff struct pf_timeout { 3493b3a8eb9SGleb Smirnoff const char *name; 3503b3a8eb9SGleb Smirnoff int timeout; 3513b3a8eb9SGleb Smirnoff }; 3523b3a8eb9SGleb Smirnoff 3533b3a8eb9SGleb Smirnoff #define PFCTL_FLAG_FILTER 0x02 3543b3a8eb9SGleb Smirnoff #define PFCTL_FLAG_NAT 0x04 3553b3a8eb9SGleb Smirnoff #define PFCTL_FLAG_OPTION 0x08 3563b3a8eb9SGleb Smirnoff #define PFCTL_FLAG_ALTQ 0x10 3573b3a8eb9SGleb Smirnoff #define PFCTL_FLAG_TABLE 0x20 3582b29ceb8SKristof Provost #define PFCTL_FLAG_ETH 0x40 3593b3a8eb9SGleb Smirnoff 3603b3a8eb9SGleb Smirnoff extern const struct pf_timeout pf_timeouts[]; 3613b3a8eb9SGleb Smirnoff 3623b3a8eb9SGleb Smirnoff void set_ipmask(struct node_host *, u_int8_t); 3633b3a8eb9SGleb Smirnoff int check_netmask(struct node_host *, sa_family_t); 3643b3a8eb9SGleb Smirnoff int unmask(struct pf_addr *, sa_family_t); 3657ce98cf2SKristof Provost struct node_host *gen_dynnode(struct node_host *, sa_family_t); 3663b3a8eb9SGleb Smirnoff void ifa_load(void); 3677cef9d19SKristof Provost unsigned int ifa_nametoindex(const char *); 3687cef9d19SKristof Provost char *ifa_indextoname(unsigned int, char *); 3691d34c9daSPatrick Kelsey int get_query_socket(void); 3701d34c9daSPatrick Kelsey struct node_host *ifa_exists(char *); 3711d34c9daSPatrick Kelsey struct node_host *ifa_grouplookup(char *ifa_name, int flags); 3721d34c9daSPatrick Kelsey struct node_host *ifa_lookup(char *, int); 3733b3a8eb9SGleb Smirnoff struct node_host *host(const char *); 3743b3a8eb9SGleb Smirnoff 3753b3a8eb9SGleb Smirnoff int append_addr(struct pfr_buffer *, char *, int); 3763b3a8eb9SGleb Smirnoff int append_addr_host(struct pfr_buffer *, 3773b3a8eb9SGleb Smirnoff struct node_host *, int, int); 3783b3a8eb9SGleb Smirnoff 3793b3a8eb9SGleb Smirnoff #endif /* _PFCTL_PARSER_H_ */ 380