• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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  */
8 #ifndef _ARPTABLES_H
9 #define _ARPTABLES_H
10 
11 #include <linux/if.h>
12 #include <linux/in.h>
13 #include <linux/if_arp.h>
14 #include <linux/skbuff.h>
15 #include <uapi/linux/netfilter_arp/arp_tables.h>
16 
17 /* Standard entry. */
18 struct arpt_standard {
19 	struct arpt_entry entry;
20 	struct xt_standard_target target;
21 };
22 
23 struct arpt_error {
24 	struct arpt_entry entry;
25 	struct xt_error_target target;
26 };
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)),       \
37 	.target		= XT_TARGET_INIT(XT_STANDARD_TARGET,		       \
38 					 sizeof(struct xt_standard_target)), \
39 	.target.verdict	= -(__verdict) - 1,				       \
40 }
41 
42 #define ARPT_ERROR_INIT							       \
43 {									       \
44 	.entry		= ARPT_ENTRY_INIT(sizeof(struct arpt_error)),	       \
45 	.target		= XT_TARGET_INIT(XT_ERROR_TARGET,		       \
46 					 sizeof(struct xt_error_target)),      \
47 	.target.errorname = "ERROR",					       \
48 }
49 
50 extern void *arpt_alloc_initial_table(const struct xt_table *);
51 extern struct xt_table *arpt_register_table(struct net *net,
52 					    const struct xt_table *table,
53 					    const struct arpt_replace *repl);
54 extern void arpt_unregister_table(struct xt_table *table);
55 extern unsigned int arpt_do_table(struct sk_buff *skb,
56 				  unsigned int hook,
57 				  const struct net_device *in,
58 				  const struct net_device *out,
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 *
compat_arpt_get_target(struct compat_arpt_entry * e)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 */
81