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>
11 /* Protocol number. */
12 unsigned int protonum;
16 /* Translate a packet to the target according to manip type.
17 Return true if succeeded. */
18 bool (*manip_pkt)(struct sk_buff *skb,
19 unsigned int iphdroff,
20 const struct nf_conntrack_tuple *tuple,
21 enum nf_nat_manip_type maniptype);
23 /* Is the manipable part of the tuple between min and max incl? */
24 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
25 enum nf_nat_manip_type maniptype,
26 const union nf_conntrack_man_proto *min,
27 const union nf_conntrack_man_proto *max);
29 /* Alter the per-proto part of the tuple (depending on
30 maniptype), to give a unique tuple in the given range if
31 possible; return false if not. Per-protocol part of tuple
32 is initialized to the incoming packet. */
33 bool (*unique_tuple)(struct nf_conntrack_tuple *tuple,
34 const struct nf_nat_range *range,
35 enum nf_nat_manip_type maniptype,
36 const struct nf_conn *ct);
38 int (*range_to_nlattr)(struct sk_buff *skb,
39 const struct nf_nat_range *range);
41 int (*nlattr_to_range)(struct nlattr *tb[],
42 struct nf_nat_range *range);
45 /* Protocol registration. */
46 extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
47 extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
49 extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
50 extern void nf_nat_proto_put(const struct nf_nat_protocol *proto);
52 /* Built-in protocols. */
53 extern const struct nf_nat_protocol nf_nat_protocol_tcp;
54 extern const struct nf_nat_protocol nf_nat_protocol_udp;
55 extern const struct nf_nat_protocol nf_nat_protocol_icmp;
56 extern const struct nf_nat_protocol nf_nat_unknown_protocol;
58 extern int init_protocols(void) __init;
59 extern void cleanup_protocols(void);
60 extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
62 extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
63 enum nf_nat_manip_type maniptype,
64 const union nf_conntrack_man_proto *min,
65 const union nf_conntrack_man_proto *max);
67 extern bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
68 const struct nf_nat_range *range,
69 enum nf_nat_manip_type maniptype,
70 const struct nf_conn *ct,
73 extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb,
74 const struct nf_nat_range *range);
75 extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
76 struct nf_nat_range *range);
78 #endif /*_NF_NAT_PROTO_H*/