1 #ifndef _IP_NAT_HELPER_H
2 #define _IP_NAT_HELPER_H
3 /* NAT protocol helper routines. */
4 
5 #include <linux/netfilter_ipv4/ip_conntrack.h>
6 
7 struct sk_buff;
8 
9 /* Flags */
10 /* NAT helper must be called on every packet (for TCP) */
11 #define IP_NAT_HELPER_F_ALWAYS		0x01
12 /* Standalone NAT helper, without a conntrack part */
13 #define IP_NAT_HELPER_F_STANDALONE	0x02
14 
15 struct ip_nat_helper
16 {
17 	struct list_head list;		/* Internal use */
18 
19 	const char *name;		/* name of the module */
20 	unsigned char flags;		/* Flags (see above) */
21 	struct module *me;		/* pointer to self */
22 
23 	/* Mask of things we will help: vs. tuple from server */
24 	struct ip_conntrack_tuple tuple;
25 	struct ip_conntrack_tuple mask;
26 
27 	/* Helper function: returns verdict */
28 	unsigned int (*help)(struct ip_conntrack *ct,
29 			     struct ip_conntrack_expect *exp,
30 			     struct ip_nat_info *info,
31 			     enum ip_conntrack_info ctinfo,
32 			     unsigned int hooknum,
33 			     struct sk_buff **pskb);
34 
35 	/* Returns verdict and sets up NAT for this connection */
36 	unsigned int (*expect)(struct sk_buff **pskb,
37 			       unsigned int hooknum,
38 			       struct ip_conntrack *ct,
39 			       struct ip_nat_info *info);
40 };
41 
42 extern struct list_head helpers;
43 
44 extern int ip_nat_helper_register(struct ip_nat_helper *me);
45 extern void ip_nat_helper_unregister(struct ip_nat_helper *me);
46 extern int ip_nat_mangle_tcp_packet(struct sk_buff **skb,
47 				struct ip_conntrack *ct,
48 				enum ip_conntrack_info ctinfo,
49 				unsigned int match_offset,
50 				unsigned int match_len,
51 				char *rep_buffer,
52 				unsigned int rep_len);
53 extern int ip_nat_mangle_udp_packet(struct sk_buff **skb,
54 				struct ip_conntrack *ct,
55 				enum ip_conntrack_info ctinfo,
56 				unsigned int match_offset,
57 				unsigned int match_len,
58 				char *rep_buffer,
59 				unsigned int rep_len);
60 extern int ip_nat_seq_adjust(struct sk_buff *skb,
61 				struct ip_conntrack *ct,
62 				enum ip_conntrack_info ctinfo);
63 extern void ip_nat_delete_sack(struct sk_buff *skb);
64 #endif
65