1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _NF_NAT_HELPER_H |
3 | #define _NF_NAT_HELPER_H |
4 | /* NAT protocol helper routines. */ |
5 | |
6 | #include <linux/skbuff.h> |
7 | #include <net/netfilter/nf_conntrack.h> |
8 | #include <net/netfilter/nf_conntrack_expect.h> |
9 | |
10 | /* These return true or false. */ |
11 | bool __nf_nat_mangle_tcp_packet(struct sk_buff *skb, struct nf_conn *ct, |
12 | enum ip_conntrack_info ctinfo, |
13 | unsigned int protoff, unsigned int match_offset, |
14 | unsigned int match_len, const char *rep_buffer, |
15 | unsigned int rep_len, bool adjust); |
16 | |
17 | static inline bool nf_nat_mangle_tcp_packet(struct sk_buff *skb, |
18 | struct nf_conn *ct, |
19 | enum ip_conntrack_info ctinfo, |
20 | unsigned int protoff, |
21 | unsigned int match_offset, |
22 | unsigned int match_len, |
23 | const char *rep_buffer, |
24 | unsigned int rep_len) |
25 | { |
26 | return __nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff, |
27 | match_offset, match_len, |
28 | rep_buffer, rep_len, adjust: true); |
29 | } |
30 | |
31 | bool nf_nat_mangle_udp_packet(struct sk_buff *skb, struct nf_conn *ct, |
32 | enum ip_conntrack_info ctinfo, |
33 | unsigned int protoff, unsigned int match_offset, |
34 | unsigned int match_len, const char *rep_buffer, |
35 | unsigned int rep_len); |
36 | |
37 | /* Setup NAT on this expected conntrack so it follows master, but goes |
38 | * to port ct->master->saved_proto. */ |
39 | void nf_nat_follow_master(struct nf_conn *ct, struct nf_conntrack_expect *this); |
40 | |
41 | u16 nf_nat_exp_find_port(struct nf_conntrack_expect *exp, u16 port); |
42 | #endif |
43 | |