xref: /linux/include/net/netfilter/nf_conntrack_seqadj.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NF_CONNTRACK_SEQADJ_H
3 #define _NF_CONNTRACK_SEQADJ_H
4 
5 #include <net/netfilter/nf_conntrack_extend.h>
6 
7 /**
8  * struct nf_ct_seqadj - sequence number adjustment information
9  *
10  * @correction_pos: position of the last TCP sequence number modification
11  * @offset_before: sequence number offset before last modification
12  * @offset_after: sequence number offset after last modification
13  */
14 struct nf_ct_seqadj {
15 	u32		correction_pos;
16 	s32		offset_before;
17 	s32		offset_after;
18 };
19 
20 struct nf_conn_seqadj {
21 	struct nf_ct_seqadj	seq[IP_CT_DIR_MAX];
22 };
23 
nfct_seqadj(const struct nf_conn * ct)24 static inline struct nf_conn_seqadj *nfct_seqadj(const struct nf_conn *ct)
25 {
26 	return nf_ct_ext_find(ct, NF_CT_EXT_SEQADJ);
27 }
28 
nfct_seqadj_ext_add(struct nf_conn * ct)29 static inline struct nf_conn_seqadj *nfct_seqadj_ext_add(struct nf_conn *ct)
30 {
31 	return nf_ct_ext_add(ct, NF_CT_EXT_SEQADJ, GFP_ATOMIC);
32 }
33 
34 int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
35 		      s32 off);
36 int nf_ct_seqadj_set(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
37 		     __be32 seq, s32 off);
38 void nf_ct_tcp_seqadj_set(struct sk_buff *skb, struct nf_conn *ct,
39 			  enum ip_conntrack_info ctinfo, s32 off);
40 
41 int nf_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
42 		     enum ip_conntrack_info ctinfo, unsigned int protoff);
43 s32 nf_ct_seq_offset(const struct nf_conn *ct, enum ip_conntrack_dir, u32 seq);
44 
45 #endif /* _NF_CONNTRACK_SEQADJ_H */
46