1 /*
2  * Copyright (C) 2022 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 FILLP_COMMON_H
17 #define FILLP_COMMON_H
18 
19 #include "fillptypes.h"
20 #include "fillp_os.h"
21 #include "spunge_stack.h"
22 #include "socket_common.h"
23 #include "hmac.h"
24 #include "res.h"
25 #include "fillp_buf_item.h"
26 #include "dympool.h"
27 #include "spunge_message.h"
28 #include "fillp_flow_control.h"
29 #include "utils.h"
30 #include "fillp.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define FILLP_GET_CONN(pcb) ((struct FtNetconn*) ((struct SpungePcb*) ((pcb)->spcb))->conn)
37 #define FILLP_GET_SOCKET(pcb) ((struct FtSocket*)(FILLP_GET_CONN(pcb)->sock))
38 #define FILLP_GET_CONN_STATE(pcb) NETCONN_GET_STATE(FILLP_GET_CONN(pcb))
39 
40 #define FILLP_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
41 
42 #define FILLP_UNACKLIST_HASHINDEX(seqNum, pcb) \
43     (((seqNum) / FILLP_UNACK_HASH_MOD) & (pcb)->send.unackList.hashModSize)
44 
45 #define FILLP_INTERVAL_THRESHOLD 5000
46 #define FILLP_INTERVAL_DEFAULT 1000
47 void InsertUnrecvListFail(struct FillpPcb *pcb, struct FillpPcbItem *item);
48 void FillpAjustTlpParameterByRtt(struct FillpPcb *pcb, FILLP_LLONG rtt);
49 void FillpFreeItemAndEvent(struct FillpPcb *pcb, struct FillpPcbItem *item);
50 void FillpAdjustFcParamsByRtt(struct FillpPcb *pcb);
51 IGNORE_OVERFLOW void FillpAckSendPcb(struct FillpPcb *pcb, FILLP_INT seqNum);
52 IGNORE_OVERFLOW void FillpUploadRecvBox(struct FillpPcb *pcb);
53 void FillpSendNack(struct FillpPcb *pcb, FILLP_UINT32 startPktNum, FILLP_UINT32 endPktNum);
54 void FillpBuildAndSendPack(struct FillpPcb *pcb, struct FtSocket *ftSock, struct FillpPktPack *pack,
55     FILLP_UINT16 dataLen);
56 void FillpMoveUnackToUnrecv(FILLP_UINT32 last_seq, FILLP_UINT32 cur_seq, struct FillpPcb *pcb,
57     FILLP_BOOL isFromPack);
58 void FillpMoveUnackToUnrecvAll(FILLP_UINT32 ackSeq, FILLP_UINT32 lostSeq, struct FillpPcb *pcb,
59     FILLP_BOOL isFromPack, FILLP_BOOL onePktOnly);
60 void FillpDataToStack(struct FillpPcb *pcb, struct FillpPcbItem *buf);
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif /* FILLP_COMMON_H */