Linux-libre 5.4.48-gnu
[librecmc/linux-libre.git] / include / linux / netfilter_arp / arp_tables.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *      Format of an ARP firewall descriptor
4  *
5  *      src, tgt, src_mask, tgt_mask, arpop, arpop_mask are always stored in
6  *      network byte order.
7  *      flags are stored in host byte order (of course).
8  */
9 #ifndef _ARPTABLES_H
10 #define _ARPTABLES_H
11
12 #include <linux/if.h>
13 #include <linux/in.h>
14 #include <linux/if_arp.h>
15 #include <linux/skbuff.h>
16 #include <uapi/linux/netfilter_arp/arp_tables.h>
17
18 /* Standard entry. */
19 struct arpt_standard {
20         struct arpt_entry entry;
21         struct xt_standard_target target;
22 };
23
24 struct arpt_error {
25         struct arpt_entry entry;
26         struct xt_error_target target;
27 };
28
29 #define ARPT_ENTRY_INIT(__size)                                                \
30 {                                                                              \
31         .target_offset  = sizeof(struct arpt_entry),                           \
32         .next_offset    = (__size),                                            \
33 }
34
35 #define ARPT_STANDARD_INIT(__verdict)                                          \
36 {                                                                              \
37         .entry          = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)),       \
38         .target         = XT_TARGET_INIT(XT_STANDARD_TARGET,                   \
39                                          sizeof(struct xt_standard_target)), \
40         .target.verdict = -(__verdict) - 1,                                    \
41 }
42
43 #define ARPT_ERROR_INIT                                                        \
44 {                                                                              \
45         .entry          = ARPT_ENTRY_INIT(sizeof(struct arpt_error)),          \
46         .target         = XT_TARGET_INIT(XT_ERROR_TARGET,                      \
47                                          sizeof(struct xt_error_target)),      \
48         .target.errorname = "ERROR",                                           \
49 }
50
51 extern void *arpt_alloc_initial_table(const struct xt_table *);
52 int arpt_register_table(struct net *net, const struct xt_table *table,
53                         const struct arpt_replace *repl,
54                         const struct nf_hook_ops *ops, struct xt_table **res);
55 void arpt_unregister_table(struct net *net, struct xt_table *table,
56                            const struct nf_hook_ops *ops);
57 extern unsigned int arpt_do_table(struct sk_buff *skb,
58                                   const struct nf_hook_state *state,
59                                   struct xt_table *table);
60
61 #ifdef CONFIG_COMPAT
62 #include <net/compat.h>
63
64 struct compat_arpt_entry {
65         struct arpt_arp arp;
66         __u16 target_offset;
67         __u16 next_offset;
68         compat_uint_t comefrom;
69         struct compat_xt_counters counters;
70         unsigned char elems[0];
71 };
72
73 static inline struct xt_entry_target *
74 compat_arpt_get_target(struct compat_arpt_entry *e)
75 {
76         return (void *)e + e->target_offset;
77 }
78
79 #endif /* CONFIG_COMPAT */
80 #endif /* _ARPTABLES_H */