ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / netfilter_ipv4 / ip_nat_helper.h
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 #include <linux/module.h>
7
8 struct sk_buff;
9
10 /* Flags */
11 /* NAT helper must be called on every packet (for TCP) */
12 #define IP_NAT_HELPER_F_ALWAYS          0x01
13
14 struct ip_nat_helper
15 {
16         struct list_head list;          /* Internal use */
17
18         const char *name;               /* name of the module */
19         unsigned char flags;            /* Flags (see above) */
20         struct module *me;              /* pointer to self */
21         
22         /* Mask of things we will help: vs. tuple from server */
23         struct ip_conntrack_tuple tuple;
24         struct ip_conntrack_tuple mask;
25         
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,
31                              unsigned int hooknum,
32                              struct sk_buff **pskb);
33
34         /* Returns verdict and sets up NAT for this connection */
35         unsigned int (*expect)(struct sk_buff **pskb,
36                                unsigned int hooknum,
37                                struct ip_conntrack *ct,
38                                struct ip_nat_info *info);
39 };
40
41 extern struct list_head helpers;
42
43 extern int ip_nat_helper_register(struct ip_nat_helper *me);
44 extern void ip_nat_helper_unregister(struct ip_nat_helper *me);
45
46 /* These return true or false. */
47 extern int ip_nat_mangle_tcp_packet(struct sk_buff **skb,
48                                 struct ip_conntrack *ct,
49                                 enum ip_conntrack_info ctinfo,
50                                 unsigned int match_offset,
51                                 unsigned int match_len,
52                                 const char *rep_buffer,
53                                 unsigned int rep_len);
54 extern int ip_nat_mangle_udp_packet(struct sk_buff **skb,
55                                 struct ip_conntrack *ct,
56                                 enum ip_conntrack_info ctinfo,
57                                 unsigned int match_offset,
58                                 unsigned int match_len,
59                                 const char *rep_buffer,
60                                 unsigned int rep_len);
61 extern int ip_nat_seq_adjust(struct sk_buff **pskb, 
62                              struct ip_conntrack *ct, 
63                              enum ip_conntrack_info ctinfo);
64 #endif