contrib: fwd - initial C implementation of the uci firewall
[project/luci.git] / contrib / fwd / src / fwd_rules.h
1 /*
2  * fwd - OpenWrt firewall daemon - header for iptables rule set
3  *
4  *   Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
5  *
6  * The fwd program is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version 2
8  * as published by the Free Software Foundation.
9  *
10  * The fwd program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with the fwd program. If not, see http://www.gnu.org/licenses/.
17  */
18
19 #ifndef __FWD_RULES_H__
20 #define __FWD_RULES_H__
21
22 #include "fwd.h"
23
24 #define IPT "iptables"
25
26 struct fwd_ipt_rulebuf {
27         char *buf;
28         size_t len;
29 };
30
31
32 #define fwd_ipt_add_format fwd_ipt_rule_append
33
34 #define fwd_ipt_exec_format(t, ...) do {         \
35         struct fwd_ipt_rulebuf *r = fwd_ipt_init(t); \
36         fwd_ipt_add_format(r, __VA_ARGS__);          \
37         fwd_ipt_exec(r);                             \
38 } while(0)
39
40 void fwd_ipt_build_ruleset(struct fwd_handle *h);
41 void fwd_ipt_addif(struct fwd_handle *h, const char *net);
42
43 #endif
44