• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PCB_H
17 #define PCB_H
18 
19 #include "fillp_os.h"
20 #include "fillp/fillp_pcb.h"
21 #include "mem_pool.h"
22 #include "queue.h"
23 #include "hlist.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /* Implementing Fair Bandwidth sharing among sockets */
31 struct SpungePcbRateControlItem {
32     FILLP_UINT32 curMaxRateLimitation;
33     FILLP_INT weight;
34 };
35 
36 struct SpungePcbRateControl {
37     struct SpungePcbRateControlItem send;
38     struct SpungePcbRateControlItem recv;
39 };
40 
41 #ifndef IFNAMESIZE
42 #define IFNAMESIZE 64
43 #endif
44 struct SpungePcb {
45     struct HlistNode udpNode;
46     struct HlistNode hashNode;
47     struct FillpPcb fpcb;
48 
49     void *conn;
50 
51     /* Implementing Fair Bandwidth sharing among sockets */
52     struct SpungePcbRateControl rateControl;
53 
54     struct sockaddr_in6 localAddr;
55     struct sockaddr_in6 remoteAddr;
56 
57     FILLP_INT localPort;
58     FILLP_UINT16 addrType;
59     FILLP_UINT16 addrLen;
60 
61     FILLP_CHAR devName[IFNAMESIZE];
62     FILLP_INT ifIndex;
63 };
64 
SpungePcbListNodeEntry(struct HlistNode * node)65 static __inline struct SpungePcb *SpungePcbListNodeEntry(struct HlistNode *node)
66 {
67     return (struct SpungePcb *)((char *)(node) - (uintptr_t)(&(((struct SpungePcb *)0)->udpNode)));
68 }
69 
SpungePcbHashNodeEntry(struct HlistNode * node)70 static __inline struct SpungePcb *SpungePcbHashNodeEntry(struct HlistNode *node)
71 {
72     return (struct SpungePcb *)((char *)(node) - (uintptr_t)(&(((struct SpungePcb *)0)->hashNode)));
73 }
74 
75 void SpcbAddPcbToSpinst(struct SpungeInstance *inst, struct SpungePcb *pcb);
76 void SpcbDeleteFromSpinst(struct SpungeInstance *inst, struct SpungePcb *pcb);
77 
78 
79 struct SpungePcb *SpungePcbNew(void *argConn, struct SpungeInstance *inst);
80 
81 void SpungePcbRemove(struct SpungePcb *pcb);
82 
83 void SpungePcbSetSendCacheSize(struct SpungePcb *pcb, FILLP_UINT32 cahceSize);
84 void SpungePcbSetRecvCacheSize(struct SpungePcb *pcb, FILLP_UINT32 cahceSize);
85 void SpungePcbSetPktSize(struct SpungePcb *pcb, FILLP_UINT32 pktSize);
86 void SpungePcbSetOppositeRate(struct SpungePcb *pcb, FILLP_UINT32 rate);
87 void SpungePcbSetSlowStart(struct SpungePcb *pcb, FILLP_BOOL slowStart);
88 void SpungePcbSetPackInterval(struct SpungePcb *pcb, FILLP_UINT32 interval);
89 void SpungePcbSetAddrType(struct SpungePcb *pcb, FILLP_UINT16 addrType);
90 void SpungePcbSetLocalPort(struct SpungePcb *pcb, FILLP_INT port);
91 void SpungePcbSetDirectlySend(struct SpungePcb *pcb, FILLP_INT directlySend);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif
98