Skip to content

Commit

Permalink
ipversion changed
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Aug 27, 2024
1 parent 459cc55 commit ff6961d
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions NetworkManager/NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ namespace WPEFramework
NetworkManagerImplementation* _instance = nullptr;

Cache<WiFiStatusCode_t> wifiStatusCache;
Cache<IARM_BUS_NetSrvMgr_Iface_Settings_t> ipv4Cache;
Cache<IARM_BUS_NetSrvMgr_Iface_Settings_t> ipv6Cache;
Cache<IPAddressInfo> ipv4Cache;
Cache<IPAddressInfo> ipv6Cache;
Cache<std::string> defaultIfaceCache;

Exchange::INetworkManager::WiFiState to_wifi_state(WiFiStatusCode_t code) {
Expand Down Expand Up @@ -833,43 +833,39 @@ 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)
{
// TODO fix netsrvmgr will return ip even after wifi disconnected
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
{
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
Expand All @@ -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;
Expand Down

0 comments on commit ff6961d

Please sign in to comment.