Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | ||
080774a2 HW |
7 | #include <linux/netfilter_ipv4/ip_nat.h> |
8 | #include <linux/netfilter/nfnetlink_conntrack.h> | |
9 | ||
1da177e4 LT |
10 | struct iphdr; |
11 | struct ip_nat_range; | |
12 | ||
13 | struct ip_nat_protocol | |
14 | { | |
15 | /* Protocol name */ | |
16 | const char *name; | |
17 | ||
18 | /* Protocol number. */ | |
19 | unsigned int protonum; | |
20 | ||
080774a2 HW |
21 | struct module *me; |
22 | ||
1da177e4 LT |
23 | /* Translate a packet to the target according to manip type. |
24 | Return true if succeeded. */ | |
25 | int (*manip_pkt)(struct sk_buff **pskb, | |
26 | unsigned int iphdroff, | |
27 | const struct ip_conntrack_tuple *tuple, | |
28 | enum ip_nat_manip_type maniptype); | |
29 | ||
30 | /* Is the manipable part of the tuple between min and max incl? */ | |
31 | int (*in_range)(const struct ip_conntrack_tuple *tuple, | |
32 | enum ip_nat_manip_type maniptype, | |
33 | const union ip_conntrack_manip_proto *min, | |
34 | const union ip_conntrack_manip_proto *max); | |
35 | ||
36 | /* Alter the per-proto part of the tuple (depending on | |
37 | maniptype), to give a unique tuple in the given range if | |
38 | possible; return false if not. Per-protocol part of tuple | |
39 | is initialized to the incoming packet. */ | |
40 | int (*unique_tuple)(struct ip_conntrack_tuple *tuple, | |
41 | const struct ip_nat_range *range, | |
42 | enum ip_nat_manip_type maniptype, | |
43 | const struct ip_conntrack *conntrack); | |
44 | ||
45 | unsigned int (*print)(char *buffer, | |
46 | const struct ip_conntrack_tuple *match, | |
47 | const struct ip_conntrack_tuple *mask); | |
48 | ||
49 | unsigned int (*print_range)(char *buffer, | |
50 | const struct ip_nat_range *range); | |
1da177e4 | 51 | |
080774a2 HW |
52 | int (*range_to_nfattr)(struct sk_buff *skb, |
53 | const struct ip_nat_range *range); | |
54 | ||
55 | int (*nfattr_to_range)(struct nfattr *tb[], | |
56 | struct ip_nat_range *range); | |
57 | }; | |
1da177e4 LT |
58 | |
59 | /* Protocol registration. */ | |
60 | extern int ip_nat_protocol_register(struct ip_nat_protocol *proto); | |
61 | extern void ip_nat_protocol_unregister(struct ip_nat_protocol *proto); | |
62 | ||
080774a2 HW |
63 | extern struct ip_nat_protocol *ip_nat_proto_find_get(u_int8_t protocol); |
64 | extern void ip_nat_proto_put(struct ip_nat_protocol *proto); | |
1da177e4 LT |
65 | |
66 | /* Built-in protocols. */ | |
67 | extern struct ip_nat_protocol ip_nat_protocol_tcp; | |
68 | extern struct ip_nat_protocol ip_nat_protocol_udp; | |
69 | extern struct ip_nat_protocol ip_nat_protocol_icmp; | |
70 | extern struct ip_nat_protocol ip_nat_unknown_protocol; | |
71 | ||
72 | extern int init_protocols(void) __init; | |
73 | extern void cleanup_protocols(void); | |
74 | extern struct ip_nat_protocol *find_nat_proto(u_int16_t protonum); | |
75 | ||
080774a2 HW |
76 | extern int ip_nat_port_range_to_nfattr(struct sk_buff *skb, |
77 | const struct ip_nat_range *range); | |
78 | extern int ip_nat_port_nfattr_to_range(struct nfattr *tb[], | |
79 | struct ip_nat_range *range); | |
80 | ||
1da177e4 | 81 | #endif /*_IP_NAT_PROTO_H*/ |