License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / include / net / netfilter / nf_nat_l4proto.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
c7232c99
PM
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
8struct nf_nat_range;
9struct nf_nat_l3proto;
10
11struct 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. */
4e77be46
JP
46int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto);
47void nf_nat_l4proto_unregister(u8 l3proto,
48 const struct nf_nat_l4proto *l4proto);
c7232c99 49
4e77be46 50const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto);
c7232c99
PM
51
52/* Built-in protocols. */
53extern const struct nf_nat_l4proto nf_nat_l4proto_tcp;
54extern const struct nf_nat_l4proto nf_nat_l4proto_udp;
55extern const struct nf_nat_l4proto nf_nat_l4proto_icmp;
58a317f1 56extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6;
c7232c99 57extern const struct nf_nat_l4proto nf_nat_l4proto_unknown;
0c4e966e
DC
58#ifdef CONFIG_NF_NAT_PROTO_DCCP
59extern const struct nf_nat_l4proto nf_nat_l4proto_dccp;
60#endif
7a2dd28c
DC
61#ifdef CONFIG_NF_NAT_PROTO_SCTP
62extern const struct nf_nat_l4proto nf_nat_l4proto_sctp;
63#endif
b8ad652f
DC
64#ifdef CONFIG_NF_NAT_PROTO_UDPLITE
65extern const struct nf_nat_l4proto nf_nat_l4proto_udplite;
66#endif
c7232c99 67
4e77be46
JP
68bool 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);
c7232c99 72
4e77be46
JP
73void 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);
c7232c99 78
4e77be46
JP
79int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[],
80 struct nf_nat_range *range);
c7232c99
PM
81
82#endif /*_NF_NAT_L4PROTO_H*/