]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - include/net/netfilter/nf_nat_l4proto.h
Merge remote-tracking branches 'asoc/topic/ac97', 'asoc/topic/ac97-mfd', 'asoc/topic...
[mirror_ubuntu-focal-kernel.git] / include / net / netfilter / nf_nat_l4proto.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Header for use in defining a given protocol. */
3 #ifndef _NF_NAT_L4PROTO_H
4 #define _NF_NAT_L4PROTO_H
5 #include <net/netfilter/nf_nat.h>
6 #include <linux/netfilter/nfnetlink_conntrack.h>
7
8 struct nf_nat_range;
9 struct nf_nat_l3proto;
10
11 struct nf_nat_l4proto {
12 /* Protocol number. */
13 u8 l4proto;
14
15 /* Translate a packet to the target according to manip type.
16 * Return true if succeeded.
17 */
18 bool (*manip_pkt)(struct sk_buff *skb,
19 const struct nf_nat_l3proto *l3proto,
20 unsigned int iphdroff, unsigned int hdroff,
21 const struct nf_conntrack_tuple *tuple,
22 enum nf_nat_manip_type maniptype);
23
24 /* Is the manipable part of the tuple between min and max incl? */
25 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
26 enum nf_nat_manip_type maniptype,
27 const union nf_conntrack_man_proto *min,
28 const union nf_conntrack_man_proto *max);
29
30 /* Alter the per-proto part of the tuple (depending on
31 * maniptype), to give a unique tuple in the given range if
32 * possible. Per-protocol part of tuple is initialized to the
33 * incoming packet.
34 */
35 void (*unique_tuple)(const struct nf_nat_l3proto *l3proto,
36 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);
40
41 int (*nlattr_to_range)(struct nlattr *tb[],
42 struct nf_nat_range *range);
43 };
44
45 /* Protocol registration. */
46 int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto);
47 void nf_nat_l4proto_unregister(u8 l3proto,
48 const struct nf_nat_l4proto *l4proto);
49
50 const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto);
51
52 /* Built-in protocols. */
53 extern const struct nf_nat_l4proto nf_nat_l4proto_tcp;
54 extern const struct nf_nat_l4proto nf_nat_l4proto_udp;
55 extern const struct nf_nat_l4proto nf_nat_l4proto_icmp;
56 extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6;
57 extern const struct nf_nat_l4proto nf_nat_l4proto_unknown;
58 #ifdef CONFIG_NF_NAT_PROTO_DCCP
59 extern const struct nf_nat_l4proto nf_nat_l4proto_dccp;
60 #endif
61 #ifdef CONFIG_NF_NAT_PROTO_SCTP
62 extern const struct nf_nat_l4proto nf_nat_l4proto_sctp;
63 #endif
64 #ifdef CONFIG_NF_NAT_PROTO_UDPLITE
65 extern const struct nf_nat_l4proto nf_nat_l4proto_udplite;
66 #endif
67
68 bool nf_nat_l4proto_in_range(const struct nf_conntrack_tuple *tuple,
69 enum nf_nat_manip_type maniptype,
70 const union nf_conntrack_man_proto *min,
71 const union nf_conntrack_man_proto *max);
72
73 void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto,
74 struct nf_conntrack_tuple *tuple,
75 const struct nf_nat_range *range,
76 enum nf_nat_manip_type maniptype,
77 const struct nf_conn *ct, u16 *rover);
78
79 int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[],
80 struct nf_nat_range *range);
81
82 #endif /*_NF_NAT_L4PROTO_H*/