]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/net/netfilter/nf_nat_protocol.h
net: cleanup include/net
[net-next-2.6.git] / include / net / netfilter / nf_nat_protocol.h
CommitLineData
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
7struct nf_nat_range;
8
fd2c3ef7 9struct nf_nat_protocol {
5b1158e9
JK
10 /* Protocol number. */
11 unsigned int protonum;
12
13 struct module *me;
14
15 /* Translate a packet to the target according to manip type.
16 Return true if succeeded. */
f2ea825f
JE
17 bool (*manip_pkt)(struct sk_buff *skb,
18 unsigned int iphdroff,
19 const struct nf_conntrack_tuple *tuple,
20 enum nf_nat_manip_type maniptype);
5b1158e9
JK
21
22 /* Is the manipable part of the tuple between min and max incl? */
f2ea825f
JE
23 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
24 enum nf_nat_manip_type maniptype,
25 const union nf_conntrack_man_proto *min,
26 const union nf_conntrack_man_proto *max);
5b1158e9
JK
27
28 /* Alter the per-proto part of the tuple (depending on
29 maniptype), to give a unique tuple in the given range if
30 possible; return false if not. Per-protocol part of tuple
31 is initialized to the incoming packet. */
f2ea825f
JE
32 bool (*unique_tuple)(struct nf_conntrack_tuple *tuple,
33 const struct nf_nat_range *range,
34 enum nf_nat_manip_type maniptype,
35 const struct nf_conn *ct);
5b1158e9 36
fdf70832 37 int (*range_to_nlattr)(struct sk_buff *skb,
5b1158e9
JK
38 const struct nf_nat_range *range);
39
fdf70832 40 int (*nlattr_to_range)(struct nlattr *tb[],
5b1158e9
JK
41 struct nf_nat_range *range);
42};
43
44/* Protocol registration. */
2b628a08
PM
45extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
46extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
5b1158e9 47
2b628a08
PM
48extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
49extern void nf_nat_proto_put(const struct nf_nat_protocol *proto);
5b1158e9
JK
50
51/* Built-in protocols. */
2b628a08
PM
52extern const struct nf_nat_protocol nf_nat_protocol_tcp;
53extern const struct nf_nat_protocol nf_nat_protocol_udp;
54extern const struct nf_nat_protocol nf_nat_protocol_icmp;
55extern const struct nf_nat_protocol nf_nat_unknown_protocol;
5b1158e9
JK
56
57extern int init_protocols(void) __init;
58extern void cleanup_protocols(void);
2b628a08 59extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
5b1158e9 60
f2ea825f
JE
61extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
62 enum nf_nat_manip_type maniptype,
63 const union nf_conntrack_man_proto *min,
64 const union nf_conntrack_man_proto *max);
937e0dfd 65
f2ea825f
JE
66extern bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
67 const struct nf_nat_range *range,
68 enum nf_nat_manip_type maniptype,
69 const struct nf_conn *ct,
70 u_int16_t *rover);
937e0dfd 71
535b57c7
PM
72extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb,
73 const struct nf_nat_range *range);
74extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
75 struct nf_nat_range *range);
5b1158e9
JK
76
77#endif /*_NF_NAT_PROTO_H*/