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
7struct iphdr;
8struct ip_nat_range;
9
10struct ip_nat_protocol
11{
12	struct list_head list;
13
14	/* Protocol name */
15	const char *name;
16
17	/* Protocol number. */
18	unsigned int protonum;
19
20	/* Do a packet translation according to the ip_nat_proto_manip
21	 * and manip type. */
22	void (*manip_pkt)(struct iphdr *iph, size_t len,
23			  const struct ip_conntrack_manip *manip,
24			  enum ip_nat_manip_type maniptype);
25
26	/* Is the manipable part of the tuple between min and max incl? */
27	int (*in_range)(const struct ip_conntrack_tuple *tuple,
28			enum ip_nat_manip_type maniptype,
29			const union ip_conntrack_manip_proto *min,
30			const union ip_conntrack_manip_proto *max);
31
32	/* Alter the per-proto part of the tuple (depending on
33	   maniptype), to give a unique tuple in the given range if
34	   possible; return false if not.  Per-protocol part of tuple
35	   is initialized to the incoming packet. */
36	int (*unique_tuple)(struct ip_conntrack_tuple *tuple,
37			    const struct ip_nat_range *range,
38			    enum ip_nat_manip_type maniptype,
39			    const struct ip_conntrack *conntrack);
40
41	unsigned int (*print)(char *buffer,
42			      const struct ip_conntrack_tuple *match,
43			      const struct ip_conntrack_tuple *mask);
44
45	unsigned int (*print_range)(char *buffer,
46				    const struct ip_nat_range *range);
47};
48
49/* Protocol registration. */
50extern int ip_nat_protocol_register(struct ip_nat_protocol *proto);
51extern void ip_nat_protocol_unregister(struct ip_nat_protocol *proto);
52
53extern int init_protocols(void) __init;
54extern void cleanup_protocols(void);
55extern struct ip_nat_protocol *find_nat_proto(u_int16_t protonum);
56
57#endif /*_IP_NAT_PROTO_H*/
58