/*- * Copyright (c) 1999-2003 Andrey Simonenko * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)$Id: kipfw.h,v 1.1 2005/12/03 10:50:25 simon Exp $ */ #ifndef KIPFW_H #define KIPFW_H #include #include #include /* Needed for IPFW1 */ #include #include #include #include #define IPFW_NUMBER_MIN 1 #define IPFW_NUMBER_MAX 65535 #if __FreeBSD_version >= 600000 # ifdef IPFW2 # warning Do not define IPFW2 on FreeBSD >= 6.0 # endif # define HAVE_IPFW2 #else # ifdef IPFW2 # define HAVE_IPFW2 # endif #endif /* __FreeBSD_version >= 600000 */ #ifdef HAVE_IPFW2 # define IPFW_BCNT(x) (x.bcnt) # define IPFWP_BCNT(p) (p->bcnt) # define IPFWP_NUMBER(p) (p->rulenum) # define IPFWP_NEXT_RULE(p) p = (struct ip_fw *)((char *)(p) + RULESIZE(p)) #else # define IPFW_BCNT(x) (x.fw_bcnt) # define IPFWP_BCNT(p) (p->fw_bcnt) # define IPFWP_NUMBER(p) (p->fw_number) # define IPFWP_NEXT_RULE(p) (++p) #endif /* HAVE_IPFW2 */ struct kipfw_rule { TAILQ_ENTRY(kipfw_rule) link; /* For linking active kipfw_rules. */ u_short number; /* Rule's number. */ u_int subnumber; /* Rule's subnumber. */ u_int ref_count; /* Reference counter. */ const struct ip_fw *ip_fw; /* Pointer to ip_fw read from kernel. */ }; TAILQ_HEAD(kipfw_rules_list, kipfw_rule); extern struct kipfw_rules_list kipfw_rules_active; extern int debug_ipfw; extern uint64_t kipfw_bcnt_max; extern int kipfw_init(void); extern int kipfw_deinit(void); extern int kipfw_get_stat(void); #endif /* KIPFW_H */