Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * 25-Jul-1998 Major changes to allow for ip chain table | |
4 | * | |
5 | * 3-Jan-2000 Named tables to allow packet selection for different uses. | |
6 | */ | |
7 | ||
8 | /* | |
9 | * Format of an IP firewall descriptor | |
10 | * | |
11 | * src, dst, src_mask, dst_mask are always stored in network byte order. | |
12 | * flags are stored in host byte order (of course). | |
13 | * Port numbers are stored in HOST byte order. | |
14 | */ | |
1da177e4 LT |
15 | #ifndef _IPTABLES_H |
16 | #define _IPTABLES_H | |
17 | ||
1da177e4 | 18 | #include <linux/if.h> |
1da177e4 LT |
19 | #include <linux/in.h> |
20 | #include <linux/ip.h> | |
21 | #include <linux/skbuff.h> | |
1da177e4 LT |
22 | |
23 | #include <linux/init.h> | |
17c07592 DH |
24 | #include <uapi/linux/netfilter_ipv4/ip_tables.h> |
25 | ||
1da177e4 LT |
26 | extern void ipt_init(void) __init; |
27 | ||
a67dd266 FW |
28 | int ipt_register_table(struct net *net, const struct xt_table *table, |
29 | const struct ipt_replace *repl, | |
30 | const struct nf_hook_ops *ops, struct xt_table **res); | |
31 | void ipt_unregister_table(struct net *net, struct xt_table *table, | |
32 | const struct nf_hook_ops *ops); | |
1da177e4 | 33 | |
1da177e4 | 34 | /* Standard entry. */ |
d94d9fee | 35 | struct ipt_standard { |
1da177e4 | 36 | struct ipt_entry entry; |
87a2e70d | 37 | struct xt_standard_target target; |
1da177e4 LT |
38 | }; |
39 | ||
d94d9fee | 40 | struct ipt_error { |
1da177e4 | 41 | struct ipt_entry entry; |
75f0a0fd | 42 | struct xt_error_target target; |
1da177e4 LT |
43 | }; |
44 | ||
3c2ad469 PM |
45 | #define IPT_ENTRY_INIT(__size) \ |
46 | { \ | |
47 | .target_offset = sizeof(struct ipt_entry), \ | |
48 | .next_offset = (__size), \ | |
49 | } | |
50 | ||
51 | #define IPT_STANDARD_INIT(__verdict) \ | |
52 | { \ | |
53 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \ | |
243bf6e2 | 54 | .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \ |
3c2ad469 PM |
55 | sizeof(struct xt_standard_target)), \ |
56 | .target.verdict = -(__verdict) - 1, \ | |
57 | } | |
58 | ||
59 | #define IPT_ERROR_INIT \ | |
60 | { \ | |
61 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \ | |
243bf6e2 | 62 | .target = XT_TARGET_INIT(XT_ERROR_TARGET, \ |
75f0a0fd | 63 | sizeof(struct xt_error_target)), \ |
3c2ad469 PM |
64 | .target.errorname = "ERROR", \ |
65 | } | |
66 | ||
e3eaa991 | 67 | extern void *ipt_alloc_initial_table(const struct xt_table *); |
3db05fea | 68 | extern unsigned int ipt_do_table(struct sk_buff *skb, |
1c491ba2 | 69 | const struct nf_hook_state *state, |
e60a13e0 | 70 | struct xt_table *table); |
1da177e4 | 71 | |
2722971c DM |
72 | #ifdef CONFIG_COMPAT |
73 | #include <net/compat.h> | |
74 | ||
d94d9fee | 75 | struct compat_ipt_entry { |
2722971c DM |
76 | struct ipt_ip ip; |
77 | compat_uint_t nfcache; | |
7ff30c43 BH |
78 | __u16 target_offset; |
79 | __u16 next_offset; | |
2722971c DM |
80 | compat_uint_t comefrom; |
81 | struct compat_xt_counters counters; | |
82 | unsigned char elems[0]; | |
83 | }; | |
84 | ||
73cd598d | 85 | /* Helper functions */ |
87a2e70d | 86 | static inline struct xt_entry_target * |
73cd598d PM |
87 | compat_ipt_get_target(struct compat_ipt_entry *e) |
88 | { | |
89 | return (void *)e + e->target_offset; | |
90 | } | |
91 | ||
2722971c | 92 | #endif /* CONFIG_COMPAT */ |
1da177e4 | 93 | #endif /* _IPTABLES_H */ |