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 TRANS_CHANNEL_CALLBACK_H 17 #define TRANS_CHANNEL_CALLBACK_H 18 19 #include <stdint.h> 20 21 #include "session.h" 22 #include "softbus_def.h" 23 #include "softbus_trans_def.h" 24 25 #ifdef __cplusplus 26 #if __cplusplus 27 extern "C" { 28 #endif /* __cplusplus */ 29 #endif /* __cplusplus */ 30 31 typedef struct { 32 int32_t (*OnChannelOpened)(const char *pkgName, int32_t pid, const char *sessionName, const ChannelInfo *channel); 33 int32_t (*OnChannelClosed)( 34 const char *pkgName, int32_t pid, int32_t channelId, int32_t channelType, int32_t messageType); 35 int32_t (*OnChannelOpenFailed)( 36 const char *pkgName, int32_t pid, int32_t channelId, int32_t channelType, int32_t errCode); 37 int32_t (*OnDataReceived)(const char *pkgName, int32_t pid, int32_t channelId, int32_t channelType, 38 TransReceiveData* receiveData); 39 int32_t (*OnQosEvent)(const char *pkgName, const QosParam *param); 40 int32_t (*GetPkgNameBySessionName)(const char *sessionName, char *pkgName, uint16_t len); 41 int32_t (*GetUidAndPidBySessionName)(const char *sessionName, int32_t *uid, int32_t *pid); 42 int32_t (*OnChannelBind)(const char *pkgName, int32_t pid, int32_t channelId, int32_t channelType); 43 } IServerChannelCallBack; 44 45 typedef struct { 46 const char *uuid; 47 const char *udid; 48 const char *peerIp; 49 const char *networkId; 50 int32_t routeType; 51 } LinkDownInfo; 52 53 IServerChannelCallBack *TransServerGetChannelCb(void); 54 55 int32_t TransServerOnChannelLinkDown(const char *pkgName, int32_t pid, const LinkDownInfo *info); 56 57 #ifdef __cplusplus 58 #if __cplusplus 59 } 60 #endif /* __cplusplus */ 61 #endif /* __cplusplus */ 62 #endif 63 64