Skip to content

Commit

Permalink
DELIA-65170 - NetworkManager unified plugin getIPSettings prefix retu…
Browse files Browse the repository at this point in the history
…rns 0 (#5242)

* DELIA-65170 - NetworkManager unified plugin getIPSettings prefix returns 0

Reason for change: Added the changes to get the prefix value from IP/Prefix
and added check for NULL prefix
Test Procedure: Build and verified
Risks: Low
Priority: P1
Signed-off-by: Gururaaja ESR <Gururaja_ErodeSriranganRamlingham@comcast.com>
Co-authored-by: Karunakaran A <48997923+karuna2git@users.noreply.github.com>
  • Loading branch information
gururaajar committed May 6, 2024
1 parent 2705e92 commit 673ed3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
27 changes: 17 additions & 10 deletions NetworkManager/service/NetworkManagerLegacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "NetworkManager.h"
#include "NetworkConnectivity.h"
#include <algorithm>

#define LOGINFOMETHOD() { std::string json; parameters.ToString(json); NMLOG_TRACE("Legacy params=%s", json.c_str() ); }
#define LOGTRACEMETHODFIN() { std::string json; response.ToString(json); NMLOG_TRACE("Legacy response=%s", json.c_str() ); }
Expand Down Expand Up @@ -336,15 +337,8 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
if (Core::ERROR_NONE == rc)
{
string ipversion = tmpResponse["ipversion"].String();
if (0 == strcasecmp("ipv4", ipversion.c_str()))
{
index = tmpResponse["prefix"].Number();
if(CIDR_NETMASK_IP_LEN <= index)
return Core::ERROR_GENERAL;
response["netmask"] = CIDR_PREFIXES[index];
}
else if (0 == strcasecmp("ipv6", ipversion.c_str()))
response["netmask"] = tmpResponse["prefix"];
std::transform(ipversion.begin(), ipversion.end(), ipversion.begin(), ::toupper);

if (parameters.HasLabel("interface"))
{
response["interface"] = parameters["interface"];
Expand All @@ -358,9 +352,22 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
}
response["ipversion"] = tmpResponse["ipversion"];
response["autoconfig"] = tmpResponse["autoconfig"];
response["dhcpserver"] = tmpResponse["dhcpserver"];
response["ipaddr"] = tmpResponse["ipaddress"];
if(tmpResponse["ipaddress"].String().empty())
response["netmask"] = "";
else if ("IPV4" == ipversion)
{
index = tmpResponse["prefix"].Number();
if(CIDR_NETMASK_IP_LEN <= index)
return Core::ERROR_GENERAL;
response["netmask"] = CIDR_PREFIXES[index];
}
else if ("IPV6" == ipversion)
{
response["netmask"] = tmpResponse["prefix"];
}
response["gateway"] = tmpResponse["gateway"];
response["dhcpserver"] = tmpResponse["dhcpserver"];
response["primarydns"] = tmpResponse["primarydns"];
response["secondarydns"] = tmpResponse["secondarydns"];
response["success"] = tmpResponse["success"];
Expand Down
6 changes: 3 additions & 3 deletions NetworkManager/service/NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,9 @@ namespace WPEFramework
result.m_v6LinkLocal = "";
result.m_ipAddress = string(iarmData.ipaddress,MAX_IP_ADDRESS_LEN - 1);
if (0 == strcasecmp("ipv4", iarmData.ipversion))
result.m_prefix = NetmaskToPrefix(iarmData.netmask);
else if (0 == strcasecmp("ipv6", iarmData.ipversion))
result.m_prefix = std::stoi(iarmData.netmask);
result.m_prefix = NetmaskToPrefix(iarmData.netmask);
else if (0 == strcasecmp("ipv6", iarmData.ipversion))
result.m_prefix = std::atoi(iarmData.netmask);
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);
Expand Down

0 comments on commit 673ed3b

Please sign in to comment.