blob: cfb7191e6efa55633dfa8eb52855e6248ccb3d4f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Format of an ARP firewall descriptor
3 *
4 * src, tgt, src_mask, tgt_mask, arpop, arpop_mask are always stored in
5 * network byte order.
6 * flags are stored in host byte order (of course).
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#ifndef _ARPTABLES_H
9#define _ARPTABLES_H
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/if.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/in.h>
13#include <linux/if_arp.h>
14#include <linux/skbuff.h>
David Howells89220822012-10-09 09:48:56 +010015#include <uapi/linux/netfilter_arp/arp_tables.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Patrick McHardy3c2ad462007-05-10 14:14:16 -070017/* Standard entry. */
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080018struct arpt_standard {
Patrick McHardy3c2ad462007-05-10 14:14:16 -070019 struct arpt_entry entry;
Jan Engelhardt87a2e70d2010-10-13 16:11:22 +020020 struct xt_standard_target target;
Patrick McHardy3c2ad462007-05-10 14:14:16 -070021};
22
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080023struct arpt_error {
Patrick McHardy3c2ad462007-05-10 14:14:16 -070024 struct arpt_entry entry;
Jan Engelhardt75f0a0f2010-10-13 16:37:45 +020025 struct xt_error_target target;
Patrick McHardy3c2ad462007-05-10 14:14:16 -070026};
27
28#define ARPT_ENTRY_INIT(__size) \
29{ \
30 .target_offset = sizeof(struct arpt_entry), \
31 .next_offset = (__size), \
32}
33
34#define ARPT_STANDARD_INIT(__verdict) \
35{ \
36 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \
Jan Engelhardt243bf6e2010-10-13 16:28:00 +020037 .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \
Jan Engelhardt87a2e70d2010-10-13 16:11:22 +020038 sizeof(struct xt_standard_target)), \
Patrick McHardy3c2ad462007-05-10 14:14:16 -070039 .target.verdict = -(__verdict) - 1, \
40}
41
42#define ARPT_ERROR_INIT \
43{ \
44 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \
Jan Engelhardt243bf6e2010-10-13 16:28:00 +020045 .target = XT_TARGET_INIT(XT_ERROR_TARGET, \
Jan Engelhardt75f0a0f2010-10-13 16:37:45 +020046 sizeof(struct xt_error_target)), \
Patrick McHardy3c2ad462007-05-10 14:14:16 -070047 .target.errorname = "ERROR", \
48}
49
Jan Engelhardte3eaa992009-06-17 22:14:54 +020050extern void *arpt_alloc_initial_table(const struct xt_table *);
Jan Engelhardt4abff072008-04-14 11:15:43 +020051extern struct xt_table *arpt_register_table(struct net *net,
Jan Engelhardt35aad0f2009-08-24 14:56:30 +020052 const struct xt_table *table,
Jan Engelhardt4abff072008-04-14 11:15:43 +020053 const struct arpt_replace *repl);
54extern void arpt_unregister_table(struct xt_table *table);
Herbert Xu3db05fe2007-10-15 00:53:15 -070055extern unsigned int arpt_do_table(struct sk_buff *skb,
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 unsigned int hook,
57 const struct net_device *in,
58 const struct net_device *out,
Jan Engelhardt4abff072008-04-14 11:15:43 +020059 struct xt_table *table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Patrick McHardyd6a2ba02007-12-17 22:26:54 -080061#ifdef CONFIG_COMPAT
62#include <net/compat.h>
63
Eric Dumazetd94d9fe2009-11-04 09:50:58 -080064struct compat_arpt_entry {
Patrick McHardyd6a2ba02007-12-17 22:26:54 -080065 struct arpt_arp arp;
Ben Hutchings7ff30c42011-08-24 18:44:57 +000066 __u16 target_offset;
67 __u16 next_offset;
Patrick McHardyd6a2ba02007-12-17 22:26:54 -080068 compat_uint_t comefrom;
69 struct compat_xt_counters counters;
70 unsigned char elems[0];
71};
72
Jan Engelhardt87a2e70d2010-10-13 16:11:22 +020073static inline struct xt_entry_target *
Patrick McHardyd6a2ba02007-12-17 22:26:54 -080074compat_arpt_get_target(struct compat_arpt_entry *e)
75{
76 return (void *)e + e->target_offset;
77}
78
Patrick McHardyd6a2ba02007-12-17 22:26:54 -080079#endif /* CONFIG_COMPAT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#endif /* _ARPTABLES_H */