1 /* 2 * Copyright (c) 2021-2025 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_DIRECT_CHANNEL_INTERFACE_H 17 #define SOFTBUS_DIRECT_CHANNEL_INTERFACE_H 18 19 #include "softbus_app_info.h" 20 #include "softbus_conn_interface.h" 21 #include "trans_channel_callback.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif /* __cplusplus */ 26 27 #define DC_MSG_PACKET_HEAD_SIZE 24 28 #define SESSION_KEY_INDEX_SIZE 4 29 #define MESSAGE_INDEX_SIZE 4 30 31 #define MAGIC_NUMBER 0xBABEFACE 32 #define MODULE_SESSION 6 33 #define FLAG_REQUEST 0 34 #define FLAG_REPLY 1 35 #define FLAG_WIFI 0 36 #define FLAG_BR 2 37 #define FLAG_BLE 4 38 #define FLAG_P2P 8 39 #define FLAG_AUTH_META 16 40 #define FLAG_ENHANCE_P2P 32 41 #define FLAG_SESSION_KEY 64 42 #define FLAG_SLE 64 43 #define AUTH_CONN_SERVER_SIDE 0x01 44 45 typedef struct { 46 uint32_t magicNumber; 47 uint32_t module; 48 uint64_t seq; 49 uint32_t flags; 50 uint32_t dataLen; 51 } TdcPacketHead; 52 53 int32_t TransTcpDirectInit(const IServerChannelCallBack *cb); 54 55 void TransTcpDirectDeinit(void); 56 57 void TransTdcDeathCallback(const char *pkgName, int32_t pid); 58 59 int32_t TransOpenDirectChannel(AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId); 60 61 void TransTdcStopSessionProc(ListenerModule listenMod); 62 63 #ifdef __cplusplus 64 } 65 #endif /* __cplusplus */ 66 67 #endif