• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_PROXYCHANNEL_MANAGER_H
17 #define SOFTBUS_PROXYCHANNEL_MANAGER_H
18 
19 #include "softbus_proxychannel_message.h"
20 #include "trans_channel_callback.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 #define FAST_EXT_BYTE_SIZE (OVERHEAD_LEN + sizeof(PacketFastHead) + sizeof(SliceFastHead) + sizeof(SessionHead))
26 #define FAST_EXT_MSG_SIZE (OVERHEAD_LEN + sizeof(PacketFastHead) + sizeof(SliceFastHead))
27 
28 #define MIN(a, b) ((a) < (b) ? (a) : (b))
29 
30 SoftBusList *GetProxyChannelMgrHead(void);
31 int32_t GetProxyChannelLock(void);
32 void ReleaseProxyChannelLock(void);
33 int32_t TransProxyManagerInit(const IServerChannelCallBack *cb);
34 void TransProxyManagerDeinit(void);
35 
36 int32_t TransProxyGetNewChanSeq(int32_t channelId);
37 int32_t TransProxyOpenProxyChannel(AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId);
38 int32_t TransProxyCloseProxyChannel(int32_t channelId);
39 
40 void TransProxyDelByConnId(uint32_t connId);
41 void TransProxyDelChanByReqId(int32_t reqId, int32_t errCode);
42 void TransProxyDelChanByChanId(int32_t chanlId);
43 int32_t TransProxyGetChanByChanId(int32_t chanId, ProxyChannelInfo *chan);
44 int32_t TransProxyGetChanByReqId(int32_t reqId, ProxyChannelInfo *chan);
45 
46 void TransProxyOpenProxyChannelSuccess(int32_t channelId);
47 void TransProxyOpenProxyChannelFail(int32_t channelId, const AppInfo *appInfo, int32_t errCode);
48 void TransProxyOnMessageReceived(const ProxyMessage *msg);
49 
50 int32_t TransProxyGetChannelCapaByChanId(int32_t channelId, uint32_t *channelCapability);
51 int32_t TransProxyGetSessionKeyByChanId(int32_t channelId, char *sessionKey, uint32_t sessionKeySize);
52 int32_t TransProxyGetSendMsgChanInfo(int32_t channelId, ProxyChannelInfo *chanInfo);
53 
54 int32_t TransProxyCreateChanInfo(ProxyChannelInfo *chan, int32_t channelId, const AppInfo *appInfo);
55 void TransProxyChanProcessByReqId(int32_t reqId, uint32_t connId, int32_t errCode);
56 
57 int32_t TransProxyGetAuthId(int32_t channelId, AuthHandle *authHandle);
58 int32_t TransProxyGetNameByChanId(int32_t chanId, char *pkgName, char *sessionName,
59     uint16_t pkgLen, uint16_t sessionLen);
60 
61 int32_t TransRefreshProxyTimesNative(int32_t channelId);
62 
63 void TransProxyDeathCallback(const char *pkgName, int32_t pid);
64 
65 int32_t TransProxyGetAppInfoByChanId(int32_t chanId, AppInfo* appInfo);
66 int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId);
67 int32_t TransProxyGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt);
68 
69 int32_t TransProxyGetAppInfoType(int16_t myId, const char *identity, AppType *appType);
70 int32_t TransProxySpecialUpdateChanInfo(ProxyChannelInfo *channelInfo);
71 int32_t TransProxySetAuthHandleByChanId(int32_t channelId, AuthHandle authHandle);
72 
73 int32_t TransDealProxyChannelOpenResult(
74     int32_t channelId, int32_t openResult, const AccessInfo *accessInfo, pid_t callingPid);
75 void TransAsyncProxyChannelTask(int32_t channelId);
76 
77 int32_t TransProxyGetPrivilegeCloseList(ListNode *privilegeCloseList, uint64_t tokenId, int32_t pid);
78 
79 int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId);
80 int32_t TransProxyGetProxyChannelInfoByChannelId(int32_t channelId, ProxyChannelInfo *chan);
81 
82 int32_t TransDealProxyCheckCollabResult(int32_t channelId, int32_t checkResult, pid_t callingPid);
83 int32_t TransProxyGetAppInfoById(int16_t channelId, AppInfo *appInfo);
84 
85 int32_t TransProxyCreatePagingChanInfo(ProxyChannelInfo *chan);
86 int32_t TransProxyGetProxyChannelIdByAuthReq(uint32_t reqId, int32_t *channelId);
87 int32_t TransPagingResetChan(ProxyChannelInfo *chanInfo);
88 char *TransPagingPackHandshakeMsg(ProxyChannelInfo *info);
89 int32_t TransPagingHandshakeUnPackErrMsg(ProxyChannelInfo *chan, const ProxyMessage *msg, int32_t *errCode);
90 int32_t TransProxyGetChannelByFlag(uint32_t businessFlag, ProxyChannelInfo *chan, bool isClient);
91 void TransProxyProcessErrMsg(ProxyChannelInfo *info, int32_t errCode);
92 int32_t TransPagingUpdatePagingChannelInfo(ProxyChannelInfo *info);
93 int32_t TransPagingUpdatePidAndData(int32_t channelId, int32_t pid, char *data, uint32_t len);
94 void TransPagingBadKeyRetry(int32_t channelId);
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif
100