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 CLIENT_TRANS_PROXY_CHANNEL_H 17 #define CLIENT_TRANS_PROXY_CHANNEL_H 18 19 #include "client_trans_file_listener.h" 20 #include "client_trans_session_callback.h" 21 #include "softbus_def.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 typedef struct { 28 int32_t isEncrypted; 29 int32_t sequence; 30 char sessionKey[SESSION_KEY_LENGTH]; 31 int32_t linkType; 32 int32_t osType; 33 }ProxyChannelInfoDetail; 34 35 typedef struct { 36 ListNode node; 37 int32_t channelId; 38 ProxyChannelInfoDetail detail; 39 }ClientProxyChannelInfo; 40 41 typedef struct { 42 int32_t active; 43 int32_t timeout; 44 int32_t sliceNumber; 45 int32_t expectedSeq; 46 int32_t dataLen; 47 int32_t bufLen; 48 char *data; 49 }SliceProcessor; 50 51 typedef enum { 52 PROXY_CHANNEL_PRORITY_MESSAGE = 0, 53 PROXY_CHANNEL_PRORITY_BYTES = 1, 54 PROXY_CHANNEL_PRORITY_FILE = 2, 55 PROXY_CHANNEL_PRORITY_BUTT = 3, 56 } ProxyChannelPriority; 57 58 typedef struct { 59 ListNode head; 60 int32_t channelId; 61 SliceProcessor processor[PROXY_CHANNEL_PRORITY_BUTT]; 62 }ChannelSliceProcessor; 63 64 int32_t ClientTransProxyInit(const IClientSessionCallBack *cb); 65 66 void ClientTransProxyDeinit(void); 67 68 int32_t ClientTransProxyGetInfoByChannelId(int32_t channelId, ProxyChannelInfoDetail *info); 69 70 int32_t ClientTransProxyGetOsTypeByChannelId(int32_t channelId, int32_t *osType); 71 72 int32_t ClientTransProxyGetLinkTypeByChannelId(int32_t channelId, int32_t *linkType); 73 74 int32_t ClientTransProxyAddChannelInfo(ClientProxyChannelInfo *info); 75 76 int32_t ClientTransProxyDelChannelInfo(int32_t channelId); 77 78 int32_t ClientTransProxyOnChannelOpened(const char *sessionName, const ChannelInfo *channel); 79 80 int32_t ClientTransProxyOnChannelClosed(int32_t channelId, ShutdownReason reason); 81 82 int32_t ClientTransProxyOnChannelOpenFailed(int32_t channelId, int32_t errCode); 83 84 int32_t ClientTransProxyOnDataReceived(int32_t channelId, 85 const void *data, uint32_t len, SessionPktType type); 86 87 void ClientTransProxyCloseChannel(int32_t channelId); 88 89 int32_t TransProxyPackAndSendData(int32_t channelId, const void *data, uint32_t len, 90 ProxyChannelInfoDetail* info, SessionPktType pktType); 91 92 int32_t TransProxyChannelSendBytes(int32_t channelId, const void *data, uint32_t len); 93 94 int32_t TransProxyChannelSendMessage(int32_t channelId, const void *data, uint32_t len); 95 96 int32_t TransProxyChannelSendFile(int32_t channelId, const char *sFileList[], const char *dFileList[], 97 uint32_t fileCnt); 98 99 int32_t ProcessFileFrameData(int32_t sessionId, int32_t channelId, const char *data, uint32_t len, int32_t type); 100 int32_t ClientTransProxyOnChannelBind(int32_t channelId, int32_t channelType); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 #endif // CLIENT_TRANS_PROXY_CHANNEL_H 106