1060ff233Sopenharmony_ci/* 2060ff233Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License. 5060ff233Sopenharmony_ci * You may obtain a copy of the License at 6060ff233Sopenharmony_ci * 7060ff233Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8060ff233Sopenharmony_ci * 9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and 13060ff233Sopenharmony_ci * limitations under the License. 14060ff233Sopenharmony_ci */ 15060ff233Sopenharmony_ci 16060ff233Sopenharmony_ci#include "softbus_client_stub.h" 17060ff233Sopenharmony_ci 18060ff233Sopenharmony_ci#include <string> 19060ff233Sopenharmony_ci 20060ff233Sopenharmony_ci#include "client_bus_center_manager.h" 21060ff233Sopenharmony_ci#include "client_trans_channel_callback.h" 22060ff233Sopenharmony_ci#include "client_trans_session_manager.h" 23060ff233Sopenharmony_ci#include "client_trans_socket_manager.h" 24060ff233Sopenharmony_ci#include "comm_log.h" 25060ff233Sopenharmony_ci#include "ipc_skeleton.h" 26060ff233Sopenharmony_ci#include "ipc_types.h" 27060ff233Sopenharmony_ci#include "message_parcel.h" 28060ff233Sopenharmony_ci#include "securec.h" 29060ff233Sopenharmony_ci#include "softbus_adapter_mem.h" 30060ff233Sopenharmony_ci#include "softbus_def.h" 31060ff233Sopenharmony_ci#include "softbus_errcode.h" 32060ff233Sopenharmony_ci#include "softbus_server_ipc_interface_code.h" 33060ff233Sopenharmony_ci#include "client_trans_udp_manager.h" 34060ff233Sopenharmony_ci 35060ff233Sopenharmony_cinamespace OHOS { 36060ff233Sopenharmony_ciSoftBusClientStub::SoftBusClientStub() 37060ff233Sopenharmony_ci{ 38060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_OPENED] = &SoftBusClientStub::OnChannelOpenedInner; 39060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_OPENFAILED] = &SoftBusClientStub::OnChannelOpenFailedInner; 40060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_LINKDOWN] = &SoftBusClientStub::OnChannelLinkDownInner; 41060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_CLOSED] = &SoftBusClientStub::OnChannelClosedInner; 42060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_MSGRECEIVED] = &SoftBusClientStub::OnChannelMsgReceivedInner; 43060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_QOSEVENT] = &SoftBusClientStub::OnChannelQosEventInner; 44060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_JOIN_RESULT] = &SoftBusClientStub::OnJoinLNNResultInner; 45060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_LEAVE_RESULT] = &SoftBusClientStub::OnLeaveLNNResultInner; 46060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_NODE_ONLINE_STATE_CHANGED] = &SoftBusClientStub::OnNodeOnlineStateChangedInner; 47060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_NODE_BASIC_INFO_CHANGED] = &SoftBusClientStub::OnNodeBasicInfoChangedInner; 48060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_NODE_STATUS_CHANGED] = &SoftBusClientStub::OnNodeStatusChangedInner; 49060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_LOCAL_NETWORK_ID_CHANGED] = &SoftBusClientStub::OnLocalNetworkIdChangedInner; 50060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_NODE_DEVICE_TRUST_CHANGED] = &SoftBusClientStub::OnNodeDeviceTrustedChangeInner; 51060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_HICHAIN_PROOF_EXCEPTION] = &SoftBusClientStub::OnHichainProofExceptionInner; 52060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_TIME_SYNC_RESULT] = &SoftBusClientStub::OnTimeSyncResultInner; 53060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_PUBLISH_LNN_RESULT] = &SoftBusClientStub::OnPublishLNNResultInner; 54060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_REFRESH_LNN_RESULT] = &SoftBusClientStub::OnRefreshLNNResultInner; 55060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_REFRESH_DEVICE_FOUND] = &SoftBusClientStub::OnRefreshDeviceFoundInner; 56060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_PERMISSION_CHANGE] = &SoftBusClientStub::OnClientPermissonChangeInner; 57060ff233Sopenharmony_ci memberFuncMap_[CLIENT_SET_CHANNEL_INFO] = &SoftBusClientStub::SetChannelInfoInner; 58060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_DATA_LEVEL_CHANGED] = &SoftBusClientStub::OnDataLevelChangedInner; 59060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_TRANS_LIMIT_CHANGE] = &SoftBusClientStub::OnClientTransLimitChangeInner; 60060ff233Sopenharmony_ci memberFuncMap_[CLIENT_ON_CHANNEL_BIND] = &SoftBusClientStub::OnChannelBindInner; 61060ff233Sopenharmony_ci} 62060ff233Sopenharmony_ci 63060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnRemoteRequest(uint32_t code, 64060ff233Sopenharmony_ci MessageParcel &data, MessageParcel &reply, MessageOption &option) 65060ff233Sopenharmony_ci{ 66060ff233Sopenharmony_ci COMM_LOGD(COMM_SDK, "SoftBusClientStub::OnReceived, code=%{public}u", code); 67060ff233Sopenharmony_ci if (data.ReadInterfaceToken() != GetDescriptor()) { 68060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "SoftBusClientStub: ReadInterfaceToken faild!"); 69060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READTOKEN_FAILED; 70060ff233Sopenharmony_ci } 71060ff233Sopenharmony_ci auto itFunc = memberFuncMap_.find(code); 72060ff233Sopenharmony_ci if (itFunc != memberFuncMap_.end()) { 73060ff233Sopenharmony_ci auto memberFunc = itFunc->second; 74060ff233Sopenharmony_ci if (memberFunc != nullptr) { 75060ff233Sopenharmony_ci return (this->*memberFunc)(data, reply); 76060ff233Sopenharmony_ci } 77060ff233Sopenharmony_ci } 78060ff233Sopenharmony_ci COMM_LOGI(COMM_SDK, "SoftBusClientStub: default case, need check."); 79060ff233Sopenharmony_ci return IPCObjectStub::OnRemoteRequest(code, data, reply, option); 80060ff233Sopenharmony_ci} 81060ff233Sopenharmony_ci 82060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnClientPermissonChangeInner(MessageParcel &data, MessageParcel &reply) 83060ff233Sopenharmony_ci{ 84060ff233Sopenharmony_ci int32_t state; 85060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 86060ff233Sopenharmony_ci data.ReadInt32(state), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read state failed"); 87060ff233Sopenharmony_ci 88060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 89060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 90060ff233Sopenharmony_ci pkgName != nullptr, SOFTBUS_TRANS_PROXY_READCSTRING_FAILED, COMM_SDK, "read pkgName failed"); 91060ff233Sopenharmony_ci 92060ff233Sopenharmony_ci PermissionStateChange(pkgName, state); 93060ff233Sopenharmony_ci return SOFTBUS_OK; 94060ff233Sopenharmony_ci} 95060ff233Sopenharmony_ci 96060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnClientTransLimitChangeInner(MessageParcel &data, MessageParcel &reply) 97060ff233Sopenharmony_ci{ 98060ff233Sopenharmony_ci int32_t channelId; 99060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 100060ff233Sopenharmony_ci data.ReadInt32(channelId), SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED, COMM_SDK, "read channelId failed"); 101060ff233Sopenharmony_ci 102060ff233Sopenharmony_ci uint8_t tos; 103060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 104060ff233Sopenharmony_ci data.ReadUint8(tos), SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED, COMM_SDK, "read tos failed"); 105060ff233Sopenharmony_ci 106060ff233Sopenharmony_ci int32_t ret = OnClientTransLimitChange(channelId, tos); 107060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 108060ff233Sopenharmony_ci reply.WriteInt32(ret), SOFTBUS_TRANS_PROXY_WRITERAWDATA_FAILED, COMM_SDK, "write reply failed"); 109060ff233Sopenharmony_ci 110060ff233Sopenharmony_ci return SOFTBUS_OK; 111060ff233Sopenharmony_ci} 112060ff233Sopenharmony_ci 113060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnClientTransLimitChange(int32_t channelId, uint8_t tos) 114060ff233Sopenharmony_ci{ 115060ff233Sopenharmony_ci return TransLimitChange(channelId, tos); 116060ff233Sopenharmony_ci} 117060ff233Sopenharmony_ci 118060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelOpened(const char *sessionName, const ChannelInfo *info) 119060ff233Sopenharmony_ci{ 120060ff233Sopenharmony_ci return TransOnChannelOpened(sessionName, info); 121060ff233Sopenharmony_ci} 122060ff233Sopenharmony_ci 123060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelOpenFailed(int32_t channelId, int32_t channelType, int32_t errCode) 124060ff233Sopenharmony_ci{ 125060ff233Sopenharmony_ci return TransOnChannelOpenFailed(channelId, channelType, errCode); 126060ff233Sopenharmony_ci} 127060ff233Sopenharmony_ci 128060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelLinkDown(const char *networkId, int32_t routeType) 129060ff233Sopenharmony_ci{ 130060ff233Sopenharmony_ci return TransOnChannelLinkDown(networkId, routeType); 131060ff233Sopenharmony_ci} 132060ff233Sopenharmony_ci 133060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelClosed(int32_t channelId, int32_t channelType, int32_t messageType) 134060ff233Sopenharmony_ci{ 135060ff233Sopenharmony_ci return TransOnChannelClosed(channelId, channelType, messageType, SHUTDOWN_REASON_PEER); 136060ff233Sopenharmony_ci} 137060ff233Sopenharmony_ci 138060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelMsgReceived(int32_t channelId, int32_t channelType, const void *data, 139060ff233Sopenharmony_ci uint32_t len, int32_t type) 140060ff233Sopenharmony_ci{ 141060ff233Sopenharmony_ci return TransOnChannelMsgReceived(channelId, channelType, data, len, static_cast<SessionPktType>(type)); 142060ff233Sopenharmony_ci} 143060ff233Sopenharmony_ci 144060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelQosEvent(int32_t channelId, int32_t channelType, int32_t eventId, 145060ff233Sopenharmony_ci int32_t tvCount, const QosTv *tvList) 146060ff233Sopenharmony_ci{ 147060ff233Sopenharmony_ci return TransOnChannelQosEvent(channelId, channelType, eventId, tvCount, tvList); 148060ff233Sopenharmony_ci} 149060ff233Sopenharmony_ci 150060ff233Sopenharmony_ciint32_t SoftBusClientStub::SetChannelInfo( 151060ff233Sopenharmony_ci const char *sessionName, int32_t sessionId, int32_t channelId, int32_t channelType) 152060ff233Sopenharmony_ci{ 153060ff233Sopenharmony_ci return TransSetChannelInfo(sessionName, sessionId, channelId, channelType); 154060ff233Sopenharmony_ci} 155060ff233Sopenharmony_ci 156060ff233Sopenharmony_cistatic int32_t MessageParcelRead(MessageParcel &data, ChannelInfo *channel) 157060ff233Sopenharmony_ci{ 158060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->channelId, SOFTBUS_IPC_ERR); 159060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->channelType, SOFTBUS_IPC_ERR); 160060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Uint64, channel->laneId, SOFTBUS_IPC_ERR); 161060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->connectType, SOFTBUS_IPC_ERR); 162060ff233Sopenharmony_ci if (channel->channelType == CHANNEL_TYPE_TCP_DIRECT) { 163060ff233Sopenharmony_ci channel->fd = data.ReadFileDescriptor(); 164060ff233Sopenharmony_ci channel->myIp = (char *)data.ReadCString(); 165060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(channel->myIp != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read myIp failed"); 166060ff233Sopenharmony_ci } 167060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Bool, channel->isServer, SOFTBUS_IPC_ERR); 168060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Bool, channel->isEnabled, SOFTBUS_IPC_ERR); 169060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Bool, channel->isEncrypt, SOFTBUS_IPC_ERR); 170060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->peerUid, SOFTBUS_IPC_ERR); 171060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->peerPid, SOFTBUS_IPC_ERR); 172060ff233Sopenharmony_ci channel->groupId = (char *)data.ReadCString(); 173060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(channel->groupId != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read groupId failed"); 174060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Uint32, channel->keyLen, SOFTBUS_IPC_ERR); 175060ff233Sopenharmony_ci channel->sessionKey = (char *)data.ReadRawData(channel->keyLen); 176060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(channel->sessionKey != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read rawData failed"); 177060ff233Sopenharmony_ci channel->peerSessionName = (char *)data.ReadCString(); 178060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 179060ff233Sopenharmony_ci channel->peerSessionName != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read peerSessionName failed"); 180060ff233Sopenharmony_ci channel->peerDeviceId = (char *)data.ReadCString(); 181060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 182060ff233Sopenharmony_ci channel->peerDeviceId != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read peerDeviceId failed"); 183060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->businessType, SOFTBUS_IPC_ERR); 184060ff233Sopenharmony_ci if (channel->channelType == CHANNEL_TYPE_UDP) { 185060ff233Sopenharmony_ci channel->myIp = (char *)data.ReadCString(); 186060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(channel->myIp != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read myIp failed"); 187060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->streamType, SOFTBUS_IPC_ERR); 188060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Bool, channel->isUdpFile, SOFTBUS_IPC_ERR); 189060ff233Sopenharmony_ci if (!channel->isServer) { 190060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->peerPort, SOFTBUS_IPC_ERR); 191060ff233Sopenharmony_ci channel->peerIp = (char *)data.ReadCString(); 192060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 193060ff233Sopenharmony_ci channel->peerIp != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read channel.peerIp failed"); 194060ff233Sopenharmony_ci } 195060ff233Sopenharmony_ci } 196060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->routeType, SOFTBUS_IPC_ERR); 197060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->encrypt, SOFTBUS_IPC_ERR); 198060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->algorithm, SOFTBUS_IPC_ERR); 199060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->crc, SOFTBUS_IPC_ERR); 200060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Uint32, channel->dataConfig, SOFTBUS_IPC_ERR); 201060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->linkType, SOFTBUS_IPC_ERR); 202060ff233Sopenharmony_ci READ_PARCEL_WITH_RET(data, Int32, channel->osType, SOFTBUS_IPC_ERR); 203060ff233Sopenharmony_ci return SOFTBUS_OK; 204060ff233Sopenharmony_ci} 205060ff233Sopenharmony_ci 206060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelOpenedInner(MessageParcel &data, MessageParcel &reply) 207060ff233Sopenharmony_ci{ 208060ff233Sopenharmony_ci const char *sessionName = data.ReadCString(); 209060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(sessionName != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read sessionName failed"); 210060ff233Sopenharmony_ci 211060ff233Sopenharmony_ci ChannelInfo channel = { 0 }; 212060ff233Sopenharmony_ci int32_t ret = MessageParcelRead(data, &channel); 213060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, COMM_SDK, "read channel info failed"); 214060ff233Sopenharmony_ci 215060ff233Sopenharmony_ci ret = OnChannelOpened(sessionName, &channel); 216060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(reply.WriteInt32(ret), SOFTBUS_IPC_ERR, COMM_SDK, "write reply failed"); 217060ff233Sopenharmony_ci return SOFTBUS_OK; 218060ff233Sopenharmony_ci} 219060ff233Sopenharmony_ci 220060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelOpenFailedInner(MessageParcel &data, MessageParcel &reply) 221060ff233Sopenharmony_ci{ 222060ff233Sopenharmony_ci int32_t channelId; 223060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 224060ff233Sopenharmony_ci data.ReadInt32(channelId), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelId failed"); 225060ff233Sopenharmony_ci 226060ff233Sopenharmony_ci int32_t channelType; 227060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 228060ff233Sopenharmony_ci data.ReadInt32(channelType), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelType failed"); 229060ff233Sopenharmony_ci 230060ff233Sopenharmony_ci int32_t errCode; 231060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 232060ff233Sopenharmony_ci data.ReadInt32(errCode), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read errCode failed"); 233060ff233Sopenharmony_ci 234060ff233Sopenharmony_ci int32_t ret = OnChannelOpenFailed(channelId, channelType, errCode); 235060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, COMM_SDK, "OnChannelOpenFailed fail! ret=%{public}d", ret); 236060ff233Sopenharmony_ci 237060ff233Sopenharmony_ci return SOFTBUS_OK; 238060ff233Sopenharmony_ci} 239060ff233Sopenharmony_ci 240060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelLinkDownInner(MessageParcel &data, MessageParcel &reply) 241060ff233Sopenharmony_ci{ 242060ff233Sopenharmony_ci const char *networkId = data.ReadCString(); 243060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 244060ff233Sopenharmony_ci networkId != nullptr, SOFTBUS_TRANS_PROXY_READCSTRING_FAILED, COMM_SDK, "read networkId failed!"); 245060ff233Sopenharmony_ci 246060ff233Sopenharmony_ci COMM_LOGD(COMM_SDK, "SDK OnChannelMsgReceived"); 247060ff233Sopenharmony_ci int32_t routeType; 248060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 249060ff233Sopenharmony_ci data.ReadInt32(routeType), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read routeType failed"); 250060ff233Sopenharmony_ci 251060ff233Sopenharmony_ci int32_t retReply = OnChannelLinkDown(networkId, routeType); 252060ff233Sopenharmony_ci if (retReply != SOFTBUS_OK) { 253060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnChannelLinkDown proc error!"); 254060ff233Sopenharmony_ci } 255060ff233Sopenharmony_ci return SOFTBUS_OK; 256060ff233Sopenharmony_ci} 257060ff233Sopenharmony_ci 258060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelClosedInner(MessageParcel &data, MessageParcel &reply) 259060ff233Sopenharmony_ci{ 260060ff233Sopenharmony_ci int32_t channelId; 261060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(channelId), SOFTBUS_IPC_ERR, COMM_SDK, "read channelId failed"); 262060ff233Sopenharmony_ci 263060ff233Sopenharmony_ci int32_t channelType; 264060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(channelType), SOFTBUS_IPC_ERR, COMM_SDK, "read channelType failed"); 265060ff233Sopenharmony_ci 266060ff233Sopenharmony_ci int32_t messageType; 267060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(messageType), SOFTBUS_IPC_ERR, COMM_SDK, "read messageType failed"); 268060ff233Sopenharmony_ci 269060ff233Sopenharmony_ci int32_t ret = OnChannelClosed(channelId, channelType, messageType); 270060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(reply.WriteInt32(ret), SOFTBUS_IPC_ERR, COMM_SDK, "write reply failed"); 271060ff233Sopenharmony_ci 272060ff233Sopenharmony_ci return SOFTBUS_OK; 273060ff233Sopenharmony_ci} 274060ff233Sopenharmony_ci 275060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelMsgReceivedInner(MessageParcel &data, MessageParcel &reply) 276060ff233Sopenharmony_ci{ 277060ff233Sopenharmony_ci int32_t channelId; 278060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 279060ff233Sopenharmony_ci data.ReadInt32(channelId), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelId failed"); 280060ff233Sopenharmony_ci 281060ff233Sopenharmony_ci int32_t channelType; 282060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 283060ff233Sopenharmony_ci data.ReadInt32(channelType), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelType failed"); 284060ff233Sopenharmony_ci 285060ff233Sopenharmony_ci uint32_t len; 286060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 287060ff233Sopenharmony_ci data.ReadUint32(len), SOFTBUS_TRANS_PROXY_READUINT_FAILED, COMM_SDK, "read data len failed"); 288060ff233Sopenharmony_ci 289060ff233Sopenharmony_ci char *dataInfo = (char *)data.ReadRawData(len); 290060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 291060ff233Sopenharmony_ci dataInfo != nullptr, SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED, COMM_SDK, "read dataInfo failed!"); 292060ff233Sopenharmony_ci 293060ff233Sopenharmony_ci int32_t type; 294060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 295060ff233Sopenharmony_ci data.ReadInt32(type), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read type failed"); 296060ff233Sopenharmony_ci 297060ff233Sopenharmony_ci int ret = OnChannelMsgReceived(channelId, channelType, dataInfo, len, type); 298060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 299060ff233Sopenharmony_ci reply.WriteInt32(ret), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, COMM_SDK, "write reply failed"); 300060ff233Sopenharmony_ci 301060ff233Sopenharmony_ci return SOFTBUS_OK; 302060ff233Sopenharmony_ci} 303060ff233Sopenharmony_ci 304060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelQosEventInner(MessageParcel &data, MessageParcel &reply) 305060ff233Sopenharmony_ci{ 306060ff233Sopenharmony_ci COMM_LOGI(COMM_EVENT, "OnChannelQosEventInner"); 307060ff233Sopenharmony_ci int32_t channelId; 308060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 309060ff233Sopenharmony_ci data.ReadInt32(channelId), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelId failed"); 310060ff233Sopenharmony_ci 311060ff233Sopenharmony_ci int32_t channelType; 312060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 313060ff233Sopenharmony_ci data.ReadInt32(channelType), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelType failed"); 314060ff233Sopenharmony_ci 315060ff233Sopenharmony_ci int32_t eventId; 316060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 317060ff233Sopenharmony_ci data.ReadInt32(eventId), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read eventId failed"); 318060ff233Sopenharmony_ci 319060ff233Sopenharmony_ci int32_t tvCount; 320060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(tvCount) && tvCount > 0, SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, 321060ff233Sopenharmony_ci "read tv failed! count=%{public}d", tvCount); 322060ff233Sopenharmony_ci 323060ff233Sopenharmony_ci QosTv *tvList = (QosTv *)data.ReadRawData(sizeof(QosTv) * tvCount); 324060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 325060ff233Sopenharmony_ci tvList != nullptr, SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED, COMM_SDK, "read tv list failed!"); 326060ff233Sopenharmony_ci 327060ff233Sopenharmony_ci int ret = OnChannelQosEvent(channelId, channelType, eventId, tvCount, tvList); 328060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 329060ff233Sopenharmony_ci reply.WriteInt32(ret), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, COMM_SDK, "write reply failed"); 330060ff233Sopenharmony_ci 331060ff233Sopenharmony_ci return SOFTBUS_OK; 332060ff233Sopenharmony_ci} 333060ff233Sopenharmony_ci 334060ff233Sopenharmony_ciint32_t SoftBusClientStub::SetChannelInfoInner(MessageParcel &data, MessageParcel &reply) 335060ff233Sopenharmony_ci{ 336060ff233Sopenharmony_ci const char *sessionName = data.ReadCString(); 337060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(sessionName != nullptr, SOFTBUS_IPC_ERR, COMM_SDK, "read sessionName failed"); 338060ff233Sopenharmony_ci 339060ff233Sopenharmony_ci int32_t sessionId; 340060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(sessionId), SOFTBUS_IPC_ERR, COMM_SDK, "read sessionId failed"); 341060ff233Sopenharmony_ci 342060ff233Sopenharmony_ci int32_t channelId; 343060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(channelId), SOFTBUS_IPC_ERR, COMM_SDK, "read channelId failed"); 344060ff233Sopenharmony_ci 345060ff233Sopenharmony_ci int32_t channelType; 346060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(channelType), SOFTBUS_IPC_ERR, COMM_SDK, "read channelType failed"); 347060ff233Sopenharmony_ci 348060ff233Sopenharmony_ci int ret = SetChannelInfo(sessionName, sessionId, channelId, channelType); 349060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE( 350060ff233Sopenharmony_ci reply.WriteInt32(ret), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, COMM_SDK, "write reply failed"); 351060ff233Sopenharmony_ci 352060ff233Sopenharmony_ci return SOFTBUS_OK; 353060ff233Sopenharmony_ci} 354060ff233Sopenharmony_ci 355060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnJoinLNNResultInner(MessageParcel &data, MessageParcel &reply) 356060ff233Sopenharmony_ci{ 357060ff233Sopenharmony_ci uint32_t addrTypeLen; 358060ff233Sopenharmony_ci if (!data.ReadUint32(addrTypeLen) || addrTypeLen != sizeof(ConnectionAddr)) { 359060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnJoinLNNResultInner read addr type failed! length=%{public}d", addrTypeLen); 360060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READUINT_FAILED; 361060ff233Sopenharmony_ci } 362060ff233Sopenharmony_ci void *addr = (void *)data.ReadRawData(addrTypeLen); 363060ff233Sopenharmony_ci if (addr == nullptr) { 364060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnJoinLNNResultInner read addr failed!"); 365060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED; 366060ff233Sopenharmony_ci } 367060ff233Sopenharmony_ci int32_t retCode; 368060ff233Sopenharmony_ci if (!data.ReadInt32(retCode)) { 369060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnJoinLNNResultInner read retCode failed!"); 370060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 371060ff233Sopenharmony_ci } 372060ff233Sopenharmony_ci const char *networkId = nullptr; 373060ff233Sopenharmony_ci if (retCode == 0) { 374060ff233Sopenharmony_ci networkId = data.ReadCString(); 375060ff233Sopenharmony_ci if (networkId == nullptr) { 376060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnJoinLNNResultInner read networkId failed!"); 377060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED; 378060ff233Sopenharmony_ci } 379060ff233Sopenharmony_ci } 380060ff233Sopenharmony_ci int32_t retReply = OnJoinLNNResult(addr, addrTypeLen, networkId, retCode); 381060ff233Sopenharmony_ci if (retReply != SOFTBUS_OK) { 382060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnJoinLNNResultInner notify join result failed!"); 383060ff233Sopenharmony_ci } 384060ff233Sopenharmony_ci return SOFTBUS_OK; 385060ff233Sopenharmony_ci} 386060ff233Sopenharmony_ci 387060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnLeaveLNNResultInner(MessageParcel &data, MessageParcel &reply) 388060ff233Sopenharmony_ci{ 389060ff233Sopenharmony_ci const char *networkId = data.ReadCString(); 390060ff233Sopenharmony_ci if (networkId == nullptr) { 391060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnLeaveLNNResultInner read networkId failed!"); 392060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED; 393060ff233Sopenharmony_ci } 394060ff233Sopenharmony_ci int32_t retCode; 395060ff233Sopenharmony_ci if (!data.ReadInt32(retCode)) { 396060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnLeaveLNNResultInner read retCode failed!"); 397060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 398060ff233Sopenharmony_ci } 399060ff233Sopenharmony_ci int32_t retReply = OnLeaveLNNResult(networkId, retCode); 400060ff233Sopenharmony_ci if (retReply != SOFTBUS_OK) { 401060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnLeaveLNNResultInner notify leave result failed!"); 402060ff233Sopenharmony_ci } 403060ff233Sopenharmony_ci return SOFTBUS_OK; 404060ff233Sopenharmony_ci} 405060ff233Sopenharmony_ci 406060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply) 407060ff233Sopenharmony_ci{ 408060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 409060ff233Sopenharmony_ci if (pkgName == nullptr || strlen(pkgName) == 0) { 410060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero"); 411060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED; 412060ff233Sopenharmony_ci } 413060ff233Sopenharmony_ci bool isOnline = false; 414060ff233Sopenharmony_ci if (!data.ReadBool(isOnline)) { 415060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeOnlineStateChangedInner read online state failed!"); 416060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READBOOL_FAILED; 417060ff233Sopenharmony_ci } 418060ff233Sopenharmony_ci uint32_t infoTypeLen; 419060ff233Sopenharmony_ci if (!data.ReadUint32(infoTypeLen) || infoTypeLen != sizeof(NodeBasicInfo)) { 420060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeOnlineStateChangedInner read info type failed! length=%{public}d", infoTypeLen); 421060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READUINT_FAILED; 422060ff233Sopenharmony_ci } 423060ff233Sopenharmony_ci void *info = (void *)data.ReadRawData(infoTypeLen); 424060ff233Sopenharmony_ci if (info == nullptr) { 425060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeOnlineStateChangedInner read basic info failed!"); 426060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED; 427060ff233Sopenharmony_ci } 428060ff233Sopenharmony_ci int32_t retReply = OnNodeOnlineStateChanged(pkgName, isOnline, info, infoTypeLen); 429060ff233Sopenharmony_ci COMM_LOGI(COMM_SDK, "notify complete, pkgName=%{public}s, isOnline=%{public}d", pkgName, isOnline); 430060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 431060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeOnlineStateChangedInner write reply failed!"); 432060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_WRITEINT_FAILED; 433060ff233Sopenharmony_ci } 434060ff233Sopenharmony_ci return SOFTBUS_OK; 435060ff233Sopenharmony_ci} 436060ff233Sopenharmony_ci 437060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply) 438060ff233Sopenharmony_ci{ 439060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 440060ff233Sopenharmony_ci if (pkgName == nullptr || strlen(pkgName) == 0) { 441060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero"); 442060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED; 443060ff233Sopenharmony_ci } 444060ff233Sopenharmony_ci int32_t type; 445060ff233Sopenharmony_ci if (!data.ReadInt32(type)) { 446060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeBasicInfoChangedInner read type failed!"); 447060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 448060ff233Sopenharmony_ci } 449060ff233Sopenharmony_ci COMM_LOGD(COMM_SDK, "OnNodeBasicInfoChangedInner type. type=%{public}d", type); 450060ff233Sopenharmony_ci uint32_t infoTypeLen; 451060ff233Sopenharmony_ci if (!data.ReadUint32(infoTypeLen) || infoTypeLen != sizeof(NodeBasicInfo)) { 452060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeBasicInfoChangedInner read failed! infoTypeLen=%{public}d", infoTypeLen); 453060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READUINT_FAILED; 454060ff233Sopenharmony_ci } 455060ff233Sopenharmony_ci void *info = (void *)data.ReadRawData(infoTypeLen); 456060ff233Sopenharmony_ci if (info == nullptr) { 457060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeBasicInfoChangedInner read basic info failed!"); 458060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED; 459060ff233Sopenharmony_ci } 460060ff233Sopenharmony_ci int32_t retReply = OnNodeBasicInfoChanged(pkgName, info, infoTypeLen, type); 461060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 462060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeBasicInfoChangedInner write reply failed!"); 463060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_WRITEINT_FAILED; 464060ff233Sopenharmony_ci } 465060ff233Sopenharmony_ci return SOFTBUS_OK; 466060ff233Sopenharmony_ci} 467060ff233Sopenharmony_ci 468060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeStatusChangedInner(MessageParcel &data, MessageParcel &reply) 469060ff233Sopenharmony_ci{ 470060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 471060ff233Sopenharmony_ci if (pkgName == nullptr || strlen(pkgName) == 0) { 472060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero"); 473060ff233Sopenharmony_ci return SOFTBUS_INVALID_PARAM; 474060ff233Sopenharmony_ci } 475060ff233Sopenharmony_ci int32_t type; 476060ff233Sopenharmony_ci if (!data.ReadInt32(type)) { 477060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeStatusChangedInner read type failed!"); 478060ff233Sopenharmony_ci return SOFTBUS_NETWORK_READINT32_FAILED; 479060ff233Sopenharmony_ci } 480060ff233Sopenharmony_ci COMM_LOGD(COMM_SDK, "OnNodeStatusChangedInner type=%{public}d", type); 481060ff233Sopenharmony_ci uint32_t infoTypeLen; 482060ff233Sopenharmony_ci if (!data.ReadUint32(infoTypeLen) || infoTypeLen != sizeof(NodeStatus)) { 483060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeStatusChangedInner read failed! infoTypeLen=%{public}d", infoTypeLen); 484060ff233Sopenharmony_ci return SOFTBUS_NETWORK_READINT32_FAILED; 485060ff233Sopenharmony_ci } 486060ff233Sopenharmony_ci void *info = (void *)data.ReadRawData(infoTypeLen); 487060ff233Sopenharmony_ci if (info == nullptr) { 488060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeStatusChangedInner read node status failed!"); 489060ff233Sopenharmony_ci return SOFTBUS_NETWORK_READRAWDATA_FAILED; 490060ff233Sopenharmony_ci } 491060ff233Sopenharmony_ci int32_t retReply = OnNodeStatusChanged(pkgName, info, infoTypeLen, type); 492060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 493060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnNodeStatusChangedInner write reply failed!"); 494060ff233Sopenharmony_ci return SOFTBUS_NETWORK_WRITEINT32_FAILED; 495060ff233Sopenharmony_ci } 496060ff233Sopenharmony_ci return SOFTBUS_OK; 497060ff233Sopenharmony_ci} 498060ff233Sopenharmony_ci 499060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnLocalNetworkIdChangedInner(MessageParcel &data, MessageParcel &reply) 500060ff233Sopenharmony_ci{ 501060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 502060ff233Sopenharmony_ci if (pkgName == nullptr || strlen(pkgName) == 0) { 503060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero"); 504060ff233Sopenharmony_ci return SOFTBUS_INVALID_PARAM; 505060ff233Sopenharmony_ci } 506060ff233Sopenharmony_ci int32_t retReply = OnLocalNetworkIdChanged(pkgName); 507060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 508060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnLocalNetworkIdChangedInner write reply failed!"); 509060ff233Sopenharmony_ci return SOFTBUS_IPC_ERR; 510060ff233Sopenharmony_ci } 511060ff233Sopenharmony_ci return SOFTBUS_OK; 512060ff233Sopenharmony_ci} 513060ff233Sopenharmony_ci 514060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeDeviceTrustedChangeInner(MessageParcel &data, MessageParcel &reply) 515060ff233Sopenharmony_ci{ 516060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 517060ff233Sopenharmony_ci if (pkgName == nullptr || strlen(pkgName) == 0) { 518060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero"); 519060ff233Sopenharmony_ci return SOFTBUS_INVALID_PARAM; 520060ff233Sopenharmony_ci } 521060ff233Sopenharmony_ci int32_t type = 0; 522060ff233Sopenharmony_ci if (!data.ReadInt32(type)) { 523060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read type failed!"); 524060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 525060ff233Sopenharmony_ci } 526060ff233Sopenharmony_ci const char *msg = data.ReadCString(); 527060ff233Sopenharmony_ci if (msg == nullptr) { 528060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read msg failed!"); 529060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED; 530060ff233Sopenharmony_ci } 531060ff233Sopenharmony_ci uint32_t msgLen = 0; 532060ff233Sopenharmony_ci if (!data.ReadUint32(msgLen)) { 533060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read failed! msgLen=%{public}u", msgLen); 534060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 535060ff233Sopenharmony_ci } 536060ff233Sopenharmony_ci int32_t retReply = OnNodeDeviceTrustedChange(pkgName, type, msg, msgLen); 537060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 538060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "write reply failed!"); 539060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_WRITEINT_FAILED; 540060ff233Sopenharmony_ci } 541060ff233Sopenharmony_ci return SOFTBUS_OK; 542060ff233Sopenharmony_ci} 543060ff233Sopenharmony_ci 544060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnHichainProofExceptionInner(MessageParcel &data, MessageParcel &reply) 545060ff233Sopenharmony_ci{ 546060ff233Sopenharmony_ci const char *pkgName = data.ReadCString(); 547060ff233Sopenharmony_ci if (pkgName == nullptr || strlen(pkgName) == 0) { 548060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero"); 549060ff233Sopenharmony_ci return SOFTBUS_INVALID_PARAM; 550060ff233Sopenharmony_ci } 551060ff233Sopenharmony_ci uint32_t deviceListLen = 0; 552060ff233Sopenharmony_ci if (!data.ReadUint32(deviceListLen)) { 553060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read failed! deviceListLen=%{public}u", deviceListLen); 554060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 555060ff233Sopenharmony_ci } 556060ff233Sopenharmony_ci char *deviceList = NULL; 557060ff233Sopenharmony_ci if (deviceListLen != 0) { 558060ff233Sopenharmony_ci deviceList = (char *)data.ReadRawData(deviceListLen); 559060ff233Sopenharmony_ci if (deviceList == nullptr) { 560060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read deviceList failed!"); 561060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 562060ff233Sopenharmony_ci } 563060ff233Sopenharmony_ci } 564060ff233Sopenharmony_ci uint16_t deviceTypeId = 0; 565060ff233Sopenharmony_ci if (!data.ReadUint16(deviceTypeId)) { 566060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read failed! deviceTypeId=%{public}hu", deviceTypeId); 567060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 568060ff233Sopenharmony_ci } 569060ff233Sopenharmony_ci int32_t errCode = 0; 570060ff233Sopenharmony_ci if (!data.ReadInt32(errCode)) { 571060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "read failed! errCode=%{public}d", errCode); 572060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 573060ff233Sopenharmony_ci } 574060ff233Sopenharmony_ci int32_t retReply = OnHichainProofException(pkgName, deviceList, deviceListLen, deviceTypeId, errCode); 575060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 576060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnHichainProofException write reply failed!"); 577060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_WRITEINT_FAILED; 578060ff233Sopenharmony_ci } 579060ff233Sopenharmony_ci return SOFTBUS_OK; 580060ff233Sopenharmony_ci} 581060ff233Sopenharmony_ci 582060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnTimeSyncResultInner(MessageParcel &data, MessageParcel &reply) 583060ff233Sopenharmony_ci{ 584060ff233Sopenharmony_ci uint32_t infoTypeLen; 585060ff233Sopenharmony_ci if (!data.ReadUint32(infoTypeLen) || infoTypeLen != sizeof(TimeSyncResultInfo)) { 586060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnTimeSyncResultInner read info failed! length=%{public}d", infoTypeLen); 587060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READUINT_FAILED; 588060ff233Sopenharmony_ci } 589060ff233Sopenharmony_ci void *info = (void *)data.ReadRawData(infoTypeLen); 590060ff233Sopenharmony_ci if (info == nullptr) { 591060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnTimeSyncResultInner read info failed!"); 592060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED; 593060ff233Sopenharmony_ci } 594060ff233Sopenharmony_ci int32_t retCode; 595060ff233Sopenharmony_ci if (!data.ReadInt32(retCode)) { 596060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnTimeSyncResultInner read retCode failed!"); 597060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 598060ff233Sopenharmony_ci } 599060ff233Sopenharmony_ci 600060ff233Sopenharmony_ci int32_t retReply = OnTimeSyncResult(info, infoTypeLen, retCode); 601060ff233Sopenharmony_ci if (!reply.WriteInt32(retReply)) { 602060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnTimeSyncResultInner write reply failed!"); 603060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_WRITEINT_FAILED; 604060ff233Sopenharmony_ci } 605060ff233Sopenharmony_ci return SOFTBUS_OK; 606060ff233Sopenharmony_ci} 607060ff233Sopenharmony_ci 608060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnPublishLNNResultInner(MessageParcel &data, MessageParcel &reply) 609060ff233Sopenharmony_ci{ 610060ff233Sopenharmony_ci int32_t publishId; 611060ff233Sopenharmony_ci if (!data.ReadInt32(publishId)) { 612060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnPublishLNNResultInner read publishId failed!"); 613060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 614060ff233Sopenharmony_ci } 615060ff233Sopenharmony_ci int32_t reason; 616060ff233Sopenharmony_ci if (!data.ReadInt32(reason)) { 617060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnPublishLNNResultInner read reason failed!"); 618060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 619060ff233Sopenharmony_ci } 620060ff233Sopenharmony_ci 621060ff233Sopenharmony_ci OnPublishLNNResult(publishId, reason); 622060ff233Sopenharmony_ci return SOFTBUS_OK; 623060ff233Sopenharmony_ci} 624060ff233Sopenharmony_ci 625060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnRefreshLNNResultInner(MessageParcel &data, MessageParcel &reply) 626060ff233Sopenharmony_ci{ 627060ff233Sopenharmony_ci int32_t refreshId; 628060ff233Sopenharmony_ci if (!data.ReadInt32(refreshId)) { 629060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnRefreshLNNResultInner read publishId failed!"); 630060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 631060ff233Sopenharmony_ci } 632060ff233Sopenharmony_ci int32_t reason; 633060ff233Sopenharmony_ci if (!data.ReadInt32(reason)) { 634060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnRefreshLNNResultInner read reason failed!"); 635060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READINT_FAILED; 636060ff233Sopenharmony_ci } 637060ff233Sopenharmony_ci 638060ff233Sopenharmony_ci OnRefreshLNNResult(refreshId, reason); 639060ff233Sopenharmony_ci return SOFTBUS_OK; 640060ff233Sopenharmony_ci} 641060ff233Sopenharmony_ci 642060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnRefreshDeviceFoundInner(MessageParcel &data, MessageParcel &reply) 643060ff233Sopenharmony_ci{ 644060ff233Sopenharmony_ci uint32_t deviceLen; 645060ff233Sopenharmony_ci if (!data.ReadUint32(deviceLen) || deviceLen != sizeof(DeviceInfo)) { 646060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnRefreshDeviceFoundInner read info failed! length=%{public}d", deviceLen); 647060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READUINT_FAILED; 648060ff233Sopenharmony_ci } 649060ff233Sopenharmony_ci void *device = (void *)data.ReadRawData(deviceLen); 650060ff233Sopenharmony_ci if (device == nullptr) { 651060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnRefreshDeviceFoundInner read info failed!"); 652060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED; 653060ff233Sopenharmony_ci } 654060ff233Sopenharmony_ci OnRefreshDeviceFound(device, deviceLen); 655060ff233Sopenharmony_ci return SOFTBUS_OK; 656060ff233Sopenharmony_ci} 657060ff233Sopenharmony_ci 658060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnDataLevelChangedInner(MessageParcel &data, MessageParcel &reply) 659060ff233Sopenharmony_ci{ 660060ff233Sopenharmony_ci const char *networkId = data.ReadCString(); 661060ff233Sopenharmony_ci if (networkId == nullptr || strlen(networkId) == 0) { 662060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "Invalid network, or length is zero"); 663060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED; 664060ff233Sopenharmony_ci } 665060ff233Sopenharmony_ci 666060ff233Sopenharmony_ci DataLevelInfo *info = (DataLevelInfo *)data.ReadRawData(sizeof(DataLevelInfo)); 667060ff233Sopenharmony_ci if (info == nullptr) { 668060ff233Sopenharmony_ci COMM_LOGE(COMM_SDK, "OnDataLevelChangedInner read data level chagne info failed"); 669060ff233Sopenharmony_ci return SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED; 670060ff233Sopenharmony_ci } 671060ff233Sopenharmony_ci OnDataLevelChanged(networkId, info); 672060ff233Sopenharmony_ci return SOFTBUS_OK; 673060ff233Sopenharmony_ci} 674060ff233Sopenharmony_ci 675060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelBind(int32_t channelId, int32_t channelType) 676060ff233Sopenharmony_ci{ 677060ff233Sopenharmony_ci return TransOnChannelBind(channelId, channelType); 678060ff233Sopenharmony_ci} 679060ff233Sopenharmony_ci 680060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnChannelBindInner(MessageParcel &data, MessageParcel &reply) 681060ff233Sopenharmony_ci{ 682060ff233Sopenharmony_ci int32_t channelId; 683060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(channelId), SOFTBUS_IPC_ERR, COMM_SDK, "read channelId failed"); 684060ff233Sopenharmony_ci 685060ff233Sopenharmony_ci int32_t channelType; 686060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(data.ReadInt32(channelType), SOFTBUS_IPC_ERR, COMM_SDK, "read channelType failed"); 687060ff233Sopenharmony_ci 688060ff233Sopenharmony_ci int32_t ret = OnChannelBind(channelId, channelType); 689060ff233Sopenharmony_ci COMM_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, COMM_SDK, 690060ff233Sopenharmony_ci "OnChannelBind failed! ret=%{public}d, channelId=%{public}d, channelType=%{public}d", 691060ff233Sopenharmony_ci ret, channelId, channelType); 692060ff233Sopenharmony_ci 693060ff233Sopenharmony_ci return SOFTBUS_OK; 694060ff233Sopenharmony_ci} 695060ff233Sopenharmony_ci 696060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnJoinLNNResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode) 697060ff233Sopenharmony_ci{ 698060ff233Sopenharmony_ci (void)addrTypeLen; 699060ff233Sopenharmony_ci return LnnOnJoinResult(addr, networkId, retCode); 700060ff233Sopenharmony_ci} 701060ff233Sopenharmony_ci 702060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnLeaveLNNResult(const char *networkId, int retCode) 703060ff233Sopenharmony_ci{ 704060ff233Sopenharmony_ci return LnnOnLeaveResult(networkId, retCode); 705060ff233Sopenharmony_ci} 706060ff233Sopenharmony_ci 707060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeOnlineStateChanged(const char *pkgName, bool isOnline, 708060ff233Sopenharmony_ci void *info, uint32_t infoTypeLen) 709060ff233Sopenharmony_ci{ 710060ff233Sopenharmony_ci (void)infoTypeLen; 711060ff233Sopenharmony_ci return LnnOnNodeOnlineStateChanged(pkgName, isOnline, info); 712060ff233Sopenharmony_ci} 713060ff233Sopenharmony_ci 714060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeBasicInfoChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) 715060ff233Sopenharmony_ci{ 716060ff233Sopenharmony_ci (void)infoTypeLen; 717060ff233Sopenharmony_ci return LnnOnNodeBasicInfoChanged(pkgName, info, type); 718060ff233Sopenharmony_ci} 719060ff233Sopenharmony_ci 720060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeStatusChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) 721060ff233Sopenharmony_ci{ 722060ff233Sopenharmony_ci (void)infoTypeLen; 723060ff233Sopenharmony_ci return LnnOnNodeStatusChanged(pkgName, info, type); 724060ff233Sopenharmony_ci} 725060ff233Sopenharmony_ci 726060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnLocalNetworkIdChanged(const char *pkgName) 727060ff233Sopenharmony_ci{ 728060ff233Sopenharmony_ci return LnnOnLocalNetworkIdChanged(pkgName); 729060ff233Sopenharmony_ci} 730060ff233Sopenharmony_ci 731060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnNodeDeviceTrustedChange(const char *pkgName, int32_t type, const char *msg, 732060ff233Sopenharmony_ci uint32_t msgLen) 733060ff233Sopenharmony_ci{ 734060ff233Sopenharmony_ci return LnnOnNodeDeviceTrustedChange(pkgName, type, msg, msgLen); 735060ff233Sopenharmony_ci} 736060ff233Sopenharmony_ci 737060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnHichainProofException( 738060ff233Sopenharmony_ci const char *pkgName, const char *deviceList, uint32_t deviceListLen, uint16_t deviceTypeId, int32_t errCode) 739060ff233Sopenharmony_ci{ 740060ff233Sopenharmony_ci return LnnOnHichainProofException(pkgName, deviceList, deviceListLen, deviceTypeId, errCode); 741060ff233Sopenharmony_ci} 742060ff233Sopenharmony_ci 743060ff233Sopenharmony_ciint32_t SoftBusClientStub::OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode) 744060ff233Sopenharmony_ci{ 745060ff233Sopenharmony_ci (void)infoTypeLen; 746060ff233Sopenharmony_ci return LnnOnTimeSyncResult(info, retCode); 747060ff233Sopenharmony_ci} 748060ff233Sopenharmony_ci 749060ff233Sopenharmony_civoid SoftBusClientStub::OnPublishLNNResult(int32_t publishId, int32_t reason) 750060ff233Sopenharmony_ci{ 751060ff233Sopenharmony_ci LnnOnPublishLNNResult(publishId, reason); 752060ff233Sopenharmony_ci} 753060ff233Sopenharmony_ci 754060ff233Sopenharmony_civoid SoftBusClientStub::OnRefreshLNNResult(int32_t refreshId, int32_t reason) 755060ff233Sopenharmony_ci{ 756060ff233Sopenharmony_ci LnnOnRefreshLNNResult(refreshId, reason); 757060ff233Sopenharmony_ci} 758060ff233Sopenharmony_ci 759060ff233Sopenharmony_civoid SoftBusClientStub::OnRefreshDeviceFound(const void *device, uint32_t deviceLen) 760060ff233Sopenharmony_ci{ 761060ff233Sopenharmony_ci (void)deviceLen; 762060ff233Sopenharmony_ci LnnOnRefreshDeviceFound(device); 763060ff233Sopenharmony_ci} 764060ff233Sopenharmony_ci 765060ff233Sopenharmony_civoid SoftBusClientStub::OnDataLevelChanged(const char *networkId, const DataLevelInfo *dataLevelInfo) 766060ff233Sopenharmony_ci{ 767060ff233Sopenharmony_ci LnnOnDataLevelChanged(networkId, dataLevelInfo); 768060ff233Sopenharmony_ci} 769060ff233Sopenharmony_ci} // namespace OHOS 770