1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SOFTBUS_SEQUENCE_VERIFICATION_H
17 #define SOFTBUS_SEQUENCE_VERIFICATION_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "softbus_def.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 /* when receive seq < minSeq, the package is duplicated.
30    when receive seq == minSeq, update minSeq.
31    when minSeq < receive seq < maxSeq, Check whether duplicate package exist, record the package in bitmap.
32    when receive seq >= maxSeq, update maxSeq, record the package in bitmap.
33 */
34 typedef struct {
35     int32_t maxSeq;
36     int32_t minSeq;
37     uint64_t recvBitmap;
38 } SeqVerifyInfo;
39 
40 /* When the received package is an ACK packet, this function does not need to be called for verification. */
41 bool IsPassSeqCheck(SeqVerifyInfo *seqVerifyInfo, int32_t recvSeq);
42 
43 #ifdef __cplusplus
44 #if __cplusplus
45 }
46 #endif /* __cplusplus */
47 #endif /* __cplusplus */
48 
49 #endif // !SOFTBUS_SEQUENCE_VERIFICATION_H
50