!4940 fix: disc and lnn event refinement report

Merge pull request !4940 from 秦浩/master
This commit is contained in:
openharmony_ci 2024-01-06 07:16:04 +00:00 committed by Gitee
commit c7ee055691
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
29 changed files with 998 additions and 280 deletions

View File

@ -317,13 +317,8 @@ static void HandleConnConnectCmd(const void *para)
AUTH_LOGE(AUTH_CONN, "invalid connType=%d", info->connInfo.type);
return;
}
LnnEventExtra lnnEventExtra = {0};
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
int32_t fd = SocketConnectDevice(info->connInfo.info.ipInfo.ip, info->connInfo.info.ipInfo.port, false);
if (fd < 0) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_AUTH_CONN_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
AUTH_LOGE(AUTH_CONN, "SocketConnectDevice fail");
RemoveConnConnectTimeout(info->requestId);
NotifyClientConnected(info->requestId, 0, SOFTBUS_AUTH_CONN_FAIL, NULL);
@ -346,8 +341,6 @@ static void HandleConnConnectResult(const void *para)
uint64_t connId = GenConnId(AUTH_LINK_TYPE_WIFI, fd);
RemoveConnConnectTimeout(item->requestId);
NotifyClientConnected(item->requestId, connId, SOFTBUS_OK, &item->connInfo);
LnnEventExtra lnnEventExtra = { .connectionId = connId, .result = EVENT_STAGE_RESULT_OK };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
DelConnRequest(item);
}
@ -524,8 +517,6 @@ static void OnCommConnectSucc(uint32_t requestId, uint32_t connectionId, const C
RemoveConnConnectTimeout(requestId);
uint64_t connId = GenConnId(connInfo.type, connectionId);
NotifyClientConnected(requestId, connId, SOFTBUS_OK, &connInfo);
LnnEventExtra lnnEventExtra = { .connectionId = (int32_t)connId, .result = EVENT_STAGE_RESULT_OK };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
}
static void OnCommConnectFail(uint32_t requestId, int32_t reason)
@ -533,8 +524,6 @@ static void OnCommConnectFail(uint32_t requestId, int32_t reason)
AUTH_LOGI(AUTH_CONN, "requestId=%u, reason=%d", requestId, reason);
RemoveConnConnectTimeout(requestId);
NotifyClientConnected(requestId, 0, SOFTBUS_CONN_FAIL, NULL);
LnnEventExtra lnnEventExtra = { .errcode = reason, .result = EVENT_STAGE_RESULT_FAILED };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
}
static int32_t ConnectCommDevice(const AuthConnInfo *info, uint32_t requestId, ConnSideType sideType)
@ -553,19 +542,24 @@ static int32_t ConnectCommDevice(const AuthConnInfo *info, uint32_t requestId, C
.OnConnectSuccessed = OnCommConnectSucc,
.OnConnectFailed = OnCommConnectFail,
};
LnnEventExtra lnnEventExtra = {0};
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
ret = ConnConnectDevice(&option, requestId, &result);
if (ret != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = ret;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, lnnEventExtra);
AUTH_LOGE(AUTH_CONN, "ConnConnectDevice fail=%d", ret);
return ret;
}
return SOFTBUS_OK;
}
static void DfxRecordLnnConnectStart(const AuthConnInfo *connInfo)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
if (connInfo != NULL) {
extra.lnnType = connInfo->type;
}
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, extra);
}
static int32_t PostCommData(uint32_t connectionId, bool toServer, const AuthDataHead *head, const uint8_t *data)
{
uint32_t size = ConnGetHeadSize() + GetAuthDataSize(head->len);
@ -621,6 +615,7 @@ void AuthConnDeinit(void)
int32_t ConnectAuthDevice(uint32_t requestId, const AuthConnInfo *connInfo, ConnSideType sideType)
{
DfxRecordLnnConnectStart(connInfo);
CHECK_NULL_PTR_RETURN_VALUE(connInfo, SOFTBUS_INVALID_PARAM);
AUTH_LOGI(AUTH_CONN, "requestId=%u, connType=%d, sideType=%d", requestId,
connInfo->type, sideType);

View File

@ -24,6 +24,7 @@
#include "auth_session_fsm.h"
#include "bus_center_manager.h"
#include "device_auth.h"
#include "lnn_event.h"
#include "softbus_adapter_mem.h"
#include "softbus_def.h"
#include "softbus_json_utils.h"
@ -85,20 +86,43 @@ static bool OnTransmit(int64_t authSeq, const uint8_t *data, uint32_t len)
return true;
}
static void DfxRecordLnnExchangekeyEnd(int64_t authSeq, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.authId = (int32_t)authSeq;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_EXCHANGE_CIPHER, extra);
}
static void OnSessionKeyReturned(int64_t authSeq, const uint8_t *sessionKey, uint32_t sessionKeyLen)
{
AUTH_LOGI(AUTH_HICHAIN, "hichain OnSessionKeyReturned: authSeq=%" PRId64 ", len=%u", authSeq, sessionKeyLen);
if (sessionKey == NULL || sessionKeyLen > SESSION_KEY_LENGTH) {
DfxRecordLnnExchangekeyEnd(authSeq, SOFTBUS_AUTH_GET_SESSION_KEY_FAIL);
AUTH_LOGW(AUTH_HICHAIN, "invalid sessionKey");
return;
}
DfxRecordLnnExchangekeyEnd(authSeq, SOFTBUS_OK);
(void)AuthSessionSaveSessionKey(authSeq, sessionKey, sessionKeyLen);
}
static void DfxRecordLnnAuthEnd(int64_t authSeq, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.authId = (int32_t)authSeq;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH, extra);
}
static void OnFinish(int64_t authSeq, int operationCode, const char *returnData)
{
(void)operationCode;
(void)returnData;
DfxRecordLnnAuthEnd(authSeq, SOFTBUS_OK);
AUTH_LOGI(AUTH_HICHAIN, "hichain OnFinish: authSeq=%" PRId64, authSeq);
(void)AuthSessionHandleAuthFinish(authSeq);
}
@ -107,6 +131,7 @@ static void OnError(int64_t authSeq, int operationCode, int errCode, const char
{
(void)operationCode;
(void)errorReturn;
DfxRecordLnnAuthEnd(authSeq, errCode);
AUTH_LOGE(AUTH_HICHAIN, "hichain OnError: authSeq=%" PRId64 ", errCode=%d", authSeq, errCode);
(void)AuthSessionHandleAuthError(authSeq, SOFTBUS_AUTH_HICHAIN_AUTH_ERROR);
}
@ -237,6 +262,16 @@ static void OnDeviceNotTrusted(const char *udid)
}
}
static void DfxRecordLnnStartHichainEnd(int64_t authSeq, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.authId = (int32_t)authSeq;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_HICHAIN, extra);
}
int32_t RegTrustDataChangeListener(const TrustDataChangeListener *listener)
{
if (listener == NULL) {
@ -269,19 +304,23 @@ void UnregTrustDataChangeListener(void)
int32_t HichainStartAuth(int64_t authSeq, const char *udid, const char *uid)
{
if (udid == NULL || uid == NULL) {
DfxRecordLnnStartHichainEnd(authSeq, SOFTBUS_INVALID_PARAM);
AUTH_LOGE(AUTH_HICHAIN, "udid/uid is invalid");
return SOFTBUS_INVALID_PARAM;
}
char *authParams = GenDeviceLevelParam(udid, uid, true);
if (authParams == NULL) {
DfxRecordLnnStartHichainEnd(authSeq, SOFTBUS_ERR);
AUTH_LOGE(AUTH_HICHAIN, "generate auth param fail");
return SOFTBUS_ERR;
}
if (AuthDevice(authSeq, authParams, &g_hichainCallback) == SOFTBUS_OK) {
DfxRecordLnnStartHichainEnd(authSeq, SOFTBUS_OK);
AUTH_LOGI(AUTH_HICHAIN, "hichain call authDevice succ");
cJSON_free(authParams);
return SOFTBUS_OK;
}
DfxRecordLnnStartHichainEnd(authSeq, SOFTBUS_AUTH_START_ERR);
AUTH_LOGE(AUTH_HICHAIN, "hichain call authDevice failed");
cJSON_free(authParams);
return SOFTBUS_AUTH_START_ERR;

View File

@ -30,6 +30,7 @@
#include "lnn_async_callback_utils.h"
#include "lnn_app_bind_interface.h"
#include "lnn_decision_db.h"
#include "lnn_event.h"
#include "lnn_feature_capability.h"
#include "lnn_heartbeat_ctrl.h"
#include "lnn_net_builder.h"
@ -702,6 +703,16 @@ static int32_t RetryRegTrustDataChangeListener()
return SOFTBUS_ERR;
}
static void DfxRecordLnnAuthStart(const AuthConnInfo *connInfo)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
if (connInfo != NULL) {
extra.lnnType = 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)
{
@ -1002,8 +1013,23 @@ static void HandleBleConnectResult(uint32_t requestId, int64_t authId, uint64_t
} while (FindAuthRequestByConnInfo(&request.connInfo, &request) == SOFTBUS_OK);
}
static void DfxRecordLnnConnectEnd(uint64_t connId, const AuthConnInfo *connInfo, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.connectionId = (int32_t)connId;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (connInfo != NULL) {
extra.lnnType = connInfo->type;
}
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_CONNECTION, extra);
}
static void OnConnectResult(uint32_t requestId, uint64_t connId, int32_t result, const AuthConnInfo *connInfo)
{
DfxRecordLnnConnectEnd(connId, connInfo, result);
AUTH_LOGI(AUTH_CONN, "OnConnectResult: requestId=%u, result=%d", requestId, result);
AuthRequest request;
if (GetAuthRequest(requestId, &request) != SOFTBUS_OK) {
@ -1270,6 +1296,7 @@ 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;

View File

@ -624,13 +624,8 @@ static void HandleMsgRecvDeviceId(AuthFsm *authFsm, const MessagePara *para)
Anonymize(info->udid, &anonyUdid);
AUTH_LOGI(AUTH_FSM, "start auth send udid=%s", anonyUdid);
AnonymizeFree(anonyUdid);
LnnEventExtra lnnEventExtra = { .authId = authFsm->authSeq };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE, lnnEventExtra);
if (HichainStartAuth(authFsm->authSeq, info->udid, info->connInfo.peerUid) != SOFTBUS_OK) {
ret = SOFTBUS_AUTH_HICHAIN_AUTH_FAIL;
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_AUTH_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE, lnnEventExtra);
break;
}
}
@ -669,13 +664,8 @@ static bool SyncDevIdStateProcess(FsmStateMachine *fsm, int32_t msgType, void *p
static void HandleMsgRecvAuthData(AuthFsm *authFsm, const MessagePara *para)
{
LnnEventExtra lnnEventExtra = {0};
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_CIPHER, lnnEventExtra);
int32_t ret = HichainProcessData(authFsm->authSeq, para->data, para->len);
if (ret != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = ret;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_CIPHER, lnnEventExtra);
LnnAuditExtra lnnAuditExtra = {0};
BuildLnnAuditEvent(&lnnAuditExtra, &authFsm->info, AUDIT_HANDLE_MSG_FAIL_END_AUTH,
ret, AUDIT_EVENT_PACKETS_ERROR);
@ -711,8 +701,6 @@ static int32_t TrySyncDeviceInfo(int64_t authSeq, const AuthSessionInfo *info)
static void HandleMsgSaveSessionKey(AuthFsm *authFsm, const MessagePara *para)
{
LnnEventExtra lnnEventExtra = { .result = EVENT_STAGE_RESULT_OK };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_CIPHER, lnnEventExtra);
SessionKey sessionKey = {.len = para->len};
if (memcpy_s(sessionKey.value, sizeof(sessionKey.value), para->data, para->len) != EOK) {
AUTH_LOGE(AUTH_FSM, "copy session key fail.");
@ -778,8 +766,6 @@ static void HandleMsgAuthFinish(AuthFsm *authFsm, MessagePara *para)
{
(void)para;
AuthSessionInfo *info = &authFsm->info;
LnnEventExtra lnnEventExtra = { .authId = (int32_t)authFsm->authSeq, .result = EVENT_STAGE_RESULT_OK };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE, lnnEventExtra);
AUTH_LOGI(AUTH_FSM, "auth fsm[%" PRId64"] hichain finished, devInfo|closeAck=%d|%d",
authFsm->authSeq, info->isNodeInfoReceived, info->isCloseAckReceived);
info->isAuthFinished = true;
@ -826,12 +812,8 @@ static bool DeviceAuthStateProcess(FsmStateMachine *fsm, int32_t msgType, void *
static void HandleMsgRecvDeviceInfo(AuthFsm *authFsm, const MessagePara *para)
{
LnnEventExtra lnnEventExtra = { .result = EVENT_STAGE_RESULT_OK };
AuthSessionInfo *info = &authFsm->info;
if (ProcessDeviceInfoMessage(authFsm->authSeq, info, para->data, para->len) != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_AUTH_UNPACK_DEVINFO_FAIL;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_DEVICE_INFO, lnnEventExtra);
LnnAuditExtra lnnAuditExtra = {0};
BuildLnnAuditEvent(&lnnAuditExtra, info, AUDIT_HANDLE_MSG_FAIL_END_AUTH,
SOFTBUS_AUTH_UNPACK_DEVINFO_FAIL, AUDIT_EVENT_PACKETS_ERROR);
@ -842,8 +824,6 @@ static void HandleMsgRecvDeviceInfo(AuthFsm *authFsm, const MessagePara *para)
}
info->isNodeInfoReceived = true;
lnnEventExtra.peerDeviceAbility = info->nodeInfo.netCapacity;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_DEVICE_INFO, lnnEventExtra);
if (info->connInfo.type == AUTH_LINK_TYPE_WIFI) {
info->isCloseAckReceived = true; /* WiFi auth no need close ack, set true directly */
if (!info->isServer) {

View File

@ -1548,8 +1548,24 @@ static int32_t PostDeviceIdNew(int64_t authSeq, const AuthSessionInfo *info)
return SOFTBUS_OK;
}
static void DfxRecordLnnPostDeviceIdStart(int64_t authSeq)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.authId = (int32_t)authSeq;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE_ID_POST, extra);
}
static void DfxRecordLnnProcessDeviceIdStart(void)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE_ID_PROCESS, extra);
}
int32_t PostDeviceIdMessage(int64_t authSeq, const AuthSessionInfo *info)
{
DfxRecordLnnPostDeviceIdStart(authSeq);
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);
@ -1560,6 +1576,7 @@ int32_t PostDeviceIdMessage(int64_t authSeq, const AuthSessionInfo *info)
int32_t ProcessDeviceIdMessage(AuthSessionInfo *info, const uint8_t *data, uint32_t len)
{
DfxRecordLnnProcessDeviceIdStart();
AUTH_CHECK_AND_RETURN_RET_LOGE(info != NULL, SOFTBUS_INVALID_PARAM, AUTH_FSM, "info is NULL");
AUTH_CHECK_AND_RETURN_RET_LOGE(data != NULL, SOFTBUS_INVALID_PARAM, AUTH_FSM, "data is NULL");
if ((info->connInfo.type != AUTH_LINK_TYPE_WIFI) && (len == DEVICE_ID_STR_LEN) && (info->isServer)) {
@ -1585,8 +1602,25 @@ 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)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.authId = (int32_t)authSeq;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE_INFO_POST, extra);
}
static void DfxRecordLnnProcessDeviceInfoStart(int64_t authSeq)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.authId = (int32_t)authSeq;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_AUTH_DEVICE_INFO_PROCESS, extra);
}
int32_t PostDeviceInfoMessage(int64_t authSeq, const AuthSessionInfo *info)
{
DfxRecordLnnPostDeviceInfoStart(authSeq);
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) {
@ -1638,12 +1672,7 @@ int32_t PostDeviceInfoMessage(int64_t authSeq, const AuthSessionInfo *info)
.flag = compressFlag,
.len = dataLen,
};
LnnEventExtra lnnEventExtra = {0};
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_DEVICE_INFO, lnnEventExtra);
if (PostAuthData(info->connId, !info->isServer, &head, data) != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_AUTH_EXCHANGE_DEVICE_INFO_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_EXCHANGE_DEVICE_INFO, lnnEventExtra);
AUTH_LOGE(AUTH_FSM, "post device info fail");
SoftBusFree(data);
return SOFTBUS_AUTH_SEND_FAIL;
@ -1654,6 +1683,7 @@ int32_t PostDeviceInfoMessage(int64_t authSeq, const AuthSessionInfo *info)
int32_t ProcessDeviceInfoMessage(int64_t authSeq, AuthSessionInfo *info, const uint8_t *data, uint32_t len)
{
DfxRecordLnnProcessDeviceInfoStart(authSeq);
AUTH_CHECK_AND_RETURN_RET_LOGE(info != NULL, SOFTBUS_INVALID_PARAM, AUTH_FSM, "info is NULL");
AUTH_CHECK_AND_RETURN_RET_LOGE(data != NULL, SOFTBUS_INVALID_PARAM, AUTH_FSM, "data is NULL");
uint8_t *msg = NULL;

View File

@ -15,79 +15,129 @@
#include "bus_center_manager.h"
#include <securec.h>
#include "disc_log.h"
#include "lnn_event.h"
#include "softbus_adapter_perf.h"
#include "softbus_errcode.h"
static void DfxRecordLnnDiscServiceStart(int32_t serverType, const char *packageName)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.discServerType = serverType;
char pkgName[PKG_NAME_SIZE_MAX] = { 0 };
if (packageName != NULL && strncpy_s(pkgName, PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) {
extra.callerPkg = pkgName;
}
}
static void DfxRecordLnnDiscServiceEnd(int32_t serverType, const char *packageName, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.discServerType = serverType;
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 && strncpy_s(pkgName, PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) {
extra.callerPkg = pkgName;
}
}
int32_t LnnPublishService(const char *pkgName, const PublishInfo *info, bool isInnerRequest)
{
DfxRecordLnnDiscServiceStart(DISC_SERVER_PUBLISH, pkgName);
DISC_CHECK_AND_RETURN_RET_LOGE(!SoftBusIsRamTest(), SOFTBUS_ERR, DISC_LNN, "LnnPublishService: ram test abort");
int32_t ret;
if (!isInnerRequest) {
if ((ret = DiscPublishService(pkgName, info)) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_PUBLISH, pkgName, ret);
DISC_LOGE(DISC_LNN, "DiscPublishService failed\n");
return ret;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_PUBLISH, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
if ((ret = DiscStartScan(MODULE_LNN, info)) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_PUBLISH, pkgName, ret);
DISC_LOGE(DISC_LNN, "DiscStartScan failed\n");
return ret;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_PUBLISH, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
int32_t LnnUnPublishService(const char *pkgName, int32_t publishId, bool isInnerRequest)
{
DfxRecordLnnDiscServiceStart(DISC_SERVER_STOP_PUBLISH, pkgName);
if (!isInnerRequest) {
if (DiscUnPublishService(pkgName, publishId) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_ERR);
DISC_LOGE(DISC_LNN, "DiscUnPublishService failed\n");
return SOFTBUS_ERR;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
if (DiscUnpublish(MODULE_LNN, publishId) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_ERR);
DISC_LOGE(DISC_LNN, "DiscUnpublish fail!\n");
return SOFTBUS_ERR;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
int32_t LnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const InnerCallback *cb,
bool isInnerRequest)
{
DfxRecordLnnDiscServiceStart(DISC_SERVER_DISCOVERY, pkgName);
DISC_CHECK_AND_RETURN_RET_LOGE(!SoftBusIsRamTest(), SOFTBUS_ERR, DISC_LNN, "LnnStartDiscDevice: ram test abort");
int32_t ret;
if (!isInnerRequest) {
if ((ret = DiscStartDiscovery(pkgName, info, &cb->serverCb)) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, ret);
DISC_LOGE(DISC_LNN, "DiscStartDiscovery failed\n");
return ret;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
if ((ret = DiscSetDiscoverCallback(MODULE_LNN, &cb->innerCb)) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, ret);
DISC_LOGE(DISC_LNN, "DiscSetDiscoverCallback failed\n");
return ret;
}
if ((ret = DiscStartAdvertise(MODULE_LNN, info)) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, ret);
DISC_LOGE(DISC_LNN, "DiscStartAdvertise failed\n");
return ret;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_DISCOVERY, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
int32_t LnnStopDiscDevice(const char *pkgName, int32_t subscribeId, bool isInnerRequest)
{
DfxRecordLnnDiscServiceStart(DISC_SERVER_STOP_DISCOVERY, pkgName);
if (!isInnerRequest) {
if (DiscStopDiscovery(pkgName, subscribeId) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_ERR);
DISC_LOGE(DISC_LNN, "DiscStopDiscovery failed\n");
return SOFTBUS_ERR;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}
if (DiscStopAdvertise(MODULE_LNN, subscribeId) != SOFTBUS_OK) {
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_ERR);
DISC_LOGE(DISC_LNN, "DiscStopAdvertise fail!\n");
return SOFTBUS_ERR;
}
DfxRecordLnnDiscServiceEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_OK);
return SOFTBUS_OK;
}

View File

@ -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"
@ -841,6 +842,9 @@ static bool CleanInvalidConnStateProcess(FsmStateMachine *fsm, int32_t msgType,
static void OnlineStateEnter(FsmStateMachine *fsm)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
LnnConnectionFsm *connFsm = NULL;
if (!CheckStateMsgCommonArgs(fsm)) {
@ -944,6 +948,9 @@ static int32_t SyncBrOffline(const LnnConnectionFsm *connFsm)
static void LeavingStateEnter(FsmStateMachine *fsm)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN, extra);
LnnConnectionFsm *connFsm = NULL;
int32_t rc;
LnnConntionInfo *connInfo = NULL;

View File

@ -1850,7 +1850,7 @@ static JoinLnnMsgPara *CreateJoinLnnMsgPara(const ConnectionAddr *addr, const ch
return para;
}
static void BuildLnnEvent(LnnEventExtra *lnnEventExtra, const ConnectionAddr *addr)
static void BuildLnnEvent(LnnEventExtra *lnnEventExtra, ConnectionAddr *addr)
{
if (lnnEventExtra == NULL || addr == NULL) {
LNN_LOGW(LNN_STATE, "lnnEventExtra or addr is null");
@ -1864,15 +1864,34 @@ static void BuildLnnEvent(LnnEventExtra *lnnEventExtra, const ConnectionAddr *ad
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, "unknow param type!");
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;
@ -2229,25 +2248,23 @@ 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;
}
LnnEventExtra lnnEventExtra = { .callerPkg = pkgName };
BuildLnnEvent(&lnnEventExtra, addr);
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, lnnEventExtra);
if (PostMessageToHandler(MSG_TYPE_JOIN_LNN, para) != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_NETWORK_JOIN_LNN_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, lnnEventExtra);
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;
}
@ -2266,12 +2283,7 @@ int32_t LnnServerLeave(const char *networkId, const char *pkgName)
LNN_LOGE(LNN_BUILDER, "prepare leave lnn message fail");
return SOFTBUS_MALLOC_ERR;
}
LnnEventExtra lnnEventExtra = { .callerPkg = pkgName };
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN_START, lnnEventExtra);
if (PostMessageToHandler(MSG_TYPE_LEAVE_LNN, para) != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_NETWORK_LEAVE_LNN_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_LEAVE_LNN_START, lnnEventExtra);
LNN_LOGE(LNN_BUILDER, "post leave lnn message fail");
SoftBusFree(para);
return SOFTBUS_NETWORK_LOOPER_ERR;
@ -2283,29 +2295,17 @@ int32_t LnnNotifyDiscoveryDevice(const ConnectionAddr *addr, bool isNeedConnect)
{
JoinLnnMsgPara *para = NULL;
LnnEventExtra lnnEventExtra = {0};
BuildLnnEvent(&lnnEventExtra, addr);
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, lnnEventExtra);
LNN_LOGI(LNN_BUILDER, "notify discovery device enter! isNeedConnect = %d", isNeedConnect);
if (g_netBuilder.isInit == false) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_NETWORK_JOIN_LNN_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, lnnEventExtra);
LNN_LOGE(LNN_BUILDER, "no init");
return SOFTBUS_NO_INIT;
}
para = CreateJoinLnnMsgPara(addr, DEFAULT_PKG_NAME, isNeedConnect);
if (para == NULL) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_NETWORK_JOIN_LNN_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, lnnEventExtra);
LNN_LOGE(LNN_BUILDER, "malloc discovery device message fail");
return SOFTBUS_MALLOC_ERR;
}
if (PostMessageToHandler(MSG_TYPE_DISCOVERY_DEVICE, para) != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_NETWORK_JOIN_LNN_START_ERR;
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_START, lnnEventExtra);
LNN_LOGE(LNN_BUILDER, "post notify discovery device message failed");
SoftBusFree(para);
return SOFTBUS_ERR;
@ -2380,12 +2380,7 @@ void LnnSyncOfflineComplete(LnnSyncInfoType type, const char *networkId, const u
LNN_LOGE(LNN_BUILDER, "prepare notify sync offline message fail");
return;
}
LnnEventExtra lnnEventExtra = {0};
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN_START, lnnEventExtra);
if (PostMessageToHandler(MSG_TYPE_SYNC_OFFLINE_FINISH, para) != SOFTBUS_OK) {
lnnEventExtra.result = EVENT_STAGE_RESULT_FAILED;
lnnEventExtra.errcode = SOFTBUS_NETWORK_LEAVE_LNN_START_ERR;
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN_START, lnnEventExtra);
LNN_LOGE(LNN_BUILDER, "post sync offline finish message failed");
SoftBusFree(para);
}

View File

@ -52,6 +52,7 @@
#define BLE_ADV_LOST_TIME 5000
#define LONG_TO_STRING_MAX_LEN 21
#define LNN_COMMON_LEN_64 8
#define DEVICE_TYPE_SIZE_LEN 3
#define SOFTBUS_BUSCENTER_DUMP_REMOTEDEVICEINFO "remote_device_info"
#define RETURN_IF_GET_NODE_VALID(networkId, buf, info) do { \
@ -1676,6 +1677,54 @@ static void GetNodeInfoDiscovery(NodeInfo *oldInfo, NodeInfo *info, NodeInfoAbil
}
}
static void DfxRecordLnnAddOnlineNodeEnd(NodeInfo *info, int32_t onlineNum, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.onlineNum = onlineNum;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (info == NULL) {
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
return;
}
char netWorkId[NETWORK_ID_BUF_LEN] = { 0 };
if (strncpy_s(netWorkId, NETWORK_ID_BUF_LEN, info->networkId, NETWORK_ID_BUF_LEN - 1) == EOK) {
extra.peerNetworkId = netWorkId;
}
char udidData[UDID_BUF_LEN] = { 0 };
if (strncpy_s(udidData, UDID_BUF_LEN, info->deviceInfo.deviceUdid, UDID_BUF_LEN - 1) == EOK) {
extra.peerUdid = udidData;
}
char bleMacAddr[MAC_LEN] = { 0 };
if (strncpy_s(bleMacAddr, MAC_LEN, info->deviceInfo.deviceUdid, MAC_LEN - 1) == EOK) {
extra.peerBleMac = bleMacAddr;
}
char deviceType[DEVICE_TYPE_SIZE_LEN + 1] = { 0 };
if (snprintf_s(deviceType, DEVICE_TYPE_SIZE_LEN + 1, DEVICE_TYPE_SIZE_LEN, "%03X",
info->deviceInfo.deviceTypeId) >= 0) {
extra.peerDeviceType = deviceType;
}
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, extra);
}
static void DfxRecordLnnSetNodeOfflineEnd(const char *udid, int32_t onlineNum, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.onlineNum = onlineNum;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
char udidData[UDID_BUF_LEN] = { 0 };
if (udid != NULL && strnlen(udid, UDID_BUF_LEN) != UDID_BUF_LEN && strncpy_s(udidData,
UDID_BUF_LEN, udid, UDID_BUF_LEN - 1) == EOK) {
extra.peerUdid = udidData;
}
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN, extra);
}
ReportCategory LnnAddOnlineNode(NodeInfo *info)
{
// judge map
@ -1715,9 +1764,7 @@ ReportCategory LnnAddOnlineNode(NodeInfo *info)
OnlinePreventBrConnection(info);
}
InsertToProfile(info);
LnnEventExtra lnnEventExtra = { .result = EVENT_STAGE_RESULT_OK,
.onlineNum = (int32_t)MapGetSize(&map->udidMap) };
LNN_EVENT(EVENT_SCENE_JOIN_LNN, EVENT_STAGE_JOIN_LNN_END, lnnEventExtra);
DfxRecordLnnAddOnlineNodeEnd(info, (int32_t)MapGetSize(&map->udidMap), SOFTBUS_OK);
return REPORT_ONLINE;
}
if (infoAbility.isMigrateEvent) {
@ -1864,8 +1911,7 @@ ReportCategory LnnSetNodeOffline(const char *udid, ConnectionAddrType type, int3
return REPORT_NONE;
}
LnnCleanNodeInfo(info);
LnnEventExtra lnnEventExtra = { .result = EVENT_STAGE_RESULT_OK, .onlineNum = (int32_t)MapGetSize(&map->udidMap) };
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN_END, lnnEventExtra);
DfxRecordLnnSetNodeOfflineEnd(udid, (int32_t)MapGetSize(&map->udidMap), SOFTBUS_OK);
return REPORT_OFFLINE;
}

View File

@ -36,6 +36,14 @@ extern "C" {
DISC_ASSIGNER(Errcode, Result, result)
DISC_ASSIGNER(Errcode, Errcode, errcode)
DISC_ASSIGNER(Int32, InitType, initType)
DISC_ASSIGNER(Int32, ServerType, serverType)
DISC_ASSIGNER(Int32, InterFuncType, interFuncType)
DISC_ASSIGNER(Int32, CapabilityBit, capabilityBit)
DISC_ASSIGNER(String, CapabilityData, capabilityData)
DISC_ASSIGNER(Int32, BleTurnState, bleTurnState)
DISC_ASSIGNER(Int32, IpLinkStatus, ipLinkStatus)
DISC_ASSIGNER(Int32, CoapChangeType, coapChangeType)
DISC_ASSIGNER(Int32, BroadcastType, broadcastType)
DISC_ASSIGNER(Int32, BroadcastFreq, broadcastFreq)
DISC_ASSIGNER(Int32, ScanType, scanType)
@ -44,22 +52,27 @@ DISC_ASSIGNER(Int32, DiscType, discType)
DISC_ASSIGNER(Int32, DiscMode, discMode)
DISC_ASSIGNER(Int32, CostTime, costTime)
DISC_ASSIGNER(AnonymizeString, LocalNetworkId, localNetworkId)
DISC_ASSIGNER(AnonymizeString, LocalUdid, localUdid)
DISC_ASSIGNER(String, LocalDeviceType, localDeviceType)
DISC_ASSIGNER(AnonymizeString, PeerIp, peerIp)
DISC_ASSIGNER(AnonymizeString, PeerBrMac, peerBrMac)
DISC_ASSIGNER(AnonymizeString, PeerBleMac, peerBleMac)
DISC_ASSIGNER(AnonymizeString, PeerWifiMac, peerWifiMac)
DISC_ASSIGNER(String, PeerPort, peerPort)
DISC_ASSIGNER(AnonymizeString, PeerUdid, peerUdid)
DISC_ASSIGNER(AnonymizeString, PeerNetworkId, peerNetworkId)
DISC_ASSIGNER(String, PeerDeviceType, peerDeviceType)
DISC_ASSIGNER(String, CallerPkg, callerPkg)
#define DISC_ASSIGNER_SIZE 21 // Size of g_discAssigners
#define DISC_ASSIGNER_SIZE 26 // Size of g_discAssigners
static HiSysEventParamAssigner g_discAssigners[] = {
{ "STAGE_RES", HISYSEVENT_INT32, DiscAssignerResult },
{ "ERROR_CODE", HISYSEVENT_INT32, DiscAssignerErrcode },
{ "INIT_TYPE", HISYSEVENT_INT32, DiscAssignerInitType },
{ "SERVER_TYPE", HISYSEVENT_INT32, DiscAssignerServerType },
{ "INTERFACE_FUNC_TYPE", HISYSEVENT_INT32, DiscAssignerInterFuncType },
{ "CAPABILITY_BIT", HISYSEVENT_INT32, DiscAssignerCapabilityBit },
{ "CAPABILITY_DATA", HISYSEVENT_STRING, DiscAssignerCapabilityData },
{ "BLE_TURN_STATE", HISYSEVENT_INT32, DiscAssignerBleTurnState },
{ "IP_LINK_STATUS", HISYSEVENT_INT32, DiscAssignerIpLinkStatus },
{ "COAP_CHANGE_TYPE", HISYSEVENT_INT32, DiscAssignerCoapChangeType },
{ "BROADCAST_TYPE", HISYSEVENT_INT32, DiscAssignerBroadcastType },
{ "BROADCAST_FREQ", HISYSEVENT_INT32, DiscAssignerBroadcastFreq },
{ "SCAN_TYPE", HISYSEVENT_INT32, DiscAssignerScanType },
@ -68,14 +81,11 @@ static HiSysEventParamAssigner g_discAssigners[] = {
{ "DISC_MODE", HISYSEVENT_INT32, DiscAssignerDiscMode },
{ "FIRST_DISCOVERY_TIME", HISYSEVENT_INT32, DiscAssignerCostTime },
{ "LOCAL_NET_ID", HISYSEVENT_STRING, DiscAssignerLocalNetworkId },
{ "LOCAL_UDID", HISYSEVENT_STRING, DiscAssignerLocalUdid },
{ "LOCAL_DEV_TYPE", HISYSEVENT_INT32, DiscAssignerLocalDeviceType},
{ "PEER_IP", HISYSEVENT_STRING, DiscAssignerPeerIp },
{ "PEER_BR_MAC", HISYSEVENT_STRING, DiscAssignerPeerBrMac },
{ "PEER_BLE_MAC", HISYSEVENT_STRING, DiscAssignerPeerBleMac },
{ "PEER_WIFI_MAC", HISYSEVENT_STRING, DiscAssignerPeerWifiMac },
{ "PEER_PORT", HISYSEVENT_INT32, DiscAssignerPeerPort },
{ "PEER_UDID", HISYSEVENT_STRING, DiscAssignerPeerUdid },
{ "PEER_NET_ID", HISYSEVENT_STRING, DiscAssignerPeerNetworkId },
{ "PEER_DEV_TYPE", HISYSEVENT_STRING, DiscAssignerPeerDeviceType },
{ "HOST_PKG", HISYSEVENT_STRING, DiscAssignerCallerPkg },

View File

@ -36,6 +36,9 @@ extern "C" {
LNN_ASSIGNER(Errcode, Result, result)
LNN_ASSIGNER(Errcode, Errcode, errcode)
LNN_ASSIGNER(Int32, DiscServerType, discServerType)
LNN_ASSIGNER(Int32, GearCycle, gearCycle)
LNN_ASSIGNER(Int32, GearDuration, gearDuration)
LNN_ASSIGNER(Int32, ConnectionId, connectionId)
LNN_ASSIGNER(Int32, AuthType, authType)
LNN_ASSIGNER(Int32, AuthId, authId)
@ -54,10 +57,13 @@ LNN_ASSIGNER(String, PeerDeviceType, peerDeviceType)
LNN_ASSIGNER(String, CallerPkg, callerPkg)
LNN_ASSIGNER(String, CalleePkg, calleePkg)
#define LNN_ASSIGNER_SIZE 19 // Size of g_connAssigners
#define LNN_ASSIGNER_SIZE 22 // Size of g_connAssigners
static const HiSysEventParamAssigner g_lnnAssigners[] = {
{ "STAGE_RES", HISYSEVENT_INT32, LnnAssignerResult },
{ "ERROR_CODE", HISYSEVENT_INT32, LnnAssignerErrcode },
{ "DISC_SERVER_TYPE", HISYSEVENT_INT32, LnnAssignerDiscServerType },
{ "GEAR_CYCLE", HISYSEVENT_INT32, LnnAssignerGearCycle },
{ "GEAR_DURATION", HISYSEVENT_INT32, LnnAssignerGearDuration },
{ "CONN_ID", HISYSEVENT_INT32, LnnAssignerConnectionId },
{ "AUTH_TYPE", HISYSEVENT_INT32, LnnAssignerAuthType },
{ "AUTH_ID", HISYSEVENT_INT32, LnnAssignerAuthId },
@ -69,10 +75,10 @@ static const HiSysEventParamAssigner g_lnnAssigners[] = {
{ "PEER_BR_MAC", HISYSEVENT_STRING, LnnAssignerPeerBrMac },
{ "PEER_BLE_MAC", HISYSEVENT_STRING, LnnAssignerPeerBleMac },
{ "PEER_WIFI_MAC", HISYSEVENT_STRING, LnnAssignerPeerWifiMac },
{ "PEER_PORT", HISYSEVENT_INT32, LnnAssignerPeerPort },
{ "PEER_PORT", HISYSEVENT_STRING, LnnAssignerPeerPort },
{ "PEER_UDID", HISYSEVENT_STRING, LnnAssignerPeerUdid },
{ "PEER_NET_ID", HISYSEVENT_STRING, LnnAssignerPeerNetworkId },
{ "PEER_DEV_TYPE", HISYSEVENT_INT32, LnnAssignerPeerDeviceType },
{ "PEER_DEV_TYPE", HISYSEVENT_STRING, LnnAssignerPeerDeviceType },
{ "HOST_PKG", HISYSEVENT_STRING, LnnAssignerCallerPkg },
{ "TO_CALL_PKG", HISYSEVENT_STRING, LnnAssignerCalleePkg },
// Modification Note: remember updating LNN_ASSIGNER_SIZE

View File

@ -62,4 +62,19 @@ void DiscAuditInner(int32_t scene, const char *func, int32_t line, DiscAuditExtr
.discAuditExtra = extra,
};
SoftbusAuditInner(EVENT_MODULE_DISC, &form);
}
void DiscEventExtraInit(DiscEventExtra *extra)
{
extra->capabilityData = NULL;
extra->scanCycle = NULL;
extra->localNetworkId = NULL;
extra->peerIp = NULL;
extra->peerBrMac = NULL;
extra->peerBleMac = NULL;
extra->peerWifiMac = NULL;
extra->peerPort = NULL;
extra->peerNetworkId = NULL;
extra->peerDeviceType = NULL;
extra->callerPkg = NULL;
}

View File

@ -62,4 +62,19 @@ void LnnAuditInner(int32_t scene, const char *func, int32_t line, LnnAuditExtra
.lnnAuditExtra = extra,
};
SoftbusAuditInner(EVENT_MODULE_LNN, &form);
}
void LnnEventExtraInit(LnnEventExtra *extra)
{
extra->peerDeviceInfo = NULL;
extra->peerIp = NULL;
extra->peerBrMac = NULL;
extra->peerBleMac = NULL;
extra->peerWifiMac = NULL;
extra->peerPort = NULL;
extra->peerUdid = NULL;
extra->peerNetworkId = NULL;
extra->peerDeviceType = NULL;
extra->callerPkg = NULL;
extra->calleePkg = NULL;
}

View File

@ -267,13 +267,13 @@ static void LnnStatsAuthLinkType(int32_t authLinkTypePara, bool success)
static void LnnStats(int32_t scene, int32_t stage, int32_t stageRes, int32_t authLinkType)
{
if (scene == EVENT_SCENE_JOIN_LNN && stage == EVENT_STAGE_AUTH_DEVICE && stageRes == EVENT_STAGE_RESULT_OK) {
if (scene == EVENT_SCENE_JOIN_LNN && stage == EVENT_STAGE_AUTH && stageRes == EVENT_STAGE_RESULT_OK) {
g_lnnStatsInfo.authSuccessTotal++;
LnnStatsAuthLinkType(authLinkType, true);
return;
}
if (scene == EVENT_SCENE_JOIN_LNN && stage == EVENT_STAGE_AUTH_DEVICE && stageRes == EVENT_STAGE_RESULT_FAILED) {
if (scene == EVENT_SCENE_JOIN_LNN && stage == EVENT_STAGE_AUTH && stageRes == EVENT_STAGE_RESULT_FAILED) {
g_lnnStatsInfo.authFailTotal++;
LnnStatsAuthLinkType(authLinkType, false);
return;
@ -284,7 +284,7 @@ static void LnnStats(int32_t scene, int32_t stage, int32_t stageRes, int32_t aut
return;
}
if (scene == EVENT_SCENE_LEAVE_LNN && stage == EVENT_STAGE_LEAVE_LNN_END && stageRes == EVENT_STAGE_RESULT_OK) {
if (scene == EVENT_SCENE_LEAVE_LNN && stage == EVENT_STAGE_LEAVE_LNN && stageRes == EVENT_STAGE_RESULT_OK) {
g_lnnStatsInfo.leaveLnnNum++;
return;
}

View File

@ -33,6 +33,8 @@ void DiscAlarmInner(int32_t scene, int32_t type, const char *func, int32_t line,
void DiscStatsInner(int32_t scene, const char *func, int32_t line, DiscStatsExtra *extra);
void DiscAuditInner(int32_t scene, const char *func, int32_t line, DiscAuditExtra *extra);
void DiscEventExtraInit(DiscEventExtra *extra);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -25,22 +25,83 @@ extern "C" {
#endif
typedef enum {
EVENT_SCENE_BROADCAST = 1,
EVENT_SCENE_SCAN = 2,
EVENT_SCENE_INIT = 1,
EVENT_SCENE_DISC = 2,
EVENT_SCENE_BLE = 3,
EVENT_SCENE_SHARE_BLE = 4,
EVENT_SCENE_APPROACH_BLE = 5,
EVENT_SCENE_COAP = 6,
EVENT_SCENE_BROADCAST = 7,
EVENT_SCENE_SCAN = 8,
} DiscEventScene;
typedef enum {
EVENT_STAGE_INIT = 1,
EVENT_STAGE_SOFTBUS_BLE_INIT = 2,
EVENT_STAGE_SHARE_BLE_INIT = 3,
EVENT_STAGE_APPROACH_BLE_INIT = 4,
} DiscEventInitStage;
typedef enum {
EVENT_STAGE_DISC_SDK = 1,
EVENT_STAGE_DISC_SERVICE = 2,
EVENT_STAGE_ADD_INFO = 3,
EVENT_STAGE_CALL_INTERFACE = 4,
} DiscEventDiscStage;
typedef enum {
EVENT_STAGE_BLE_PROCESS = 1,
EVENT_STAGE_BLE_HANDLER = 2,
EVENT_STAGE_STATE_TURN = 3,
} DiscEventBleStage;
typedef enum {
EVENT_STAGE_SHARE_BLE_PROCESS = 1,
EVENT_STAGE_SHARE_BLE_UPDATE_DEVICE = 2,
} DiscEventShareBleStage;
typedef enum {
EVENT_STAGE_APPROACH_BLE_PROCESS = 1,
} DiscEventApproachBleStage;
typedef enum {
EVENT_STAGE_COAP = 1,
EVENT_STAGE_UPDATE_IP = 2,
EVENT_STAGE_UPDATE_DEVICE = 3,
EVENT_STAGE_REGISTER = 4,
EVENT_STAGE_SET_FILTER = 5,
EVENT_STAGE_DISCOVERY_START = 6,
EVENT_STAGE_DISCOVERY_STOP = 7,
} DiscEventCoapStage;
typedef enum {
EVENT_STAGE_BROADCAST = 1,
} DiscEventBroadcastStage;
typedef enum {
EVENT_STAGE_SCAN_START = 1,
EVENT_STAGE_SCAN_END = 2,
EVENT_STAGE_SCAN_RECV = 2,
EVENT_STAGE_SCAN_END = 3,
} DiscEventScanStage;
typedef enum {
SERVER_PUBLISH = 1,
SERVER_STOP_PUBLISH = 2,
SERVER_DISCOVERY = 3,
SERVER_STOP_DISCOVERY = 4,
} DiscServerType;
typedef struct {
int32_t result; // STAGE_RES
int32_t errcode; // ERROR_CODE
int32_t initType; // INIT_TYPE
int32_t serverType; // SERVER_TYPE
int32_t interFuncType; // INTERFACE_FUNC_TYPE
int32_t capabilityBit; // CAPABILITY_BIT
const char *capabilityData; // CAPABILITY_DATA
int32_t bleTurnState; // BLE_TURN_STATE
int32_t ipLinkStatus; // IP_LINK_STATUS
int32_t coapChangeType; // COAP_CHANGE_TYPE
int32_t broadcastType; // BROADCAST_TYPE
int32_t broadcastFreq; // BROADCAST_FREQ
int32_t scanType; // SCAN_TYPE
@ -49,14 +110,11 @@ typedef struct {
int32_t discMode; // DISC_MODE
int32_t costTime; // FIRST_DISCOVERY_TIME
const char *localNetworkId; // LOCAL_NET_ID
const char *localUdid; // LOCAL_UDID
const char *localDeviceType; // LOCAL_DEV_TYPE
const char *peerIp; // PEER_IP
const char *peerBrMac; // PEER_BR_MAC
const char *peerBleMac; // PEER_BLE_MAC
const char *peerWifiMac; // PEER_WIFI_MAC
const char *peerPort; // PEER_PORT
const char *peerUdid; // PEER_UDID
const char *peerNetworkId; // PEER_NET_ID
const char *peerDeviceType; // PEER_DEV_TYPE
const char *callerPkg; // HOST_PKG

View File

@ -27,27 +27,50 @@ extern "C" {
#endif
typedef enum {
EVENT_SCENE_JOIN_LNN = 1,
EVENT_SCENE_LEAVE_LNN = 2,
EVENT_SCENE_LNN = 1,
EVENT_SCENE_JOIN_LNN = 2,
EVENT_SCENE_LEAVE_LNN = 3,
} LnnEventScene;
typedef enum {
EVENT_STAGE_LNN_DISC_SDK = 1,
EVENT_STAGE_LNN_DISC_SERVICE = 2,
EVENT_STAGE_LNN_JOIN_SDK = 3,
EVENT_STAGE_LNN_LEAVE_SDK = 4,
EVENT_STAGE_LNN_REG_NODE = 5,
EVENT_STAGE_LNN_SHIFT_GEAR = 6,
} LnnEventLnnStage;
typedef enum {
EVENT_STAGE_JOIN_LNN_START = 1,
EVENT_STAGE_AUTH_CONNECTION = 2,
EVENT_STAGE_AUTH_DEVICE = 3,
EVENT_STAGE_EXCHANGE_CIPHER = 4,
EVENT_STAGE_EXCHANGE_DEVICE_INFO = 5,
EVENT_STAGE_JOIN_LNN_END = 6,
EVENT_STAGE_AUTH = 2,
EVENT_STAGE_AUTH_CONNECTION = 3,
EVENT_STAGE_AUTH_DEVICE_ID_POST = 4,
EVENT_STAGE_AUTH_DEVICE_ID_PROCESS = 5,
EVENT_STAGE_AUTH_HICHAIN = 6,
EVENT_STAGE_AUTH_EXCHANGE_CIPHER = 7,
EVENT_STAGE_AUTH_DEVICE_INFO_POST = 8,
EVENT_STAGE_AUTH_DEVICE_INFO_PROCESS = 9,
EVENT_STAGE_JOIN_LNN_END = 10,
} LnnEventJoinLnnStage;
typedef enum {
EVENT_STAGE_LEAVE_LNN_START = 1,
EVENT_STAGE_LEAVE_LNN_END = 2,
EVENT_STAGE_LEAVE_LNN = 1,
} LnnEventLeaveLnnStage;
typedef enum {
DISC_SERVER_PUBLISH = 1,
DISC_SERVER_STOP_PUBLISH = 2,
DISC_SERVER_DISCOVERY = 3,
DISC_SERVER_STOP_DISCOVERY = 4,
} LnnDiscServerType;
typedef struct {
int32_t result; // STAGE_RES
int32_t errcode; // ERROR_CODE
int32_t discServerType; // DISC_SERVER_TYPE
int32_t gearCycle; // GEAR_CYCLE
int32_t gearDuration; // GEAR_DURATION
int32_t connectionId; // CONN_ID
int32_t authType; // AUTH_TYPE
int32_t authId; // AUTH_ID

View File

@ -33,6 +33,8 @@ void LnnAlarmInner(int32_t scene, int32_t type, const char *func, int32_t line,
void LnnStatsInner(int32_t scene, const char *func, int32_t line, LnnStatsExtra *extra);
void LnnAuditInner(int32_t scene, const char *func, int32_t line, LnnAuditExtra *extra);
void LnnEventExtraInit(LnnEventExtra *extra);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -175,9 +175,24 @@ static DiscoveryFuncInterface g_discBleFrameFuncInterface = {
.UpdateLocalDeviceInfo = BleDispatchUpdateLocalDeviceInfo,
};
static void DfxRecordBleInitEnd(int32_t stage, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.initType = BLE + 1;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_INIT, stage, extra);
if (stage != EVENT_STAGE_INIT && reason != SOFTBUS_OK) {
DISC_EVENT(EVENT_SCENE_INIT, EVENT_STAGE_INIT, extra);
}
}
DiscoveryFuncInterface *DiscBleInit(DiscInnerCallback *discInnerCb)
{
if (discInnerCb == NULL) {
DfxRecordBleInitEnd(EVENT_STAGE_INIT, SOFTBUS_INVALID_PARAM);
DISC_LOGW(DISC_INIT, "discInnerCb err");
return NULL;
}
@ -185,25 +200,32 @@ DiscoveryFuncInterface *DiscBleInit(DiscInnerCallback *discInnerCb)
g_dispatcherSize = 0;
DiscoveryBleDispatcherInterface *softbusInterface = DiscSoftBusBleInit(discInnerCb);
if (softbusInterface == NULL) {
DfxRecordBleInitEnd(EVENT_STAGE_SOFTBUS_BLE_INIT, SOFTBUS_DISCOVER_MANAGER_INIT_FAIL);
DISC_LOGE(DISC_INIT, "DiscSoftBusBleInit err");
return NULL;
}
g_dispatchers[g_dispatcherSize++] = softbusInterface;
DfxRecordBleInitEnd(EVENT_STAGE_SOFTBUS_BLE_INIT, SOFTBUS_OK);
DiscoveryBleDispatcherInterface *shareInterface = DiscShareBleInit(discInnerCb);
if (shareInterface == NULL) {
DfxRecordBleInitEnd(EVENT_STAGE_SHARE_BLE_INIT, SOFTBUS_DISCOVER_MANAGER_INIT_FAIL);
DISC_LOGE(DISC_INIT, "DiscShareBleInit err");
return NULL;
}
g_dispatchers[g_dispatcherSize++] = shareInterface;
DfxRecordBleInitEnd(EVENT_STAGE_SHARE_BLE_INIT, SOFTBUS_OK);
DiscoveryBleDispatcherInterface *approachInterface = DiscApproachBleInit(discInnerCb);
if (approachInterface == NULL) {
DfxRecordBleInitEnd(EVENT_STAGE_APPROACH_BLE_INIT, SOFTBUS_DISCOVER_MANAGER_INIT_FAIL);
DISC_LOGE(DISC_INIT, "DiscApproachBleInit err");
return NULL;
}
g_dispatchers[g_dispatcherSize++] = approachInterface;
DfxRecordBleInitEnd(EVENT_STAGE_APPROACH_BLE_INIT, SOFTBUS_OK);
DfxRecordBleInitEnd(EVENT_STAGE_INIT, SOFTBUS_OK);
return &g_discBleFrameFuncInterface;
}

View File

@ -557,6 +557,10 @@ static void BleOnScanStop(int listenerId, int status)
static void BleOnStateChanged(int32_t listenerId, int32_t state)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.bleTurnState = state;
DISC_EVENT(EVENT_SCENE_BLE, EVENT_STAGE_STATE_TURN, extra);
(void)listenerId;
SoftBusMessage *msg = NULL;
switch (state) {
@ -823,6 +827,17 @@ static void BuildAdvParam(BroadcastParam *advParam)
advParam->txPower = BLE_ADV_TX_POWER_DEFAULT;
}
static void DfxRecordAdevertiserEnd(int32_t adv, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = BLE + 1;
extra.broadcastType = adv;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, extra);
}
static int32_t StartAdvertiser(int32_t adv)
{
DISC_LOGD(DISC_BLE, "enter");
@ -857,17 +872,13 @@ static int32_t StartAdvertiser(int32_t adv)
SignalingMsgPrint("ble adv send", (uint8_t *)packet.bcData.payload, (uint8_t)packet.bcData.payloadLen,
DISC_BLE);
DiscEventExtra discEventExtra = { .broadcastType = BLE };
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
if (StartBroadcasting(advertiser->channel, &advParam, &packet) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_START_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
DfxRecordAdevertiserEnd(adv, SOFTBUS_DISCOVER_START_BROADCAST_FAIL);
DestroyBleConfigAdvData(&packet);
DISC_LOGE(DISC_BLE, "start adv adv=%d failed", adv);
return SOFTBUS_DISCOVER_START_BROADCAST_FAIL;
}
DfxRecordAdevertiserEnd(adv, SOFTBUS_OK);
UpdateInfoManager(adv, false);
DestroyBleConfigAdvData(&packet);
return SOFTBUS_OK;
@ -880,12 +891,7 @@ static int32_t StopAdvertiser(int32_t adv)
DISC_LOGI(DISC_BLE, "advertiser adv adv=%d is already stopped.", adv);
return SOFTBUS_OK;
}
DiscEventExtra discEventExtra = { .broadcastType = BLE, .result = EVENT_STAGE_RESULT_OK };
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
if (StopBroadcasting(advertiser->channel) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_END_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
DISC_LOGE(DISC_BLE, "stop advertiser advId=%d failed.", adv);
}
if (adv == NON_ADV_ID) {
@ -916,12 +922,7 @@ static int32_t UpdateAdvertiser(int32_t adv)
}
BroadcastParam advParam = {};
BuildAdvParam(&advParam);
DiscEventExtra discEventExtra = { .broadcastType = BLE };
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
if (UpdateBroadcasting(advertiser->channel, &advParam, &packet) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_START_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
DestroyBleConfigAdvData(&packet);
DISC_LOGE(DISC_BLE, "UpdateAdv failed");
return SOFTBUS_DISCOVER_START_BROADCAST_FAIL;
@ -946,6 +947,16 @@ static int32_t GetScannerParam(int32_t freq, BcScanParams *scanParam)
return SOFTBUS_OK;
}
static void DfxRecordScanEnd(int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.scanType = BLE + 1;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, extra);
}
static void StartScaner(void)
{
if (!CheckScanner()) {
@ -959,22 +970,17 @@ static void StartScaner(void)
}
BcScanParams scanParam;
int32_t maxFreq = GetMaxExchangeFreq();
DiscEventExtra discEventExtra = { .scanType = BLE };
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discEventExtra);
if (GetScannerParam(maxFreq, &scanParam) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_START_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discEventExtra);
DfxRecordScanEnd(SOFTBUS_DISCOVER_START_SCAN_FAIL);
DISC_LOGE(DISC_BLE, "GetScannerParam failed");
return;
}
if (StartScan(g_bleListener.scanListenerId, &scanParam) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_START_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discEventExtra);
DfxRecordScanEnd(SOFTBUS_DISCOVER_START_SCAN_FAIL);
DISC_LOGE(DISC_BLE, "start scan failed");
return;
}
DfxRecordScanEnd(SOFTBUS_OK);
DISC_LOGI(DISC_BLE, "StartScanner success");
}
@ -984,12 +990,7 @@ static int32_t StopScaner(void)
DISC_LOGI(DISC_BLE, "already stop scanning");
return SOFTBUS_OK;
}
DiscEventExtra discEventExtra = { .scanType = BLE, .result = EVENT_STAGE_RESULT_OK };
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discEventExtra);
if (StopScan(g_bleListener.scanListenerId) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_END_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discEventExtra);
DISC_LOGI(DISC_BLE, "StopScaner failed");
return SOFTBUS_DISCOVER_END_SCAN_FAIL;
}
@ -1161,24 +1162,47 @@ static SoftBusMessage *CreateBleHandlerMsg(int32_t what, uint64_t arg1, uint64_t
return msg;
}
static void DfxRecordBleProcessEnd(uint8_t publishFlag, uint8_t activeFlag, const void *option, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = BLE + 1;
extra.discMode = (activeFlag == BLE_ACTIVE) ? DISCOVER_MODE_ACTIVE : DISCOVER_MODE_PASSIVE;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (publishFlag == BLE_PUBLISH && option != NULL) {
PublishOption *publishOption = (PublishOption *)option;
extra.capabilityBit = (int32_t)publishOption->capabilityBitmap[0];
} else if (publishFlag == BLE_SUBSCRIBE && option != NULL) {
SubscribeOption *subscribeOption = (SubscribeOption *)option;
extra.capabilityBit = (int32_t)subscribeOption->capabilityBitmap[0];
}
DISC_EVENT(EVENT_SCENE_BLE, EVENT_STAGE_BLE_PROCESS, extra);
}
static int32_t ProcessBleDiscFunc(bool isStart, uint8_t publishFlags, uint8_t activeFlags,
int32_t funcCode, const void *option)
{
if (isStart && SoftBusGetBtState() != BLE_ENABLE) {
DfxRecordBleProcessEnd(publishFlags, activeFlags, option, SOFTBUS_ERR);
DISC_LOGE(DISC_BLE, "get bt state failed.");
return SOFTBUS_ERR;
}
int32_t ret = ProcessBleInfoManager(isStart, publishFlags, activeFlags, option);
if (ret != SOFTBUS_OK) {
DfxRecordBleProcessEnd(publishFlags, activeFlags, option, ret);
DISC_LOGE(DISC_BLE, "process ble info manager failed");
return ret;
}
SoftBusMessage *msg = CreateBleHandlerMsg(funcCode, 0, 0, NULL);
if (msg == NULL) {
DfxRecordBleProcessEnd(publishFlags, activeFlags, option, SOFTBUS_MALLOC_ERR);
DISC_LOGE(DISC_BLE, "CreateBleHandlerMsg failed");
return SOFTBUS_MALLOC_ERR;
}
g_discBleHandler.looper->PostMessage(g_discBleHandler.looper, msg);
DfxRecordBleProcessEnd(publishFlags, activeFlags, option, SOFTBUS_OK);
return SOFTBUS_OK;
}
@ -1471,10 +1495,25 @@ static uint32_t RecvMsgAggregateCap(void)
return revMessageCap;
}
static void DfxRecordAddRecvMsgEnd(const uint32_t *capBitMap, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = BLE + 1;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (capBitMap != NULL) {
extra.capabilityBit = (int32_t)capBitMap[0];
}
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_RECV, extra);
}
static int32_t AddRecvMessage(const char *key, const uint32_t *capBitMap, bool needBrMac)
{
DISC_LOGD(DISC_BLE, "enter");
if (SoftBusMutexLock(&g_recvMessageInfo.lock) != 0) {
DfxRecordAddRecvMsgEnd(capBitMap, SOFTBUS_LOCK_ERR);
DISC_LOGE(DISC_BLE, "lock failed");
return SOFTBUS_LOCK_ERR;
}
@ -1484,11 +1523,13 @@ static int32_t AddRecvMessage(const char *key, const uint32_t *capBitMap, bool n
DISC_LOGI(DISC_BLE, "key is not exit");
recvMsg = (RecvMessage *)SoftBusCalloc(sizeof(RecvMessage));
if (recvMsg == NULL) {
DfxRecordAddRecvMsgEnd(capBitMap, SOFTBUS_MALLOC_ERR);
DISC_LOGE(DISC_BLE, "malloc recv msg failed");
SoftBusMutexUnlock(&g_recvMessageInfo.lock);
return SOFTBUS_MALLOC_ERR;
}
if (memcpy_s(&recvMsg->key, SHA_HASH_LEN, key, SHA_HASH_LEN) != EOK) {
DfxRecordAddRecvMsgEnd(capBitMap, SOFTBUS_MEM_ERR);
DISC_LOGE(DISC_BLE, "copy key to create recv msg failed");
SoftBusFree(recvMsg);
SoftBusMutexUnlock(&g_recvMessageInfo.lock);
@ -1511,6 +1552,7 @@ static int32_t AddRecvMessage(const char *key, const uint32_t *capBitMap, bool n
RemoveTimeout(recvMsg->key);
}
StartTimeout(recvMsg->key);
DfxRecordAddRecvMsgEnd(capBitMap, SOFTBUS_OK);
return SOFTBUS_OK;
}
@ -1557,8 +1599,21 @@ static void ProcessTimeout(SoftBusMessage *msg)
UpdateAdvertiser(NON_ADV_ID);
}
static void DfxRecordBleMsgHandlerStart(SoftBusMessage *msg)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = BLE + 1;
if (msg != NULL) {
extra.interFuncType = msg->what + 1;
}
DISC_EVENT(EVENT_SCENE_BLE, EVENT_STAGE_BLE_HANDLER, extra);
}
static void DiscBleMsgHandler(SoftBusMessage *msg)
{
DfxRecordBleMsgHandlerStart(msg);
switch (msg->what) {
case PUBLISH_ACTIVE_SERVICE:
StartActivePublish(msg);

View File

@ -15,7 +15,9 @@
#include "disc_coap.h"
#include <securec.h>
#include <stdio.h>
#include "disc_event.h"
#include "disc_log.h"
#include "disc_nstackx_adapter.h"
@ -121,6 +123,74 @@ static void SetDiscCoapOption(DiscCoapOption *discCoapOption, DiscOption *option
discCoapOption->allCap = allCap;
}
static void DfxRecordCoapEnd(bool isStart, bool isActive, bool isPublish, const void *option, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.discMode = isActive ? DISCOVER_MODE_ACTIVE : DISCOVER_MODE_PASSIVE;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (isPublish) {
extra.interFuncType = (isStart ? PUBLISH_FUNC : UNPUBLISH_FUNC) + 1;
PublishOption *publishOption = (PublishOption *)option;
extra.broadcastFreq = publishOption == NULL ? 0 : publishOption->freq;
} else {
extra.interFuncType = (isStart ? STARTDISCOVERTY_FUNC : STOPDISCOVERY_FUNC) + 1;
SubscribeOption *subscribeOption = (SubscribeOption *)option;
extra.broadcastFreq = subscribeOption == NULL ? 0 : subscribeOption->freq;
}
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_COAP, extra);
}
static void DfxRecordRegisterEnd(const unsigned char *capabilityData, uint32_t capability, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.capabilityBit = (int32_t)capability;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_REGISTER, extra);
}
static void DfxRecordSetFilterEnd(uint32_t capability, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.capabilityBit = (int32_t)capability;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_SET_FILTER, extra);
}
static void DfxRecordStartDiscoveryEnd(DiscCoapOption *discCoapOption, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (discCoapOption != NULL) {
extra.broadcastFreq = discCoapOption->freq;
extra.capabilityBit = (int32_t)discCoapOption->capability;
}
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_DISCOVERY_START, extra);
}
static void DfxRecordStopDiscoveryEnd(int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_DISCOVERY_STOP, extra);
}
static int32_t Publish(const PublishOption *option, bool isActive)
{
DISC_CHECK_AND_RETURN_RET_LOGE(option != NULL && g_publishMgr != NULL, SOFTBUS_INVALID_PARAM, DISC_COAP,
@ -133,28 +203,28 @@ static int32_t Publish(const PublishOption *option, bool isActive)
DISC_CHECK_AND_RETURN_RET_LOGE(SoftBusMutexLock(&(g_publishMgr->lock)) == 0, SOFTBUS_LOCK_ERR, DISC_COAP,
"%s publish mutex lock failed", isActive ? "active" : "passive");
DiscEventExtra discScanEventExtra = { .scanType = COAP };
DiscEventExtra discBroadacastEventExtra = { .broadcastType = COAP, .broadcastFreq = option->freq };
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
if (RegisterAllCapBitmap(CAPABILITY_NUM, option->capabilityBitmap, g_publishMgr, MAX_CAP_NUM) != SOFTBUS_OK) {
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_MERGE_CAP_FAIL);
DISC_LOGE(DISC_COAP, "merge %s publish capability failed", isActive ? "active" : "passive");
goto REG_FAIL;
goto PUB_FAIL;
}
if (g_publishMgr->isUpdate && DiscCoapRegisterCapability(CAPABILITY_NUM, g_publishMgr->allCap) != SOFTBUS_OK) {
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_REGISTER_CAP_FAIL);
DISC_LOGE(DISC_COAP, "register all capability to dfinder failed.");
goto REG_FAIL;
goto PUB_FAIL;
}
if (DiscCoapRegisterServiceData(option->capabilityData, option->dataLen,
option->capabilityBitmap[0]) != SOFTBUS_OK) {
DfxRecordRegisterEnd(option->capabilityData, option->capabilityBitmap[0],
SOFTBUS_DISCOVER_COAP_REGISTER_CAP_FAIL);
DISC_LOGE(DISC_COAP, "register service data to dfinder failed.");
goto REG_FAIL;
goto PUB_FAIL;
}
DfxRecordRegisterEnd(option->capabilityData, option->capabilityBitmap[0], SOFTBUS_OK);
if (DiscCoapRegisterCapabilityData(option->capabilityData, option->dataLen,
option->capabilityBitmap[0]) != SOFTBUS_OK) {
DISC_LOGW(DISC_COAP, "register capability data to dfinder failed.");
goto REG_FAIL;
goto PUB_FAIL;
}
if (isActive) {
DiscCoapOption discCoapOption;
@ -163,34 +233,28 @@ static int32_t Publish(const PublishOption *option, bool isActive)
.option.publishOption = *option,
};
SetDiscCoapOption(&discCoapOption, &discOption, 0);
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discBroadacastEventExtra);
if (DiscCoapStartDiscovery(&discCoapOption) != SOFTBUS_OK) {
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP,
SOFTBUS_HISYSEVT_DISCOVER_COAP_START_DISCOVER_FAIL);
DfxRecordStartDiscoveryEnd(&discCoapOption, SOFTBUS_DISCOVER_COAP_START_DISCOVER_FAIL);
DISC_LOGE(DISC_COAP, "coap active publish failed, allCap: %u", g_publishMgr->allCap[0]);
goto BROADCAST_FAIL;
goto PUB_FAIL;
}
DfxRecordStartDiscoveryEnd(&discCoapOption, SOFTBUS_OK);
}
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
DISC_LOGI(DISC_COAP, "coap %s publish succ, allCap: %u", isActive ? "active" : "passive", g_publishMgr->allCap[0]);
return SOFTBUS_OK;
REG_FAIL:
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_START_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
return SOFTBUS_DISCOVER_COAP_START_PUBLISH_FAIL;
BROADCAST_FAIL:
discBroadacastEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discBroadacastEventExtra.errcode = SOFTBUS_DISCOVER_START_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discBroadacastEventExtra);
PUB_FAIL:
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
return SOFTBUS_DISCOVER_COAP_START_PUBLISH_FAIL;
}
static int32_t CoapPublish(const PublishOption *option)
{
return Publish(option, true);
int32_t ret = Publish(option, true);
DfxRecordCoapEnd(true, true, true, (void *)option, ret);
return ret;
}
static int32_t CoapStartScan(const PublishOption *option)
@ -207,6 +271,7 @@ static int32_t CoapStartScan(const PublishOption *option)
};
DISC_AUDIT(AUDIT_SCENE_COAP_PUBLISH, extra);
}
DfxRecordCoapEnd(true, false, true, (void *)option, ret);
return ret;
}
@ -219,12 +284,7 @@ static int32_t UnPublish(const PublishOption *option, bool isActive)
DISC_CHECK_AND_RETURN_RET_LOGE(SoftBusMutexLock(&(g_publishMgr->lock)) == 0, SOFTBUS_LOCK_ERR, DISC_COAP,
"%s unPublish mutex lock failed", isActive ? "active" : "passive");
DiscEventExtra discScanEventExtra = { .scanType = COAP, .result = EVENT_STAGE_RESULT_OK };
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
if (UnregisterAllCapBitmap(CAPABILITY_NUM, option->capabilityBitmap, g_publishMgr, MAX_CAP_NUM) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_COAP_CANCEL_CAP_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
DISC_LOGE(DISC_COAP, "unRegister %s publish capability failed", isActive ? "active" : "passive");
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_CANCEL_CAP_FAIL);
@ -232,9 +292,6 @@ static int32_t UnPublish(const PublishOption *option, bool isActive)
}
if (g_publishMgr->isUpdate) {
if (DiscCoapRegisterCapability(CAPABILITY_NUM, g_publishMgr->allCap) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_COAP_REGISTER_CAP_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
DISC_LOGE(DISC_COAP, "register all capability to dfinder failed.");
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP,
@ -244,23 +301,17 @@ static int32_t UnPublish(const PublishOption *option, bool isActive)
}
if (DiscCoapRegisterServiceData(option->capabilityData, option->dataLen,
option->capabilityBitmap[0]) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_END_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
DfxRecordRegisterEnd(option->capabilityData, option->capabilityBitmap[0],
SOFTBUS_DISCOVER_COAP_REGISTER_CAP_FAIL);
DISC_LOGE(DISC_COAP, "register service data to dfinder failed.");
return SOFTBUS_ERR;
}
DfxRecordRegisterEnd(option->capabilityData, option->capabilityBitmap[0], SOFTBUS_OK);
if (isActive && g_publishMgr->isEmpty) {
DiscEventExtra discEventExtra = {
.broadcastType = COAP, .broadcastFreq = option->freq, .result = EVENT_STAGE_RESULT_OK
};
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
if (DiscCoapStopDiscovery() != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_END_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
DfxRecordStopDiscoveryEnd(SOFTBUS_DISCOVER_COAP_STOP_PUBLISH_FAIL);
DISC_LOGE(DISC_COAP, "coap unpublish failed, allCap: %u", g_publishMgr->allCap[0]);
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP,
SOFTBUS_HISYSEVT_DISCOVER_COAP_STOP_DISCOVER_FAIL);
@ -268,6 +319,7 @@ static int32_t UnPublish(const PublishOption *option, bool isActive)
}
}
(void)SoftBusMutexUnlock(&(g_publishMgr->lock));
DfxRecordStopDiscoveryEnd(SOFTBUS_OK);
DISC_LOGI(DISC_COAP, "coap %s unPublish succ, allCap: %u", isActive ?
"active" : "passive", g_publishMgr->allCap[0]);
return SOFTBUS_OK;
@ -275,12 +327,16 @@ static int32_t UnPublish(const PublishOption *option, bool isActive)
static int32_t CoapUnPublish(const PublishOption *option)
{
return UnPublish(option, true);
int32_t ret = UnPublish(option, true);
DfxRecordCoapEnd(false, true, true, (void *)option, ret);
return ret;
}
static int32_t CoapStopScan(const PublishOption *option)
{
return UnPublish(option, false);
int32_t ret = UnPublish(option, false);
DfxRecordCoapEnd(false, false, true, (void *)option, ret);
return ret;
}
static int32_t Discovery(const SubscribeOption *option, bool isActive)
@ -292,12 +348,7 @@ static int32_t Discovery(const SubscribeOption *option, bool isActive)
DISC_CHECK_AND_RETURN_RET_LOGE(SoftBusMutexLock(&(g_subscribeMgr->lock)) == 0, SOFTBUS_LOCK_ERR, DISC_COAP,
"%s discovery mutex lock failed", isActive ? "active" : "passive");
DiscEventExtra discScanEventExtra = { .scanType = COAP };
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
if (RegisterAllCapBitmap(CAPABILITY_NUM, option->capabilityBitmap, g_subscribeMgr, MAX_CAP_NUM) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_START_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DISC_LOGE(DISC_COAP, "merge %s discovery capability failed", isActive ? "active" : "passive");
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_MERGE_CAP_FAIL);
@ -305,15 +356,14 @@ static int32_t Discovery(const SubscribeOption *option, bool isActive)
}
if (g_subscribeMgr->isUpdate) {
if (DiscCoapSetFilterCapability(CAPABILITY_NUM, g_subscribeMgr->allCap) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_START_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordSetFilterEnd(g_subscribeMgr->allCap[0], SOFTBUS_DISCOVER_COAP_SET_FILTER_CAP_FAIL);
DISC_LOGE(DISC_COAP, "set all filter capability to dfinder failed.");
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP,
SOFTBUS_HISYSEVT_DISCOVER_COAP_SET_FILTER_CAP_FAIL);
return SOFTBUS_DISCOVER_COAP_SET_FILTER_CAP_FAIL;
}
DfxRecordSetFilterEnd(g_subscribeMgr->allCap[0], SOFTBUS_OK);
}
if (!isActive) {
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
@ -322,28 +372,27 @@ static int32_t Discovery(const SubscribeOption *option, bool isActive)
}
if (DiscCoapStopDiscovery() != SOFTBUS_OK) {
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordStopDiscoveryEnd(SOFTBUS_DISCOVER_COAP_STOP_DISCOVER_FAIL);
DISC_LOGE(DISC_COAP, "coap stop discovery failed, filters: %u", g_subscribeMgr->allCap[0]);
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_STOP_DISCOVER_FAIL);
return SOFTBUS_DISCOVER_COAP_STOP_DISCOVER_FAIL;
}
DfxRecordStopDiscoveryEnd(SOFTBUS_OK);
DiscCoapOption discCoapOption;
DiscOption discOption = {
.isPublish = false,
.option.subscribeOption = *option,
};
SetDiscCoapOption(&discCoapOption, &discOption, g_subscribeMgr->allCap[0]);
DiscEventExtra discEventExtra = { .broadcastType = COAP, .broadcastFreq = option->freq };
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
if (DiscCoapStartDiscovery(&discCoapOption) != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_START_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordStartDiscoveryEnd(&discCoapOption, SOFTBUS_DISCOVER_COAP_START_DISCOVER_FAIL);
DISC_LOGE(DISC_COAP, "coap start discovery failed, filters: %u", g_subscribeMgr->allCap[0]);
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_START_DISCOVER_FAIL);
return SOFTBUS_DISCOVER_COAP_START_DISCOVER_FAIL;
}
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordStartDiscoveryEnd(&discCoapOption, SOFTBUS_OK);
DISC_LOGI(DISC_COAP, "coap start active discovery succ, filters: %u", g_subscribeMgr->allCap[0]);
return SOFTBUS_OK;
}
@ -362,12 +411,15 @@ static int32_t CoapStartAdvertise(const SubscribeOption *option)
};
DISC_AUDIT(AUDIT_SCENE_COAP_DISCOVERY, extra);
}
DfxRecordCoapEnd(true, true, false, (void *)option, ret);
return ret;
}
static int32_t CoapSubscribe(const SubscribeOption *option)
{
return Discovery(option, false);
int32_t ret = Discovery(option, false);
DfxRecordCoapEnd(true, false, false, (void *)option, ret);
return ret;
}
static int32_t StopDisc(const SubscribeOption *option, bool isActive)
@ -379,12 +431,7 @@ static int32_t StopDisc(const SubscribeOption *option, bool isActive)
DISC_CHECK_AND_RETURN_RET_LOGE(SoftBusMutexLock(&(g_subscribeMgr->lock)) == 0, SOFTBUS_LOCK_ERR,
DISC_COAP, "stop %s discovery mutex lock failed", isActive ? "active" : "passive");
DiscEventExtra discScanEventExtra = { .scanType = COAP, .result = EVENT_STAGE_RESULT_OK };
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
if (UnregisterAllCapBitmap(CAPABILITY_NUM, option->capabilityBitmap, g_subscribeMgr, MAX_CAP_NUM) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_END_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DISC_LOGE(DISC_COAP, "unRegister %s discovery capability failed", isActive ? "active" : "passive");
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP, SOFTBUS_HISYSEVT_DISCOVER_COAP_CANCEL_CAP_FAIL);
@ -392,26 +439,19 @@ static int32_t StopDisc(const SubscribeOption *option, bool isActive)
}
if (g_subscribeMgr->isUpdate) {
if (DiscCoapSetFilterCapability(CAPABILITY_NUM, g_subscribeMgr->allCap) != SOFTBUS_OK) {
discScanEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discScanEventExtra.errcode = SOFTBUS_DISCOVER_END_SCAN_FAIL;
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_START, discScanEventExtra);
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordSetFilterEnd(g_subscribeMgr->allCap[0], SOFTBUS_DISCOVER_COAP_SET_FILTER_CAP_FAIL);
DISC_LOGE(DISC_COAP, "set all filter capability to dfinder failed.");
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP,
SOFTBUS_HISYSEVT_DISCOVER_COAP_SET_FILTER_CAP_FAIL);
return SOFTBUS_DISCOVER_COAP_SET_FILTER_CAP_FAIL;
}
DfxRecordSetFilterEnd(g_subscribeMgr->allCap[0], SOFTBUS_OK);
}
if (isActive && g_subscribeMgr->isEmpty) {
DiscEventExtra discEventExtra = {
.broadcastType = COAP, .broadcastFreq = option->freq, .result = EVENT_STAGE_RESULT_OK
};
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
if (DiscCoapStopDiscovery() != SOFTBUS_OK) {
discEventExtra.result = EVENT_STAGE_RESULT_FAILED;
discEventExtra.errcode = SOFTBUS_DISCOVER_END_BROADCAST_FAIL;
DISC_EVENT(EVENT_SCENE_BROADCAST, EVENT_STAGE_BROADCAST, discEventExtra);
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordStopDiscoveryEnd(SOFTBUS_DISCOVER_COAP_STOP_DISCOVER_FAIL);
DISC_LOGE(DISC_COAP, "coap stop active discovery failed, filters: %u", g_subscribeMgr->allCap[0]);
SoftbusReportDiscFault(SOFTBUS_HISYSEVT_DISC_MEDIUM_COAP,
SOFTBUS_HISYSEVT_DISCOVER_COAP_STOP_DISCOVER_FAIL);
@ -419,6 +459,7 @@ static int32_t StopDisc(const SubscribeOption *option, bool isActive)
}
}
(void)SoftBusMutexUnlock(&(g_subscribeMgr->lock));
DfxRecordStopDiscoveryEnd(SOFTBUS_OK);
DISC_LOGI(DISC_COAP, "coap stop %s discovery succ, filters: %u",
isActive ? "active" : "passive", g_subscribeMgr->allCap[0]);
return SOFTBUS_OK;
@ -426,21 +467,36 @@ static int32_t StopDisc(const SubscribeOption *option, bool isActive)
static int32_t CoapStopAdvertise(const SubscribeOption *option)
{
return StopDisc(option, true);
int32_t ret = StopDisc(option, true);
DfxRecordCoapEnd(false, true, false, (void *)option, ret);
return ret;
}
static int32_t CoapUnsubscribe(const SubscribeOption *option)
{
return StopDisc(option, false);
int32_t ret = StopDisc(option, false);
DfxRecordCoapEnd(false, false, false, (void *)option, ret);
return ret;
}
static void CoapUpdateLocalIp(LinkStatus status)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.ipLinkStatus = status + 1;
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_UPDATE_IP, extra);
DiscCoapUpdateLocalIp(status);
}
static void CoapUpdateLocalDeviceInfo(InfoTypeChanged type)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discType = COAP + 1;
extra.coapChangeType = type + 1;
DISC_EVENT(EVENT_SCENE_COAP, EVENT_STAGE_UPDATE_DEVICE, extra);
if (type == TYPE_LOCAL_DEVICE_NAME) {
DiscCoapUpdateDevName();
} else if (type == TYPE_ACCOUNT) {
@ -505,24 +561,41 @@ static int32_t InitCoapManager(void)
return SOFTBUS_OK;
}
static void DfxRecordCoapInitEnd(int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.initType = COAP + 1;
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
DISC_EVENT(EVENT_SCENE_INIT, EVENT_STAGE_INIT, extra);
}
DiscoveryFuncInterface *DiscCoapInit(DiscInnerCallback *discInnerCb)
{
if (InitCoapManager() != SOFTBUS_OK) {
int32_t ret = InitCoapManager();
if (ret != SOFTBUS_OK) {
DfxRecordCoapInitEnd(ret);
DISC_LOGE(DISC_INIT, "coap manager init failed.");
return NULL;
}
if (DiscNstackxInit() != SOFTBUS_OK) {
ret = DiscNstackxInit();
if (ret != SOFTBUS_OK) {
DfxRecordCoapInitEnd(ret);
DISC_LOGE(DISC_INIT, "dfinder init failed.");
DeinitCoapManager();
return NULL;
}
if (DiscCoapRegisterCb(discInnerCb) != SOFTBUS_OK) {
ret = DiscCoapRegisterCb(discInnerCb);
if (ret != SOFTBUS_OK) {
DfxRecordCoapInitEnd(ret);
DISC_LOGE(DISC_INIT, "register coap callback to dfinder failed.");
DiscCoapDeinit();
return NULL;
}
SoftBusRegDiscVarDump(COAP_PUBLISH_INFO, &CoapPubInfoDump);
SoftBusRegDiscVarDump(COAP_SUBSCRIBE_INFO, &CoapSubInfoDump);
DfxRecordCoapInitEnd(SOFTBUS_OK);
DISC_LOGI(DISC_INIT, "coap discovery init success.");
return &g_discCoapFuncInterface;
}

View File

@ -96,12 +96,12 @@ static void UpdateDiscEventAndReport(DiscEventExtra *extra, const DeviceInfo *de
{
if (device == NULL) {
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_END, *extra);
DISC_LOGI(DISC_CONTROL, "discEventExtra or device is null");
DISC_LOGI(DISC_CONTROL, "device info is null");
return;
}
if (device->addrNum <= CONNECTION_ADDR_WLAN || device->addrNum > CONNECTION_ADDR_MAX) {
DISC_EVENT(EVENT_SCENE_SCAN, EVENT_STAGE_SCAN_END, *extra);
DISC_LOGI(DISC_CONTROL, "unknow device info");
DISC_LOGI(DISC_CONTROL, "unknown device info");
return;
}
@ -119,7 +119,7 @@ static void UpdateDiscEventAndReport(DiscEventExtra *extra, const DeviceInfo *de
extra->peerIp = device->addr[i].info.ip.ip;
break;
default:
DISC_LOGI(DISC_CONTROL, "unknow param type!");
DISC_LOGI(DISC_CONTROL, "unknown param type!");
break;
}
}
@ -143,15 +143,17 @@ static void DfxRecordStartDiscoveryDevice(DiscInfo *infoNode)
static void DfxRecordDeviceFound(DiscInfo *infoNode, const DeviceInfo *device, const InnerDeviceInfoAddtions *addtions)
{
DISC_LOGI(DISC_CONTROL, "record device found");
DiscEventExtra discEventExtra = {
.discType = addtions->medium, .discMode = infoNode->mode, .result = EVENT_STAGE_RESULT_OK
};
if (infoNode->statistics.repTimes == 0) {
uint64_t costTime = SoftBusGetSysTimeMs() - infoNode->statistics.startTime;
SoftbusRecordFirstDiscTime((SoftBusDiscMedium)addtions->medium, costTime);
discEventExtra.costTime = costTime;
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.discMode = infoNode == NULL ? 0 : infoNode->mode;
extra.discType = addtions == NULL ? 0 : addtions->medium + 1;
extra.costTime = (int32_t)costTime;
extra.result = EVENT_STAGE_RESULT_OK;
UpdateDiscEventAndReport(&extra, device);
}
UpdateDiscEventAndReport(&discEventExtra, device);
infoNode->statistics.repTimes++;
infoNode->statistics.devNum++;
}
@ -195,8 +197,21 @@ static int32_t CallSpecificInterfaceFunc(const InnerOption *option,
}
}
static void DfxRecordCallInterfaceStart(const DiscInfo *info, const InterfaceFuncType type)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.interFuncType = type + 1;
if (info != NULL) {
extra.discType = info->medium + 1;
extra.discMode = info->mode;
}
}
static int32_t CallInterfaceByMedium(const DiscInfo *info, const InterfaceFuncType type)
{
DfxRecordCallInterfaceStart(info, type);
switch (info->medium) {
case COAP:
return CallSpecificInterfaceFunc(&(info->option), g_discCoapInterface, info->mode, type);
@ -286,8 +301,6 @@ static void InnerDeviceFound(DiscInfo *infoNode, const DeviceInfo *device,
const InnerDeviceInfoAddtions *additions)
{
if (IsInnerModule(infoNode) == false) {
DiscEventExtra discEventExtra = { .discMode = infoNode->mode, .result = EVENT_STAGE_RESULT_OK };
UpdateDiscEventAndReport(&discEventExtra, device);
(void)infoNode->item->callback.serverCb.OnServerDeviceFound(infoNode->item->packageName, device, additions);
return;
}
@ -541,10 +554,30 @@ static void DumpDiscInfoList(const DiscItem *itemNode)
}
}
static void DfxRecordAddDiscInfoEnd(DiscInfo *info, const char *packageName, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.errcode = reason;
extra.result = (reason == SOFTBUS_OK) ? EVENT_STAGE_RESULT_OK : EVENT_STAGE_RESULT_FAILED;
if (info != NULL) {
extra.discType = info->medium + 1;
extra.discMode = info->mode;
}
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;
}
DISC_EVENT(EVENT_SCENE_DISC, EVENT_STAGE_ADD_INFO, extra);
}
static int32_t AddDiscInfoToList(SoftBusList *serviceList, const char *packageName, const InnerCallback *cb,
DiscInfo *info, ServiceType type)
{
if (SoftBusMutexLock(&(serviceList->lock)) != 0) {
DfxRecordAddDiscInfoEnd(info, packageName, SOFTBUS_LOCK_ERR);
DISC_LOGE(DISC_CONTROL, "lock failed");
return SOFTBUS_LOCK_ERR;
}
@ -563,6 +596,7 @@ static int32_t AddDiscInfoToList(SoftBusList *serviceList, const char *packageNa
DiscInfo *infoNode = NULL;
LIST_FOR_EACH_ENTRY(infoNode, &(itemNode->InfoList), DiscInfo, node) {
if (infoNode->id == info->id) {
DfxRecordAddDiscInfoEnd(info, packageName, SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM);
DISC_LOGI(DISC_CONTROL, "id already existed");
(void)SoftBusMutexUnlock(&(serviceList->lock));
return SOFTBUS_DISCOVER_MANAGER_DUPLICATE_PARAM;
@ -581,6 +615,7 @@ static int32_t AddDiscInfoToList(SoftBusList *serviceList, const char *packageNa
if (exist == false) {
itemNode = CreateDiscItem(serviceList, packageName, cb, type);
if (itemNode == NULL) {
DfxRecordAddDiscInfoEnd(info, packageName, SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE);
DISC_LOGE(DISC_CONTROL, "itemNode create failed");
(void)SoftBusMutexUnlock(&(serviceList->lock));
return SOFTBUS_DISCOVER_MANAGER_ITEM_NOT_CREATE;
@ -592,6 +627,7 @@ static int32_t AddDiscInfoToList(SoftBusList *serviceList, const char *packageNa
AddDiscInfoToCapabilityList(info, type);
}
DfxRecordAddDiscInfoEnd(info, packageName, SOFTBUS_OK);
(void)SoftBusMutexUnlock(&(serviceList->lock));
return SOFTBUS_OK;
}
@ -891,8 +927,35 @@ int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId)
return InnerStopDiscovery(TransferModuleIdToPackageName(moduleId), subscribeId, SUBSCRIBE_INNER_SERVICE);
}
static void DfxRecordServiceStart(int32_t serverType, const char *packageName)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.serverType = serverType;
char pkgName[PKG_NAME_SIZE_MAX] = { 0 };
if (packageName != NULL && strncpy_s(pkgName, PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) {
extra.callerPkg = pkgName;
}
}
static void DfxRecordServiceEnd(int32_t serverType, const char *packageName, int32_t reason)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.serverType = serverType;
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 && strncpy_s(pkgName, PKG_NAME_SIZE_MAX, packageName, PKG_NAME_SIZE_MAX - 1) == EOK) {
extra.callerPkg = pkgName;
}
}
int32_t DiscPublishService(const char *packageName, const PublishInfo *info)
{
DfxRecordServiceStart(SERVER_PUBLISH, packageName);
DISC_CHECK_AND_RETURN_RET_LOGW(packageName != NULL && info != NULL, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
"invalid parameters");
DISC_CHECK_AND_RETURN_RET_LOGW(strlen(packageName) < PKG_NAME_SIZE_MAX,
@ -910,22 +973,27 @@ int32_t DiscPublishService(const char *packageName, const PublishInfo *info)
if (ret != SOFTBUS_OK) {
FreeDiscInfo(infoNode, PUBLISH_SERVICE);
}
DfxRecordServiceEnd(SERVER_PUBLISH, packageName, ret);
return ret;
}
int32_t DiscUnPublishService(const char *packageName, int32_t publishId)
{
DfxRecordServiceStart(SERVER_STOP_PUBLISH, packageName);
DISC_CHECK_AND_RETURN_RET_LOGW(packageName != NULL && strlen(packageName) < PKG_NAME_SIZE_MAX,
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid parameters");
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
"manager is not inited");
return InnerUnPublishService(packageName, publishId, PUBLISH_SERVICE);
int32_t ret = InnerUnPublishService(packageName, publishId, PUBLISH_SERVICE);
DfxRecordServiceEnd(SERVER_STOP_PUBLISH, packageName, ret);
return ret;
}
int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info,
const IServerDiscInnerCallback *cb)
{
DfxRecordServiceStart(SERVER_DISCOVERY, packageName);
DISC_CHECK_AND_RETURN_RET_LOGW(packageName != NULL && strlen(packageName) < PKG_NAME_SIZE_MAX,
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid package name");
DISC_CHECK_AND_RETURN_RET_LOGW(info != NULL && cb != NULL, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
@ -943,17 +1011,21 @@ int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info,
if (ret != SOFTBUS_OK) {
FreeDiscInfo(infoNode, SUBSCRIBE_SERVICE);
}
DfxRecordServiceEnd(SERVER_DISCOVERY, packageName, ret);
return ret;
}
int32_t DiscStopDiscovery(const char *packageName, int32_t subscribeId)
{
DfxRecordServiceStart(SERVER_STOP_DISCOVERY, packageName);
DISC_CHECK_AND_RETURN_RET_LOGW(packageName != NULL && strlen(packageName) < PKG_NAME_SIZE_MAX,
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid parameters");
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
"manager is not inited");
return InnerStopDiscovery(packageName, subscribeId, SUBSCRIBE_SERVICE);
int32_t ret = InnerStopDiscovery(packageName, subscribeId, SUBSCRIBE_SERVICE);
DfxRecordServiceEnd(SERVER_STOP_DISCOVERY, packageName, ret);
return ret;
}
void DiscLinkStatusChanged(LinkStatus status, ExchangeMedium medium)

View File

@ -48,6 +48,14 @@ DISCOVER_BEHAVIOR:
BIZ_STAGE: {type: INT32, desc: business stage }
STAGE_RES: {type: INT32, desc: stage result }
ERROR_CODE: { type: INT32, desc: error code }
INIT_TYPE: { type: INT32, desc: init type }
SERVER_TYPE: { type: INT32, desc: server type }
INTERFACE_FUNC_TYPE: { type: INT32, desc: interface func type }
CAPABILITY_BIT: { type: INT32, desc: capability bit map }
CAPABILITY_DATA: { type: INT32, desc: capability data }
BLE_TURN_STATE: { type: INT32, desc: ble turn state }
IP_LINK_STATUS: { type: INT32, desc: ip link status }
COAP_CHANGE_TYPE: { type: INT32, desc: coap change type }
BROADCAST_TYPE: { type: INT32, desc: broadcast type }
BROADCAST_FREQ: { type: INT32, desc: broadcast frequency }
SCAN_TYPE: { type: INT32, desc: scan type }
@ -56,14 +64,11 @@ DISCOVER_BEHAVIOR:
DISC_MODE: { type: INT32, desc: discovery mode }
FIRST_DISCOVERY_TIME: { type: INT32, desc: time consuming to discover for the first time }
LOCAL_NET_ID: { type: STRING, desc: local device net id }
LOCAL_UDID: { type: STRING, desc: local device udid }
LOCAL_DEV_TYPE: { type: STRING, desc: local device type }
PEER_IP: { type: STRING, desc: peer device ip }
PEER_BR_MAC: { type: STRING, desc: peer device br mac }
PEER_BLE_MAC: { type: STRING, desc: peer device ble mac }
PEER_WIFI_MAC: { type: STRING, desc: peer device wifi mac }
PEER_PORT: { type: STRING, desc: peer device port }
PEER_UDID: { type: STRING, desc: peer device udid }
PEER_NET_ID: { type: STRING, desc: peer device net id }
PEER_DEV_TYPE: { type: STRING, desc: peer device type }
@ -121,6 +126,9 @@ BUSCENTER_BEHAVIOR:
BIZ_STAGE: {type: INT32, desc: business stage }
STAGE_RES: {type: INT32, desc: stage result }
ERROR_CODE: { type: INT32, desc: error code }
DISC_SERVER_TYPE: {type: INT32, desc: disc server type }
GEAR_CYCLE: {type: INT32, desc: gear cycle }
GEAR_DURATION: {type: INT32, desc: gear duration }
CONN_ID: { type: INT32, desc: connection id }
AUTH_TYPE: { type: INT32, desc: auth type }
AUTH_ID: { type: INT32, desc: auth id }

View File

@ -20,6 +20,7 @@
#include "client_bus_center_manager.h"
#include "client_trans_session_manager.h"
#include "lnn_event.h"
#include "lnn_log.h"
#include "softbus_adapter_mem.h"
#include "softbus_client_frame_manager.h"
@ -136,6 +137,80 @@ static int32_t SubscribeInfoCheck(const SubscribeInfo *info)
return SOFTBUS_OK;
}
static void DfxRecordSdkJoinLnnEnd(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;
}
LNN_EVENT(EVENT_SCENE_LNN, EVENT_STAGE_LNN_JOIN_SDK, extra);
}
static void DfxRecordSdkLeaveLnnEnd(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;
}
LNN_EVENT(EVENT_SCENE_LNN, EVENT_STAGE_LNN_LEAVE_SDK, extra);
}
static void DfxRecordSdkShiftGearStart(const char *packageName, const GearMode *mode)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
if (mode != NULL) {
extra.gearCycle = mode->cycle;
extra.gearDuration = mode->duration;
}
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_LNN, EVENT_STAGE_LNN_SHIFT_GEAR, extra);
}
static void DfxRecordLnnDiscServerEnd(int32_t serverType, const char *packageName, int32_t reason)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
extra.discServerType = serverType;
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;
}
LNN_EVENT(EVENT_SCENE_LNN, EVENT_STAGE_LNN_DISC_SDK, extra);
}
static void DfxRecordRegNodeStart(const char *packageName)
{
LnnEventExtra extra = { 0 };
LnnEventExtraInit(&extra);
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_LNN, EVENT_STAGE_LNN_REG_NODE, extra);
}
int32_t GetAllNodeDeviceInfo(const char *pkgName, NodeBasicInfo **info, int32_t *infoNum)
{
if (pkgName == NULL || info == NULL || infoNum == NULL) {
@ -212,27 +287,35 @@ int32_t SetNodeDataChangeFlag(const char *pkgName, const char *networkId, uint16
int32_t JoinLNN(const char *pkgName, ConnectionAddr *target, OnJoinLNNResult cb)
{
if (pkgName == NULL || target == NULL || cb == NULL) {
DfxRecordSdkJoinLnnEnd(pkgName, SOFTBUS_INVALID_PARAM);
LNN_LOGE(LNN_STATE, "params are NULL");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = CommonInit(pkgName);
if (ret != SOFTBUS_OK) {
DfxRecordSdkJoinLnnEnd(pkgName, ret);
return ret;
}
return JoinLNNInner(pkgName, target, cb);
ret = JoinLNNInner(pkgName, target, cb);
DfxRecordSdkJoinLnnEnd(pkgName, ret);
return ret;
}
int32_t LeaveLNN(const char *pkgName, const char *networkId, OnLeaveLNNResult cb)
{
if (!IsValidString(networkId, NETWORK_ID_BUF_LEN) || cb == NULL || !IsValidString(pkgName, PKG_NAME_SIZE_MAX - 1)) {
DfxRecordSdkLeaveLnnEnd(pkgName, SOFTBUS_INVALID_PARAM);
LNN_LOGE(LNN_STATE, "networkId or cb is NULL");
return SOFTBUS_INVALID_PARAM;
}
return LeaveLNNInner(pkgName, networkId, cb);
int32_t ret = LeaveLNNInner(pkgName, networkId, cb);
DfxRecordSdkLeaveLnnEnd(pkgName, ret);
return ret;
}
int32_t RegNodeDeviceStateCb(const char *pkgName, INodeStateCb *callback)
{
DfxRecordRegNodeStart(pkgName);
if (pkgName == NULL || IsValidNodeStateCb(callback) == false) {
LNN_LOGE(LNN_STATE, "invalid parameters");
return SOFTBUS_INVALID_PARAM;
@ -284,59 +367,77 @@ int32_t StopTimeSync(const char *pkgName, const char *targetNetworkId)
int32_t PublishLNN(const char *pkgName, const PublishInfo *info, const IPublishCb *cb)
{
if (pkgName == NULL || info == NULL || cb == NULL) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_PUBLISH, pkgName, SOFTBUS_INVALID_PARAM);
LNN_LOGE(LNN_STATE, "invalid parameters");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = CommonInit(pkgName);
if (ret != SOFTBUS_OK) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_PUBLISH, pkgName, ret);
return ret;
}
if (PublishInfoCheck(info) != SOFTBUS_OK) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_PUBLISH, pkgName, SOFTBUS_INVALID_PARAM);
return SOFTBUS_INVALID_PARAM;
}
return PublishLNNInner(pkgName, info, cb);
ret = PublishLNNInner(pkgName, info, cb);
DfxRecordLnnDiscServerEnd(DISC_SERVER_PUBLISH, pkgName, ret);
return ret;
}
int32_t StopPublishLNN(const char *pkgName, int32_t publishId)
{
if (pkgName == NULL) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_STOP_PUBLISH, pkgName, SOFTBUS_INVALID_PARAM);
LNN_LOGE(LNN_STATE, "invalid parameters");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = CommonInit(pkgName);
if (ret != SOFTBUS_OK) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_STOP_PUBLISH, pkgName, ret);
return ret;
}
return StopPublishLNNInner(pkgName, publishId);
ret = StopPublishLNNInner(pkgName, publishId);
DfxRecordLnnDiscServerEnd(DISC_SERVER_STOP_PUBLISH, pkgName, ret);
return ret;
}
int32_t RefreshLNN(const char *pkgName, const SubscribeInfo *info, const IRefreshCallback *cb)
{
if (pkgName == NULL || info == NULL || cb == NULL) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_DISCOVERY, pkgName, SOFTBUS_INVALID_PARAM);
LNN_LOGE(LNN_STATE, "invalid parameters");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = CommonInit(pkgName);
if (ret != SOFTBUS_OK) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_DISCOVERY, pkgName, ret);
return ret;
}
if (SubscribeInfoCheck(info) != SOFTBUS_OK) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_DISCOVERY, pkgName, SOFTBUS_INVALID_PARAM);
return SOFTBUS_INVALID_PARAM;
}
return RefreshLNNInner(pkgName, info, cb);
ret = RefreshLNNInner(pkgName, info, cb);
DfxRecordLnnDiscServerEnd(DISC_SERVER_DISCOVERY, pkgName, ret);
return ret;
}
int32_t StopRefreshLNN(const char *pkgName, int32_t refreshId)
{
if (pkgName == NULL) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, SOFTBUS_INVALID_PARAM);
LNN_LOGE(LNN_STATE, "invalid parameters");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = CommonInit(pkgName);
if (ret != SOFTBUS_OK) {
DfxRecordLnnDiscServerEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, ret);
return ret;
}
return StopRefreshLNNInner(pkgName, refreshId);
ret = StopRefreshLNNInner(pkgName, refreshId);
DfxRecordLnnDiscServerEnd(DISC_SERVER_STOP_DISCOVERY, pkgName, ret);
return ret;
}
int32_t ActiveMetaNode(const char *pkgName, const MetaNodeConfigInfo *info, char *metaNodeId)
@ -380,6 +481,7 @@ int32_t GetAllMetaNodeInfo(const char *pkgName, MetaNodeInfo *infos, int32_t *in
int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId, const GearMode *mode)
{
DfxRecordSdkShiftGearStart(pkgName, mode);
if (pkgName == NULL || callerId == NULL || mode == NULL) {
LNN_LOGE(LNN_STATE, "invalid shift lnn gear para");
return SOFTBUS_INVALID_PARAM;

View File

@ -15,13 +15,18 @@
#include "client_disc_service.h"
#include <securec.h>
#include <stdbool.h>
#include <string.h>
#include "client_disc_manager.h"
#include "disc_event.h"
#include "disc_log.h"
#include "softbus_adapter_mem.h"
#include "softbus_client_frame_manager.h"
#include "softbus_def.h"
#include "softbus_errcode.h"
#include "softbus_utils.h"
static int32_t PublishInfoCheck(const PublishInfo *info)
{
@ -92,78 +97,115 @@ static int32_t SubscribeInfoCheck(const SubscribeInfo *info)
return SOFTBUS_OK;
}
static void DfxRecordDiscServerEnd(int32_t serverType, int32_t reason, const char *packageName)
{
DiscEventExtra extra = { 0 };
DiscEventExtraInit(&extra);
extra.serverType = serverType;
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;
}
DISC_EVENT(EVENT_SCENE_DISC, EVENT_STAGE_DISC_SDK, extra);
}
int PublishService(const char *packageName, const PublishInfo *info, const IPublishCallback *cb)
{
if ((packageName == NULL) || (strlen(packageName) >= PKG_NAME_SIZE_MAX) || (info == NULL) || (cb == NULL)) {
DfxRecordDiscServerEnd(SERVER_PUBLISH, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "invalid parameter:null");
return SOFTBUS_INVALID_PARAM;
}
if (InitSoftBus(packageName) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_PUBLISH, SOFTBUS_DISCOVER_NOT_INIT, packageName);
DISC_LOGE(DISC_SDK, "init softbus err");
return SOFTBUS_DISCOVER_NOT_INIT;
}
if (CheckPackageName(packageName) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_PUBLISH, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "check packageName failed");
return SOFTBUS_INVALID_PARAM;
}
if (PublishInfoCheck(info) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_PUBLISH, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "publish infoCheck failed");
return SOFTBUS_INVALID_PARAM;
}
return PublishServiceInner(packageName, info, cb);
int32_t ret = PublishServiceInner(packageName, info, cb);
DfxRecordDiscServerEnd(SERVER_PUBLISH, ret, packageName);
return ret;
}
int UnPublishService(const char *packageName, int publishId)
{
if ((packageName == NULL) || (strlen(packageName) >= PKG_NAME_SIZE_MAX)) {
DfxRecordDiscServerEnd(SERVER_STOP_PUBLISH, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "invalid packageName");
return SOFTBUS_INVALID_PARAM;
}
if (CheckPackageName(packageName) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_STOP_PUBLISH, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "check packageName failed");
return SOFTBUS_INVALID_PARAM;
}
return UnpublishServiceInner(packageName, publishId);
int32_t ret = UnpublishServiceInner(packageName, publishId);
DfxRecordDiscServerEnd(SERVER_STOP_PUBLISH, ret, packageName);
return ret;
}
int StartDiscovery(const char *packageName, const SubscribeInfo *info, const IDiscoveryCallback *cb)
{
if ((packageName == NULL) || (strlen(packageName) >= PKG_NAME_SIZE_MAX) || (info == NULL) || (cb == NULL)) {
DfxRecordDiscServerEnd(SERVER_DISCOVERY, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, " invalid parameter:null");
return SOFTBUS_INVALID_PARAM;
}
if (InitSoftBus(packageName) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_DISCOVERY, SOFTBUS_DISCOVER_NOT_INIT, packageName);
DISC_LOGE(DISC_SDK, "init softbus err");
return SOFTBUS_DISCOVER_NOT_INIT;
}
if (CheckPackageName(packageName) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_DISCOVERY, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "check packageName failed");
return SOFTBUS_INVALID_PARAM;
}
if (SubscribeInfoCheck(info) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_DISCOVERY, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "subscribe infoCheck failed");
return SOFTBUS_INVALID_PARAM;
}
return StartDiscoveryInner(packageName, info, cb);
int32_t ret = StartDiscoveryInner(packageName, info, cb);
DfxRecordDiscServerEnd(SERVER_DISCOVERY, ret, packageName);
return ret;
}
int StopDiscovery(const char *packageName, int subscribeId)
{
if ((packageName == NULL) || (strlen(packageName) >= PKG_NAME_SIZE_MAX)) {
DfxRecordDiscServerEnd(SERVER_STOP_DISCOVERY, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "invalid packageName:null");
return SOFTBUS_INVALID_PARAM;
}
if (CheckPackageName(packageName) != SOFTBUS_OK) {
DfxRecordDiscServerEnd(SERVER_STOP_DISCOVERY, SOFTBUS_INVALID_PARAM, packageName);
DISC_LOGE(DISC_SDK, "check packageName failed");
return SOFTBUS_INVALID_PARAM;
}
return StopDiscoveryInner(packageName, subscribeId);
int32_t ret = StopDiscoveryInner(packageName, subscribeId);
DfxRecordDiscServerEnd(SERVER_STOP_DISCOVERY, ret, packageName);
return ret;
}

View File

@ -38,6 +38,38 @@ MATCHER_P2(DiscValidParamArrayMatcher, inExtra, validSize, "disc valid param arr
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.initType);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.serverType);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.interFuncType);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.capabilityBit);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_STREQ(params[index].v.s, extra.capabilityData);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.bleTurnState);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.ipLinkStatus);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.coapChangeType);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_EQ(params[index].v.i32, extra.broadcastType);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
@ -73,16 +105,6 @@ MATCHER_P2(DiscValidParamArrayMatcher, inExtra, validSize, "disc valid param arr
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
Anonymize(extra.localUdid, &anonyStr);
EXPECT_STREQ(params[index].v.s, anonyStr);
AnonymizeFree(anonyStr);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
EXPECT_STREQ(params[index].v.s, extra.localDeviceType);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
Anonymize(extra.peerIp, &anonyStr);
EXPECT_STREQ(params[index].v.s, anonyStr);
AnonymizeFree(anonyStr);
@ -111,12 +133,6 @@ MATCHER_P2(DiscValidParamArrayMatcher, inExtra, validSize, "disc valid param arr
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
Anonymize(extra.peerUdid, &anonyStr);
EXPECT_STREQ(params[index].v.s, anonyStr);
AnonymizeFree(anonyStr);
++index;
EXPECT_STREQ(params[index].name, g_discAssigners[index].name);
EXPECT_EQ(params[index].t, g_discAssigners[index].type);
Anonymize(extra.peerNetworkId, &anonyStr);
EXPECT_STREQ(params[index].v.s, anonyStr);
AnonymizeFree(anonyStr);

View File

@ -39,6 +39,18 @@ 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.discServerType);
++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.gearCycle);
++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.gearDuration);
++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.connectionId);
++index;
EXPECT_STREQ(params[index].name, g_lnnAssigners[index].name);

View File

@ -61,22 +61,27 @@ HWTEST_F(DiscEventTest, DiscEventTest002, TestSize.Level0)
DiscEventExtra validExtra = {
.result = 1,
.errcode = 2,
.broadcastType = 3,
.broadcastFreq = 4,
.scanType = 5,
.initType = 3,
.serverType = 4,
.interFuncType = 5,
.capabilityBit = 6,
.capabilityData = "testCapabilityData",
.bleTurnState = 8,
.ipLinkStatus = 9,
.coapChangeType = 10,
.broadcastType = 11,
.broadcastFreq = 12,
.scanType = 13,
.scanCycle = "testScanCycle",
.discType = 7,
.discMode = 8,
.costTime = 9,
.discType = 15,
.discMode = 16,
.costTime = 17,
.localNetworkId = "a8ynvpdaihw1f6nknjd2hkfhxljxypkr6kvjsbhnhpp16974uo4fvsrpfa6t50fm",
.localUdid = "a8ynvpdaihw1f6nknjd2hkfhxljxypkr6kvjsbhnhpp16974uo4fvsrpfa6t50fm",
.localDeviceType = "testLocalDeviceType",
.peerIp = "10.11.12.1",
.peerBrMac = "dd:15:bc:b9:f2:05",
.peerBleMac = "dd:15:bc:b9:f2:04",
.peerWifiMac = "dd:15:bc:b9:f2:04",
.peerPort = "testPeerPort",
.peerUdid = "testPeerUdid",
.peerNetworkId = "a8ynvpdaihw1f6nknjd2hkfhxljxypkr6kvjsbhnhpp16974uo4fvsrpfa6t50fm",
.peerDeviceType = "a8ynvpdaihw1f6nknjd2hkfhxljxypkr6kvjsbhnhpp16974uo4fvsrpfa6t50fm",
.callerPkg = "testCallerPkg",
@ -102,22 +107,27 @@ HWTEST_F(DiscEventTest, DiscEventTest003, TestSize.Level0)
DiscEventExtra invalidExtra = {
.result = -1, // valid
.errcode = -2, // valid
.broadcastType = -3,
.broadcastFreq = -4,
.scanType = -5,
.initType = -3,
.serverType = -4,
.interFuncType = -5,
.capabilityBit = -6,
.capabilityData = "",
.bleTurnState = -8,
.ipLinkStatus = -9,
.coapChangeType = -10,
.broadcastType = -11,
.broadcastFreq = -12,
.scanType = -13,
.scanCycle = "",
.discType = -7,
.discMode = -8,
.costTime = -9,
.discType = -15,
.discMode = -16,
.costTime = -17,
.localNetworkId = "",
.localUdid = "",
.localDeviceType = "",
.peerIp = "",
.peerBrMac = "",
.peerBleMac = "",
.peerWifiMac = "",
.peerPort = "",
.peerUdid = "",
.peerNetworkId = "",
.peerDeviceType = "\0",
.callerPkg = nullptr,

View File

@ -61,12 +61,15 @@ HWTEST_F(LnnEventTest, LnnEventTest002, TestSize.Level0)
LnnEventExtra validExtra = {
.result = 1,
.errcode = 2,
.connectionId = 3,
.authType = 4,
.authId = 5,
.lnnType = 6,
.onlineNum = 7,
.peerDeviceAbility = 8,
.discServerType = 3,
.gearCycle = 4,
.gearDuration = 5,
.connectionId = 6,
.authType = 7,
.authId = 8,
.lnnType = 9,
.onlineNum = 10,
.peerDeviceAbility = 11,
.peerDeviceInfo = "testPeerDeviceInfo",
.peerIp = "10.11.12.1",
.peerBrMac = "dd:15:bc:b9:f2:04",
@ -100,12 +103,15 @@ HWTEST_F(LnnEventTest, LnnEventTest003, TestSize.Level0)
LnnEventExtra invalidExtra = {
.result = -1, // vaild
.errcode = -2, // valid
.connectionId = -3,
.authType = -4,
.authId = -5,
.lnnType = -6,
.onlineNum = -7,
.peerDeviceAbility = -8,
.discServerType = -3,
.gearCycle = -4,
.gearDuration = -5,
.connectionId = -6,
.authType = -7,
.authId = -8,
.lnnType = -9,
.onlineNum = -10,
.peerDeviceAbility = -11,
.peerDeviceInfo = "",
.peerIp = "",
.peerBrMac = "",
@ -125,7 +131,7 @@ HWTEST_F(LnnEventTest, LnnEventTest003, TestSize.Level0)
HiSysEvent_Write(_, _, StrEq(SOFTBUS_EVENT_DOMAIN), StrEq(LNN_EVENT_NAME), Eq(SOFTBUS_EVENT_TYPE_BEHAVIOR),
LnnInvalidParamArrayMatcher(invalidExtra, VALID_EXTRA_SIZE), ParamArraySizeMatcher(VALID_EXTRA_SIZE)))
.Times(1);
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN_START, invalidExtra);
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN, invalidExtra);
}
/**
@ -144,7 +150,7 @@ HWTEST_F(LnnEventTest, LnnEventTest004, TestSize.Level0)
HiSysEvent_Write(_, _, StrEq(SOFTBUS_EVENT_DOMAIN), StrEq(LNN_EVENT_NAME), Eq(SOFTBUS_EVENT_TYPE_BEHAVIOR),
LnnInvalidParamArrayMatcher(emptyExtra, VALID_EXTRA_SIZE), ParamArraySizeMatcher(VALID_EXTRA_SIZE)))
.Times(1);
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN_END, emptyExtra);
LNN_EVENT(EVENT_SCENE_LEAVE_LNN, EVENT_STAGE_LEAVE_LNN, emptyExtra);
}
/**