pfctl.h revision 330449
1/* $OpenBSD: pfctl.h,v 1.42 2007/12/05 12:01:47 chl Exp $ */ 2 3/*- 4 * SPDX-License-Identifier: BSD-2-Clause 5 * 6 * Copyright (c) 2001 Daniel Hartmeier 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * - Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * - Redistributions in binary form must reproduce the above 16 * copyright notice, this list of conditions and the following 17 * disclaimer in the documentation and/or other materials provided 18 * with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * 33 * $FreeBSD: stable/11/sbin/pfctl/pfctl.h 330449 2018-03-05 07:26:05Z eadler $ 34 */ 35 36#ifndef _PFCTL_H_ 37#define _PFCTL_H_ 38 39enum pfctl_show { PFCTL_SHOW_RULES, PFCTL_SHOW_LABELS, PFCTL_SHOW_NOTHING }; 40 41enum { PFRB_TABLES = 1, PFRB_TSTATS, PFRB_ADDRS, PFRB_ASTATS, 42 PFRB_IFACES, PFRB_TRANS, PFRB_MAX }; 43struct pfr_buffer { 44 int pfrb_type; /* type of content, see enum above */ 45 int pfrb_size; /* number of objects in buffer */ 46 int pfrb_msize; /* maximum number of objects in buffer */ 47 void *pfrb_caddr; /* malloc'ated memory area */ 48}; 49#define PFRB_FOREACH(var, buf) \ 50 for ((var) = pfr_buf_next((buf), NULL); \ 51 (var) != NULL; \ 52 (var) = pfr_buf_next((buf), (var))) 53 54int pfr_get_fd(void); 55int pfr_clr_tables(struct pfr_table *, int *, int); 56int pfr_add_tables(struct pfr_table *, int, int *, int); 57int pfr_del_tables(struct pfr_table *, int, int *, int); 58int pfr_get_tables(struct pfr_table *, struct pfr_table *, int *, int); 59int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int); 60int pfr_clr_tstats(struct pfr_table *, int, int *, int); 61int pfr_clr_addrs(struct pfr_table *, int *, int); 62int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int); 63int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int); 64int pfr_set_addrs(struct pfr_table *, struct pfr_addr *, int, int *, 65 int *, int *, int *, int); 66int pfr_get_addrs(struct pfr_table *, struct pfr_addr *, int *, int); 67int pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int); 68int pfr_tst_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int); 69int pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *, 70 int *, int, int); 71void pfr_buf_clear(struct pfr_buffer *); 72int pfr_buf_add(struct pfr_buffer *, const void *); 73void *pfr_buf_next(struct pfr_buffer *, const void *); 74int pfr_buf_grow(struct pfr_buffer *, int); 75int pfr_buf_load(struct pfr_buffer *, char *, int, 76 int (*)(struct pfr_buffer *, char *, int)); 77char *pfr_strerror(int); 78int pfi_get_ifaces(const char *, struct pfi_kif *, int *); 79int pfi_clr_istats(const char *, int *, int); 80 81void pfctl_print_title(char *); 82int pfctl_clear_tables(const char *, int); 83int pfctl_show_tables(const char *, int); 84int pfctl_command_tables(int, char *[], char *, const char *, char *, 85 const char *, int); 86int pfctl_show_altq(int, const char *, int, int); 87void warn_namespace_collision(const char *); 88int pfctl_show_ifaces(const char *, int); 89FILE *pfctl_fopen(const char *, const char *); 90 91#ifdef __FreeBSD__ 92extern int altqsupport; 93extern int dummynetsupport; 94#define HTONL(x) (x) = htonl((__uint32_t)(x)) 95#endif 96 97#ifndef DEFAULT_PRIORITY 98#define DEFAULT_PRIORITY 1 99#endif 100 101#ifndef DEFAULT_QLIMIT 102#define DEFAULT_QLIMIT 50 103#endif 104 105/* 106 * generalized service curve used for admission control 107 */ 108struct segment { 109 LIST_ENTRY(segment) _next; 110 double x, y, d, m; 111}; 112 113extern int loadopt; 114 115int check_commit_altq(int, int); 116void pfaltq_store(struct pf_altq *); 117struct pf_altq *pfaltq_lookup(const char *); 118char *rate2str(double); 119 120void print_addr(struct pf_addr_wrap *, sa_family_t, int); 121void print_host(struct pf_addr *, u_int16_t p, sa_family_t, int); 122void print_seq(struct pfsync_state_peer *); 123void print_state(struct pfsync_state *, int); 124int unmask(struct pf_addr *, sa_family_t); 125 126int pfctl_cmdline_symset(char *); 127int pfctl_add_trans(struct pfr_buffer *, int, const char *); 128u_int32_t 129 pfctl_get_ticket(struct pfr_buffer *, int, const char *); 130int pfctl_trans(int, struct pfr_buffer *, u_long, int); 131 132#endif /* _PFCTL_H_ */ 133