From d899fceeaf226e52af1cf7a5b77d8f7b492dba8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E6=B5=A9?= Date: Mon, 18 Mar 2024 10:20:33 +0800 Subject: [PATCH] fix: buscenter event info add requestId Signed-off-by: qinhao --- core/authentication/src/auth_manager.c | 16 +-- core/authentication/src/auth_session_fsm.c | 1 + .../authentication/src/auth_session_message.c | 14 ++- .../disc_mgr/src/lnn_discovery_interface.c | 24 ++-- .../heartbeat/src/lnn_heartbeat_medium_mgr.c | 19 ++++ .../lnn/net_builder/src/lnn_connection_fsm.c | 17 +++ .../lnn/net_builder/src/lnn_net_builder.c | 104 ++++++++++-------- .../event/src/convert/lnn_event_converter.h | 4 +- .../interface/include/form/lnn_event_form.h | 8 ++ .../unittest/auth_hichain_test.cpp | 3 + .../unittest/auth_manager_test.cpp | 4 +- .../src/lnn_connection_fsm_test.cpp | 1 + .../src/lnn_net_builder_mock_test.cpp | 1 + .../lnn_disctributed_net_ledger_test.cpp | 2 + .../test/heartbeat/hb_medium_mgr_test.cpp | 1 + .../unittest/mock/lnn_hisysevent_matcher.h | 4 + .../dfx/event/unittest/src/lnn_event_test.cpp | 18 +-- 17 files changed, 156 insertions(+), 85 deletions(-) diff --git a/core/authentication/src/auth_manager.c b/core/authentication/src/auth_manager.c index acf3b7736..f2846ee42 100644 --- a/core/authentication/src/auth_manager.c +++ b/core/authentication/src/auth_manager.c @@ -756,16 +756,6 @@ static int32_t RetryRegTrustDataChangeListener() return SOFTBUS_ERR; } -static void DfxRecordLnnAuthStart(const AuthConnInfo *connInfo) -{ - LnnEventExtra extra = { 0 }; - LnnEventExtraInit(&extra); - if (connInfo != NULL) { - extra.authLinkType = connInfo->type; - } - LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH, extra); -} - static int32_t StartVerifyDevice(uint32_t requestId, const AuthConnInfo *connInfo, const AuthVerifyCallback *verifyCb, const AuthConnCallback *connCb, bool isFastAuth) { @@ -1117,10 +1107,11 @@ static int32_t GetUdidShortHash(const AuthConnInfo *connInfo, char *udidBuf, uin } -static void DfxRecordLnnConnectEnd(uint64_t connId, const AuthConnInfo *connInfo, int32_t reason) +static void DfxRecordLnnConnectEnd(uint32_t requestId, uint64_t connId, const AuthConnInfo *connInfo, int32_t reason) { LnnEventExtra extra = { 0 }; LnnEventExtraInit(&extra); + extra.authRequestId = (int32_t)requestId; extra.connectionId = (int32_t)connId; extra.errcode = reason; extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED; @@ -1165,7 +1156,7 @@ static uint32_t AddConcurrentAuthRequest(const AuthConnInfo *connInfo, AuthReque static void OnConnectResult(uint32_t requestId, uint64_t connId, int32_t result, const AuthConnInfo *connInfo) { - DfxRecordLnnConnectEnd(connId, connInfo, result); + DfxRecordLnnConnectEnd(requestId, connId, connInfo, result); AUTH_LOGI(AUTH_CONN, "OnConnectResult: requestId=%{public}u, result=%{public}d", requestId, result); AuthRequest request; if (GetAuthRequest(requestId, &request) != SOFTBUS_OK) { @@ -1507,7 +1498,6 @@ uint32_t AuthGenRequestId(void) int32_t AuthStartVerify(const AuthConnInfo *connInfo, uint32_t requestId, const AuthVerifyCallback *callback, bool isFastAuth) { - DfxRecordLnnAuthStart(connInfo); if (connInfo == NULL || !CheckVerifyCallback(callback)) { AUTH_LOGE(AUTH_CONN, "invalid param"); return SOFTBUS_INVALID_PARAM; diff --git a/core/authentication/src/auth_session_fsm.c b/core/authentication/src/auth_session_fsm.c index 1469c1d27..8cecc231a 100644 --- a/core/authentication/src/auth_session_fsm.c +++ b/core/authentication/src/auth_session_fsm.c @@ -323,6 +323,7 @@ static void DfxRecordLnnAuthEnd(AuthFsm *authFsm, uint64_t costTime, int32_t rea if (authFsm != NULL) { extra.authLinkType = authFsm->info.connInfo.type; extra.authId = (int32_t)authFsm->authSeq; + extra.authRequestId = (int32_t)authFsm->info.requestId; } LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH, extra); } diff --git a/core/authentication/src/auth_session_message.c b/core/authentication/src/auth_session_message.c index b2287d6cc..a515ad05b 100644 --- a/core/authentication/src/auth_session_message.c +++ b/core/authentication/src/auth_session_message.c @@ -1850,17 +1850,20 @@ static int32_t PostDeviceIdNew(int64_t authSeq, const AuthSessionInfo *info) return SOFTBUS_OK; } -static void DfxRecordLnnPostDeviceIdStart(int64_t authSeq) +static void DfxRecordLnnPostDeviceIdStart(int64_t authSeq, const AuthSessionInfo *info) { LnnEventExtra extra = { 0 }; LnnEventExtraInit(&extra); extra.authId = (int32_t)authSeq; + if (info != NULL) { + extra.authRequestId = (int32_t)info->requestId; + } LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE_ID_POST, extra); } int32_t PostDeviceIdMessage(int64_t authSeq, const AuthSessionInfo *info) { - DfxRecordLnnPostDeviceIdStart(authSeq); + DfxRecordLnnPostDeviceIdStart(authSeq, info); AUTH_CHECK_AND_RETURN_RET_LOGE(info != NULL, SOFTBUS_INVALID_PARAM, AUTH_FSM, "info is NULL"); if (info->version == SOFTBUS_OLD_V1) { return PostDeviceIdV1(authSeq, info); @@ -1896,17 +1899,20 @@ static void GetSessionKeyList(int64_t authSeq, const AuthSessionInfo *info, Sess (void)memset_s(&sessionKey, sizeof(SessionKey), 0, sizeof(SessionKey)); } -static void DfxRecordLnnPostDeviceInfoStart(int64_t authSeq) +static void DfxRecordLnnPostDeviceInfoStart(int64_t authSeq, const AuthSessionInfo *info) { LnnEventExtra extra = { 0 }; LnnEventExtraInit(&extra); extra.authId = (int32_t)authSeq; + if (info != NULL) { + extra.authRequestId = (int32_t)info->requestId; + } LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE_INFO_POST, extra); } int32_t PostDeviceInfoMessage(int64_t authSeq, const AuthSessionInfo *info) { - DfxRecordLnnPostDeviceInfoStart(authSeq); + DfxRecordLnnPostDeviceInfoStart(authSeq, info); AUTH_CHECK_AND_RETURN_RET_LOGE(info != NULL, SOFTBUS_INVALID_PARAM, AUTH_FSM, "info is NULL"); char *msg = PackDeviceInfoMessage(info->connInfo.type, info->version, false, info->uuid); if (msg == NULL) { diff --git a/core/bus_center/lnn/disc_mgr/src/lnn_discovery_interface.c b/core/bus_center/lnn/disc_mgr/src/lnn_discovery_interface.c index 7e4778e90..493ff0e46 100644 --- a/core/bus_center/lnn/disc_mgr/src/lnn_discovery_interface.c +++ b/core/bus_center/lnn/disc_mgr/src/lnn_discovery_interface.c @@ -56,7 +56,7 @@ int32_t LnnPublishService(const char *pkgName, const PublishInfo *info, bool isI return SOFTBUS_OK; } if ((ret = DiscStartScan(MODULE_LNN, info)) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_PUBLISH, pkgName, ret); + DfxRecordLnnDiscServiceEnd(DISC_SERVER_PUBLISH, LNN_DEFAULT_PKG_NAME, ret); LNN_LOGE(LNN_BUILDER, "DiscStartScan failed\n"); return ret; } @@ -65,16 +65,17 @@ int32_t LnnPublishService(const char *pkgName, const PublishInfo *info, bool isI int32_t LnnUnPublishService(const char *pkgName, int32_t publishId, bool isInnerRequest) { + int32_t ret; if (!isInnerRequest) { - if (DiscUnPublishService(pkgName, publishId) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_ERR); + if ((ret = DiscUnPublishService(pkgName, publishId)) != SOFTBUS_OK) { + DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, ret); LNN_LOGE(LNN_BUILDER, "DiscUnPublishService failed\n"); return SOFTBUS_ERR; } return SOFTBUS_OK; } - if (DiscUnpublish(MODULE_LNN, publishId) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_ERR); + if ((ret = DiscUnpublish(MODULE_LNN, publishId)) != SOFTBUS_OK) { + DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, LNN_DEFAULT_PKG_NAME, ret); LNN_LOGE(LNN_BUILDER, "DiscUnpublish fail!\n"); return SOFTBUS_ERR; } @@ -95,12 +96,12 @@ int32_t LnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const return SOFTBUS_OK; } if ((ret = DiscSetDiscoverCallback(MODULE_LNN, &cb->innerCb)) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, ret); + DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, LNN_DEFAULT_PKG_NAME, ret); LNN_LOGE(LNN_BUILDER, "DiscSetDiscoverCallback failed\n"); return ret; } if ((ret = DiscStartAdvertise(MODULE_LNN, info)) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, ret); + DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, LNN_DEFAULT_PKG_NAME, ret); LNN_LOGE(LNN_BUILDER, "DiscStartAdvertise failed\n"); return ret; } @@ -109,16 +110,17 @@ int32_t LnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const int32_t LnnStopDiscDevice(const char *pkgName, int32_t subscribeId, bool isInnerRequest) { + int32_t ret; if (!isInnerRequest) { - if (DiscStopDiscovery(pkgName, subscribeId) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_ERR); + if ((ret = DiscStopDiscovery(pkgName, subscribeId)) != SOFTBUS_OK) { + DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, ret); LNN_LOGE(LNN_BUILDER, "DiscStopDiscovery failed\n"); return SOFTBUS_ERR; } return SOFTBUS_OK; } - if (DiscStopAdvertise(MODULE_LNN, subscribeId) != SOFTBUS_OK) { - DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_ERR); + if ((ret = DiscStopAdvertise(MODULE_LNN, subscribeId)) != SOFTBUS_OK) { + DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, LNN_DEFAULT_PKG_NAME, ret); LNN_LOGE(LNN_BUILDER, "DiscStopAdvertise fail!\n"); return SOFTBUS_ERR; } diff --git a/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_medium_mgr.c b/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_medium_mgr.c index 4f5252821..de3154ed5 100644 --- a/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_medium_mgr.c +++ b/core/bus_center/lnn/lane_hub/heartbeat/src/lnn_heartbeat_medium_mgr.c @@ -30,6 +30,7 @@ #include "lnn_device_info.h" #include "lnn_device_info_recovery.h" #include "lnn_distributed_net_ledger.h" +#include "lnn_event.h" #include "lnn_feature_capability.h" #include "lnn_heartbeat_strategy.h" #include "lnn_heartbeat_utils.h" @@ -427,6 +428,23 @@ static int32_t SoftBusNetNodeResult(DeviceInfo *device, bool isConnect) } } +static void DfxRecordHeartBeatAuthStart(const AuthConnInfo *connInfo, const char *packageName, uint32_t requestId) +{ + LnnEventExtra extra = { 0 }; + LnnEventExtraInit(&extra); + extra.authRequestId = (int32_t)requestId; + + if (connInfo != NULL) { + extra.authLinkType = connInfo->type; + } + char pkgName[PKG_NAME_SIZE_MAX] = { 0 }; + if (packageName != NULL && IsValidString(packageName, PKG_NAME_SIZE_MAX - 1) && strncpy_s(pkgName, + PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) { + extra.callerPkg = pkgName; + } + LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH, extra); +} + static int32_t HbNotifyReceiveDevice(DeviceInfo *device, int32_t weight, int32_t masterWeight, LnnHeartbeatType hbType, bool isOnlineDirectly, HbRespData *hbResp) { @@ -469,6 +487,7 @@ static int32_t HbNotifyReceiveDevice(DeviceInfo *device, int32_t weight, AuthConnInfo authConn; uint32_t requestId = AuthGenRequestId(); (void)LnnConvertAddrToAuthConnInfo(device->addr, &authConn); + DfxRecordHeartBeatAuthStart(&authConn, LNN_DEFAULT_PKG_NAME, requestId); if (AuthStartVerify(&authConn, requestId, LnnGetReAuthVerifyCallback(), false) != SOFTBUS_OK) { LNN_LOGI(LNN_HEART_BEAT, "AuthStartVerify error"); (void)SoftBusMutexUnlock(&g_hbRecvList->lock); diff --git a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c index db0bab3ad..f9f3e534e 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c +++ b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c @@ -30,6 +30,7 @@ #include "lnn_device_info.h" #include "lnn_device_info_recovery.h" #include "lnn_distributed_net_ledger.h" +#include "lnn_event.h" #include "lnn_heartbeat_ctrl.h" #include "lnn_heartbeat_utils.h" #include "lnn_link_finder.h" @@ -594,6 +595,21 @@ static int32_t LnnRecoveryBroadcastKey() return SOFTBUS_OK; } +static void DfxRecordConnAuthStart(const AuthConnInfo *connInfo, LnnConnectionFsm *connFsm, uint32_t requestId) +{ + LnnEventExtra extra = { 0 }; + LnnEventExtraInit(&extra); + extra.authRequestId = (int32_t)requestId; + + if (connInfo != NULL) { + extra.authLinkType = connInfo->type; + } + if (connFsm != NULL && IsValidString(connFsm->pkgName, PKG_NAME_SIZE_MAX - 1)) { + extra.callerPkg = connFsm->pkgName; + } + LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH, extra); +} + static int32_t OnJoinLNN(LnnConnectionFsm *connFsm) { int32_t rc; @@ -633,6 +649,7 @@ static int32_t OnJoinLNN(LnnConnectionFsm *connFsm) } } } + DfxRecordConnAuthStart(&authConn, connFsm, connInfo->requestId); if (AuthStartVerify(&authConn, connInfo->requestId, LnnGetVerifyCallback(), true) != SOFTBUS_OK) { LNN_LOGE(LNN_BUILDER, "auth verify device failed. [id=%{public}u]", connFsm->id); CompleteJoinLNN(connFsm, NULL, SOFTBUS_ERR); diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c index e95c68912..95e75eefa 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c @@ -567,6 +567,62 @@ static bool IsNeedWifiReauth(const char *networkId, const char *newAccountHash, return memcmp(info.accountHash, newAccountHash, HB_SHORT_ACCOUNT_HASH_LEN) != 0; } +static void BuildLnnEvent(LnnEventExtra *lnnEventExtra, const ConnectionAddr *addr) +{ + if (lnnEventExtra == NULL || addr == NULL) { + LNN_LOGW(LNN_STATE, "lnnEventExtra or addr is null"); + return; + } + switch (addr->type) { + case CONNECTION_ADDR_BR: + lnnEventExtra->peerBrMac = addr->info.br.brMac; + break; + case CONNECTION_ADDR_BLE: + lnnEventExtra->peerBleMac = addr->info.ble.bleMac; + break; + case CONNECTION_ADDR_WLAN: + /* fall-through */ + case CONNECTION_ADDR_ETH: + lnnEventExtra->peerIp = addr->info.ip.ip; + break; + default: + LNN_LOGE(LNN_BUILDER, "unknown param type!"); + break; + } +} + +static void DfxRecordLnnServerjoinStart(const ConnectionAddr *addr, const char *packageName, bool needReportFailure) +{ + LnnEventExtra extra = { 0 }; + LnnEventExtraInit(&extra); + extra.lnnType = needReportFailure ? LNN_TYPE_MANUAL : LNN_TYPE_AUTOMATIC; + + char pkgName[PKG_NAME_SIZE_MAX] = { 0 }; + if (packageName != NULL && IsValidString(packageName, PKG_NAME_SIZE_MAX - 1) && strncpy_s(pkgName, + PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) { + extra.callerPkg = pkgName; + } + if (addr != NULL) { + BuildLnnEvent(&extra, addr); + } + LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, extra); +} + +static void DfxRecordLnnAuthStart(const AuthConnInfo *connInfo, const JoinLnnMsgPara *para, uint32_t requestId) +{ + LnnEventExtra extra = { 0 }; + LnnEventExtraInit(&extra); + extra.authRequestId = (int32_t)requestId; + + if (connInfo != NULL) { + extra.authLinkType = connInfo->type; + } + if (para != NULL && IsValidString(para->pkgName, PKG_NAME_SIZE_MAX - 1)) { + extra.callerPkg = para->pkgName; + } + LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH, extra); +} + static int32_t TrySendJoinLNNRequest(const JoinLnnMsgPara *para, bool needReportFailure, bool isShort) { LnnConnectionFsm *connFsm = NULL; @@ -578,6 +634,7 @@ static int32_t TrySendJoinLNNRequest(const JoinLnnMsgPara *para, bool needReport if (!para->isNeedConnect) { isShort = true; } + DfxRecordLnnServerjoinStart(¶->addr, para->pkgName, needReportFailure); connFsm = FindConnectionFsmByAddr(¶->addr, isShort); if (connFsm == NULL || connFsm->isDead) { if (TryPendingJoinRequest(para, needReportFailure)) { @@ -608,6 +665,7 @@ static int32_t TrySendJoinLNNRequest(const JoinLnnMsgPara *para, bool needReport AuthConnInfo authConn; uint32_t requestId = AuthGenRequestId(); (void)LnnConvertAddrToAuthConnInfo(&addr, &authConn); + DfxRecordLnnAuthStart(&authConn, para, requestId); if (AuthStartVerify(&authConn, requestId, LnnGetReAuthVerifyCallback(), false) != SOFTBUS_OK) { LNN_LOGI(LNN_BUILDER, "AuthStartVerify error"); return SOFTBUS_ERR; @@ -1895,48 +1953,6 @@ static JoinLnnMsgPara *CreateJoinLnnMsgPara(const ConnectionAddr *addr, const ch return para; } -static void BuildLnnEvent(LnnEventExtra *lnnEventExtra, ConnectionAddr *addr) -{ - if (lnnEventExtra == NULL || addr == NULL) { - LNN_LOGW(LNN_STATE, "lnnEventExtra or addr is null"); - return; - } - switch (addr->type) { - case CONNECTION_ADDR_BR: - lnnEventExtra->peerBrMac = addr->info.br.brMac; - break; - case CONNECTION_ADDR_BLE: - lnnEventExtra->peerBleMac = addr->info.ble.bleMac; - break; - case CONNECTION_ADDR_WLAN: - /* fall-through */ - case CONNECTION_ADDR_ETH: - lnnEventExtra->peerIp = addr->info.ip.ip; - break; - default: - LNN_LOGE(LNN_BUILDER, "unknown param type!"); - break; - } -} - -static void DfxRecordLnnServerjoinEnd(ConnectionAddr *addr, const char *packageName, int32_t reason) -{ - LnnEventExtra extra = { 0 }; - LnnEventExtraInit(&extra); - extra.errcode = reason; - extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED; - - char pkgName[PKG_NAME_SIZE_MAX] = { 0 }; - if (packageName != NULL && IsValidString(packageName, PKG_NAME_SIZE_MAX - 1) && strncpy_s(pkgName, - PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) { - extra.callerPkg = pkgName; - } - if (addr != NULL) { - BuildLnnEvent(&extra, addr); - } - LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, extra); -} - static char *CreateNetworkIdMsgPara(const char *networkId) { char *para = NULL; @@ -2325,23 +2341,19 @@ int32_t LnnServerJoin(ConnectionAddr *addr, const char *pkgName) LNN_LOGI(LNN_BUILDER, "enter!"); if (g_netBuilder.isInit == false) { - DfxRecordLnnServerjoinEnd(addr, pkgName, SOFTBUS_NO_INIT); LNN_LOGE(LNN_BUILDER, "no init"); return SOFTBUS_NO_INIT; } para = CreateJoinLnnMsgPara(addr, pkgName, true); if (para == NULL) { - DfxRecordLnnServerjoinEnd(addr, pkgName, SOFTBUS_MALLOC_ERR); LNN_LOGE(LNN_BUILDER, "prepare join lnn message fail"); return SOFTBUS_MALLOC_ERR; } if (PostMessageToHandler(MSG_TYPE_JOIN_LNN, para) != SOFTBUS_OK) { - DfxRecordLnnServerjoinEnd(addr, pkgName, SOFTBUS_NETWORK_LOOPER_ERR); LNN_LOGE(LNN_BUILDER, "post join lnn message fail"); SoftBusFree(para); return SOFTBUS_NETWORK_LOOPER_ERR; } - DfxRecordLnnServerjoinEnd(addr, pkgName, SOFTBUS_OK); return SOFTBUS_OK; } diff --git a/core/common/dfx/event/src/convert/lnn_event_converter.h b/core/common/dfx/event/src/convert/lnn_event_converter.h index 792dd5137..2829cff01 100644 --- a/core/common/dfx/event/src/convert/lnn_event_converter.h +++ b/core/common/dfx/event/src/convert/lnn_event_converter.h @@ -42,6 +42,7 @@ LNN_ASSIGNER(Int32, GearCycle, gearCycle) LNN_ASSIGNER(Int32, GearDuration, gearDuration) LNN_ASSIGNER(Int32, ConnectionId, connectionId) LNN_ASSIGNER(Int32, AuthLinkType, authLinkType) +LNN_ASSIGNER(Int32, AuthRequestId, authRequestId) LNN_ASSIGNER(Int32, AuthCostTime, authCostTime) LNN_ASSIGNER(Int32, LnnType, lnnType) LNN_ASSIGNER(Int32, OnlineNum, onlineNum) @@ -58,7 +59,7 @@ LNN_ASSIGNER(String, PeerDeviceType, peerDeviceType) LNN_ASSIGNER(String, CallerPkg, callerPkg) LNN_ASSIGNER(String, CalleePkg, calleePkg) -#define LNN_ASSIGNER_SIZE 23 // Size of g_connAssigners +#define LNN_ASSIGNER_SIZE 24 // Size of g_connAssigners static const HiSysEventParamAssigner g_lnnAssigners[] = { { "STAGE_RES", HISYSEVENT_INT32, LnnAssignerResult }, { "ERROR_CODE", HISYSEVENT_INT32, LnnAssignerErrcode }, @@ -68,6 +69,7 @@ static const HiSysEventParamAssigner g_lnnAssigners[] = { { "GEAR_DURATION", HISYSEVENT_INT32, LnnAssignerGearDuration }, { "CONN_ID", HISYSEVENT_INT32, LnnAssignerConnectionId }, { "AUTH_LINK_TYPE", HISYSEVENT_INT32, LnnAssignerAuthLinkType }, + { "AUTH_REQUEST_ID", HISYSEVENT_INT32, LnnAssignerAuthRequestId }, { "AUTH_COST_TIME", HISYSEVENT_INT32, LnnAssignerAuthCostTime }, { "LNN_TYPE", HISYSEVENT_INT32, LnnAssignerLnnType }, { "ONLINE_NUM", HISYSEVENT_INT32, LnnAssignerOnlineNum }, diff --git a/core/common/dfx/interface/include/form/lnn_event_form.h b/core/common/dfx/interface/include/form/lnn_event_form.h index b2ab164c2..8046c8cd8 100644 --- a/core/common/dfx/interface/include/form/lnn_event_form.h +++ b/core/common/dfx/interface/include/form/lnn_event_form.h @@ -26,6 +26,8 @@ extern "C" { #endif +#define LNN_DEFAULT_PKG_NAME "MODULE_LNN" + typedef enum { EVENT_SCENE_LNN = 1, EVENT_SCENE_JOIN_LNN = 2, @@ -66,6 +68,11 @@ typedef enum { DISC_SERVER_STOP_DISCOVERY = 4, } LnnDiscServerType; +typedef enum { + LNN_TYPE_AUTOMATIC = 1, + LNN_TYPE_MANUAL = 2, +} LnnType; + typedef struct { int32_t result; // STAGE_RES int32_t errcode; // ERROR_CODE @@ -75,6 +82,7 @@ typedef struct { int32_t gearDuration; // GEAR_DURATION int32_t connectionId; // CONN_ID int32_t authLinkType; // AUTH_LINK_TYPE + int32_t authRequestId; // AUTH_REQUEST_ID int32_t authCostTime; // AUTH_COST_TIME int32_t lnnType; // LNN_TYPE int32_t onlineNum; // ONLINE_NUM diff --git a/tests/core/authentication/unittest/auth_hichain_test.cpp b/tests/core/authentication/unittest/auth_hichain_test.cpp index 2026b2d11..3c9edf2e5 100644 --- a/tests/core/authentication/unittest/auth_hichain_test.cpp +++ b/tests/core/authentication/unittest/auth_hichain_test.cpp @@ -134,6 +134,9 @@ HWTEST_F(AuthHichainTest, ON_REQUEST_TEST_001, TestSize.Level1) const char *groupInfo; OnDeviceBound(NULL, groupInfo); OnDeviceBound(udid, groupInfo); + + DfxRecordLnnExchangekeyEnd(authSeq, SOFTBUS_OK); + DfxRecordLnnEndHichainEnd(authSeq, SOFTBUS_OK); } /* diff --git a/tests/core/authentication/unittest/auth_manager_test.cpp b/tests/core/authentication/unittest/auth_manager_test.cpp index 767268b00..140c95101 100644 --- a/tests/core/authentication/unittest/auth_manager_test.cpp +++ b/tests/core/authentication/unittest/auth_manager_test.cpp @@ -399,11 +399,11 @@ HWTEST_F(AuthManagerTest, HANDLE_RECONNECT_RESULT_TEST_001, TestSize.Level1) EXPECT_TRUE(AddAuthRequest(&request) == SOFTBUS_OK); HandleBleConnectResult(REQUEST_ID_1, AUTH_SEQ, CONN_ID, SOFTBUS_OK, 0); HandleBleConnectResult(REQUEST_ID, AUTH_SEQ, CONN_ID, SOFTBUS_OK, 0); - DfxRecordLnnConnectEnd(CONN_ID_1, nullptr, SOFTBUS_OK); + DfxRecordLnnConnectEnd(REQUEST_ID_1, CONN_ID_1, nullptr, SOFTBUS_OK); AuthConnInfo connInfo; (void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); connInfo.type = AUTH_LINK_TYPE_WIFI; - DfxRecordLnnConnectEnd(CONN_ID_1, &connInfo, SOFTBUS_OK); + DfxRecordLnnConnectEnd(REQUEST_ID_1, CONN_ID_1, &connInfo, SOFTBUS_OK); OnConnectResult(REQUEST_ID_1, CONN_ID_1, SOFTBUS_OK, &connInfo); OnConnectResult(REQUEST_ID, CONN_ID_1, SOFTBUS_OK, &connInfo); connInfo.type = AUTH_LINK_TYPE_BLE; diff --git a/tests/core/bus_center/lnn/net_builder/src/lnn_connection_fsm_test.cpp b/tests/core/bus_center/lnn/net_builder/src/lnn_connection_fsm_test.cpp index 52c52829a..45e03e27a 100644 --- a/tests/core/bus_center/lnn/net_builder/src/lnn_connection_fsm_test.cpp +++ b/tests/core/bus_center/lnn/net_builder/src/lnn_connection_fsm_test.cpp @@ -116,6 +116,7 @@ HWTEST_F(LNNConnectionFsmTest, LNN_CREATE_CONNECTION_FSM_TEST_001, TestSize.Leve LnnConnectionFsm *fsm = LnnCreateConnectionFsm(target1, "pkgName", true); EXPECT_TRUE(fsm == nullptr); LnnDestroyConnectionFsm(fsm); + DfxRecordConnAuthStart(nullptr, fsm, 0); } /* diff --git a/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock_test.cpp b/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock_test.cpp index 1eed13f54..4f404542e 100644 --- a/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock_test.cpp +++ b/tests/core/bus_center/lnn/net_builder/src/lnn_net_builder_mock_test.cpp @@ -1359,6 +1359,7 @@ HWTEST_F(LNNNetBuilderMockTest, TRY_SEND_JOIN_LNN_REQUEST_TEST_001, TestSize.Lev EXPECT_TRUE(TrySendJoinLNNRequest(nullptr, true, false) == SOFTBUS_INVALID_PARAM); EXPECT_TRUE(TrySendJoinLNNRequest(para, true, false) == SOFTBUS_ERR); + DfxRecordLnnAuthStart(nullptr, para, 0); ListDelete(&connFsm->node); SoftBusFree(connFsm); } diff --git a/tests/core/bus_center/lnn/net_ledger/lnn_disctributed_net_ledger_test.cpp b/tests/core/bus_center/lnn/net_ledger/lnn_disctributed_net_ledger_test.cpp index f67aacc4e..d98f0c1d3 100644 --- a/tests/core/bus_center/lnn/net_ledger/lnn_disctributed_net_ledger_test.cpp +++ b/tests/core/bus_center/lnn/net_ledger/lnn_disctributed_net_ledger_test.cpp @@ -121,6 +121,7 @@ HWTEST_F(LNNDisctributedLedgerTest, LNN_ADD_ONLINE_NODE_Test_001, TestSize.Level (void)strncpy_s(info.networkId, NETWORK_ID_BUF_LEN, NODE1_NETWORK_ID, strlen(NODE1_NETWORK_ID)); (void)strncpy_s(info.connectInfo.macAddr, MAC_LEN, NODE1_BT_MAC, strlen(NODE1_BT_MAC)); EXPECT_TRUE(REPORT_NONE == LnnAddOnlineNode(&info)); + DfxRecordLnnAddOnlineNodeEnd(&info, 1, SOFTBUS_OK); } /* @@ -283,6 +284,7 @@ HWTEST_F(LNNDisctributedLedgerTest, LNN_SET_NODE_OFFLINE_Test_001, TestSize.Leve { EXPECT_TRUE(REPORT_NONE == LnnSetNodeOffline(NODE1_UDID, CONNECTION_ADDR_WLAN, AUTH_ID)); EXPECT_TRUE(REPORT_NONE == LnnSetNodeOffline(NODE2_UDID, CONNECTION_ADDR_WLAN, AUTH_ID)); + DfxRecordLnnSetNodeOfflineEnd(NODE1_UDID, 1, SOFTBUS_OK); } /* diff --git a/tests/core/bus_center/test/heartbeat/hb_medium_mgr_test.cpp b/tests/core/bus_center/test/heartbeat/hb_medium_mgr_test.cpp index 6e6eee0d3..0bbe98316 100644 --- a/tests/core/bus_center/test/heartbeat/hb_medium_mgr_test.cpp +++ b/tests/core/bus_center/test/heartbeat/hb_medium_mgr_test.cpp @@ -314,6 +314,7 @@ HWTEST_F(HeartBeatMediumTest, HbMediumMgrRecvProcessTest_01, TestSize.Level1) (void)memset_s(&device, sizeof(DeviceInfo), 0, sizeof(DeviceInfo)); ret = HbMediumMgrRecvProcess(&device, weight, masterWeight, HEARTBEAT_TYPE_BLE_V1, false, &hbResp); EXPECT_TRUE(ret == SOFTBUS_NETWORK_HEARTBEAT_UNTRUSTED); + DfxRecordHeartBeatAuthStart(nullptr, "pkgName", 0); } /* diff --git a/tests/core/common/dfx/event/unittest/mock/lnn_hisysevent_matcher.h b/tests/core/common/dfx/event/unittest/mock/lnn_hisysevent_matcher.h index c13b8c378..46015f99d 100644 --- a/tests/core/common/dfx/event/unittest/mock/lnn_hisysevent_matcher.h +++ b/tests/core/common/dfx/event/unittest/mock/lnn_hisysevent_matcher.h @@ -63,6 +63,10 @@ MATCHER_P2(LnnValidParamArrayMatcher, inExtra, validSize, "lnn valid param array ++index; EXPECT_STREQ(params[index].name, g_lnnAssigners[index].name); EXPECT_EQ(params[index].t, g_lnnAssigners[index].type); + EXPECT_EQ(params[index].v.i32, extra.authRequestId); + ++index; + EXPECT_STREQ(params[index].name, g_lnnAssigners[index].name); + EXPECT_EQ(params[index].t, g_lnnAssigners[index].type); EXPECT_EQ(params[index].v.i32, extra.authCostTime); ++index; EXPECT_STREQ(params[index].name, g_lnnAssigners[index].name); diff --git a/tests/core/common/dfx/event/unittest/src/lnn_event_test.cpp b/tests/core/common/dfx/event/unittest/src/lnn_event_test.cpp index d08f8bf55..9135cf68a 100644 --- a/tests/core/common/dfx/event/unittest/src/lnn_event_test.cpp +++ b/tests/core/common/dfx/event/unittest/src/lnn_event_test.cpp @@ -68,10 +68,11 @@ HWTEST_F(LnnEventTest, LnnEventTest002, TestSize.Level0) .gearDuration = 6, .connectionId = 7, .authLinkType = 8, - .authCostTime = 9, - .lnnType = 10, - .onlineNum = 11, - .peerDeviceAbility = 12, + .authRequestId = 9, + .authCostTime = 10, + .lnnType = 11, + .onlineNum = 12, + .peerDeviceAbility = 13, .peerDeviceInfo = "testPeerDeviceInfo", .peerIp = "10.11.12.1", .peerBrMac = "dd:15:bc:b9:f2:04", @@ -111,10 +112,11 @@ HWTEST_F(LnnEventTest, LnnEventTest003, TestSize.Level0) .gearDuration = -6, .connectionId = -7, .authLinkType = -8, - .authCostTime = -9, - .lnnType = -10, - .onlineNum = -11, - .peerDeviceAbility = -12, + .authRequestId = -9, + .authCostTime = -10, + .lnnType = -11, + .onlineNum = -12, + .peerDeviceAbility = -13, .peerDeviceInfo = "", .peerIp = "", .peerBrMac = "",