Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nf_nat_l4proto.h
Go to the documentation of this file.
1 /* Header for use in defining a given protocol. */
2 #ifndef _NF_NAT_L4PROTO_H
3 #define _NF_NAT_L4PROTO_H
4 #include <net/netfilter/nf_nat.h>
6 
7 struct nf_nat_range;
8 struct nf_nat_l3proto;
9 
11  /* Protocol number. */
13 
14  /* Translate a packet to the target according to manip type.
15  * Return true if succeeded.
16  */
17  bool (*manip_pkt)(struct sk_buff *skb,
18  const struct nf_nat_l3proto *l3proto,
19  unsigned int iphdroff, unsigned int hdroff,
20  const struct nf_conntrack_tuple *tuple,
21  enum nf_nat_manip_type maniptype);
22 
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);
28 
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. Per-protocol part of tuple is initialized to the
32  * incoming packet.
33  */
35  struct nf_conntrack_tuple *tuple,
36  const struct nf_nat_range *range,
37  enum nf_nat_manip_type maniptype,
38  const struct nf_conn *ct);
39 
40  int (*nlattr_to_range)(struct nlattr *tb[],
41  struct nf_nat_range *range);
42 };
43 
44 /* Protocol registration. */
45 extern int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto);
46 extern void nf_nat_l4proto_unregister(u8 l3proto, const struct nf_nat_l4proto *l4proto);
47 
48 extern const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto);
49 
50 /* Built-in protocols. */
51 extern const struct nf_nat_l4proto nf_nat_l4proto_tcp;
52 extern const struct nf_nat_l4proto nf_nat_l4proto_udp;
53 extern const struct nf_nat_l4proto nf_nat_l4proto_icmp;
54 extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6;
55 extern const struct nf_nat_l4proto nf_nat_l4proto_unknown;
56 
57 extern bool nf_nat_l4proto_in_range(const struct nf_conntrack_tuple *tuple,
58  enum nf_nat_manip_type maniptype,
59  const union nf_conntrack_man_proto *min,
60  const union nf_conntrack_man_proto *max);
61 
62 extern void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto,
63  struct nf_conntrack_tuple *tuple,
64  const struct nf_nat_range *range,
65  enum nf_nat_manip_type maniptype,
66  const struct nf_conn *ct,
67  u16 *rover);
68 
69 extern int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[],
70  struct nf_nat_range *range);
71 
72 #endif /*_NF_NAT_L4PROTO_H*/