lane log optimize

Signed-off-by: 15958027009 <xiguodong1@huawei.com>
This commit is contained in:
15958027009 2024-10-10 19:26:05 +08:00
parent 16646b0180
commit f97e2813aa
4 changed files with 27 additions and 50 deletions

View File

@ -850,13 +850,15 @@ static int32_t ConvertUdidToHexStr(const char *peerUdid, char *udidHashStr, uint
return SOFTBUS_INVALID_PARAM;
}
uint8_t peerUdidHash[UDID_HASH_LEN] = {0};
if (SoftBusGenerateStrHash((const unsigned char*)peerUdid, strlen(peerUdid), peerUdidHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "generate udidHash fail");
return SOFTBUS_LANE_GET_LEDGER_INFO_ERR;
int32_t ret = SoftBusGenerateStrHash((const unsigned char*)peerUdid, strlen(peerUdid), peerUdidHash);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "generate udidHash fail, ret=%{public}d", ret);
return ret;
}
if (ConvertBytesToHexString(udidHashStr, hashStrLen, peerUdidHash, UDID_SHORT_HASH_LEN_TMP) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "convert bytes to string fail");
return SOFTBUS_BYTE_CONVERT_FAIL;
ret = ConvertBytesToHexString(udidHashStr, hashStrLen, peerUdidHash, UDID_SHORT_HASH_LEN_TMP);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "convert bytes to string fail, ret=%{public}d", ret);
return ret;
}
return SOFTBUS_OK;
}
@ -894,11 +896,7 @@ static int32_t FetchLaneResourceByDevId(const char *peerNetworkId, LaneLinkType
}
}
LaneUnlock();
char *anonyPeerNetworkId = NULL;
Anonymize(peerNetworkId, &anonyPeerNetworkId);
LNN_LOGI(LNN_LANE, "not found lane resource, peerNetworkId=%{public}s, linkType=%{public}d, "
"isSameDevice=%{public}d", AnonymizeWrapper(anonyPeerNetworkId), type, isSameDevice);
AnonymizeFree(anonyPeerNetworkId);
LNN_LOGI(LNN_LANE, "not found lane resource, linkType=%{public}d, isSameDevice=%{public}d", type, isSameDevice);
return SOFTBUS_LANE_RESOURCE_NOT_FOUND;
}
@ -931,11 +929,7 @@ static int32_t FetchLaneResourceByDevIdHash(const char *udidHashStr, LaneLinkTyp
}
}
LaneUnlock();
char *anonyUdidHashStr = NULL;
Anonymize(udidHashStr, &anonyUdidHashStr);
LNN_LOGI(LNN_LANE, "not found lane resource, udidHashStr=%{public}s, linkType=%{public}d, "
"isSameDevice=%{public}d", AnonymizeWrapper(anonyUdidHashStr), type, isSameDevice);
AnonymizeFree(anonyUdidHashStr);
LNN_LOGI(LNN_LANE, "not found lane resource, linkType=%{public}d, isSameDevice=%{public}d", type, isSameDevice);
return SOFTBUS_LANE_RESOURCE_NOT_FOUND;
}
@ -945,19 +939,10 @@ int32_t QueryOtherLaneResource(const DevIdentifyInfo *inputInfo, LaneLinkType ty
LNN_LOGE(LNN_LANE, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
int32_t ret = SOFTBUS_OK;
if (inputInfo->type == IDENTIFY_TYPE_DEV_ID) {
ret = FetchLaneResourceByDevId(inputInfo->devInfo.peerDevId, type, false);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "fetch lane resource fail by deviceId");
}
return ret;
return FetchLaneResourceByDevId(inputInfo->devInfo.peerDevId, type, false);
} else if (inputInfo->type == IDENTIFY_TYPE_UDID_HASH && strlen(inputInfo->devInfo.udidHash) > 0) {
ret = FetchLaneResourceByDevIdHash(inputInfo->devInfo.udidHash, type, false);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "fetch lane resource fail by udidHashStr");
}
return ret;
return FetchLaneResourceByDevIdHash(inputInfo->devInfo.udidHash, type, false);
}
LNN_LOGE(LNN_LANE, "no fetch lane resource");
return SOFTBUS_LANE_RESOURCE_NOT_FOUND;
@ -973,14 +958,12 @@ bool FindLaneResourceByDevInfo(const DevIdentifyInfo *inputInfo, LaneLinkType ty
if (inputInfo->type == IDENTIFY_TYPE_DEV_ID) {
ret = FetchLaneResourceByDevId(inputInfo->devInfo.peerDevId, type, true);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "fetch lane resource fail");
return false;
}
return true;
} else if (inputInfo->type == IDENTIFY_TYPE_UDID_HASH && strlen(inputInfo->devInfo.udidHash) > 0) {
ret = FetchLaneResourceByDevIdHash(inputInfo->devInfo.udidHash, type, true);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "fetch lane resource fail");
return false;
}
return true;

View File

@ -122,7 +122,7 @@ static int32_t RemoveConflictInfoTimeliness(const SoftBusMessage *msg, void *dat
}
if (srcInfo->conflictType == dstInfo->conflictType &&
memcmp(&srcInfo->identifyInfo, &dstInfo->identifyInfo, sizeof(DevIdentifyInfo)) == 0) {
LNN_LOGI(LNN_LANE, "remove conflict info timeliness message success");
LNN_LOGI(LNN_LANE, "remove timeliness msg succ");
SoftBusFree(srcInfo);
return SOFTBUS_OK;
}
@ -138,8 +138,8 @@ void RemoveConflictInfoTimelinessMsg(const DevIdentifyInfo *inputInfo, LinkConfl
char *anonyDevInfo = NULL;
Anonymize(inputInfo->type == IDENTIFY_TYPE_UDID_HASH ?
inputInfo->devInfo.udidHash : inputInfo->devInfo.peerDevId, &anonyDevInfo);
LNN_LOGI(LNN_LANE, "remove conflict info timeliness msg, identifyType=%{public}d, devInfo=%{public}s,"
" conflictType=%{public}d", inputInfo->type, AnonymizeWrapper(anonyDevInfo), conflictType);
LNN_LOGI(LNN_LANE, "remove timeliness msg, identifyType=%{public}d, devInfo=%{public}s, conflictType=%{public}d",
inputInfo->type, AnonymizeWrapper(anonyDevInfo), conflictType);
AnonymizeFree(anonyDevInfo);
LinkConflictInfo conflictItem;
(void)memset_s(&conflictItem, sizeof(LinkConflictInfo), 0, sizeof(LinkConflictInfo));
@ -330,7 +330,7 @@ int32_t AddLinkConflictInfo(const LinkConflictInfo *inputInfo)
}
int32_t ret = UpdateExistsLinkConflictInfo(inputInfo);
if (ret == SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "update exists link conflict info success, update conflict info timeliness");
LNN_LOGE(LNN_LANE, "update link conflict info succ");
RemoveConflictInfoTimelinessMsg(&inputInfo->identifyInfo, inputInfo->conflictType);
ret = PostConflictInfoTimelinessMsg(&inputInfo->identifyInfo, inputInfo->conflictType);
if (ret != SOFTBUS_OK) {
@ -357,19 +357,21 @@ int32_t AddLinkConflictInfo(const LinkConflictInfo *inputInfo)
static void GenerateConflictInfoWithDevIdHash(const DevIdentifyInfo *inputInfo, DevIdentifyInfo *outputInfo)
{
char peerUdid[UDID_BUF_LEN] = {0};
if (LnnGetRemoteStrInfo(inputInfo->devInfo.peerDevId, STRING_KEY_DEV_UDID,
peerUdid, UDID_BUF_LEN) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "get udid error");
int32_t ret = LnnGetRemoteStrInfo(inputInfo->devInfo.peerDevId, STRING_KEY_DEV_UDID, peerUdid, UDID_BUF_LEN);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "get udid error, ret=%{public}d", ret);
return;
}
uint8_t udidHash[UDID_HASH_LEN] = {0};
if (SoftBusGenerateStrHash((const unsigned char*)peerUdid, strlen(peerUdid), udidHash) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "generate udidHash fail");
ret = SoftBusGenerateStrHash((const unsigned char*)peerUdid, strlen(peerUdid), udidHash);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "generate udidHash fail, ret=%{public}d", ret);
return;
}
if (ConvertBytesToHexString(outputInfo->devInfo.udidHash, CONFLICT_UDIDHASH_STR_LEN + 1, udidHash,
CONFLICT_SHORT_HASH_LEN_TMP) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "convert bytes to string fail");
ret = ConvertBytesToHexString(outputInfo->devInfo.udidHash, CONFLICT_UDIDHASH_STR_LEN + 1, udidHash,
CONFLICT_SHORT_HASH_LEN_TMP);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "convert bytes to string fail, ret=%{public}d", ret);
return;
}
}

View File

@ -264,7 +264,7 @@ static int32_t GetListScore(const char *networkId, uint32_t expectedBw, const La
}
LinkAttribute *linkAttr = GetLinkAttrByLinkType(resList[i]);
resListScore[resList[i]] = linkAttr->getLinkScore(networkId, expectedBw);
LNN_LOGI(LNN_LANE, "LaneLinkType=%{public}d, Score=%{public}d",
LNN_LOGD(LNN_LANE, "LaneLinkType=%{public}d, Score=%{public}d",
resList[i], resListScore[resList[i]]);
}
return SOFTBUS_OK;

View File

@ -112,10 +112,6 @@ static int32_t Wlan2P4GCapCheck(const char *networkId)
{
int32_t ret = NodeStateCheck(networkId);
if (ret != SOFTBUS_OK) {
char *anonyNetworkId = NULL;
Anonymize(networkId, &anonyNetworkId);
LNN_LOGE(LNN_LANE, "peer device wifi not online, networkId=%{public}s", AnonymizeWrapper(anonyNetworkId));
AnonymizeFree(anonyNetworkId);
return ret;
}
SoftBusBand band = SoftBusGetLinkBand();
@ -146,10 +142,6 @@ static int32_t Wlan5GCapCheck(const char *networkId)
{
int32_t ret = NodeStateCheck(networkId);
if (ret != SOFTBUS_OK) {
char *anonyNetworkId = NULL;
Anonymize(networkId, &anonyNetworkId);
LNN_LOGE(LNN_LANE, "peer device wifi not online, networkId=%{public}s", AnonymizeWrapper(anonyNetworkId));
AnonymizeFree(anonyNetworkId);
return ret;
}
SoftBusBand band = SoftBusGetLinkBand();