block: add a new revalidate_disk_size helper
[linux-2.6-microblaze.git] / include / linux / netfilter_ipv4 / ip_tables.h
1 /* SPDX-License-Identifier: GPL-2.0 */
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  */
15 #ifndef _IPTABLES_H
16 #define _IPTABLES_H
17
18 #include <linux/if.h>
19 #include <linux/in.h>
20 #include <linux/init.h>
21 #include <linux/ip.h>
22 #include <linux/skbuff.h>
23 #include <uapi/linux/netfilter_ipv4/ip_tables.h>
24
25 int ipt_register_table(struct net *net, const struct xt_table *table,
26                        const struct ipt_replace *repl,
27                        const struct nf_hook_ops *ops, struct xt_table **res);
28
29 void ipt_unregister_table_pre_exit(struct net *net, struct xt_table *table,
30                        const struct nf_hook_ops *ops);
31
32 void ipt_unregister_table_exit(struct net *net, struct xt_table *table);
33
34 void ipt_unregister_table(struct net *net, struct xt_table *table,
35                           const struct nf_hook_ops *ops);
36
37 /* Standard entry. */
38 struct ipt_standard {
39         struct ipt_entry entry;
40         struct xt_standard_target target;
41 };
42
43 struct ipt_error {
44         struct ipt_entry entry;
45         struct xt_error_target target;
46 };
47
48 #define IPT_ENTRY_INIT(__size)                                                 \
49 {                                                                              \
50         .target_offset  = sizeof(struct ipt_entry),                            \
51         .next_offset    = (__size),                                            \
52 }
53
54 #define IPT_STANDARD_INIT(__verdict)                                           \
55 {                                                                              \
56         .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_standard)),         \
57         .target         = XT_TARGET_INIT(XT_STANDARD_TARGET,                   \
58                                          sizeof(struct xt_standard_target)),   \
59         .target.verdict = -(__verdict) - 1,                                    \
60 }
61
62 #define IPT_ERROR_INIT                                                         \
63 {                                                                              \
64         .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_error)),            \
65         .target         = XT_TARGET_INIT(XT_ERROR_TARGET,                      \
66                                          sizeof(struct xt_error_target)),      \
67         .target.errorname = "ERROR",                                           \
68 }
69
70 extern void *ipt_alloc_initial_table(const struct xt_table *);
71 extern unsigned int ipt_do_table(struct sk_buff *skb,
72                                  const struct nf_hook_state *state,
73                                  struct xt_table *table);
74
75 #ifdef CONFIG_COMPAT
76 #include <net/compat.h>
77
78 struct compat_ipt_entry {
79         struct ipt_ip ip;
80         compat_uint_t nfcache;
81         __u16 target_offset;
82         __u16 next_offset;
83         compat_uint_t comefrom;
84         struct compat_xt_counters counters;
85         unsigned char elems[];
86 };
87
88 /* Helper functions */
89 static inline struct xt_entry_target *
90 compat_ipt_get_target(struct compat_ipt_entry *e)
91 {
92         return (void *)e + e->target_offset;
93 }
94
95 #endif /* CONFIG_COMPAT */
96 #endif /* _IPTABLES_H */