1 /*
2  * Copyright (c) 2024 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 TRANS_NETWORK_STATISTICS_H
17 #define TRANS_NETWORK_STATISTICS_H
18 
19 #include "softbus_common.h"
20 #include "softbus_def.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define MAX_LANE_ID_LEN 64
27 #define MAX_SOCKET_RESOURCE_NUM 128
28 #define MAX_NETWORK_RESOURCE_NUM 128
29 #define MAX_CHANNEL_INFO_NUM 128
30 #define MAX_SOCKET_RESOURCE_LEN 1024
31 
32 typedef struct {
33     ListNode node;
34     char socketName[SESSION_NAME_SIZE_MAX];
35     int32_t socketId;
36     int32_t channelId;
37     int32_t channelType;
38     uint64_t laneId;
39     int64_t traffic;
40     int64_t startTime;
41     int64_t endTime;
42 } SocketResource;
43 
44 typedef struct {
45     uint64_t laneId;
46     char localUdid[UDID_BUF_LEN];
47     char peerUdid[UDID_BUF_LEN];
48     int32_t laneLinkType;
49 } NetworkResource;
50 
51 void AddChannelStatisticsInfo(int32_t channelId, int32_t channelType);
52 
53 void AddNetworkResource(NetworkResource *networkResource);
54 
55 void UpdateNetworkResourceByLaneId(int32_t channelId, int32_t channelType, uint64_t laneId, const void *dataInfo,
56     uint32_t len);
57 
58 void DeleteNetworkResourceByLaneId(uint64_t laneId);
59 
60 int32_t TransNetworkStatisticsInit(void);
61 
62 void TransNetworkStatisticsDeinit(void);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 #endif // TRANS_NETWORK_STATISTICS_H