vserver 1.9.3
[linux-2.6.git] / include / linux / netfilter_ipv4 / ip_nat_protocol.h
1 /* Header for use in defining a given protocol. */
2 #ifndef _IP_NAT_PROTOCOL_H
3 #define _IP_NAT_PROTOCOL_H
4 #include <linux/init.h>
5 #include <linux/list.h>
6
7 struct iphdr;
8 struct ip_nat_range;
9
10 struct ip_nat_protocol
11 {
12         /* Protocol name */
13         const char *name;
14
15         /* Protocol number. */
16         unsigned int protonum;
17
18         /* Do a packet translation according to the ip_nat_proto_manip
19          * and manip type.  Return true if succeeded. */
20         int (*manip_pkt)(struct sk_buff **pskb,
21                          unsigned int hdroff,
22                          const struct ip_conntrack_manip *manip,
23                          enum ip_nat_manip_type maniptype);
24
25         /* Is the manipable part of the tuple between min and max incl? */
26         int (*in_range)(const struct ip_conntrack_tuple *tuple,
27                         enum ip_nat_manip_type maniptype,
28                         const union ip_conntrack_manip_proto *min,
29                         const union ip_conntrack_manip_proto *max);
30
31         /* Alter the per-proto part of the tuple (depending on
32            maniptype), to give a unique tuple in the given range if
33            possible; return false if not.  Per-protocol part of tuple
34            is initialized to the incoming packet. */
35         int (*unique_tuple)(struct ip_conntrack_tuple *tuple,
36                             const struct ip_nat_range *range,
37                             enum ip_nat_manip_type maniptype,
38                             const struct ip_conntrack *conntrack);
39
40         unsigned int (*print)(char *buffer,
41                               const struct ip_conntrack_tuple *match,
42                               const struct ip_conntrack_tuple *mask);
43
44         unsigned int (*print_range)(char *buffer,
45                                     const struct ip_nat_range *range);
46 };
47
48 #define MAX_IP_NAT_PROTO 256
49 extern struct ip_nat_protocol *ip_nat_protos[MAX_IP_NAT_PROTO];
50
51 /* Protocol registration. */
52 extern int ip_nat_protocol_register(struct ip_nat_protocol *proto);
53 extern void ip_nat_protocol_unregister(struct ip_nat_protocol *proto);
54
55 static inline struct ip_nat_protocol *ip_nat_find_proto(u_int8_t protocol)
56 {
57         return ip_nat_protos[protocol];
58 }
59
60 /* Built-in protocols. */
61 extern struct ip_nat_protocol ip_nat_protocol_tcp;
62 extern struct ip_nat_protocol ip_nat_protocol_udp;
63 extern struct ip_nat_protocol ip_nat_protocol_icmp;
64 extern struct ip_nat_protocol ip_nat_unknown_protocol;
65
66 extern int init_protocols(void) __init;
67 extern void cleanup_protocols(void);
68 extern struct ip_nat_protocol *find_nat_proto(u_int16_t protonum);
69
70 #endif /*_IP_NAT_PROTO_H*/