1 #ifndef _IP_NAT_HELPER_H
2 #define _IP_NAT_HELPER_H
3 /* NAT protocol helper routines. */
5 #include <linux/netfilter_ipv4/ip_conntrack.h>
6 #include <linux/module.h>
11 /* NAT helper must be called on every packet (for TCP) */
12 #define IP_NAT_HELPER_F_ALWAYS 0x01
16 struct list_head list; /* Internal use */
18 const char *name; /* name of the module */
19 unsigned char flags; /* Flags (see above) */
20 struct module *me; /* pointer to self */
22 /* Mask of things we will help: vs. tuple from server */
23 struct ip_conntrack_tuple tuple;
24 struct ip_conntrack_tuple mask;
26 /* Helper function: returns verdict */
27 unsigned int (*help)(struct ip_conntrack *ct,
28 struct ip_conntrack_expect *exp,
29 struct ip_nat_info *info,
30 enum ip_conntrack_info ctinfo,
32 struct sk_buff **pskb);
34 /* Returns verdict and sets up NAT for this connection */
35 unsigned int (*expect)(struct sk_buff **pskb,
37 struct ip_conntrack *ct,
38 struct ip_nat_info *info);
41 extern int ip_nat_helper_register(struct ip_nat_helper *me);
42 extern void ip_nat_helper_unregister(struct ip_nat_helper *me);
44 extern struct ip_nat_helper *
45 ip_nat_find_helper(const struct ip_conntrack_tuple *tuple);
47 extern struct ip_nat_helper *
48 __ip_nat_find_helper(const struct ip_conntrack_tuple *tuple);
50 /* These return true or false. */
51 extern int ip_nat_mangle_tcp_packet(struct sk_buff **skb,
52 struct ip_conntrack *ct,
53 enum ip_conntrack_info ctinfo,
54 unsigned int match_offset,
55 unsigned int match_len,
56 const char *rep_buffer,
57 unsigned int rep_len);
58 extern int ip_nat_mangle_udp_packet(struct sk_buff **skb,
59 struct ip_conntrack *ct,
60 enum ip_conntrack_info ctinfo,
61 unsigned int match_offset,
62 unsigned int match_len,
63 const char *rep_buffer,
64 unsigned int rep_len);
65 extern int ip_nat_seq_adjust(struct sk_buff **pskb,
66 struct ip_conntrack *ct,
67 enum ip_conntrack_info ctinfo);