• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * 25-Jul-1998 Major changes to allow for ip chain table
3  *
4  * 3-Jan-2000 Named tables to allow packet selection for different uses.
5  */
6 
7 /*
8  * 	Format of an IP firewall descriptor
9  *
10  * 	src, dst, src_mask, dst_mask are always stored in network byte order.
11  * 	flags are stored in host byte order (of course).
12  * 	Port numbers are stored in HOST byte order.
13  */
14 #ifndef _IPTABLES_H
15 #define _IPTABLES_H
16 
17 #include <linux/if.h>
18 #include <linux/in.h>
19 #include <linux/ip.h>
20 #include <linux/skbuff.h>
21 
22 #include <linux/init.h>
23 #include <uapi/linux/netfilter_ipv4/ip_tables.h>
24 
25 extern void ipt_init(void) __init;
26 
27 extern struct xt_table *ipt_register_table(struct net *net,
28 					   const struct xt_table *table,
29 					   const struct ipt_replace *repl);
30 extern void ipt_unregister_table(struct net *net, struct xt_table *table);
31 
32 /* Standard entry. */
33 struct ipt_standard {
34 	struct ipt_entry entry;
35 	struct xt_standard_target target;
36 };
37 
38 struct ipt_error {
39 	struct ipt_entry entry;
40 	struct xt_error_target target;
41 };
42 
43 #define IPT_ENTRY_INIT(__size)						       \
44 {									       \
45 	.target_offset	= sizeof(struct ipt_entry),			       \
46 	.next_offset	= (__size),					       \
47 }
48 
49 #define IPT_STANDARD_INIT(__verdict)					       \
50 {									       \
51 	.entry		= IPT_ENTRY_INIT(sizeof(struct ipt_standard)),	       \
52 	.target		= XT_TARGET_INIT(XT_STANDARD_TARGET,		       \
53 					 sizeof(struct xt_standard_target)),   \
54 	.target.verdict	= -(__verdict) - 1,				       \
55 }
56 
57 #define IPT_ERROR_INIT							       \
58 {									       \
59 	.entry		= IPT_ENTRY_INIT(sizeof(struct ipt_error)),	       \
60 	.target		= XT_TARGET_INIT(XT_ERROR_TARGET,		       \
61 					 sizeof(struct xt_error_target)),      \
62 	.target.errorname = "ERROR",					       \
63 }
64 
65 extern void *ipt_alloc_initial_table(const struct xt_table *);
66 extern unsigned int ipt_do_table(struct sk_buff *skb,
67 				 unsigned int hook,
68 				 const struct net_device *in,
69 				 const struct net_device *out,
70 				 struct xt_table *table);
71 
72 #ifdef CONFIG_COMPAT
73 #include <net/compat.h>
74 
75 struct compat_ipt_entry {
76 	struct ipt_ip ip;
77 	compat_uint_t nfcache;
78 	__u16 target_offset;
79 	__u16 next_offset;
80 	compat_uint_t comefrom;
81 	struct compat_xt_counters counters;
82 	unsigned char elems[0];
83 };
84 
85 /* Helper functions */
86 static inline struct xt_entry_target *
compat_ipt_get_target(struct compat_ipt_entry * e)87 compat_ipt_get_target(struct compat_ipt_entry *e)
88 {
89 	return (void *)e + e->target_offset;
90 }
91 
92 #endif /* CONFIG_COMPAT */
93 #endif /* _IPTABLES_H */
94