Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / include / net / netfilter / nf_nat_protocol.h
blob4aa0edbb5b966c7b2b7f16969734c522cf840ecf
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>
7 struct nf_nat_range;
9 struct nf_nat_protocol
11 /* Protocol name */
12 const char *name;
14 /* Protocol number. */
15 unsigned int protonum;
17 struct module *me;
19 /* Translate a packet to the target according to manip type.
20 Return true if succeeded. */
21 int (*manip_pkt)(struct sk_buff *skb,
22 unsigned int iphdroff,
23 const struct nf_conntrack_tuple *tuple,
24 enum nf_nat_manip_type maniptype);
26 /* Is the manipable part of the tuple between min and max incl? */
27 int (*in_range)(const struct nf_conntrack_tuple *tuple,
28 enum nf_nat_manip_type maniptype,
29 const union nf_conntrack_man_proto *min,
30 const union nf_conntrack_man_proto *max);
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 nf_conntrack_tuple *tuple,
37 const struct nf_nat_range *range,
38 enum nf_nat_manip_type maniptype,
39 const struct nf_conn *ct);
41 int (*range_to_nlattr)(struct sk_buff *skb,
42 const struct nf_nat_range *range);
44 int (*nlattr_to_range)(struct nlattr *tb[],
45 struct nf_nat_range *range);
48 /* Protocol registration. */
49 extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
50 extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
52 extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
53 extern void nf_nat_proto_put(const struct nf_nat_protocol *proto);
55 /* Built-in protocols. */
56 extern const struct nf_nat_protocol nf_nat_protocol_tcp;
57 extern const struct nf_nat_protocol nf_nat_protocol_udp;
58 extern const struct nf_nat_protocol nf_nat_protocol_icmp;
59 extern const struct nf_nat_protocol nf_nat_unknown_protocol;
61 extern int init_protocols(void) __init;
62 extern void cleanup_protocols(void);
63 extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
65 extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb,
66 const struct nf_nat_range *range);
67 extern int nf_nat_port_nlattr_to_range(struct nlattr *tb[],
68 struct nf_nat_range *range);
70 #endif /*_NF_NAT_PROTO_H*/