Skip to content

Commit

Permalink
Merge branch 'rdkcentral:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi authored Sep 30, 2024
2 parents ed5e81c + 5bc1b30 commit 53691b0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
63 changes: 45 additions & 18 deletions LegacyPlugin_NetworkAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace WPEFramework
Register("getCaptivePortalURI", &Network::getCaptivePortalURI, this);
Register("stopConnectivityMonitoring", &Network::stopConnectivityMonitoring, this);
GetHandler(2)->Register<JsonObject, JsonObject>("setIPSettings", &Network::setIPSettings, this);
GetHandler(2)->Register<JsonObject, JsonObject>("getIPSettings", &Network::getIPSettings, this);
GetHandler(2)->Register<JsonObject, JsonObject>("getIPSettings", &Network::getIPSettings2, this);
}

/**
Expand Down Expand Up @@ -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");
response["success"] = false;
}

LOGTRACEMETHODFIN();
return rc;
}

uint32_t Network::getIPSettings2 (const JsonObject& parameters, JsonObject& response)
{
uint32_t rc = Core::ERROR_GENERAL;
JsonObject tmpResponse;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -842,6 +864,11 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
m_timer.stop();
NMLOG_INFO("subscriber timer stoped");
}
else
{
m_timer.start(SUBSCRIPTION_TIMEOUT_IN_MILLISECONDS);
NMLOG_INFO("subscriber timer started");
}
}

string Network::getInterfaceMapping(const string & interface)
Expand Down
1 change: 1 addition & 0 deletions LegacyPlugin_NetworkAPIs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions LegacyPlugin_WiFiManagerAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ namespace WPEFramework
m_timer.stop();
NMLOG_INFO("subscriber timer stoped");
}
else
{
m_timer.start(SUBSCRIPTION_TIMEOUT_IN_MILLISECONDS);
NMLOG_INFO("subscriber timer started");
}
}

bool WiFiManager::ErrorCodeMapping(const uint32_t ipvalue, uint32_t &opvalue)
Expand Down
1 change: 1 addition & 0 deletions NetworkManager.conf.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
callsign= "org.rdk.NetworkManager"
startuporder = "@PLUGIN_NETWORKMANAGER_STARTUPORDER@"
autostart = "true"

process= JSON()
process.add("outofprocess", "true")
Expand Down
1 change: 1 addition & 0 deletions NetworkManager.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(callsign "org.rdk.NetworkManager")
set (startuporder ${PLUGIN_NETWORKMANAGER_STARTUPORDER})
set (autostart true)

map()
key(root)
Expand Down

0 comments on commit 53691b0

Please sign in to comment.