From 35b1b6bb1a3f14d7f2518d9cb60c55dd53b88bd4 Mon Sep 17 00:00:00 2001 From: wuchunbo Date: Thu, 11 Jan 2024 22:18:43 +0800 Subject: [PATCH] fix bug of get local ip for p2p_reuse Signed-off-by: wuchunbo --- .../manager/src/trans_channel_manager.c | 12 ++++++++++-- .../manager/trans_channel_manager_test/BUILD.gn | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/transmission/trans_channel/manager/src/trans_channel_manager.c b/core/transmission/trans_channel/manager/src/trans_channel_manager.c index d69cf9bdc..8a8c922a4 100644 --- a/core/transmission/trans_channel/manager/src/trans_channel_manager.c +++ b/core/transmission/trans_channel/manager/src/trans_channel_manager.c @@ -44,6 +44,7 @@ #include "trans_tcp_direct_sessionconn.h" #include "lnn_network_manager.h" #include "trans_event.h" +#include "wifi_direct_manager.h" #define MIGRATE_ENABLE 2 #define MIGRATE_SUPPORTED 1 @@ -390,8 +391,15 @@ static void FillAppInfo(AppInfo *appInfo, const SessionParam *param, appInfo->linkType = connInfo->type; appInfo->channelType = transInfo->channelType; (void)TransGetLocalConfig(appInfo->channelType, appInfo->businessType, &appInfo->myData.dataConfig); - if (strcpy_s(appInfo->myData.addr, IP_LEN, connInfo->connInfo.p2p.localIp) != EOK) { - TRANS_LOGE(TRANS_CTRL, "copy local ip failed"); + if (connInfo->type == LANE_P2P || connInfo->type == LANE_HML) { + if (strcpy_s(appInfo->myData.addr, IP_LEN, connInfo->connInfo.p2p.localIp) != EOK) { + TRANS_LOGE(TRANS_CTRL, "copy local ip failed"); + } + } else if (connInfo->type == LANE_P2P_REUSE) { + if (GetWifiDirectManager()->getLocalIpByRemoteIp(connInfo->connInfo.wlan.addr, appInfo->myData.addr, IP_LEN) != + SOFTBUS_OK) { + TRANS_LOGE(TRANS_CTRL, "get local ip failed"); + } } } diff --git a/tests/core/transmission/trans_channel/manager/trans_channel_manager_test/BUILD.gn b/tests/core/transmission/trans_channel/manager/trans_channel_manager_test/BUILD.gn index f2e1e5fd1..986d9800f 100644 --- a/tests/core/transmission/trans_channel/manager/trans_channel_manager_test/BUILD.gn +++ b/tests/core/transmission/trans_channel/manager/trans_channel_manager_test/BUILD.gn @@ -31,6 +31,7 @@ ohos_unittest("TransChannelManagerTest") { "$dsoftbus_root_path/core/discovery/manager/include", "$dsoftbus_root_path/interfaces/kits/common", "$dsoftbus_root_path/core/connection/interface", + "$dsoftbus_root_path/core/connection/wifi_direct", "$dsoftbus_root_path/core/transmission/common/include", "$dsoftbus_root_path/core/transmission/trans_channel/common/include", "$dsoftbus_root_path/core/transmission/trans_channel/auth/src",