From ff6961d21f2fc058144d51ef3851a60ca6fced84 Mon Sep 17 00:00:00 2001 From: cmuhammedrafi Date: Tue, 27 Aug 2024 17:15:01 +0530 Subject: [PATCH] ipversion changed --- NetworkManager/NetworkManagerRDKProxy.cpp | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/NetworkManager/NetworkManagerRDKProxy.cpp b/NetworkManager/NetworkManagerRDKProxy.cpp index 6fc6604a63..9a87912b80 100644 --- a/NetworkManager/NetworkManagerRDKProxy.cpp +++ b/NetworkManager/NetworkManagerRDKProxy.cpp @@ -366,8 +366,8 @@ namespace WPEFramework NetworkManagerImplementation* _instance = nullptr; Cache wifiStatusCache; - Cache ipv4Cache; - Cache ipv6Cache; + Cache ipv4Cache; + Cache ipv6Cache; Cache defaultIfaceCache; Exchange::INetworkManager::WiFiState to_wifi_state(WiFiStatusCode_t code) { @@ -833,14 +833,15 @@ namespace WPEFramework //TODO: Fix netsrvmgr to accept eth0 & wlan0 // Convert the string to uppercase - std::transform(ipversion.begin(), ipversion.end(), ipversion.begin(), ::toupper); + std::string ipversionNonConst = ipversion; + std::transform(ipversionNonConst.begin(), ipversionNonConst.end(), ipversionNonConst.begin(), ::toupper); if ("wlan0" == interface) strncpy(iarmData.interface, "WIFI", INTERFACE_SIZE); else if ("eth0" == interface) strncpy(iarmData.interface, "ETHERNET", INTERFACE_SIZE); - strncpy(iarmData.ipversion, ipversion.c_str(), 16); + strncpy(iarmData.ipversion, ipversionNonConst.c_str(), 16); iarmData.isSupported = true; if ("wlan0" == interface && wifiStatusCache.isSet() && wifiStatusCache.getValue() != WIFI_CONNECTED) { @@ -848,16 +849,16 @@ namespace WPEFramework NMLOG_WARNING("wifi not connected so address will be empty"); rc = Core::ERROR_NONE; } - else if(ipversion == "IPV4" && ipv4Cache.isSet() && interface == ipv4Cache.getValue().interface) + else if(ipversionNonConst == "IPV4" && ipv4Cache.isSet() && interface == ipv4Cache.getValue().interface) { NMLOG_INFO("Reading ipv4 cached value"); - memcpy(&iarmData, &ipv4Cache.getValue(), sizeof(IARM_BUS_NetSrvMgr_Iface_Settings_t)); + result = ipv4Cache.getValue(); rc = Core::ERROR_NONE; } - else if(ipversion == "IPV6" && ipv6Cache.isSet() && interface == ipv4Cache.getValue().interface) + else if(ipversionNonConst == "IPV6" && ipv6Cache.isSet() && interface == ipv4Cache.getValue().interface) { NMLOG_INFO("Reading ipv6 cached value"); - memcpy(&iarmData, &ipv6Cache.getValue(), sizeof(IARM_BUS_NetSrvMgr_Iface_Settings_t)); + result = ipv4Cache.getValue(); rc = Core::ERROR_NONE; } else @@ -865,11 +866,6 @@ namespace WPEFramework if (IARM_RESULT_SUCCESS == IARM_Bus_Call (IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_getIPSettings, (void *)&iarmData, sizeof(iarmData))) { NMLOG_INFO("GetIPSettings - IARM Success"); - if(ipversion == "IPV4") - ipv4Cache = iarmData; - else - ipv6Cache = iarmData; - rc = Core::ERROR_NONE; } else @@ -890,6 +886,11 @@ namespace WPEFramework result.m_gateway = string(iarmData.gateway,MAX_IP_ADDRESS_LEN - 1); result.m_primaryDns = string(iarmData.primarydns,MAX_IP_ADDRESS_LEN - 1); result.m_secondaryDns = string(iarmData.secondarydns,MAX_IP_ADDRESS_LEN - 1); + + if(ipversionNonConst == "IPV4") + ipv4Cache = result; + else + ipv6Cache = result; } return rc;