GNU Linux-libre 4.19.286-gnu1
[releases.git] / include / net / netfilter / nf_nat_l3proto.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NF_NAT_L3PROTO_H
3 #define _NF_NAT_L3PROTO_H
4
5 struct nf_nat_l4proto;
6 struct nf_nat_l3proto {
7         u8      l3proto;
8
9         bool    (*in_range)(const struct nf_conntrack_tuple *t,
10                             const struct nf_nat_range2 *range);
11
12         u32     (*secure_port)(const struct nf_conntrack_tuple *t, __be16);
13
14         bool    (*manip_pkt)(struct sk_buff *skb,
15                              unsigned int iphdroff,
16                              const struct nf_nat_l4proto *l4proto,
17                              const struct nf_conntrack_tuple *target,
18                              enum nf_nat_manip_type maniptype);
19
20         void    (*csum_update)(struct sk_buff *skb, unsigned int iphdroff,
21                                __sum16 *check,
22                                const struct nf_conntrack_tuple *t,
23                                enum nf_nat_manip_type maniptype);
24
25         void    (*csum_recalc)(struct sk_buff *skb, u8 proto,
26                                void *data, __sum16 *check,
27                                int datalen, int oldlen);
28
29         void    (*decode_session)(struct sk_buff *skb,
30                                   const struct nf_conn *ct,
31                                   enum ip_conntrack_dir dir,
32                                   unsigned long statusbit,
33                                   struct flowi *fl);
34
35         int     (*nlattr_to_range)(struct nlattr *tb[],
36                                    struct nf_nat_range2 *range);
37 };
38
39 int nf_nat_l3proto_register(const struct nf_nat_l3proto *);
40 void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *);
41 const struct nf_nat_l3proto *__nf_nat_l3proto_find(u8 l3proto);
42
43 int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
44                                   enum ip_conntrack_info ctinfo,
45                                   unsigned int hooknum);
46
47 int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
48                                     enum ip_conntrack_info ctinfo,
49                                     unsigned int hooknum, unsigned int hdrlen);
50
51 int nf_nat_l3proto_ipv4_register_fn(struct net *net, const struct nf_hook_ops *ops);
52 void nf_nat_l3proto_ipv4_unregister_fn(struct net *net, const struct nf_hook_ops *ops);
53
54 int nf_nat_l3proto_ipv6_register_fn(struct net *net, const struct nf_hook_ops *ops);
55 void nf_nat_l3proto_ipv6_unregister_fn(struct net *net, const struct nf_hook_ops *ops);
56
57 #endif /* _NF_NAT_L3PROTO_H */