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 CLIENT_TRANS_TCP_DIRECT_MANAGER_H 17 #define CLIENT_TRANS_TCP_DIRECT_MANAGER_H 18 19 #include "client_trans_session_callback.h" 20 #include "client_trans_tcp_direct_message.h" 21 #include "softbus_sequence_verification.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 typedef struct { 28 int32_t fd; 29 int32_t channelType; 30 int32_t businessType; 31 bool aliveState; 32 int apiVersion; 33 int32_t sequence; 34 SeqVerifyInfo verifyInfo; 35 char sessionKey[SESSION_KEY_LENGTH]; 36 SoftBusList *pendingPacketsList; 37 } TcpDirectChannelDetail; 38 39 typedef struct { 40 ListNode node; 41 int32_t channelId; 42 TcpDirectChannelDetail detail; 43 } TcpDirectChannelInfo; 44 45 int32_t ClientTransTdcOnChannelOpened(const char *sessionName, const ChannelInfo *channel); 46 int32_t ClientTransTdcOnChannelOpenFailed(int32_t channelId, int32_t errCode); 47 48 void TransTdcCloseChannel(int32_t channelId); 49 50 TcpDirectChannelInfo *TransTdcGetInfoById(int32_t channelId, TcpDirectChannelInfo *info); 51 TcpDirectChannelInfo *TransTdcGetInfoByFd(int32_t fd, TcpDirectChannelInfo *info); 52 TcpDirectChannelInfo *TransTdcGetInfoByIdWithIncSeq(int32_t channelId, TcpDirectChannelInfo *info); 53 54 int32_t TransTdcManagerInit(const IClientSessionCallBack *callback); 55 void TransTdcManagerDeinit(void); 56 57 int32_t TransTdcGetSessionKey(int32_t channelId, char *key, unsigned int len); 58 int32_t TransTdcGetHandle(int32_t channelId, int *handle); 59 int32_t TransDisableSessionListener(int32_t channelId); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif 66