From a4750583258658a08acf48867112fd053c862a07 Mon Sep 17 00:00:00 2001 From: Karunakaran A Date: Fri, 27 Sep 2024 12:23:58 -0400 Subject: [PATCH] DELIA-66407 : Add Legacy GetIPSettings2() in Unified NetworkManager Plugin Reason for change: Add Legacy GetIPSettings2() in Unified NetworkManager Plugin Test Procedure: As per DELIA-66407 Risks: Low Signed-off-by: Karunakaran A --- LegacyPlugin_NetworkAPIs.cpp | 58 +++++++++++++++++++++++++----------- LegacyPlugin_NetworkAPIs.h | 1 + NetworkManager.conf.in | 1 + NetworkManager.config | 1 + 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/LegacyPlugin_NetworkAPIs.cpp b/LegacyPlugin_NetworkAPIs.cpp index 9e689769..c7fc9e76 100644 --- a/LegacyPlugin_NetworkAPIs.cpp +++ b/LegacyPlugin_NetworkAPIs.cpp @@ -204,7 +204,7 @@ namespace WPEFramework Register("getCaptivePortalURI", &Network::getCaptivePortalURI, this); Register("stopConnectivityMonitoring", &Network::stopConnectivityMonitoring, this); GetHandler(2)->Register("setIPSettings", &Network::setIPSettings, this); - GetHandler(2)->Register("getIPSettings", &Network::getIPSettings, this); + GetHandler(2)->Register("getIPSettings", &Network::getIPSettings2, this); } /** @@ -436,6 +436,26 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = { } uint32_t Network::getIPSettings (const JsonObject& parameters, JsonObject& response) + { + uint32_t rc = Core::ERROR_GENERAL; + JsonObject tmpResponse; + + LOGINFOMETHOD(); + rc = getIPSettings2(parameters, tmpResponse); + + if (tmpResponse.HasLabel("ipaddr")) + response = tmpResponse; + else + { + NMLOG_INFO("IP Address not assigned to the given interface yet"); + rc = Core::ERROR_GENERAL; + } + + LOGTRACEMETHODFIN(); + return rc; + } + + uint32_t Network::getIPSettings2 (const JsonObject& parameters, JsonObject& response) { uint32_t rc = Core::ERROR_GENERAL; JsonObject tmpResponse; @@ -475,31 +495,33 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = { response["interface"] = "ETHERNET"; } - response["ipversion"] = tmpResponse["ipversion"]; response["autoconfig"] = tmpResponse["autoconfig"]; - response["ipaddr"] = tmpResponse["ipaddress"]; - if(tmpResponse["ipaddress"].String().empty()) - response["netmask"] = ""; - else if (caseInsensitiveCompare(ipversion, "IPV4")) - { - index = tmpResponse["prefix"].Number(); - if(CIDR_NETMASK_IP_LEN <= index) - return Core::ERROR_GENERAL; - response["netmask"] = CIDR_PREFIXES[index]; - } - else if (caseInsensitiveCompare(ipversion, "IPV6")) + if(!tmpResponse["ipaddress"].String().empty()) { - response["netmask"] = tmpResponse["prefix"]; + response["ipversion"] = tmpResponse["ipversion"]; + response["ipaddr"] = tmpResponse["ipaddress"]; + if (caseInsensitiveCompare(ipversion, "IPV4")) + { + index = tmpResponse["prefix"].Number(); + if(CIDR_NETMASK_IP_LEN <= index) + return Core::ERROR_GENERAL; + response["netmask"] = CIDR_PREFIXES[index]; + } + else if (caseInsensitiveCompare(ipversion, "IPV6")) + { + response["netmask"] = tmpResponse["prefix"]; + } + response["gateway"] = tmpResponse["gateway"]; + response["dhcpserver"] = tmpResponse["dhcpserver"]; + response["primarydns"] = tmpResponse["primarydns"]; + response["secondarydns"] = tmpResponse["secondarydns"]; } - response["gateway"] = tmpResponse["gateway"]; - response["dhcpserver"] = tmpResponse["dhcpserver"]; - response["primarydns"] = tmpResponse["primarydns"]; - response["secondarydns"] = tmpResponse["secondarydns"]; response["success"] = tmpResponse["success"]; } LOGTRACEMETHODFIN(); return rc; } + uint32_t Network::isConnectedToInternet(const JsonObject& parameters, JsonObject& response) { uint32_t rc = Core::ERROR_GENERAL; diff --git a/LegacyPlugin_NetworkAPIs.h b/LegacyPlugin_NetworkAPIs.h index bbaa7eef..037b91b0 100644 --- a/LegacyPlugin_NetworkAPIs.h +++ b/LegacyPlugin_NetworkAPIs.h @@ -44,6 +44,7 @@ namespace WPEFramework { uint32_t doPing(const JsonObject& parameters, JsonObject& response); uint32_t setIPSettings(const JsonObject& parameters, JsonObject& response); uint32_t getIPSettings(const JsonObject& parameters, JsonObject& response); + uint32_t getIPSettings2(const JsonObject& parameters, JsonObject& response); uint32_t isConnectedToInternet(const JsonObject& parameters, JsonObject& response); uint32_t setConnectivityTestEndpoints(const JsonObject& parameters, JsonObject& response); uint32_t getInternetConnectionState(const JsonObject& parameters, JsonObject& response); diff --git a/NetworkManager.conf.in b/NetworkManager.conf.in index cbfc0e53..49b18e46 100644 --- a/NetworkManager.conf.in +++ b/NetworkManager.conf.in @@ -1,5 +1,6 @@ callsign= "org.rdk.NetworkManager" startuporder = "@PLUGIN_NETWORKMANAGER_STARTUPORDER@" +autostart = "true" process= JSON() process.add("outofprocess", "true") diff --git a/NetworkManager.config b/NetworkManager.config index 0019947d..c70241fc 100644 --- a/NetworkManager.config +++ b/NetworkManager.config @@ -1,5 +1,6 @@ set(callsign "org.rdk.NetworkManager") set (startuporder ${PLUGIN_NETWORKMANAGER_STARTUPORDER}) +set (autostart true) map() key(root)