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_TRANSCEIVER_H 17 #define SOFTBUS_PROXYCHANNEL_TRANSCEIVER_H 18 19 #include "softbus_proxychannel_message.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 typedef struct { 26 ListNode node; 27 uint32_t requestId; 28 uint32_t connId; 29 int32_t ref; 30 uint32_t state; 31 bool isServerSide; 32 ConnectOption connInfo; 33 } ProxyConnInfo; 34 35 typedef struct { 36 ListNode node; 37 uint32_t businessFlag; 38 bool isListened; 39 bool isLoadFailed; 40 int32_t retryTime; 41 } ProxyPagingWaitInfo; 42 43 void TransProxyPostResetPeerMsgToLoop(const ProxyChannelInfo *chan); 44 void TransProxyPostHandshakeMsgToLoop(int32_t channelId); 45 void TransProxyPostDisConnectMsgToLoop(uint32_t connId, bool isServer, const ProxyChannelInfo *chan); 46 void TransProxyPostOpenClosedMsgToLoop(const ProxyChannelInfo *chan); 47 void TransProxyPostOpenFailMsgToLoop(const ProxyChannelInfo *chan, int32_t errCode); 48 void TransProxyPostKeepAliveMsgToLoop(const ProxyChannelInfo *chan); 49 void TransProxyPostAuthNegoMsgToLooperDelay(uint32_t authRequestId, int32_t channelId, uint32_t delayTime); 50 void TransProxyPagingHandshakeMsgToLoop(int32_t channelId, uint8_t *authKey, uint32_t keyLen); 51 int32_t TransProxyTransInit(void); 52 int32_t TransProxyCloseConnChannel(uint32_t connectionId, bool isServer); 53 int32_t TransProxyCloseConnChannelReset(uint32_t connectionId, bool isDisconnect, bool isServer, bool deviceType); 54 int32_t TransProxyOpenConnChannel(const AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId); 55 int32_t TransProxyTransSendMsg(uint32_t connectionId, uint8_t *buf, uint32_t len, int32_t priority, int32_t pid); 56 void TransCreateConnByConnId(uint32_t connId, bool isServer); 57 int32_t TransDecConnRefByConnId(uint32_t connId, bool isServer); 58 int32_t TransAddConnRefByConnId(uint32_t connId, bool isServer); 59 int32_t TransProxyGetConnInfoByConnId(uint32_t connId, ConnectOption *connInfo); 60 int32_t TransDelConnByReqId(uint32_t requestId); 61 int32_t CheckIsProxyAuthChannel(ConnectOption *connInfo); 62 void TransProxyNegoSessionKeySucc(int32_t channelId); 63 void TransProxyNegoSessionKeyFail(int32_t channelId, int32_t errCode); 64 int32_t TransProxyGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt); 65 int32_t TransCheckPagingListenState(uint32_t businessFlag); 66 int32_t TransPagingWaitListenStatus(const uint32_t businessFlag, PagingWaitListenStatus status); 67 int32_t TransAddConnItem(ProxyConnInfo *conn); 68 69 #ifdef __cplusplus 70 } 71 #endif 72 73 #endif 74