mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 08:49:59 +00:00
回退 'Pull Request !4857 : fix code cathing bugs'
This commit is contained in:
parent
e3e0600e6d
commit
a67d710e56
@ -144,12 +144,7 @@ int32_t SoftbusGattcUnRegister(int32_t clientId)
|
||||
|
||||
int32_t SoftbusGattcConnect(int32_t clientId, SoftBusBtAddr *addr)
|
||||
{
|
||||
if (addr == NULL) {
|
||||
CONN_LOGE(CONN_BLE, "param invalid");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
BdAddr bdAddr;
|
||||
(void)memset_s(&bdAddr, sizeof(BdAddr), 0, sizeof(BdAddr));
|
||||
if (memcpy_s(bdAddr.addr, OHOS_BD_ADDR_LEN, addr->addr, BT_ADDR_LEN) != EOK) {
|
||||
CONN_LOGE(CONN_BLE, "SoftbusGattcConnect memcpy error");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
@ -211,13 +206,8 @@ int32_t SoftbusGattcGetService(int32_t clientId, SoftBusBtUuid *serverUuid)
|
||||
int32_t SoftbusGattcRegisterNotification(
|
||||
int32_t clientId, SoftBusBtUuid *serverUuid, SoftBusBtUuid *charaUuid, SoftBusBtUuid *descriptorUuid)
|
||||
{
|
||||
if (charaUuid == NULL || serverUuid == NULL) {
|
||||
CONN_LOGE(CONN_BLE, "param invalid");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
(void)descriptorUuid;
|
||||
BtGattCharacteristic btCharaUuid;
|
||||
(void)memset_s(&btCharaUuid, sizeof(BtGattCharacteristic), 0, sizeof(BtGattCharacteristic));
|
||||
btCharaUuid.serviceUuid.uuid = serverUuid->uuid;
|
||||
btCharaUuid.serviceUuid.uuidLen = serverUuid->uuidLen;
|
||||
btCharaUuid.characteristicUuid.uuid = charaUuid->uuid;
|
||||
@ -247,7 +237,6 @@ int32_t SoftbusGattcWriteCharacteristic(int32_t clientId, SoftBusGattcData *clie
|
||||
}
|
||||
CONN_LOGI(CONN_BLE, "SoftbusGattcRegisterNotification clientId = %d", clientId);
|
||||
BtGattCharacteristic characteristic;
|
||||
(void)memset_s(&characteristic, sizeof(BtGattCharacteristic), 0, sizeof(BtGattCharacteristic));
|
||||
characteristic.serviceUuid.uuid = clientData->serviceUuid.uuid;
|
||||
characteristic.serviceUuid.uuidLen = clientData->serviceUuid.uuidLen;
|
||||
characteristic.characteristicUuid.uuid = clientData->characterUuid.uuid;
|
||||
|
@ -173,7 +173,6 @@ int SoftBusGattsDisconnect(SoftBusBtAddr btAddr, int connId)
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
BdAddr addr;
|
||||
(void)memset_s(&addr, sizeof(BdAddr), 0, sizeof(BdAddr));
|
||||
if (memcpy_s(addr.addr, BT_ADDR_LEN, btAddr.addr, BT_ADDR_LEN) != EOK) {
|
||||
CONN_LOGE(CONN_BLE, "memcpy fail");
|
||||
return SOFTBUS_ERR;
|
||||
@ -425,7 +424,6 @@ int SoftBusRegisterGattsCallbacks(SoftBusGattsCallback *callback)
|
||||
}
|
||||
if (g_halRegFlag == -1) {
|
||||
BtUuid uuid;
|
||||
(void)memset_s(&uuid, sizeof(BtUuid), 0, sizeof(BtUuid));
|
||||
uuid.uuid = (char *)SOFTBUS_APP_UUID;
|
||||
uuid.uuidLen = sizeof(SOFTBUS_APP_UUID);
|
||||
g_halRegFlag = 0;
|
||||
|
@ -142,7 +142,7 @@ static int32_t NotifyOpenAuthChannelSuccess(const AppInfo *appInfo, bool isServe
|
||||
channelInfo.channelType = CHANNEL_TYPE_AUTH;
|
||||
channelInfo.isServer = isServer;
|
||||
channelInfo.isEnabled = true;
|
||||
channelInfo.channelId = (int32_t)appInfo->myData.channelId;
|
||||
channelInfo.channelId = appInfo->myData.channelId;
|
||||
channelInfo.peerDeviceId = (char *)appInfo->peerData.deviceId;
|
||||
channelInfo.peerSessionName = (char *)appInfo->peerData.sessionName;
|
||||
channelInfo.businessType = BUSINESS_TYPE_NOT_CARE;
|
||||
@ -184,8 +184,8 @@ static int32_t NotifyOnDataReceived(int32_t authId, const void *data, uint32_t l
|
||||
receiveData.dataLen = len;
|
||||
receiveData.dataType = TRANS_SESSION_BYTES;
|
||||
|
||||
return g_cb->OnDataReceived((char *)(channel.appInfo.myData.pkgName), (int32_t)(channel.appInfo.myData.pid),
|
||||
(int32_t)(channel.appInfo.myData.channelId), CHANNEL_TYPE_AUTH, &receiveData);
|
||||
return g_cb->OnDataReceived(channel.appInfo.myData.pkgName, channel.appInfo.myData.pid,
|
||||
channel.appInfo.myData.channelId, CHANNEL_TYPE_AUTH, &receiveData);
|
||||
}
|
||||
|
||||
static int32_t CopyPeerAppInfo(AppInfo *recvAppInfo, AppInfo *channelAppInfo)
|
||||
|
@ -38,7 +38,7 @@ static int32_t TransProxyParseMessageHead(char *data, int32_t len, ProxyMessage
|
||||
char *ptr = data;
|
||||
uint8_t firstByte = *ptr;
|
||||
ptr += sizeof(int8_t);
|
||||
int8_t version = (int8_t)((firstByte >> VERSION_SHIFT) & FOUR_BIT_MASK);
|
||||
int8_t version = (firstByte >> VERSION_SHIFT) & FOUR_BIT_MASK;
|
||||
msg->msgHead.type = firstByte & FOUR_BIT_MASK;
|
||||
if (version != VERSION || msg->msgHead.type >= PROXYCHANNEL_MSG_TYPE_MAX) {
|
||||
TRANS_LOGE(TRANS_CTRL, "parseMessage: unsupported message, version=%d, type=%d",
|
||||
@ -52,7 +52,7 @@ static int32_t TransProxyParseMessageHead(char *data, int32_t len, ProxyMessage
|
||||
ptr += sizeof(uint16_t);
|
||||
msg->msgHead.myId = (int16_t)SoftBusBEtoLEs(*(uint16_t *)ptr);
|
||||
msg->data = data + sizeof(ProxyMessageHead);
|
||||
msg->dateLen = (int32_t)(len - sizeof(ProxyMessageHead));
|
||||
msg->dateLen = len - sizeof(ProxyMessageHead);
|
||||
UnpackProxyMessageHead(&msg->msgHead);
|
||||
|
||||
return SOFTBUS_OK;
|
||||
@ -139,7 +139,7 @@ static int32_t TransProxyGetAuthConnInfo(uint32_t connId, AuthConnInfo *connInfo
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
connInfo->info.bleInfo.protocol = info.bleInfo.protocol;
|
||||
connInfo->info.bleInfo.psm = (int32_t)info.bleInfo.psm;
|
||||
connInfo->info.bleInfo.psm = info.bleInfo.psm;
|
||||
break;
|
||||
default:
|
||||
TRANS_LOGE(TRANS_CTRL, "unexpected conn type=%d.", info.type);
|
||||
@ -459,7 +459,7 @@ char *TransProxyPackHandshakeMsg(ProxyChannelInfo *info)
|
||||
!AddStringToJsonObject(root, JSON_KEY_DEVICE_ID, appInfo->myData.deviceId) ||
|
||||
!AddStringToJsonObject(root, JSON_KEY_SRC_BUS_NAME, appInfo->myData.sessionName) ||
|
||||
!AddStringToJsonObject(root, JSON_KEY_DST_BUS_NAME, appInfo->peerData.sessionName) ||
|
||||
!AddNumberToJsonObject(root, JSON_KEY_MTU_SIZE, (int)appInfo->myData.dataConfig)) {
|
||||
!AddNumberToJsonObject(root, JSON_KEY_MTU_SIZE, appInfo->myData.dataConfig)) {
|
||||
goto EXIT;
|
||||
}
|
||||
(void)cJSON_AddTrueToObject(root, JSON_KEY_HAS_PRIORITY);
|
||||
@ -519,7 +519,7 @@ char *TransProxyPackHandshakeAckMsg(ProxyChannelInfo *chan)
|
||||
return NULL;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
if (!AddNumberToJsonObject(root, JSON_KEY_MTU_SIZE, (int)appInfo->myData.dataConfig)) {
|
||||
if (!AddNumberToJsonObject(root, JSON_KEY_MTU_SIZE, appInfo->myData.dataConfig)) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -592,16 +592,16 @@ static void TransProxyPipelineHandleMessage(SoftBusMessage *msg)
|
||||
TRANS_LOGD(TRANS_CTRL, "enter, messageType=%d", msg->what);
|
||||
switch (msg->what) {
|
||||
case LOOPER_MSG_TYPE_OPEN_CHANNEL:
|
||||
InnerOpenProxyChannel((int32_t)msg->arg1);
|
||||
InnerOpenProxyChannel(msg->arg1);
|
||||
break;
|
||||
case LOOPER_MSG_TYPE_DELEY_CLOSE_CHANNEL:
|
||||
TransProxyPipelineCloseChannel((int32_t)msg->arg1);
|
||||
TransProxyPipelineCloseChannel(msg->arg1);
|
||||
break;
|
||||
case LOOPER_MSG_TYPE_ON_CHANNEL_OPEN_FAILED:
|
||||
InnerOnChannelOpenFailed((int32_t)msg->arg1);
|
||||
InnerOnChannelOpenFailed(msg->arg1);
|
||||
break;
|
||||
case LOOPER_MSG_TYPE_ON_CHANNEL_OPENED:
|
||||
InnerOnChannelOpened((int32_t)msg->arg1, (char *)msg->obj, (unsigned char)msg->arg2);
|
||||
InnerOnChannelOpened(msg->arg1, (char *)msg->obj, msg->arg2);
|
||||
break;
|
||||
default:
|
||||
TRANS_LOGE(TRANS_CTRL, "unknown messageType=%d", msg->what);
|
||||
|
@ -116,7 +116,7 @@ int32_t TransProxyPostPacketData(int32_t channelId, const unsigned char *data,
|
||||
return SOFTBUS_TRANS_PROXY_CHANNEL_NOT_FOUND;
|
||||
}
|
||||
TRANS_LOGI(TRANS_MSG, "send msg len=%d seq=%d flags=%d", len, seq, flags);
|
||||
int32_t ret = TransProxyTransDataSendMsg(chanInfo, data, (int)len, flags);
|
||||
int32_t ret = TransProxyTransDataSendMsg(chanInfo, data, len, flags);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_MSG, "TransProxyTransDataSendMsg fail ret=%d", ret);
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ int32_t TransProxyTransSendMsg(uint32_t connectionId, uint8_t *buf, uint32_t len
|
||||
int32_t ret;
|
||||
|
||||
data.module = MODULE_PROXY_CHANNEL;
|
||||
data.seq = (int64_t)seq++;
|
||||
data.seq = seq++;
|
||||
data.flag = priority;
|
||||
data.pid = pid;
|
||||
data.len = len;
|
||||
|
@ -1123,7 +1123,7 @@ static int32_t TransTdcUpdateDataBufWInfo(int32_t channelId, char *recvBuf, int3
|
||||
if (item->channelId != channelId) {
|
||||
continue;
|
||||
}
|
||||
int32_t freeLen = (int32_t)(item->size - (item->w - item->data));
|
||||
int32_t freeLen = (int32_t)(item->size) - (item->w - item->data);
|
||||
if (recvLen > freeLen) {
|
||||
(void)SoftBusMutexUnlock(&g_tcpSrvDataList->lock);
|
||||
TRANS_LOGE(TRANS_CTRL,
|
||||
@ -1161,7 +1161,7 @@ int32_t TransTdcSrvRecvData(ListenerModule module, int32_t channelId)
|
||||
TRANS_LOGE(TRANS_CTRL, "trans channelId=%d malloc len%zu failed..", channelId, len);
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
int32_t recvLen = (int32_t)ConnRecvSocketData(fd, recvBuf, len, 0);
|
||||
int32_t recvLen = ConnRecvSocketData(fd, recvBuf, len, 0);
|
||||
if (recvLen < 0) {
|
||||
SoftBusFree(recvBuf);
|
||||
TRANS_LOGE(TRANS_CTRL, "channelId=%d recv tcp data fail,retLen=%d.", channelId, recvLen);
|
||||
|
@ -458,7 +458,7 @@ static void SendVerifyP2pFailRsp(int64_t authId, int64_t seq,
|
||||
return;
|
||||
}
|
||||
TransProxyPipelineSendMessage(
|
||||
(int32_t)authId, (uint8_t *)sendMsg, strLen + sizeof(int64_t) + sizeof(int64_t), MSG_TYPE_IP_PORT_EXCHANGE);
|
||||
authId, (uint8_t *)sendMsg, strLen + sizeof(int64_t) + sizeof(int64_t), MSG_TYPE_IP_PORT_EXCHANGE);
|
||||
SoftBusFree(sendMsg);
|
||||
}
|
||||
cJSON_free(reply);
|
||||
@ -487,7 +487,7 @@ static int32_t SendVerifyP2pRsp(int64_t authId, int32_t module, int32_t flag, in
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
ret = TransProxyPipelineSendMessage(
|
||||
(int32_t)authId, (uint8_t *)sendMsg, strLen + sizeof(int64_t) + sizeof(int64_t), MSG_TYPE_IP_PORT_EXCHANGE);
|
||||
authId, (uint8_t *)sendMsg, strLen + sizeof(int64_t) + sizeof(int64_t), MSG_TYPE_IP_PORT_EXCHANGE);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "TransProxyPipelineSendMessage fail");
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ static int32_t NotifyUdpChannelOpened(const AppInfo *appInfo, bool isServerSide)
|
||||
char networkId[NETWORK_ID_BUF_LEN] = {0};
|
||||
info.myHandleId = appInfo->myHandleId;
|
||||
info.peerHandleId = appInfo->peerHandleId;
|
||||
info.channelId = (int32_t)appInfo->myData.channelId;
|
||||
info.channelId = appInfo->myData.channelId;
|
||||
info.channelType = CHANNEL_TYPE_UDP;
|
||||
info.isServer = isServerSide;
|
||||
info.businessType = appInfo->businessType;
|
||||
@ -254,20 +254,20 @@ static int32_t AcceptUdpChannelAsServer(AppInfo *appInfo)
|
||||
int32_t udpPort = NotifyUdpChannelOpened(appInfo, true);
|
||||
if (udpPort <= 0) {
|
||||
TRANS_LOGE(TRANS_CTRL, "get udp listen port failed udpPort=%d.", udpPort);
|
||||
ReleaseUdpChannelId((int32_t)appInfo->myData.channelId);
|
||||
ReleaseUdpChannelId(appInfo->myData.channelId);
|
||||
return SOFTBUS_TRANS_UDP_SERVER_NOTIFY_APP_OPEN_FAILED;
|
||||
}
|
||||
appInfo->myData.port = udpPort;
|
||||
UdpChannelInfo *newChannel = NewUdpChannelByAppInfo(appInfo);
|
||||
if (newChannel == NULL) {
|
||||
ReleaseUdpChannelId((int32_t)appInfo->myData.channelId);
|
||||
ReleaseUdpChannelId(appInfo->myData.channelId);
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
newChannel->seq = GenerateSeq(true);
|
||||
newChannel->status = UDP_CHANNEL_STATUS_INIT;
|
||||
if (TransAddUdpChannel(newChannel) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "add new udp channel failed.");
|
||||
ReleaseUdpChannelId((int32_t)appInfo->myData.channelId);
|
||||
ReleaseUdpChannelId(appInfo->myData.channelId);
|
||||
SoftBusFree(newChannel);
|
||||
return SOFTBUS_TRANS_UDP_SERVER_ADD_CHANNEL_FAILED;
|
||||
}
|
||||
@ -287,7 +287,7 @@ static int32_t AcceptUdpChannelAsClient(AppInfo *appInfo)
|
||||
static int32_t CloseUdpChannel(AppInfo *appInfo)
|
||||
{
|
||||
TRANS_LOGI(TRANS_CTRL, "process udp channel close state");
|
||||
if (TransDelUdpChannel((int32_t)appInfo->myData.channelId) != SOFTBUS_OK) {
|
||||
if (TransDelUdpChannel(appInfo->myData.channelId) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "delete udp channel failed.");
|
||||
}
|
||||
if (NotifyUdpChannelClosed(appInfo) != SOFTBUS_OK) {
|
||||
@ -496,10 +496,10 @@ static void ProcessAbnormalUdpChannelState(const AppInfo *info, int32_t errCode,
|
||||
}
|
||||
if (info->udpChannelOptType == TYPE_UDP_CHANNEL_OPEN) {
|
||||
(void)NotifyUdpChannelOpenFailed(info, errCode);
|
||||
(void)TransDelUdpChannel((int32_t)info->myData.channelId);
|
||||
(void)TransDelUdpChannel(info->myData.channelId);
|
||||
} else if (needClose) {
|
||||
NotifyUdpChannelClosed(info);
|
||||
(void)TransDelUdpChannel((int32_t)info->myData.channelId);
|
||||
(void)TransDelUdpChannel(info->myData.channelId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,7 +779,7 @@ static int32_t OpenAuthConnForUdpNegotiation(UdpChannelInfo *channel)
|
||||
if (GetUdpChannelLock() != SOFTBUS_OK) {
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
UdpChannelInfo *channelObj = TransGetChannelObj((int32_t)channel->info.myData.channelId);
|
||||
UdpChannelInfo *channelObj = TransGetChannelObj(channel->info.myData.channelId);
|
||||
if (channelObj == NULL) {
|
||||
ReleaseUdpChannelLock();
|
||||
return SOFTBUS_NOT_FIND;
|
||||
|
@ -424,7 +424,7 @@ int32_t ClientTransProxyNotifySession(int32_t channelId,
|
||||
ClientTransProxySendSessionAck(channelId, seq);
|
||||
return g_sessionCb.OnDataReceived(channelId, CHANNEL_TYPE_PROXY, data, len, flags);
|
||||
case TRANS_SESSION_ACK:
|
||||
return ClientTransProxyProcSendMsgAck(channelId, data, (int32_t)len);
|
||||
return (int32_t)(ClientTransProxyProcSendMsgAck(channelId, data, len));
|
||||
case TRANS_SESSION_BYTES:
|
||||
case TRANS_SESSION_FILE_FIRST_FRAME:
|
||||
case TRANS_SESSION_FILE_ONGOINE_FRAME:
|
||||
@ -844,7 +844,7 @@ static int32_t ClientTransProxyPackBytes(int32_t channelId, ClientProxyDataInfo
|
||||
pktHead->magicNumber = MAGIC_NUMBER;
|
||||
pktHead->seq = seq;
|
||||
pktHead->flags = flag;
|
||||
pktHead->dataLen = (int32_t)(dataInfo->outLen - sizeof(PacketHead));
|
||||
pktHead->dataLen = (int32_t)((int32_t)dataInfo->outLen - sizeof(PacketHead));
|
||||
ClientPackPacketHead(pktHead);
|
||||
|
||||
return SOFTBUS_OK;
|
||||
|
@ -563,7 +563,7 @@ static int32_t TransClientUpdateTdcDataBufWInfo(int32_t channelId, char *recvBuf
|
||||
if (item->channelId != channelId) {
|
||||
continue;
|
||||
}
|
||||
int32_t freeLen = (int32_t)((item->size) - (item->w - item->data));
|
||||
int32_t freeLen = (int32_t)(item->size) - (item->w - item->data);
|
||||
if (recvLen > freeLen) {
|
||||
(void)SoftBusMutexUnlock(&g_tcpDataList->lock);
|
||||
TRANS_LOGE(TRANS_SDK, "client tdc recvLen=%d override freeLen=%d.", recvLen, freeLen);
|
||||
@ -603,7 +603,7 @@ int32_t TransTdcRecvData(int32_t channelId)
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
int32_t recvLen = (int32_t)ConnRecvSocketData(fd, recvBuf, len, 0);
|
||||
int32_t recvLen = ConnRecvSocketData(fd, recvBuf, len, 0);
|
||||
if (recvLen < 0) {
|
||||
SoftBusFree(recvBuf);
|
||||
TRANS_LOGE(TRANS_SDK, "client channelId=%d recv data failed,recvLen=%d.", channelId, recvLen);
|
||||
|
@ -150,12 +150,12 @@ static void NotifyRecvResult(int32_t sessionId, DFileMsgType msgType, const DFil
|
||||
switch (msgType) {
|
||||
case DFILE_ON_FILE_LIST_RECEIVED:
|
||||
if (listener->recvListener.OnReceiveFileStarted != NULL) {
|
||||
listener->recvListener.OnReceiveFileStarted(sessionId, firstFile, (int)fileNum);
|
||||
listener->recvListener.OnReceiveFileStarted(sessionId, firstFile, fileNum);
|
||||
}
|
||||
break;
|
||||
case DFILE_ON_FILE_RECEIVE_SUCCESS:
|
||||
if (listener->recvListener.OnReceiveFileFinished != NULL) {
|
||||
listener->recvListener.OnReceiveFileFinished(sessionId, firstFile, (int)fileNum);
|
||||
listener->recvListener.OnReceiveFileFinished(sessionId, firstFile, fileNum);
|
||||
}
|
||||
break;
|
||||
case DFILE_ON_FILE_RECEIVE_FAIL:
|
||||
|
@ -51,10 +51,10 @@ public:
|
||||
StreamFrameInfo tmpf = {0};
|
||||
auto uniptr = stream->GetBuffer();
|
||||
char *retbuf = uniptr.get();
|
||||
int32_t buflen = (int32_t)(stream->GetBufferLen());
|
||||
int32_t buflen = stream->GetBufferLen();
|
||||
auto extUniptr = stream->GetExtBuffer();
|
||||
char *extRetBuf = extUniptr.get();
|
||||
int32_t extRetBuflen = (int32_t)(stream->GetExtBufferLen());
|
||||
int32_t extRetBuflen = stream->GetExtBufferLen();
|
||||
StreamData retStreamData = {0};
|
||||
int32_t streamType = adaptor_->GetStreamType();
|
||||
std::unique_ptr<char[]> plainData = nullptr;
|
||||
|
@ -64,7 +64,7 @@ std::unique_ptr<IStream> IStream::MakeRawStream(const char *buf, ssize_t bufLen,
|
||||
TRANS_LOGE(TRANS_STREAM, "memcpy failed");
|
||||
return nullptr;
|
||||
}
|
||||
RawStreamData::InsertBufferLength(reinterpret_cast<int>(bufLen), RawStreamData::FRAME_HEADER_LEN,
|
||||
RawStreamData::InsertBufferLength(bufLen, RawStreamData::FRAME_HEADER_LEN,
|
||||
reinterpret_cast<uint8_t *>(buffer.get()));
|
||||
|
||||
raw->InitStreamData(std::move(buffer), bufLen + RawStreamData::FRAME_HEADER_LEN, nullptr, 0);
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
{
|
||||
char *pos = new (start + offset) char[size];
|
||||
if (ext_ != nullptr) {
|
||||
auto extTlvAlignSize = HEADER_LEN + NUMS_LEN + AlignTo4Bytes(reinterpret_cast<int>(extLen_));
|
||||
auto extTlvAlignSize = HEADER_LEN + NUMS_LEN + AlignTo4Bytes(extLen_);
|
||||
if (AddFrameExtData(pos + HEADER_LEN + NUMS_LEN) != 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -151,7 +151,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
checkSum_ = ntohl(*reinterpret_cast<uint32_t *>((reinterpret_cast<char *>(tmp) + AlignTo4Bytes(reinterpret_cast<int>(extLen_)))));
|
||||
checkSum_ = ntohl(*reinterpret_cast<uint32_t *>((reinterpret_cast<char *>(tmp) + AlignTo4Bytes(extLen_))));
|
||||
}
|
||||
|
||||
uint16_t GetTlvNums() const
|
||||
@ -210,7 +210,7 @@ private:
|
||||
*(pos++) = htons(extTlv.length);
|
||||
|
||||
char *extPos = reinterpret_cast<char *>(pos);
|
||||
int ret = memcpy_s(extPos, AlignTo4Bytes(reinterpret_cast<int>(extLen_)), ext_.get(), extLen_);
|
||||
int ret = memcpy_s(extPos, AlignTo4Bytes(extLen_), ext_.get(), extLen_);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ ssize_t StreamPacketizer::CalculateExtSize(ssize_t extSize) const
|
||||
if (extSize > 0) {
|
||||
total += TwoLevelsTlv::HEADER_LEN + TwoLevelsTlv::NUMS_LEN;
|
||||
total += TwoLevelsTlv::HEADER_LEN + TwoLevelsTlv::NUMS_LEN;
|
||||
total += Align((int)extSize, SHIFT);
|
||||
total += Align(extSize, SHIFT);
|
||||
total += TwoLevelsTlv::CHECK_SUM_LEN;
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ bool VtpStreamSocket::Send(std::unique_ptr<IStream> stream)
|
||||
"encrypted failed, dataLen=%zd, encLen=%zd", len, encLen);
|
||||
return false;
|
||||
}
|
||||
InsertBufferLength(reinterpret_cast<int>(len), FRAME_HEADER_LEN, reinterpret_cast<uint8_t *>(data.get()));
|
||||
InsertBufferLength(len, FRAME_HEADER_LEN, reinterpret_cast<uint8_t *>(data.get()));
|
||||
len += FRAME_HEADER_LEN;
|
||||
|
||||
FrameInfo frameInfo;
|
||||
@ -1061,7 +1061,7 @@ void VtpStreamSocket::DoStreamRecv()
|
||||
int decryptedLength = dataLength;
|
||||
auto decryptedBuffer = std::move(dataBuffer);
|
||||
|
||||
int plainDataLength = decryptedLength - reinterpret_cast<int>(GetEncryptOverhead());
|
||||
int plainDataLength = decryptedLength - GetEncryptOverhead();
|
||||
if (plainDataLength <= 0) {
|
||||
TRANS_LOGE(
|
||||
TRANS_STREAM, "Decrypt failed, invalid decryptedLen=%zd", decryptedLength);
|
||||
@ -1087,7 +1087,7 @@ void VtpStreamSocket::DoStreamRecv()
|
||||
decode.DepacketizeBuffer(buffer, plainDataLength - sizeof(CommonHeader));
|
||||
|
||||
extBuffer = decode.GetUserExt();
|
||||
extLen = reinterpret_cast<int>(decode.GetUserExtSize());
|
||||
extLen = decode.GetUserExtSize();
|
||||
info = decode.GetFrameInfo();
|
||||
dataBuffer = decode.GetData();
|
||||
dataLength = decode.GetDataLength();
|
||||
|
Loading…
Reference in New Issue
Block a user