1 /* 2 * Copyright (c) 2021 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_AUTH_MANAGER_H 17 #define TRANS_AUTH_MANAGER_H 18 19 #include "softbus_conn_interface.h" 20 #include "trans_channel_callback.h" 21 #include "softbus_app_info.h" 22 #include "lnn_lane_interface.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif /* __cplusplus */ 28 #endif /* __cplusplus */ 29 30 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 31 32 typedef struct { 33 ListNode node; 34 AppInfo appInfo; 35 int32_t authId; 36 ConnectOption connOpt; 37 bool isClient; 38 } AuthChannelInfo; 39 40 SoftBusList *GetAuthChannelListHead(void); 41 int32_t GetAuthChannelLock(void); 42 void ReleaseAuthChannelLock(void); 43 int32_t TransAuthInit(IServerChannelCallBack *cb); 44 void TransAuthDeinit(void); 45 int32_t TransAuthGetNameByChanId(int32_t chanId, char *pkgName, char *sessionName, 46 uint16_t pkgLen, uint16_t sessionLen); 47 int32_t TransOpenAuthMsgChannelWithPara(const char *sessionName, const LaneConnInfo *connInfo, int32_t *channelId); 48 int32_t TransOpenAuthMsgChannel(const char *sessionName, const ConnectOption *connOpt, int32_t *channelId, 49 const char *reqId); 50 int32_t TransNotifyAuthDataSuccess(int32_t channelId, const ConnectOption *connOpt); 51 int32_t TransCloseAuthChannel(int32_t channelId); 52 int32_t TransSendAuthMsg(int32_t channelId, const char *msg, int32_t len); 53 int32_t TransAuthGetAppInfoByChanId(int32_t channelId, AppInfo *appInfo); 54 int32_t TransAuthGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt); 55 int32_t TransAuthGetConnIdByChanId(int32_t channelId, int32_t *connId); 56 int32_t GetAppInfo(const char *sessionName, int32_t channelId, AppInfo *appInfo, bool isClient); 57 int32_t NotifyOpenAuthChannelFailed(const char *pkgName, int32_t pid, int32_t channelId, int32_t errCode); 58 int32_t CheckIsWifiAuthChannel(ConnectOption *connInfo); 59 60 #ifdef __cplusplus 61 #if __cplusplus 62 } 63 #endif /* __cplusplus */ 64 #endif /* __cplusplus */ 65 66 #endif