mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 08:49:59 +00:00
commit
6bf2ca7b8f
@ -1557,12 +1557,51 @@ static void GuideChannelDetect(uint32_t authRequestId, AuthHandle authHandle)
|
||||
AuthChannelDetectSucc(laneReqId, authRequestId, authHandle);
|
||||
}
|
||||
|
||||
static int32_t GetPreferAuthByType(const char *networkId, AuthLinkType type, AuthConnInfo *connInfo, bool isMetaAuth)
|
||||
{
|
||||
char uuid[UDID_BUF_LEN] = {0};
|
||||
if (LnnGetRemoteStrInfo(networkId, STRING_KEY_UUID, uuid, sizeof(uuid)) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get peer uuid fail");
|
||||
return SOFTBUS_LANE_GET_LEDGER_INFO_ERR;
|
||||
}
|
||||
return AuthGetConnInfoByType(uuid, type, connInfo, isMetaAuth);
|
||||
}
|
||||
|
||||
static int32_t GetCurrentGuideType(uint32_t laneReqId, LaneLinkType linkType, WdGuideType *guideType)
|
||||
{
|
||||
WdGuideInfo guideInfo = {0};
|
||||
if (GetGuideInfo(laneReqId, linkType, &guideInfo) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get guide channel info fail.");
|
||||
return SOFTBUS_LANE_NOT_FOUND;
|
||||
}
|
||||
*guideType = guideInfo.guideList[guideInfo.guideIdx];
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t GetAuthConnInfo(const LinkRequest *request, uint32_t laneReqId, AuthConnInfo *connInfo, bool isMetaAuth)
|
||||
{
|
||||
WdGuideType guideType = LANE_CHANNEL_BUTT;
|
||||
int32_t ret = GetCurrentGuideType(laneReqId, request->linkType, &guideType);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get current guide channel info fail");
|
||||
return ret;
|
||||
}
|
||||
if (!isMetaAuth && (guideType == LANE_NEW_AUTH_TRIGGER || guideType == LANE_ACTIVE_BR_NEGO ||
|
||||
guideType == LANE_NEW_AUTH_NEGO)) {
|
||||
LNN_LOGI(LNN_LANE, "current guideType=%{public}d", guideType);
|
||||
ret = GetPreferAuthByType(request->peerNetworkId, AUTH_LINK_TYPE_BR, connInfo, isMetaAuth);
|
||||
} else {
|
||||
ret = GetPreferAuth(request->peerNetworkId, connInfo, isMetaAuth);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t OpenAuthToConnP2p(const LinkRequest *request, uint32_t laneReqId, const LaneLinkCb *callback)
|
||||
{
|
||||
AuthConnInfo connInfo;
|
||||
(void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo));
|
||||
bool isMetaAuth = GetAuthType(request->peerNetworkId);
|
||||
int32_t ret = GetPreferAuth(request->peerNetworkId, &connInfo, isMetaAuth);
|
||||
int32_t ret = GetAuthConnInfo(request, laneReqId, &connInfo, isMetaAuth);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "no auth conn exist");
|
||||
return ret;
|
||||
@ -1590,7 +1629,7 @@ static int32_t OpenAuthTriggerToConn(const LinkRequest *request, uint32_t laneRe
|
||||
AuthConnInfo connInfo;
|
||||
(void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo));
|
||||
bool isMetaAuth = GetAuthType(request->peerNetworkId);
|
||||
int32_t ret = GetPreferAuth(request->peerNetworkId, &connInfo, isMetaAuth);
|
||||
int32_t ret = GetAuthConnInfo(request, laneReqId, &connInfo, isMetaAuth);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "no auth conn exist");
|
||||
return ret;
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
virtual int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len) = 0;
|
||||
virtual int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint32_t len) = 0;
|
||||
virtual int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
|
||||
virtual int32_t AuthGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo, bool isMeta) = 0;
|
||||
virtual int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
|
||||
virtual int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta) = 0;
|
||||
virtual int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId,
|
||||
@ -124,6 +125,7 @@ public:
|
||||
MOCK_METHOD3(LnnGetLocalStrInfo, int32_t (InfoKey, char*, uint32_t));
|
||||
MOCK_METHOD4(LnnGetRemoteStrInfo, int32_t (const char*, InfoKey, char*, uint32_t));
|
||||
MOCK_METHOD3(AuthGetPreferConnInfo, int32_t (const char*, AuthConnInfo*, bool));
|
||||
MOCK_METHOD4(AuthGetConnInfoByType, int32_t (const char*, AuthLinkType, AuthConnInfo *, bool));
|
||||
MOCK_METHOD3(AuthGetP2pConnInfo, int32_t (const char*, AuthConnInfo*, bool));
|
||||
MOCK_METHOD3(AuthGetHmlConnInfo, int32_t (const char*, AuthConnInfo*, bool));
|
||||
MOCK_METHOD4(AuthOpenConn, int32_t (const AuthConnInfo*, uint32_t, const AuthConnCallback*, bool));
|
||||
|
@ -197,6 +197,11 @@ int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isM
|
||||
return GetLaneDepsInterface()->AuthGetPreferConnInfo(uuid, connInfo, isMeta);
|
||||
}
|
||||
|
||||
int32_t AuthGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo, bool isMeta)
|
||||
{
|
||||
return GetLaneDepsInterface()->AuthGetConnInfoByType(uuid, type, connInfo, isMeta);
|
||||
}
|
||||
|
||||
int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta)
|
||||
{
|
||||
return GetLaneDepsInterface()->AuthGetP2pConnInfo(uuid, connInfo, isMeta);
|
||||
|
@ -255,7 +255,7 @@ HWTEST_F(LNNLaneLinkTest, LnnConnectP2p_002, TestSize.Level1)
|
||||
EXPECT_CALL(linkMock, LnnGetRemoteStrInfo).WillRepeatedly(Return(SOFTBUS_NOT_FIND));
|
||||
|
||||
ret = LnnConnectP2p(&request, laneReqId, &cb);
|
||||
EXPECT_EQ(SOFTBUS_LANE_GET_LEDGER_INFO_ERR, ret);
|
||||
EXPECT_EQ(SOFTBUS_LANE_NOT_FOUND, ret);
|
||||
LnnDestroyP2p();
|
||||
}
|
||||
|
||||
@ -833,6 +833,8 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelRetryOfAsync_002, TestSize.Level1)
|
||||
EXPECT_CALL(linkMock, CheckActiveConnection).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(linkMock, AuthGetPreferConnInfo)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM2>(connInfo), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(linkMock, AuthGetConnInfoByType)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM3>(connInfo), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(laneLinkMock, GetTransReqInfoByLaneReqId).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(linkMock, AuthGenRequestId).WillRepeatedly(Return(requestId));
|
||||
EXPECT_CALL(linkMock, AuthOpenConn(_, requestId, NotNull(), _)).WillOnce(linkMock.ActionOfConnOpenFailed)
|
||||
@ -888,7 +890,7 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelRetryOfAsync_003, TestSize.Level1)
|
||||
.WillOnce(DoAll(SetArrayArgument<LANE_MOCK_PARAM3>(BRMAC, BRMAC + BT_MAC_LEN), Return(SOFTBUS_OK)))
|
||||
.WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(linkMock, CheckActiveConnection).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(linkMock, AuthGetPreferConnInfo)
|
||||
EXPECT_CALL(linkMock, AuthGetConnInfoByType)
|
||||
.WillOnce(Return(SOFTBUS_OK)).WillRepeatedly(Return(SOFTBUS_AUTH_GET_BR_CONN_INFO_FAIL));
|
||||
EXPECT_CALL(laneLinkMock, GetTransReqInfoByLaneReqId).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(linkMock, AuthGenRequestId).WillRepeatedly(Return(requestId));
|
||||
@ -1314,6 +1316,8 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelRetry_004, TestSize.Level1)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM3>(remote), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(linkMock, AuthGetPreferConnInfo)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM2>(connInfo), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(linkMock, AuthGetConnInfoByType)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM3>(connInfo), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(laneLinkMock, GetTransReqInfoByLaneReqId).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(linkMock, AuthGenRequestId).WillRepeatedly(Return(requestId));
|
||||
EXPECT_CALL(linkMock, AuthOpenConn(_, requestId, NotNull(), _)).WillOnce(Return(SOFTBUS_LANE_BUILD_LINK_FAIL))
|
||||
@ -1372,6 +1376,8 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelDetect_001, TestSize.Level1)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM3>(remote), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(linkMock, AuthGetPreferConnInfo)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM2>(connInfo), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(linkMock, AuthGetConnInfoByType)
|
||||
.WillRepeatedly(DoAll(SetArgPointee<LANE_MOCK_PARAM3>(connInfo), Return(SOFTBUS_OK)));
|
||||
EXPECT_CALL(laneLinkMock, GetTransReqInfoByLaneReqId).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(linkMock, AuthGenRequestId).WillRepeatedly(Return(requestId));
|
||||
EXPECT_CALL(linkMock, AuthOpenConn(_, requestId, NotNull(), _)).WillRepeatedly(linkMock.ActionOfConnOpened);
|
||||
|
Loading…
Reference in New Issue
Block a user