From owner-svn-src-projects@FreeBSD.ORG Sat Jun 14 11:13:04 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DBD8A290; Sat, 14 Jun 2014 11:13:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD36826B5; Sat, 14 Jun 2014 11:13:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5EBD37l017323; Sat, 14 Jun 2014 11:13:03 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5EBD2VR017317; Sat, 14 Jun 2014 11:13:02 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201406141113.s5EBD2VR017317@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Sat, 14 Jun 2014 11:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r267469 - projects/ipfw/sys/netpfil/ipfw X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jun 2014 11:13:04 -0000 Author: melifaro Date: Sat Jun 14 11:13:02 2014 New Revision: 267469 URL: http://svnweb.freebsd.org/changeset/base/267469 Log: Move most of external table structures/functions to separate ip_fw_table.h Added: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Sat Jun 14 11:02:55 2014 (r267468) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Sat Jun 14 11:13:02 2014 (r267469) @@ -385,84 +385,14 @@ struct table_info; typedef int (table_lookup_t)(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val); -struct table_info { - table_lookup_t *lookup; /* Lookup function */ - void *state; /* Lookup radix/other structure */ - void *xstate; /* eXtended state */ - u_long data; /* Hints for given func */ -}; - -typedef int (ta_init)(void **ta_state, struct table_info *ti); -typedef void (ta_destroy)(void *ta_state, struct table_info *ti); -typedef int (ta_prepare_add)(struct tentry_info *tei, void *ta_buf); -typedef int (ta_prepare_del)(struct tentry_info *tei, void *ta_buf); -typedef int (ta_add)(void *ta_state, struct table_info *ti, - struct tentry_info *tei, void *ta_buf); -typedef int (ta_del)(void *ta_state, struct table_info *ti, - struct tentry_info *tei, void *ta_buf); -typedef void (ta_flush_entry)(struct tentry_info *tei, void *ta_buf); - -typedef int ta_foreach_f(void *node, void *arg); -typedef void ta_foreach(void *ta_state, struct table_info *ti, ta_foreach_f *f, - void *arg); -typedef int ta_dump_entry(void *ta_state, struct table_info *ti, void *e, - ipfw_table_entry *ent); -typedef int ta_dump_xentry(void *ta_state, struct table_info *ti, void *e, - ipfw_table_xentry *xent); - -struct table_algo { - char name[64]; - int idx; - ta_init *init; - ta_destroy *destroy; - table_lookup_t *lookup; - ta_prepare_add *prepare_add; - ta_prepare_del *prepare_del; - ta_add *add; - ta_del *del; - ta_flush_entry *flush_entry; - ta_foreach *foreach; - ta_dump_entry *dump_entry; - ta_dump_xentry *dump_xentry; -}; -void ipfw_add_table_algo(struct ip_fw_chain *ch, struct table_algo *ta); -extern struct table_algo radix_cidr, radix_iface; -struct radix_node; int ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr, uint32_t *val); int ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, uint16_t plen, void *paddr, uint32_t *val); int ipfw_init_tables(struct ip_fw_chain *ch); -int ipfw_destroy_table(struct ip_fw_chain *ch, struct tid_info *ti); -void ipfw_destroy_tables(struct ip_fw_chain *ch); -int ipfw_flush_table(struct ip_fw_chain *ch, struct tid_info *ti); -int ipfw_add_table_entry(struct ip_fw_chain *ch, struct tid_info *ti, - struct tentry_info *tei); -int ipfw_del_table_entry(struct ip_fw_chain *ch, struct tid_info *ti, - struct tentry_info *tei); -int ipfw_count_table(struct ip_fw_chain *ch, struct tid_info *ti, - uint32_t *cnt); -int ipfw_count_xtable(struct ip_fw_chain *ch, struct tid_info *ti, - uint32_t *cnt); -int ipfw_dump_table(struct ip_fw_chain *ch, struct tid_info *ti, - ipfw_table *tbl); -int ipfw_dump_xtable(struct ip_fw_chain *ch, struct tid_info *ti, - ipfw_xtable *tbl); -int ipfw_describe_table(struct ip_fw_chain *ch, struct tid_info *ti, - ipfw_xtable_info *i); -int ipfw_count_tables(struct ip_fw_chain *ch, ipfw_obj_lheader *olh); -int ipfw_list_tables(struct ip_fw_chain *ch, struct tid_info *ti, - ipfw_obj_lheader *olh); int ipfw_resize_tables(struct ip_fw_chain *ch, unsigned int ntables); -int ipfw_rewrite_table_uidx(struct ip_fw_chain *chain, - struct rule_check_info *ci); -int ipfw_rewrite_table_kidx(struct ip_fw_chain *chain, struct ip_fw *rule); -void ipfw_unbind_table_rule(struct ip_fw_chain *chain, struct ip_fw *rule); -void ipfw_unbind_table_list(struct ip_fw_chain *chain, struct ip_fw *head); - -void ipfw_table_algo_init(struct ip_fw_chain *chain); -void ipfw_table_algo_destroy(struct ip_fw_chain *chain); +void ipfw_destroy_tables(struct ip_fw_chain *ch); /* In ip_fw_nat.c -- XXX to be moved to ip_var.h */ Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c Sat Jun 14 11:02:55 2014 (r267468) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_sockopt.c Sat Jun 14 11:13:02 2014 (r267469) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifdef MAC #include Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c Sat Jun 14 11:02:55 2014 (r267468) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c Sat Jun 14 11:13:02 2014 (r267469) @@ -40,11 +40,6 @@ __FBSDID("$FreeBSD$"); */ #include "opt_ipfw.h" -#include "opt_inet.h" -#ifndef INET -#error IPFIREWALL requires INET. -#endif /* INET */ -#include "opt_inet6.h" #include #include @@ -55,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include /* ip_fw.h requires IFNAMSIZ */ -#include #include #include @@ -64,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include /* Added: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table.h Sat Jun 14 11:13:02 2014 (r267469) @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa + * + * 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. + * + * $FreeBSD: projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h 267467 2014-06-14 10:58:39Z melifaro $ + */ + +#ifndef _IPFW2_TABLE_H +#define _IPFW2_TABLE_H + +/* + * Internal constants and data structures used by ipfw tables + * and not meant to be exported outside the kernel. + */ +#ifdef _KERNEL + +struct table_info { + table_lookup_t *lookup; /* Lookup function */ + void *state; /* Lookup radix/other structure */ + void *xstate; /* eXtended state */ + u_long data; /* Hints for given func */ +}; + +typedef int (ta_init)(void **ta_state, struct table_info *ti); +typedef void (ta_destroy)(void *ta_state, struct table_info *ti); +typedef int (ta_prepare_add)(struct tentry_info *tei, void *ta_buf); +typedef int (ta_prepare_del)(struct tentry_info *tei, void *ta_buf); +typedef int (ta_add)(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf); +typedef int (ta_del)(void *ta_state, struct table_info *ti, + struct tentry_info *tei, void *ta_buf); +typedef void (ta_flush_entry)(struct tentry_info *tei, void *ta_buf); + +typedef int ta_foreach_f(void *node, void *arg); +typedef void ta_foreach(void *ta_state, struct table_info *ti, ta_foreach_f *f, + void *arg); +typedef int ta_dump_entry(void *ta_state, struct table_info *ti, void *e, + ipfw_table_entry *ent); +typedef int ta_dump_xentry(void *ta_state, struct table_info *ti, void *e, + ipfw_table_xentry *xent); + +struct table_algo { + char name[64]; + int idx; + ta_init *init; + ta_destroy *destroy; + table_lookup_t *lookup; + ta_prepare_add *prepare_add; + ta_prepare_del *prepare_del; + ta_add *add; + ta_del *del; + ta_flush_entry *flush_entry; + ta_foreach *foreach; + ta_dump_entry *dump_entry; + ta_dump_xentry *dump_xentry; +}; +void ipfw_add_table_algo(struct ip_fw_chain *ch, struct table_algo *ta); +extern struct table_algo radix_cidr, radix_iface; + +int ipfw_destroy_table(struct ip_fw_chain *ch, struct tid_info *ti); +int ipfw_flush_table(struct ip_fw_chain *ch, struct tid_info *ti); +int ipfw_add_table_entry(struct ip_fw_chain *ch, struct tid_info *ti, + struct tentry_info *tei); +int ipfw_del_table_entry(struct ip_fw_chain *ch, struct tid_info *ti, + struct tentry_info *tei); +int ipfw_count_table(struct ip_fw_chain *ch, struct tid_info *ti, + uint32_t *cnt); +int ipfw_count_xtable(struct ip_fw_chain *ch, struct tid_info *ti, + uint32_t *cnt); +int ipfw_dump_table(struct ip_fw_chain *ch, struct tid_info *ti, + ipfw_table *tbl); +int ipfw_dump_xtable(struct ip_fw_chain *ch, struct tid_info *ti, + ipfw_xtable *tbl); +int ipfw_describe_table(struct ip_fw_chain *ch, struct tid_info *ti, + ipfw_xtable_info *i); +int ipfw_count_tables(struct ip_fw_chain *ch, ipfw_obj_lheader *olh); +int ipfw_list_tables(struct ip_fw_chain *ch, struct tid_info *ti, + ipfw_obj_lheader *olh); +int ipfw_rewrite_table_uidx(struct ip_fw_chain *chain, + struct rule_check_info *ci); +int ipfw_rewrite_table_kidx(struct ip_fw_chain *chain, struct ip_fw *rule); +void ipfw_unbind_table_rule(struct ip_fw_chain *chain, struct ip_fw *rule); +void ipfw_unbind_table_list(struct ip_fw_chain *chain, struct ip_fw *head); + +void ipfw_table_algo_init(struct ip_fw_chain *chain); +void ipfw_table_algo_destroy(struct ip_fw_chain *chain); + + +#endif /* _KERNEL */ +#endif /* _IPFW2_TABLE_H */ Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c Sat Jun 14 11:02:55 2014 (r267468) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_table_algo.c Sat Jun 14 11:13:02 2014 (r267469) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD: projects/ipfw/sys/ne #include #include +#include static MALLOC_DEFINE(M_IPFW_TBL, "ipfw_tbl", "IpFw tables");