Skip to content

Commit

Permalink
Merge branch 'rdkcentral:sprint/24Q2' into sprint/24Q2
Browse files Browse the repository at this point in the history
  • Loading branch information
DineshkumarJP authored Jun 14, 2024
2 parents 79cb214 + af758c3 commit 66ec1ed
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 53 deletions.
13 changes: 3 additions & 10 deletions Network/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,17 +1461,10 @@ typedef struct _IARM_BUS_NetSrvMgr_Iface_EventData_t {
m_defInterfaceCache = "";

sendNotify("onConnectionStatusChanged", params);
if(connected)
connectivityMonitor.doInitialConnectivityMonitoring(30);
if(!connected)
{
connectivityMonitor.doInitialConnectivityMonitoring(30);
}
else
{
if (!connectivityMonitor.isMonitorThreadRunning())
{
/*run the thread again to notify no_internet state*/
connectivityMonitor.doInitialConnectivityMonitoring(30);
}
/* if disconnectd need to stop the thread after one event */
connectivityMonitor.stopInitialConnectivityMonitoring();
}
}
Expand Down
1 change: 1 addition & 0 deletions Network/NetworkConnectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ namespace WPEFramework {
if (isMonitorThreadRunning() && stopFlag == false)
{
LOGINFO("Connectivity Monitor Thread is active so notify");
g_internetState = nsm_internetState::UNKNOWN;
cv_.notify_all();
}
else
Expand Down
2 changes: 1 addition & 1 deletion NetworkManager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ find_package(WPEFramework)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(VERSION_PATCH 3)

add_compile_definitions(NETWORKMANAGER_MAJOR_VERSION=${VERSION_MAJOR})
add_compile_definitions(NETWORKMANAGER_MINOR_VERSION=${VERSION_MINOR})
Expand Down
10 changes: 5 additions & 5 deletions NetworkManager/LegacyPlugin_NetworkAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
tmpParameters["guid"] = parameters["guid"];

if (m_networkmanager)
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(5000, _T("Ping"), tmpParameters, response);
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(15000, _T("Ping"), tmpParameters, response);
else
rc = Core::ERROR_UNAVAILABLE;

Expand All @@ -597,12 +597,12 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
LOGINFOMETHOD();
uint32_t rc = Core::ERROR_GENERAL;
JsonObject tmpParameters;
tmpParameters["endpoint"] = parameters["endpoint"].String();
tmpParameters["noOfRequest"] = parameters["packets"].Number();
tmpParameters["guid"] = "";
tmpParameters["endpoint"] = parameters["endpoint"].String();
tmpParameters["packets"] = parameters["packets"].Number();
tmpParameters["guid"] = "";

if(m_networkmanager)
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(5000, _T("Trace"), tmpParameters, response);
rc = m_networkmanager->Invoke<JsonObject, JsonObject>(20000, _T("Trace"), tmpParameters, response);
else
rc = Core::ERROR_UNAVAILABLE;

Expand Down
1 change: 1 addition & 0 deletions NetworkManager/NetworkManagerConnectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ namespace WPEFramework {
if (isMonitorThreadRunning() && stopFlag == false)
{
NMLOG_INFO("Connectivity Monitor Thread is active so notify");
g_internetState = nsm_internetState::UNKNOWN;
cv_.notify_all();
}
else
Expand Down
10 changes: 8 additions & 2 deletions NetworkManager/NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ namespace WPEFramework
uint32_t NetworkManagerImplementation::Trace (const string ipversion /* @in */, const string endpoint /* @in */, const uint32_t noOfRequest /* @in */, const string guid /* @in */, string& response /* @out */)
{
char cmd[256] = "";
string tempResult = "";
if(0 == strcasecmp("IPv6", ipversion.c_str()))
{
snprintf(cmd, 256, "traceroute6 -w 3 -m 6 -q %d %s 64 2>&1", noOfRequest, endpoint.c_str());
Expand All @@ -311,7 +312,12 @@ namespace WPEFramework

NMLOG_INFO ("The Command is %s", cmd);
string commandToExecute(cmd);
executeExternally(NETMGR_TRACE, commandToExecute, response);
executeExternally(NETMGR_TRACE, commandToExecute, tempResult);

JsonObject temp;
temp["target"] = endpoint;
temp["results"] = tempResult;
temp.ToString(response);

return Core::ERROR_NONE;
}
Expand Down Expand Up @@ -427,7 +433,7 @@ namespace WPEFramework
while (!feof(pipe) && fgets(buffer, 1024, pipe) != NULL)
{
// remove newline from buffer
buffer[strcspn(buffer, "\n")] = '\0';
buffer[strcspn(buffer, "\n")] = ' ';
string line(buffer);
list.Add(line);
}
Expand Down
6 changes: 3 additions & 3 deletions NetworkManager/NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ namespace WPEFramework
response["ipversion"] = ipversion;
response["success"] = true;

/* TODO :: Cache this public IP Address */
m_publicIPAddress = ipAddress;
m_publicIPAddressType = ipversion;
PublishToThunderAboutInternet();
}
LOGTRACEMETHODFIN();
return rc;
Expand Down Expand Up @@ -661,8 +661,8 @@ namespace WPEFramework
string result{};
const string ipversion = parameters["ipversion"].String();
const string endpoint = parameters["endpoint"].String();
const uint32_t noOfRequest = parameters["noOfRequest"].Number();
const string guid = parameters["guid"].String();
const uint32_t noOfRequest = parameters["packets"].Number();
const string guid = parameters["guid"].String();

if (_NetworkManager)
rc = _NetworkManager->Trace(ipversion, endpoint, noOfRequest, guid, result);
Expand Down
16 changes: 13 additions & 3 deletions NetworkManager/NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,12 @@ namespace WPEFramework
{
if (e->status)
::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_UP, interface);
else
::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_DOWN, interface);
else {
::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_DOWN, interface);
/* when ever interface down we start connectivity monitor to post noInternet event */
::_instance->connectivityMonitor.doInitialConnectivityMonitoring(5);
::_instance->connectivityMonitor.stopInitialConnectivityMonitoring();
}
}
break;
}
Expand All @@ -436,8 +440,14 @@ namespace WPEFramework
interface = e->interface;
NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_IPADDRESS :: %s -- %s", interface.c_str(), e->ip_address);

if(interface == "eth0" || interface == "wlan0")
if(interface == "eth0" || interface == "wlan0") {
::_instance->ReportIPAddressChangedEvent(interface, e->acquired, e->is_ipv6, string(e->ip_address));
if(e->acquired)
{
/* if ip address acquired we start connectivity monitor */
::_instance->connectivityMonitor.doInitialConnectivityMonitoring(5);
}
}
break;
}
case IARM_BUS_NETWORK_MANAGER_EVENT_DEFAULT_INTERFACE:
Expand Down
36 changes: 36 additions & 0 deletions RDKShell/RDKShell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,28 @@
]
}
},
"getFocus": {
"summary": "Gets focus to the specified client.",
"params": {
"type":"object",
"properties": {
"client": {
"$ref": "#/definitions/client"
},
"callsign": {
"summary": "The application callsign",
"type": "string",
"example": "org.rdk.Netflix"
}
},
"required": [
"client"
]
},
"result": {
"$ref": "#/common/result"
}
},
"hideAllClients": {
"summary": "Hides/Unhides all the clients.",
"params": {
Expand Down Expand Up @@ -2370,6 +2392,20 @@
]
}
},
"onApplicationFocusChanged":{
"summary": "Triggered when an application focus is changed",
"params": {
"type": "object",
"properties": {
"client":{
"$ref": "#/definitions/client"
}
},
"required": [
"client"
]
}
},
"onApplicationConnected":{
"summary": "Triggered when a connection to an application succeeds",
"params": {
Expand Down
40 changes: 11 additions & 29 deletions docs/api/NetworkManagerPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a name="head.NetworkManager_Plugin"></a>
# NetworkManager Plugin

**Version: [0.2.0]()**
**Version: [0.2.3]()**

A NetworkManager plugin for Thunder framework.

Expand Down Expand Up @@ -1037,29 +1037,21 @@ No Events

### Parameters

| Name | Type | Description |
| :-------- | :-------- | :-------- |
| Name | Type | Description |
| :-------- | :-------- | :-------- |
| params | object | |
| params.endpoint | string | The host name or IP address |
| params.ipversion | string | either IPv4 or IPv6 |
| params.noOfRequest | integer | The number of packets to send. Default is 15 |
| params.guid | string | The globally unique identifier |
| params.ipversion| string | <sup>*(optional)*</sup> The host name or IP address |
| params.endpoint | string | The host name or IP address |
| params.packets | integer | <sup>*(optional)*</sup> The number of packets to send. Default is 10 |
| params.guid | string | <sup>*(optional)*</sup> The globally unique identifier |

### Result

| Name | Type | Description |
| :-------- | :-------- | :-------- |
| result | object | |
| result.target | string | The target IP address |
| result.packetsTransmitted | integer | The number of packets sent |
| result.packetsReceived | integer | The number of packets received |
| result.packetLoss | string | The number of packets lost |
| result.tripMin | string | The minimum amount of time to receive the packets |
| result.tripAvg | string | The average time to receive the packets |
| result.tripMax | string | The maximum amount of time to receive the packets |
| result.tripStdDev | string | The standard deviation for the trip |
| result.error | string | An error message |
| result.guid | string | The globally unique identifier |
| result.results | string | The results from `traceroute` |
| result.success | boolean | Whether the request succeeded |

### Example
Expand All @@ -1073,9 +1065,7 @@ No Events
"method": "org.rdk.NetworkManager.Trace",
"params": {
"endpoint": "45.57.221.20",
"ipversion": "IPv4",
"noOfRequest": 10,
"guid": "..."
"packets": 10
}
}
```
Expand All @@ -1088,16 +1078,8 @@ No Events
"id": 42,
"result": {
"target": "45.57.221.20",
"packetsTransmitted": 10,
"packetsReceived": 10,
"packetLoss": "0.0",
"tripMin": "61.264",
"tripAvg": "130.397",
"tripMax": "230.832",
"tripStdDev": "80.919",
"error": "...",
"guid": "...",
"success": true
"success": true,
"results": "<<<traceroute command results>>>"
}
}
```
Expand Down

0 comments on commit 66ec1ed

Please sign in to comment.