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_CHANNEL_COMMON_H
17 #define TRANS_CHANNEL_COMMON_H
18 
19 #include <stdint.h>
20 #include <stdlib.h>
21 #include <stdbool.h>
22 
23 #include "lnn_distributed_net_ledger.h"
24 #include "lnn_lane_interface.h"
25 #include "lnn_node_info.h"
26 #include "softbus_app_info.h"
27 #include "softbus_conn_interface.h"
28 #include "softbus_trans_def.h"
29 #include "trans_event.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
35 void FillAppInfo(AppInfo *appInfo, const SessionParam *param,
36     TransInfo *transInfo, const LaneConnInfo *connInfo);
37 
38 int32_t TransCommonGetAppInfo(const SessionParam *param, AppInfo *appInfo);
39 
40 void TransOpenChannelSetModule(int32_t channelType, ConnectOption *connOpt);
41 
42 void TransBuildTransOpenChannelStartEvent(
43     TransEventExtra *extra, AppInfo *appInfo, NodeInfo *nodeInfo, int32_t peerRet);
44 
45 void TransBuildOpenAuthChannelStartEvent(
46     TransEventExtra *extra, const char *sessionName, const ConnectOption *connOpt, char *localUdid, char *callerPkg);
47 
48 void TransBuildTransOpenChannelEndEvent(TransEventExtra *extra, TransInfo *transInfo, int64_t timeStart, int32_t ret);
49 
50 void TransBuildTransOpenChannelCancelEvent(
51     TransEventExtra *extra, TransInfo *transInfo, int64_t timeStart, int32_t ret);
52 
53 void TransBuildTransAlarmEvent(TransAlarmExtra *extraAlarm, AppInfo *appInfo, int32_t ret);
54 
55 void TransReportBadKeyEvent(int32_t errCode, uint32_t connectionId, int64_t seq, int32_t len);
56 
57 LaneTransType TransGetLaneTransTypeBySession(const SessionParam *param);
58 
59 int32_t TransOpenChannelProc(ChannelType type, AppInfo *appInfo, const ConnectOption *connOpt,
60     int32_t *channelId);
61 
62 int32_t TransCommonCloseChannel(const char *sessionName, int32_t channelId, int32_t channelType);
63 
64 int32_t TransCommonGetLocalConfig(int32_t channelType, int32_t businessType, uint32_t *len);
65 
66 void TransFreeAppInfo(AppInfo *appInfo);
67 
68 void TransFreeLane(uint32_t laneHandle, bool isQosLane, bool isAsync);
69 
70 bool IsPeerDeviceLegacyOs(int32_t osType);
71 
72 void GetOsTypeByNetworkId(const char *networkId, int32_t *osType);
73 
74 void GetRemoteUdidWithNetworkId(const char *networkId, char *info, uint32_t len);
75 
76 void TransGetRemoteDeviceVersion(const char *id, IdCategory type, char *deviceVersion, uint32_t len);
77 
78 TransDeviceState TransGetDeviceState(const char *networkId);
79 
80 #ifdef __cplusplus
81 }
82 #endif /* __cplusplus */
83 #endif
84