Commit | Line | Data |
---|---|---|
5b1158e9 JK |
1 | /* Header for use in defining a given protocol. */ |
2 | #ifndef _NF_NAT_PROTOCOL_H | |
3 | #define _NF_NAT_PROTOCOL_H | |
4 | #include <net/netfilter/nf_nat.h> | |
5 | #include <linux/netfilter/nfnetlink_conntrack.h> | |
6 | ||
cbc9f2f4 | 7 | struct nf_nat_ipv4_range; |
5b1158e9 | 8 | |
fd2c3ef7 | 9 | struct nf_nat_protocol { |
5b1158e9 JK |
10 | /* Protocol number. */ |
11 | unsigned int protonum; | |
12 | ||
5b1158e9 JK |
13 | /* Translate a packet to the target according to manip type. |
14 | Return true if succeeded. */ | |
f2ea825f JE |
15 | bool (*manip_pkt)(struct sk_buff *skb, |
16 | unsigned int iphdroff, | |
17 | const struct nf_conntrack_tuple *tuple, | |
18 | enum nf_nat_manip_type maniptype); | |
5b1158e9 JK |
19 | |
20 | /* Is the manipable part of the tuple between min and max incl? */ | |
f2ea825f JE |
21 | bool (*in_range)(const struct nf_conntrack_tuple *tuple, |
22 | enum nf_nat_manip_type maniptype, | |
23 | const union nf_conntrack_man_proto *min, | |
24 | const union nf_conntrack_man_proto *max); | |
5b1158e9 JK |
25 | |
26 | /* Alter the per-proto part of the tuple (depending on | |
27 | maniptype), to give a unique tuple in the given range if | |
f43dc98b CG |
28 | possible. Per-protocol part of tuple is initialized to the |
29 | incoming packet. */ | |
30 | void (*unique_tuple)(struct nf_conntrack_tuple *tuple, | |
cbc9f2f4 | 31 | const struct nf_nat_ipv4_range *range, |
f2ea825f JE |
32 | enum nf_nat_manip_type maniptype, |
33 | const struct nf_conn *ct); | |
5b1158e9 | 34 | |
fdf70832 | 35 | int (*nlattr_to_range)(struct nlattr *tb[], |
cbc9f2f4 | 36 | struct nf_nat_ipv4_range *range); |
5b1158e9 JK |
37 | }; |
38 | ||
39 | /* Protocol registration. */ | |
2b628a08 PM |
40 | extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); |
41 | extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); | |
5b1158e9 | 42 | |
5b1158e9 | 43 | /* Built-in protocols. */ |
2b628a08 PM |
44 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; |
45 | extern const struct nf_nat_protocol nf_nat_protocol_udp; | |
46 | extern const struct nf_nat_protocol nf_nat_protocol_icmp; | |
47 | extern const struct nf_nat_protocol nf_nat_unknown_protocol; | |
5b1158e9 JK |
48 | |
49 | extern int init_protocols(void) __init; | |
50 | extern void cleanup_protocols(void); | |
2b628a08 | 51 | extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); |
5b1158e9 | 52 | |
f2ea825f JE |
53 | extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple, |
54 | enum nf_nat_manip_type maniptype, | |
55 | const union nf_conntrack_man_proto *min, | |
56 | const union nf_conntrack_man_proto *max); | |
937e0dfd | 57 | |
f43dc98b | 58 | extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, |
cbc9f2f4 | 59 | const struct nf_nat_ipv4_range *range, |
f2ea825f JE |
60 | enum nf_nat_manip_type maniptype, |
61 | const struct nf_conn *ct, | |
62 | u_int16_t *rover); | |
937e0dfd | 63 | |
535b57c7 | 64 | extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[], |
cbc9f2f4 | 65 | struct nf_nat_ipv4_range *range); |
5b1158e9 JK |
66 | |
67 | #endif /*_NF_NAT_PROTO_H*/ |