From d88045e0431e5a3402b07bdf631ade7f0d70ec94 Mon Sep 17 00:00:00 2001 From: wangyipeng Date: Thu, 4 Jul 2024 20:44:44 +0800 Subject: [PATCH] fix:add dimension test log Signed-off-by: wangyipeng --- .../standard/softbus_permission.cpp | 2 +- .../common/src/softbus_message_open_channel.c | 1 - .../manager/src/trans_lane_manager.c | 1 - .../src/trans_tcp_direct_listener.c | 25 ++++++++++++------- .../tcp_direct/src/trans_tcp_direct_message.c | 13 +++++++--- .../tcp_direct/src/trans_tcp_direct_p2p.c | 3 +++ .../tcp_direct/src/trans_tcp_direct_wifi.c | 8 +++--- .../auth/include/client_trans_auth_manager.h | 5 ++-- .../auth/src/client_trans_auth_manager.c | 19 +++++++------- .../src/client_trans_tcp_direct_listener.c | 4 +-- .../src/client_trans_tcp_direct_manager.c | 2 +- 11 files changed, 48 insertions(+), 35 deletions(-) diff --git a/core/common/security/permission/standard/softbus_permission.cpp b/core/common/security/permission/standard/softbus_permission.cpp index 73903b154..f6f81c4a7 100644 --- a/core/common/security/permission/standard/softbus_permission.cpp +++ b/core/common/security/permission/standard/softbus_permission.cpp @@ -98,7 +98,7 @@ int32_t CheckTransPermission(pid_t callingUid, pid_t callingPid, } Anonymize(sessionName, &tmpName); COMM_LOGE(COMM_PERM, "permission denied, permType=%{public}d, ret=%{public}d, sessionName=%{public}s, \ - callingUid=%{piblic}d, callingPid=%{public}d", permType, ret, tmpName, callingUid, callingPid); + callingUid=%{public}d, callingPid=%{public}d", permType, ret, tmpName, callingUid, callingPid); AnonymizeFree(tmpName); return SOFTBUS_PERMISSION_DENIED; } diff --git a/core/transmission/common/src/softbus_message_open_channel.c b/core/transmission/common/src/softbus_message_open_channel.c index ce58bec9d..4c3d95414 100644 --- a/core/transmission/common/src/softbus_message_open_channel.c +++ b/core/transmission/common/src/softbus_message_open_channel.c @@ -409,7 +409,6 @@ int32_t UnpackReplyErrCode(const cJSON *msg, int32_t *errCode) } if (!GetJsonObjectInt32Item(msg, ERR_CODE, errCode)) { - TRANS_LOGW(TRANS_CTRL, "unpack reply faild"); return SOFTBUS_PARSE_JSON_ERR; } diff --git a/core/transmission/trans_channel/manager/src/trans_lane_manager.c b/core/transmission/trans_channel/manager/src/trans_lane_manager.c index 042062b56..8eac32cd0 100644 --- a/core/transmission/trans_channel/manager/src/trans_lane_manager.c +++ b/core/transmission/trans_channel/manager/src/trans_lane_manager.c @@ -246,7 +246,6 @@ int32_t TransLaneMgrAddLane( int32_t TransLaneMgrDelLane(int32_t channelId, int32_t channelType) { - TRANS_LOGI(TRANS_SVC, "del trans land mgr. chanId=%{public}d channelType=%{public}d", channelId, channelType); if (g_channelLaneList == NULL) { TRANS_LOGE(TRANS_INIT, "trans lane manager hasn't init."); return SOFTBUS_NO_INIT; diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c index c9ee28b53..bda470a69 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_listener.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -87,9 +87,11 @@ int32_t GetCipherFlagByAuthId(AuthHandle authHandle, uint32_t *flag, bool *isAut static int32_t StartVerifySession(SessionConn *conn) { - TRANS_LOGI(TRANS_CTRL, "enter."); + TRANS_LOGI(TRANS_CTRL, "verify enter. channelId=%{public}d, fd=%{public}d", conn->channelId, conn->appInfo.fd); if (SoftBusGenerateSessionKey(conn->appInfo.sessionKey, SESSION_KEY_LENGTH) != SOFTBUS_OK) { - TRANS_LOGE(TRANS_CTRL, "Generate SessionKey failed"); + TRANS_LOGE(TRANS_CTRL, + "Generate SessionKey failed channelId=%{public}d, fd=%{public}d", + conn->channelId, conn->appInfo.fd); return SOFTBUS_TRANS_TCP_GENERATE_SESSIONKEY_FAILED; } SetSessionKeyByChanId(conn->channelId, conn->appInfo.sessionKey, sizeof(conn->appInfo.sessionKey)); @@ -97,7 +99,9 @@ static int32_t StartVerifySession(SessionConn *conn) uint32_t cipherFlag = FLAG_WIFI; bool isLegacyOs = IsPeerDeviceLegacyOs(conn->appInfo.osType); if (GetCipherFlagByAuthId(conn->authHandle, &cipherFlag, &isAuthServer, isLegacyOs)) { - TRANS_LOGE(TRANS_CTRL, "get cipher flag failed"); + TRANS_LOGE(TRANS_CTRL, + "get cipher flag failed channelId=%{public}d, fd=%{public}d", + conn->channelId, conn->appInfo.fd); return SOFTBUS_TRANS_GET_CIPHER_FAILED; } uint64_t seq = TransTdcGetNewSeqId(); @@ -106,7 +110,9 @@ static int32_t StartVerifySession(SessionConn *conn) } char *bytes = PackRequest(&conn->appInfo); if (bytes == NULL) { - TRANS_LOGE(TRANS_CTRL, "Pack Request failed"); + TRANS_LOGE(TRANS_CTRL, + "Pack Request failed channelId=%{public}d, fd=%{public}d", + conn->channelId, conn->appInfo.fd); return SOFTBUS_TRANS_PACK_REQUEST_FAILED; } TdcPacketHead packetHead = { @@ -120,13 +126,14 @@ static int32_t StartVerifySession(SessionConn *conn) packetHead.flags |= FLAG_AUTH_META; } int32_t ret = TransTdcPostBytes(conn->channelId, &packetHead, bytes); + cJSON_free(bytes); if (ret != SOFTBUS_OK) { - TRANS_LOGE(TRANS_CTRL, "TransTdc post bytes failed"); - cJSON_free(bytes); + TRANS_LOGE(TRANS_CTRL, + "TransTdc post bytes failed channelId=%{public}d, fd=%{public}d, ret=%{public}d", + conn->channelId, conn->appInfo.fd, ret); return ret; } - cJSON_free(bytes); - TRANS_LOGI(TRANS_CTRL, "ok"); + TRANS_LOGI(TRANS_CTRL, "verify ok. channelId=%{public}d, fd=%{public}d", conn->channelId, conn->appInfo.fd); return SOFTBUS_OK; } diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c index 2a744d0e4..9fcf92177 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_message.c @@ -607,14 +607,16 @@ static int32_t TransTdcProcessDataConfig(AppInfo *appInfo) static int32_t OpenDataBusReply(int32_t channelId, uint64_t seq, const cJSON *reply) { (void)seq; - TRANS_LOGI(TRANS_CTRL, "channelId=%{public}d", channelId); + TRANS_LOGI(TRANS_CTRL, "channelId=%{public}d, seq=%{public}" PRIu64, channelId, seq); SessionConn conn; (void)memset_s(&conn, sizeof(SessionConn), 0, sizeof(SessionConn)); TRANS_CHECK_AND_RETURN_RET_LOGE(GetSessionConnById(channelId, &conn) == SOFTBUS_OK, SOFTBUS_TRANS_GET_SESSION_CONN_FAILED, TRANS_CTRL, "notify channel open failed, get tdcInfo is null"); int32_t errCode = SOFTBUS_OK; if (UnpackReplyErrCode(reply, &errCode) == SOFTBUS_OK) { - TRANS_LOGE(TRANS_CTRL, "receive err reply msg"); + TRANS_LOGE(TRANS_CTRL, + "receive err reply msg channelId=%{public}d, errCode=%{public}d, seq=%{public}" PRIu64, + channelId, errCode, seq); return errCode; } uint16_t fastDataSize = 0; @@ -644,7 +646,8 @@ static int32_t OpenDataBusReply(int32_t channelId, uint64_t seq, const cJSON *re .calleePkg = NULL, .callerPkg = NULL, .channelId = channelId, - .result = EVENT_STAGE_RESULT_OK }; + .result = EVENT_STAGE_RESULT_OK + }; TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_HANDSHAKE_REPLY, extra); TRANS_LOGD(TRANS_CTRL, "ok"); return SOFTBUS_OK; @@ -1098,7 +1101,9 @@ static int32_t ProcessReceivedData(int32_t channelId, int32_t type) seq = pktHead->seq; flags = pktHead->flags; - TRANS_LOGI(TRANS_CTRL, "recv tdc packet, flags=%{public}d, seq=%{public}" PRIu64, flags, seq); + TRANS_LOGI(TRANS_CTRL, + "recv tdc packet. channelId=%{public}d, flags=%{public}d, seq=%{public}" PRIu64, + channelId, flags, seq); if (DecryptMessage(channelId, pktHead, pktData, &data, &dataLen) != SOFTBUS_OK) { TRANS_LOGE(TRANS_CTRL, "srv process recv data: decrypt fail."); SoftBusMutexUnlock(&g_tcpSrvDataList->lock); diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c index 48d0af7f7..0b1e36ffb 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c @@ -109,6 +109,9 @@ static void DelHmlListenerByMoudle(ListenerModule type) LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &g_hmlListenerList->list, HmlListenerInfo, node) { if (item->moudleType == type) { ListDelete(&item->node); + TRANS_LOGI(TRANS_CTRL, + "del hmlListener port=%{public}d, listenerModule=%{public}d", + item->myPort, (int32_t)item->moudleType); SoftBusFree(item); g_hmlListenerList->cnt--; return; diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c index 8a3c8fddb..827d7fab2 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_wifi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -162,7 +162,7 @@ int32_t OpenTcpDirectChannel(const AppInfo *appInfo, const ConnectOption *connIn if (fd < 0) { FreeFastTransData(&(newConn->appInfo)); SoftBusFree(newConn); - TRANS_LOGE(TRANS_CTRL, "connect fail"); + TRANS_LOGE(TRANS_CTRL, "connect failed. fd=%{public}d", fd); return fd; } newConn->appInfo.fd = fd; @@ -172,6 +172,8 @@ int32_t OpenTcpDirectChannel(const AppInfo *appInfo, const ConnectOption *connIn return ret; } *channelId = newchannelId; - TRANS_LOGI(TRANS_CTRL, "ok: channelId=%{public}d", newchannelId); + TRANS_LOGI(TRANS_CTRL, + "ok: channelId=%{public}d, module=%{public}d, fd=%{public}d", + newchannelId, (int32_t)module, fd); return SOFTBUS_OK; } diff --git a/sdk/transmission/trans_channel/auth/include/client_trans_auth_manager.h b/sdk/transmission/trans_channel/auth/include/client_trans_auth_manager.h index 40290bc2d..63af9fbf2 100644 --- a/sdk/transmission/trans_channel/auth/include/client_trans_auth_manager.h +++ b/sdk/transmission/trans_channel/auth/include/client_trans_auth_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,8 +31,7 @@ int32_t ClientTransAuthOnChannelClosed(int32_t channelId, ShutdownReason reason) int32_t ClientTransAuthOnChannelOpenFailed(int32_t channelId, int32_t errCode); -int32_t ClientTransAuthOnDataReceived(int32_t channelId, - const void *data, uint32_t len, SessionPktType type); +int32_t ClientTransAuthOnDataReceived(int32_t channelId, const void *data, uint32_t len, SessionPktType type); void ClientTransAuthCloseChannel(int32_t channelId, ShutdownReason reason); diff --git a/sdk/transmission/trans_channel/auth/src/client_trans_auth_manager.c b/sdk/transmission/trans_channel/auth/src/client_trans_auth_manager.c index 20eacc42b..26a86329c 100644 --- a/sdk/transmission/trans_channel/auth/src/client_trans_auth_manager.c +++ b/sdk/transmission/trans_channel/auth/src/client_trans_auth_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,7 +14,7 @@ */ #include "client_trans_auth_manager.h" -#include "softbus_def.h" + #include "softbus_errcode.h" #include "trans_log.h" #include "trans_server_proxy.h" @@ -38,7 +38,7 @@ int32_t ClientTransAuthOnChannelOpened(const char *sessionName, const ChannelInf return SOFTBUS_INVALID_PARAM; } - int ret = g_sessionCb.OnSessionOpened(sessionName, channel, TYPE_MESSAGE); + int32_t ret = g_sessionCb.OnSessionOpened(sessionName, channel, TYPE_MESSAGE); if (ret != SOFTBUS_OK) { TRANS_LOGE(TRANS_SDK, "notify session open fail, ret=%{public}d", ret); return ret; @@ -49,7 +49,7 @@ int32_t ClientTransAuthOnChannelOpened(const char *sessionName, const ChannelInf int32_t ClientTransAuthOnChannelClosed(int32_t channelId, ShutdownReason reason) { - int ret = g_sessionCb.OnSessionClosed(channelId, CHANNEL_TYPE_AUTH, reason); + int32_t ret = g_sessionCb.OnSessionClosed(channelId, CHANNEL_TYPE_AUTH, reason); if (ret != SOFTBUS_OK) { TRANS_LOGE(TRANS_SDK, "notify session open fail. ret=%{public}d, channelId=%{public}d", ret, channelId); return ret; @@ -59,7 +59,7 @@ int32_t ClientTransAuthOnChannelClosed(int32_t channelId, ShutdownReason reason) int32_t ClientTransAuthOnChannelOpenFailed(int32_t channelId, int32_t errCode) { - int ret = g_sessionCb.OnSessionOpenFailed(channelId, CHANNEL_TYPE_AUTH, errCode); + int32_t ret = g_sessionCb.OnSessionOpenFailed(channelId, CHANNEL_TYPE_AUTH, errCode); if (ret != SOFTBUS_OK) { TRANS_LOGE(TRANS_SDK, "notify session open fail. ret=%{public}d, errCode=%{public}d, channelId=%{public}d", @@ -70,14 +70,13 @@ int32_t ClientTransAuthOnChannelOpenFailed(int32_t channelId, int32_t errCode) return SOFTBUS_OK; } -int32_t ClientTransAuthOnDataReceived(int32_t channelId, - const void *data, uint32_t len, SessionPktType type) +int32_t ClientTransAuthOnDataReceived(int32_t channelId, const void *data, uint32_t len, SessionPktType type) { if (data == NULL) { TRANS_LOGE(TRANS_SDK, "param invalid"); return SOFTBUS_INVALID_PARAM; } - int ret = g_sessionCb.OnDataReceived(channelId, CHANNEL_TYPE_AUTH, data, len, type); + int32_t ret = g_sessionCb.OnDataReceived(channelId, CHANNEL_TYPE_AUTH, data, len, type); if (ret != SOFTBUS_OK) { TRANS_LOGE(TRANS_SDK, "notify data recv err, ret=%{public}d, channelId=%{public}d", ret, channelId); return ret; @@ -98,14 +97,14 @@ void ClientTransAuthCloseChannel(int32_t channelId, ShutdownReason reason) int32_t TransAuthChannelSendBytes(int32_t channelId, const void *data, uint32_t len) { - int ret = ServerIpcSendMessage(channelId, CHANNEL_TYPE_AUTH, data, len, TRANS_SESSION_BYTES); + int32_t ret = ServerIpcSendMessage(channelId, CHANNEL_TYPE_AUTH, data, len, TRANS_SESSION_BYTES); TRANS_LOGI(TRANS_BYTES, "send bytes: channelId=%{public}d, ret=%{public}d", channelId, ret); return ret; } int32_t TransAuthChannelSendMessage(int32_t channelId, const void *data, uint32_t len) { - int ret = ServerIpcSendMessage(channelId, CHANNEL_TYPE_AUTH, data, len, TRANS_SESSION_BYTES); + int32_t ret = ServerIpcSendMessage(channelId, CHANNEL_TYPE_AUTH, data, len, TRANS_SESSION_BYTES); TRANS_LOGI(TRANS_MSG, "send msg: channelId=%{public}d, ret=%{public}d", channelId, ret); return ret; } \ No newline at end of file diff --git a/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_listener.c b/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_listener.c index f0a5c64ee..2ae0cb5cb 100644 --- a/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_listener.c +++ b/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_listener.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -107,7 +107,7 @@ int32_t TransTdcCreateListener(int32_t fd) SoftBusMutexUnlock(&g_lock.lock); return ret; } - TRANS_LOGI(TRANS_SDK, "create sdk listener success."); + TRANS_LOGI(TRANS_SDK, "create sdk listener success. fd=%{public}d", fd); } SoftBusMutexUnlock(&g_lock.lock); diff --git a/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_manager.c b/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_manager.c index b023e030d..0514c263e 100644 --- a/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_manager.c +++ b/sdk/transmission/trans_channel/tcp_direct/src/client_trans_tcp_direct_manager.c @@ -249,7 +249,7 @@ int32_t ClientTransTdcOnChannelOpened(const char *sessionName, const ChannelInfo goto EXIT_ERR; } ListAdd(&g_tcpDirectChannelInfoList->list, &item->node); - TRANS_LOGI(TRANS_SDK, "add channelId=%{public}d", item->channelId); + TRANS_LOGI(TRANS_SDK, "add channelId=%{public}d, fd=%{public}d", item->channelId, channel->fd); (void)SoftBusMutexUnlock(&g_tcpDirectChannelInfoList->lock); ret = ClientTransTdcOnSessionOpened(sessionName, channel);