mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 16:59:54 +00:00
!8257 fix:ptk not match
Merge pull request !8257 from zhanghaowen/master
This commit is contained in:
commit
be1593b0a3
@ -32,6 +32,8 @@ void LnnDisconnectP2pWithoutLnn(uint32_t laneReqId);
|
||||
void NotifyLinkFailForForceDown(uint32_t requestId, int32_t reason);
|
||||
void RecycleP2pLinkedReqByLinkType(const char *peerNetworkId, LaneLinkType linkType);
|
||||
int32_t WifiDirectReconnectDevice(uint32_t p2pRequestId);
|
||||
int32_t LnnInitPtkSyncListener(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -3075,4 +3075,46 @@ void LnnCancelWifiDirect(uint32_t laneReqId)
|
||||
return;
|
||||
}
|
||||
NotifyLinkFail(ASYNC_RESULT_P2P, wifiDirectInfo.requestId, SOFTBUS_LANE_BUILD_LINK_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
static void HandlePtkNotMatch(const char *remoteNetworkId, uint32_t len, int32_t result)
|
||||
{
|
||||
if (remoteNetworkId == NULL || len == 0 || len > NETWORK_ID_BUF_LEN) {
|
||||
LNN_LOGE(LNN_LANE, "invalid param");
|
||||
return;
|
||||
}
|
||||
char *anonyNetworkId = NULL;
|
||||
Anonymize(remoteNetworkId, &anonyNetworkId);
|
||||
LNN_LOGI(LNN_LANE, "handle ptk not match, networkId=%{public}s, result=%{public}d",
|
||||
AnonymizeWrapper(anonyNetworkId), result);
|
||||
AnonymizeFree(anonyNetworkId);
|
||||
if (LnnSyncPtk(remoteNetworkId) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "sync ptk fail");
|
||||
return;
|
||||
}
|
||||
char peerUdid[UDID_BUF_LEN] = {0};
|
||||
if (LnnGetRemoteStrInfo(remoteNetworkId, STRING_KEY_DEV_UDID, peerUdid, sizeof(peerUdid)) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get peer udid fail");
|
||||
return;
|
||||
}
|
||||
LnnEventExtra extra = {0};
|
||||
LnnEventExtraInit(&extra);
|
||||
extra.result = SOFTBUS_LANE_PTK_NOT_MATCH;
|
||||
extra.peerUdid = peerUdid;
|
||||
LNN_EVENT(EVENT_SCENE_LNN, EVENT_STAGE_LNN_LANE_SELECT_END, extra);
|
||||
}
|
||||
|
||||
int32_t LnnInitPtkSyncListener(void)
|
||||
{
|
||||
struct WifiDirectManager *pManager = GetWifiDirectManager();
|
||||
if (pManager == NULL) {
|
||||
LNN_LOGE(LNN_LANE, "get wifi direct manager fail");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (pManager->addPtkMismatchListener == NULL) {
|
||||
LNN_LOGE(LNN_LANE, "addPtkMismatchListener null");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
pManager->addPtkMismatchListener(HandlePtkNotMatch);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
@ -78,3 +78,8 @@ int32_t WifiDirectReconnectDevice(uint32_t p2pRequestId)
|
||||
(void)p2pRequestId;
|
||||
return SOFTBUS_P2P_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t LnnInitPtkSyncListener(void)
|
||||
{
|
||||
return SOFTBUS_P2P_NOT_SUPPORT;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ int32_t LnnGetLocalPtkByUuid(const char *uuid, char *localPtk, uint32_t len);
|
||||
int32_t LnnGetLocalDefaultPtkByUuid(const char *uuid, char *localPtk, uint32_t len);
|
||||
int32_t LnnGetRemoteDefaultPtkByUuid(const char *uuid, char *remotePtk, uint32_t len);
|
||||
void LnnLoadPtkInfo(void);
|
||||
int32_t LnnSyncPtk(char *networkId);
|
||||
int32_t LnnSyncPtk(const char *networkId);
|
||||
int32_t UpdateLocalPtkIfValid(char *udid);
|
||||
int32_t LnnSetLocalPtkConn(char *udid);
|
||||
int32_t LnnGenerateLocalPtk(char *udid, char *uuid);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "lnn_async_callback_utils.h"
|
||||
#include "lnn_distributed_net_ledger.h"
|
||||
#include "lnn_feature_capability.h"
|
||||
#include "lnn_lane_link_p2p.h"
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_log.h"
|
||||
#include "lnn_secure_storage.h"
|
||||
@ -359,6 +360,9 @@ int32_t LnnInitP2p(void)
|
||||
if (LnnInitPtk() != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "init ptk fail");
|
||||
}
|
||||
if (LnnInitPtkSyncListener() != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "init ptk listener fail");
|
||||
}
|
||||
return LnnRegSyncInfoHandler(LNN_INFO_TYPE_P2P_INFO, OnReceiveP2pSyncInfoMsg);
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ int32_t LnnGetRemoteDefaultPtkByUuid(const char *uuid, char *remotePtk, uint32_t
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnSyncPtk(char *networkId)
|
||||
int32_t LnnSyncPtk(const char *networkId)
|
||||
{
|
||||
(void)networkId;
|
||||
return SOFTBUS_OK;
|
||||
|
@ -170,7 +170,7 @@ void DelLogicAndLaneRelationship(uint64_t laneId)
|
||||
GetLaneLinkDepsInterface()->DelLogicAndLaneRelationship(laneId);
|
||||
}
|
||||
|
||||
int32_t LnnSyncPtk(char *networkId)
|
||||
int32_t LnnSyncPtk(const char *networkId)
|
||||
{
|
||||
return GetLaneLinkDepsInterface()->LnnSyncPtk(networkId);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
virtual int32_t ClearLaneResourceByLaneId(uint64_t laneId) = 0;
|
||||
virtual void RemoveDelayDestroyMessage(uint64_t laneId) = 0;
|
||||
virtual void DelLogicAndLaneRelationship(uint64_t laneId) = 0;
|
||||
virtual int32_t LnnSyncPtk(char *networkId) = 0;
|
||||
virtual int32_t LnnSyncPtk(const char *networkId) = 0;
|
||||
};
|
||||
|
||||
class LaneLinkDepsInterfaceMock : public LaneLinkDepsInterface {
|
||||
@ -81,7 +81,7 @@ public:
|
||||
MOCK_METHOD1(ClearLaneResourceByLaneId, int32_t (uint64_t laneId));
|
||||
MOCK_METHOD1(RemoveDelayDestroyMessage, void (uint64_t laneId));
|
||||
MOCK_METHOD1(DelLogicAndLaneRelationship, void (uint64_t laneId));
|
||||
MOCK_METHOD1(LnnSyncPtk, int32_t (char *networkId));
|
||||
MOCK_METHOD1(LnnSyncPtk, int32_t (const char *networkId));
|
||||
|
||||
static int32_t ActionOfChannelOpenFailed(int32_t requestId, const char *networkId,
|
||||
const TransProxyPipelineChannelOption *option, const ITransProxyPipelineCallback *callback);
|
||||
|
Loading…
Reference in New Issue
Block a user