License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / include / linux / netfilter_arp / arp_tables.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
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 */
1da177e4
LT
9#ifndef _ARPTABLES_H
10#define _ARPTABLES_H
11
1da177e4 12#include <linux/if.h>
1da177e4
LT
13#include <linux/in.h>
14#include <linux/if_arp.h>
15#include <linux/skbuff.h>
8922082a 16#include <uapi/linux/netfilter_arp/arp_tables.h>
1da177e4 17
3c2ad469 18/* Standard entry. */
d94d9fee 19struct arpt_standard {
3c2ad469 20 struct arpt_entry entry;
87a2e70d 21 struct xt_standard_target target;
3c2ad469
PM
22};
23
d94d9fee 24struct arpt_error {
3c2ad469 25 struct arpt_entry entry;
75f0a0fd 26 struct xt_error_target target;
3c2ad469
PM
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)), \
243bf6e2 38 .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \
87a2e70d 39 sizeof(struct xt_standard_target)), \
3c2ad469
PM
40 .target.verdict = -(__verdict) - 1, \
41}
42
43#define ARPT_ERROR_INIT \
44{ \
45 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \
243bf6e2 46 .target = XT_TARGET_INIT(XT_ERROR_TARGET, \
75f0a0fd 47 sizeof(struct xt_error_target)), \
3c2ad469
PM
48 .target.errorname = "ERROR", \
49}
50
e3eaa991 51extern void *arpt_alloc_initial_table(const struct xt_table *);
a67dd266
FW
52int 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);
55void arpt_unregister_table(struct net *net, struct xt_table *table,
56 const struct nf_hook_ops *ops);
3db05fea 57extern unsigned int arpt_do_table(struct sk_buff *skb,
b85c3dc9 58 const struct nf_hook_state *state,
4abff077 59 struct xt_table *table);
1da177e4 60
d6a2ba07
PM
61#ifdef CONFIG_COMPAT
62#include <net/compat.h>
63
d94d9fee 64struct compat_arpt_entry {
d6a2ba07 65 struct arpt_arp arp;
7ff30c43
BH
66 __u16 target_offset;
67 __u16 next_offset;
d6a2ba07
PM
68 compat_uint_t comefrom;
69 struct compat_xt_counters counters;
70 unsigned char elems[0];
71};
72
87a2e70d 73static inline struct xt_entry_target *
d6a2ba07
PM
74compat_arpt_get_target(struct compat_arpt_entry *e)
75{
76 return (void *)e + e->target_offset;
77}
78
d6a2ba07 79#endif /* CONFIG_COMPAT */
1da177e4 80#endif /* _ARPTABLES_H */