126746a79f72cd60a6c0edb1296110dec0e18940
[project/luci.git] / contrib / fwd / src / fwd_xtables.h
1 /*
2  * fwd - OpenWrt firewall daemon - libiptc/libxtables interface headers
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
20 #ifndef __FWD_XTABLES_H__
21 #define __FWD_XTABLES_H__
22
23 #include <iptables.h>
24 #include <xtables.h>
25 #include <libiptc/libxtc.h>
26
27 #include <dlfcn.h>
28 #include <errno.h>
29
30 #include <sys/stat.h>
31 #include <sys/utsname.h>
32
33
34
35 struct fwd_xt_rule {
36         struct iptc_handle *iptc;
37         struct ipt_entry *entry;
38         struct xtables_rule_match *matches;
39         struct xtables_target *target;
40 };
41
42
43 /* Required by certain extensions like SNAT and DNAT */
44 extern int kernel_version;
45 extern void get_kernel_version(void);
46
47
48 void fwd_xt_init(void);
49
50 struct fwd_xt_rule * fwd_xt_init_rule(const char *table);
51
52 void fwd_xt_parse_proto(struct fwd_xt_rule *r, struct fwd_proto *p, int inv);
53 void fwd_xt_parse_in(struct fwd_xt_rule *r, struct fwd_network_list *n, int inv);
54 void fwd_xt_parse_out(struct fwd_xt_rule *r, struct fwd_network_list *n, int inv);
55 void fwd_xt_parse_src(struct fwd_xt_rule *r, struct fwd_cidr *c, int inv);
56 void fwd_xt_parse_dest(struct fwd_xt_rule *r, struct fwd_cidr *c, int inv);
57
58 struct xtables_match * fwd_xt_get_match(struct fwd_xt_rule *r, const char *name);
59 void fwd_xt_parse_match(struct fwd_xt_rule *r, struct xtables_match *m, const char *opt, const char *val);
60
61 struct xtables_target * fwd_xt_get_target(struct fwd_xt_rule *r, const char *name);
62 void fwd_xt_parse_target(struct fwd_xt_rule *r, struct xtables_target *t, const char *opt, const char *val);
63
64 int fwd_xt_exec_rule(struct fwd_xt_rule *r, const char *chain);
65
66 #endif