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