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_session_callback.h" 20 #include "trans_proxy_process_data.h" 21 22 #define PAGING_NONCE_LEN 16 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef struct { 29 int32_t isEncrypted; 30 int32_t sequence; 31 char sessionKey[SESSION_KEY_LENGTH]; 32 int32_t linkType; 33 int32_t osType; 34 bool isD2D; 35 uint32_t dataLen; 36 char extraData[EXTRA_DATA_MAX_LEN]; 37 char pagingNonce[PAGING_NONCE_LEN]; 38 char pagingSessionkey[SHORT_SESSION_KEY_LENGTH]; 39 char pagingAccountId[ACCOUNT_UID_LEN_MAX]; 40 }ProxyChannelInfoDetail; 41 42 typedef struct { 43 ListNode node; 44 int32_t channelId; 45 ProxyChannelInfoDetail detail; 46 }ClientProxyChannelInfo; 47 48 int32_t ClientTransProxyInit(const IClientSessionCallBack *cb); 49 50 void ClientTransProxyDeinit(void); 51 52 int32_t ClientTransProxyGetInfoByChannelId(int32_t channelId, ProxyChannelInfoDetail *info); 53 54 int32_t ClientTransProxyGetOsTypeByChannelId(int32_t channelId, int32_t *osType); 55 56 int32_t ClientTransProxyGetLinkTypeByChannelId(int32_t channelId, int32_t *linkType); 57 58 int32_t ClientTransProxyAddChannelInfo(ClientProxyChannelInfo *info); 59 60 int32_t ClientTransProxyDelChannelInfo(int32_t channelId); 61 62 int32_t ClientTransProxyOnChannelOpened( 63 const char *sessionName, const ChannelInfo *channel, SocketAccessInfo *accessInfo); 64 65 int32_t ClientTransProxyOnChannelClosed(int32_t channelId, ShutdownReason reason); 66 67 int32_t ClientTransProxyOnChannelOpenFailed(int32_t channelId, int32_t errCode); 68 69 int32_t ClientTransProxyOnDataReceived(int32_t channelId, 70 const void *data, uint32_t len, SessionPktType type); 71 72 void ClientTransProxyCloseChannel(int32_t channelId); 73 74 int32_t ClientTransProxyPackAndSendData(int32_t channelId, const void *data, uint32_t len, 75 ProxyChannelInfoDetail* info, SessionPktType pktType); 76 77 int32_t TransProxyAsyncPackAndSendData(int32_t channelId, const void *data, uint32_t len, uint32_t dataSeq, 78 SessionPktType pktType); 79 80 int32_t TransProxyChannelSendBytes(int32_t channelId, const void *data, uint32_t len, bool neeedAck); 81 82 int32_t TransProxyChannelAsyncSendBytes(int32_t channelId, const void *data, uint32_t len, uint32_t dataSeq); 83 84 int32_t TransProxyChannelSendMessage(int32_t channelId, const void *data, uint32_t len); 85 86 int32_t TransProxyChannelSendFile(int32_t channelId, const char *sFileList[], const char *dFileList[], 87 uint32_t fileCnt); 88 89 int32_t ProcessFileFrameData(int32_t sessionId, int32_t channelId, const char *data, uint32_t len, int32_t type); 90 91 int32_t ClientTransProxyOnChannelBind(int32_t channelId, int32_t channelType); 92 93 int32_t TransProxyChannelAsyncSendMessage(int32_t channelId, const void *data, uint32_t len, uint16_t dataSeq); 94 95 int32_t TransProxyAsyncPackAndSendMessage( 96 int32_t channelId, const void *data, uint32_t len, uint16_t dataSeq, SessionPktType pktType); 97 #ifdef __cplusplus 98 } 99 #endif 100 #endif // CLIENT_TRANS_PROXY_CHANNEL_H 101