1 /* 2 * Copyright (c) 2021-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 SOFTBUS_PROXYCHANNEL_MANAGER_H 17 #define SOFTBUS_PROXYCHANNEL_MANAGER_H 18 19 #include "stdint.h" 20 #include "auth_interface.h" 21 #include "softbus_app_info.h" 22 #include "softbus_conn_interface.h" 23 #include "softbus_proxychannel_message.h" 24 #include "trans_channel_callback.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 #define FAST_EXT_BYTE_SIZE (OVERHEAD_LEN + sizeof(PacketFastHead) + sizeof(SliceFastHead) + sizeof(SessionHead)) 30 #define FAST_EXT_MSG_SIZE (OVERHEAD_LEN + sizeof(PacketFastHead) + sizeof(SliceFastHead)) 31 32 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 33 34 SoftBusList *GetProxyChannelMgrHead(void); 35 int32_t GetProxyChannelLock(void); 36 void ReleaseProxyChannelLock(void); 37 int32_t TransProxyManagerInit(const IServerChannelCallBack *cb); 38 void TransProxyManagerDeinit(void); 39 40 int32_t TransProxyGetNewChanSeq(int32_t channelId); 41 int32_t TransProxyOpenProxyChannel(AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId); 42 int32_t TransProxyCloseProxyChannel(int32_t channelId); 43 44 void TransProxyDelByConnId(uint32_t connId); 45 void TransProxyDelChanByReqId(int32_t reqId, int32_t errCode); 46 void TransProxyDelChanByChanId(int32_t chanlId); 47 int32_t TransProxyGetChanByChanId(int32_t chanId, ProxyChannelInfo *chan); 48 int32_t TransProxyGetChanByReqId(int32_t reqId, ProxyChannelInfo *chan); 49 50 void TransProxyOpenProxyChannelSuccess(int32_t channelId); 51 void TransProxyOpenProxyChannelFail(int32_t channelId, const AppInfo *appInfo, int32_t errCode); 52 void TransProxyOnMessageReceived(const ProxyMessage *msg); 53 54 int32_t TransProxyGetSessionKeyByChanId(int32_t channelId, char *sessionKey, uint32_t sessionKeySize); 55 int32_t TransProxyGetSendMsgChanInfo(int32_t channelId, ProxyChannelInfo *chanInfo); 56 57 int32_t TransProxyCreateChanInfo(ProxyChannelInfo *chan, int32_t channelId, const AppInfo *appInfo); 58 void TransProxyChanProcessByReqId(int32_t reqId, uint32_t connId); 59 60 int32_t TransProxyGetAuthId(int32_t channelId, AuthHandle *authHandle); 61 int32_t TransProxyGetNameByChanId(int32_t chanId, char *pkgName, char *sessionName, 62 uint16_t pkgLen, uint16_t sessionLen); 63 64 int32_t TransRefreshProxyTimesNative(int channelId); 65 66 void TransProxyDeathCallback(const char *pkgName, int32_t pid); 67 68 int32_t TransProxyGetAppInfoByChanId(int32_t chanId, AppInfo* appInfo); 69 int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId); 70 int32_t TransProxyGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt); 71 72 int32_t TransProxyGetAppInfoType(int16_t myId, const char *identity, AppType *appType); 73 int32_t TransProxySpecialUpdateChanInfo(ProxyChannelInfo *channelInfo); 74 int32_t TransProxySetAuthHandleByChanId(int32_t channelId, AuthHandle authHandle); 75 76 void TransProxyNegoSessionKeySucc(int32_t channelId); 77 void TransProxyNegoSessionKeyFail(int32_t channelId, int32_t errCode); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif 84