Skip to content

RDKEMW-17624 : NetworkconnectionRecovery.sh migration to C/C++ Module#301

Open
gururaajar wants to merge 138 commits intodevelopfrom
topic/RDK-61067_new
Open

RDKEMW-17624 : NetworkconnectionRecovery.sh migration to C/C++ Module#301
gururaajar wants to merge 138 commits intodevelopfrom
topic/RDK-61067_new

Conversation

@gururaajar
Copy link
Copy Markdown
Contributor

Reason for Change: Added outofprocess networkconnectionstats plugin, which is the replacement for NetworkconnectionRecovery.sh script.
Test Procedure: Required to check all the functionality done by the script is covered with the plugin.
Priority: P1
Signed-off-by: Gururaaja ESRGururaja_ErodeSriranganRamlingham@comcast.com

Garpathi, Uday Krishna and others added 30 commits December 10, 2025 11:37
Signed-off-by: Balaji Punnuru <Balaji_Punnuru@comcast.com>
Signed-off-by: Balaji Punnuru <Balaji_Punnuru@comcast.com>
Signed-off-by: Garpathi, Uday Krishna <UdayKrishna_GARPATHI@comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 20:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new out-of-process NetworkConnectionStats Thunder plugin intended to replace the legacy NetworkconnectionRecovery.sh behavior, while also improving NetworkManager’s internal state handling and resource cleanup paths.

Changes:

  • Added the networkstats submodule implementing NetworkConnectionStats (in-process plugin + out-of-process implementation) with COM-RPC/JSON-RPC provider options, periodic diagnostics, and event-driven reporting.
  • Improved NetworkManager thread-safety and robustness (mutex-protected default-interface access, additional iterator null checks, some GLib/libnm context isolation + cleanup work).
  • Minor fixes/cleanups in existing tests and log/error handling paths.

Reviewed changes

Copilot reviewed 39 out of 40 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/l2Test/libnm/l2_test_libnmproxyWifi.cpp Minor whitespace cleanup in WiFi connect test.
tests/l2Test/libnm/l2_test_libnmproxy.cpp Fix duplicate mock expectation and formatting.
plugin/rdk/NetworkManagerRDKProxy.cpp Default interface access switched to locked getters/setters; adds platform_deinit stub and iterator null checks.
plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp Uses locked default interface access; adds iterator null checks.
plugin/gnome/NetworkManagerGnomeWIFI.cpp Fix log typo and improve GLib context cleanup + scan error handling.
plugin/gnome/NetworkManagerGnomeProxy.cpp Replaces global NMClient with members; adds isolated GMainContext strategy and platform_deinit cleanup; adds iterator null checks.
plugin/NetworkManagerJsonRpc.cpp Adds null checks after iterator creation for endpoints/SSIDs.
plugin/NetworkManagerImplementation.h Adds mutex-protected default interface accessors; adds platform_deinit declaration; forward-declares GLib/libnm types.
plugin/NetworkManagerImplementation.cpp Calls platform_deinit on shutdown; uses default interface accessors; adds iterator null checks; adjusts connectivity-trigger logic.
plugin/NetworkManagerConnectivity.cpp Uses default interface accessor; refactors initial/ideal connectivity logic and logging.
legacy/LegacyWiFiManagerAPIs.cpp Adds null check after iterator creation.
legacy/LegacyNetworkAPIs.cpp Adds null check after iterator creation.
networkstats/plugin/ThunderJsonRPCProvider.h Declares JSON-RPC-based provider for NetworkManager data.
networkstats/plugin/ThunderJsonRPCProvider.cpp Implements JSON-RPC provider calls to NetworkManager (GetIPSettings, Ping, event subscribe, etc.).
networkstats/plugin/ThunderComRPCProvider.h Declares COM-RPC provider for NetworkManager data.
networkstats/plugin/ThunderComRPCProvider.cpp Implements COM-RPC provider calls to NetworkManager.
networkstats/plugin/NetworkDataProviderFactory.h Factory to choose COM-RPC vs JSON-RPC provider at runtime.
networkstats/plugin/NetworkConnectionStatsLogger.h Adds standalone logger interface/macros for networkstats module.
networkstats/plugin/NetworkConnectionStatsLogger.cpp Implements logger backend (stdout or RDK logger).
networkstats/plugin/NetworkConnectionStatsImplementation.h Declares out-of-process implementation: state machine, queues, periodic threads, subscriptions.
networkstats/plugin/NetworkConnectionStatsImplementation.cpp Implements diagnostics/reporting, subscriptions, message queue + state machine, WiFi reassociation trigger.
networkstats/plugin/NetworkConnectionStats.h Declares in-process Thunder plugin wrapper (IPlugin) aggregating the COM-RPC interface.
networkstats/plugin/NetworkConnectionStats.cpp Implements plugin lifecycle, spawns out-of-process implementation, configures it.
networkstats/plugin/NetworkConnectionStats.config Adds plugin configuration template (cmake config generator format).
networkstats/plugin/NetworkConnectionStats.conf.in Adds plugin configuration template (conf.in).
networkstats/plugin/Module.h Adds module declarations/includes for NetworkConnectionStats.
networkstats/plugin/Module.cpp Adds module registration entry point.
networkstats/plugin/INetworkData.h Adds provider interface for retrieving network data via NetworkManager.
networkstats/plugin/CMakeLists.txt Builds in-process and out-of-process libraries; adds config variables.
networkstats/interface/INetworkConnectionStats.h Adds COM-RPC interface definition (Configure/Register/Unregister).
networkstats/interface/CMakeLists.txt Adds ProxyStub generation and install rules for the interface.
networkstats/definition/NetworkConnectionStats.json Adds JSON-RPC API definition (currently not built by default in subproject).
networkstats/definition/CMakeLists.txt Adds JSON-RPC documentation/code generation step.
networkstats/THUNDER_PLUGIN_QUICK_REFERENCE.md Adds architectural quick reference documentation.
networkstats/THUNDER_PLUGIN_CONVERSION.md Adds conversion notes/doc for standalone-to-plugin migration.
networkstats/README_INTERNAL_PLUGIN.md Adds internal-only plugin documentation.
networkstats/NetworkStatsDesign_ver1.md Adds design document and diagrams for the module.
networkstats/CMakeLists.txt Adds networkstats build entry (currently structured as a nested project).
CMakeLists.txt Adds add_subdirectory(networkstats) to the root build.
.DS_Store Adds macOS metadata file (should not be committed).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread networkstats/plugin/ThunderComRPCProvider.h
Comment thread CMakeLists.txt
Comment thread plugin/rdk/NetworkManagerRDKProxy.cpp
Comment on lines 276 to 286
@@ -274,14 +286,14 @@ namespace WPEFramework
}
Comment thread plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp
Comment thread networkstats/plugin/NetworkConnectionStatsImplementation.cpp
Comment thread plugin/NetworkManagerConnectivity.cpp
Comment thread networkstats/CMakeLists.txt
bpunnuru
bpunnuru previously approved these changes Apr 24, 2026
Copilot AI review requested due to automatic review settings April 24, 2026 20:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an out-of-process NetworkConnectionStats Thunder plugin intended to replace the legacy NetworkconnectionRecovery.sh behavior, while also tightening robustness in the existing NetworkManager plugin (thread-safe default-interface access, safer iterator creation, and improved GLib/libnm lifecycle handling).

Changes:

  • Added a new networkstats/ module implementing an out-of-process NetworkConnectionStats plugin with COM-RPC interface, providers (COM-RPC / JSON-RPC), config, and build integration.
  • Made NetworkManager default-interface access thread-safe and added platform-specific deinitialization hooks.
  • Added null checks for iterator creation across several APIs and improved error handling / cleanup in gnome WiFi flows.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
CMakeLists.txt Adds networkstats as a subdirectory in the main build.
legacy/LegacyNetworkAPIs.cpp Adds nullptr check after creating RPC string iterator for endpoints.
legacy/LegacyWiFiManagerAPIs.cpp Adds nullptr check after creating RPC string iterator for SSIDs.
plugin/NetworkManagerConnectivity.cpp Uses thread-safe default-interface getter in connectivity monitor logic.
plugin/NetworkManagerImplementation.cpp Calls new platform_deinit() during shutdown/cleanup.
plugin/NetworkManagerImplementation.h Adds mutex-protected default-interface getters/setters; forward-declares NMClient/GMainContext; declares platform_deinit().
plugin/NetworkManagerJsonRpc.cpp Adds nullptr checks for created iterators in JSON-RPC endpoints/SSIDs flows.
plugin/gnome/NetworkManagerGnomeProxy.cpp Introduces isolated GMainContext + m_nmClient member usage and context-drain iterations for safer libnm access.
plugin/gnome/NetworkManagerGnomeWIFI.cpp Improves WPS error-path cleanup and adds scan request error handling; fixes log typo.
plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp Switches default-interface handling to the new thread-safe accessors and adds iterator nullptr checks.
plugin/rdk/NetworkManagerRDKProxy.cpp Switches default-interface handling to thread-safe accessors; adds iterator nullptr checks; adds stub platform_deinit().
tests/l2Test/libnm/l2_test_libnmproxy.cpp Fixes a duplicated/malformed mock .WillOnce(...) chain; minor formatting.
tests/l2Test/libnm/l2_test_libnmproxyWifi.cpp Removes stray whitespace-only lines; no behavior change.
networkstats/CMakeLists.txt Adds a standalone-style CMake entry for NetworkConnectionStats (interface + plugin).
networkstats/NetworkStatsDesign_ver1.md Adds design documentation for the network stats module.
networkstats/README_INTERNAL_PLUGIN.md Adds internal-plugin documentation and operational notes.
networkstats/THUNDER_PLUGIN_CONVERSION.md Adds conversion notes/documentation for Thunder plugin integration.
networkstats/THUNDER_PLUGIN_QUICK_REFERENCE.md Adds quick reference documentation for the plugin pattern.
networkstats/definition/CMakeLists.txt Adds JSON-RPC documentation generation CMake (currently not wired in main networkstats/CMakeLists.txt).
networkstats/definition/NetworkConnectionStats.json Adds a JSON-RPC API definition document for NetworkConnectionStats.
networkstats/interface/CMakeLists.txt Adds ProxyStub generation build for INetworkConnectionStats.
networkstats/interface/INetworkConnectionStats.h Adds COM-RPC interface for NetworkConnectionStats (Configure + Register/Unregister).
networkstats/plugin/CMakeLists.txt Adds build rules for in-process plugin + out-of-process implementation and providers.
networkstats/plugin/INetworkData.h Defines provider interface used by NetworkConnectionStats implementation.
networkstats/plugin/Module.cpp Adds module declaration for NetworkConnectionStats.
networkstats/plugin/Module.h Adds module header for NetworkConnectionStats.
networkstats/plugin/NetworkConnectionStats.config Adds plugin configuration template (CMake config generator format).
networkstats/plugin/NetworkConnectionStats.conf.in Adds plugin configuration .conf.in template.
networkstats/plugin/NetworkConnectionStats.cpp Adds in-process Thunder plugin shell spawning out-of-process implementation.
networkstats/plugin/NetworkConnectionStats.h Adds plugin class declaration (IPlugin + interface aggregation).
networkstats/plugin/NetworkConnectionStatsImplementation.cpp Adds out-of-process implementation: diagnostics, event subscription, state machine, periodic reporting.
networkstats/plugin/NetworkConnectionStatsImplementation.h Adds implementation header: state machine + worker threads + provider integration.
networkstats/plugin/NetworkConnectionStatsLogger.cpp Adds logging backend for the NetworkConnectionStats module.
networkstats/plugin/NetworkConnectionStatsLogger.h Adds logging macros and logger API for the NetworkConnectionStats module.
networkstats/plugin/NetworkDataProviderFactory.h Adds provider factory (COM-RPC vs JSON-RPC).
networkstats/plugin/ThunderComRPCProvider.cpp Adds COM-RPC provider implementation for NetworkManager interactions.
networkstats/plugin/ThunderComRPCProvider.h Adds COM-RPC provider header.
networkstats/plugin/ThunderJsonRPCProvider.cpp Adds JSON-RPC provider implementation for NetworkManager interactions.
networkstats/plugin/ThunderJsonRPCProvider.h Adds JSON-RPC provider header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugin/NetworkManagerJsonRpc.cpp
Comment thread CMakeLists.txt
Comment thread plugin/gnome/NetworkManagerGnomeProxy.cpp
Comment thread plugin/NetworkManagerImplementation.cpp
Comment thread plugin/rdk/NetworkManagerRDKProxy.cpp
Comment thread plugin/NetworkManagerConnectivity.cpp Outdated
Comment thread plugin/NetworkManagerJsonRpc.cpp
@gururaajar gururaajar changed the title RDK-61007 : NetworkconnectionRecovery.sh migration to C/C++ Module RDKEMW-17624 : NetworkconnectionRecovery.sh migration to C/C++ Module Apr 24, 2026
Copilot AI review requested due to automatic review settings April 24, 2026 21:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an out-of-process NetworkConnectionStats Thunder plugin intended to replace functionality previously handled by NetworkconnectionRecovery.sh, and also hardens parts of the existing NetworkManager plugin around default-interface handling, iterator creation, and libnm client lifecycle.

Changes:

  • Add new networkstats out-of-process plugin (providers, state machine, logging, build + config scaffolding).
  • Make NetworkManager default-interface access thread-safe and add platform_deinit() hooks across platform backends.
  • Improve stability checks (null iterator returns, GLib context cleanup paths, minor log/error handling and test tidy-ups).

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/l2Test/libnm/l2_test_libnmproxyWifi.cpp Minor whitespace cleanup in a WiFi connect test.
tests/l2Test/libnm/l2_test_libnmproxy.cpp Fix duplicated mock expectation and formatting.
plugin/rdk/NetworkManagerRDKProxy.cpp Use locked default-interface accessors; add platform deinit stub; iterator null-check.
plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp Use locked default-interface accessors; add platform deinit stub; iterator null-check.
plugin/gnome/NetworkManagerGnomeWIFI.cpp Fix typo and add GLib context cleanup + scan-error handling.
plugin/gnome/NetworkManagerGnomeProxy.cpp Replace global NMClient with per-instance client/context; add platform_deinit; iterator null-checks.
plugin/NetworkManagerJsonRpc.cpp Add null checks after iterator creation for endpoints/SSIDs.
plugin/NetworkManagerImplementation.h Introduce mutex-protected default-interface getters/setters; add NMClient/GMainContext members; declare platform_deinit.
plugin/NetworkManagerImplementation.cpp Call platform_deinit at shutdown; use locked default-interface accessors; add iterator null-check.
plugin/NetworkManagerConnectivity.cpp Use locked default-interface accessor instead of direct member access.
networkstats/plugin/ThunderJsonRPCProvider.h Add JSON-RPC-based NetworkManager client provider interface.
networkstats/plugin/ThunderJsonRPCProvider.cpp Implement JSON-RPC provider for IP settings, ping, events, and WiFi reconnect.
networkstats/plugin/ThunderComRPCProvider.h Add COM-RPC LinkType-based NetworkManager client provider interface.
networkstats/plugin/ThunderComRPCProvider.cpp Implement COM-RPC provider for IP settings, ping, events, and WiFi reconnect.
networkstats/plugin/NetworkDataProviderFactory.h Add factory to select provider type (comrpc/jsonrpc).
networkstats/plugin/NetworkConnectionStatsLogger.h Add logger API/macros for networkstats plugin.
networkstats/plugin/NetworkConnectionStatsLogger.cpp Implement logger backend (RDK logger or stdout).
networkstats/plugin/NetworkConnectionStatsImplementation.h Define out-of-process implementation (state machine, threads, queue).
networkstats/plugin/NetworkConnectionStatsImplementation.cpp Implement event-driven + periodic diagnostics and WiFi reassociation logic.
networkstats/plugin/NetworkConnectionStats.h Define in-process plugin wrapper that spawns OOP implementation.
networkstats/plugin/NetworkConnectionStats.cpp Implement plugin lifecycle + OOP instantiation and teardown.
networkstats/plugin/NetworkConnectionStats.config Add plugin config template inputs (interval/providerType/OOP locator).
networkstats/plugin/NetworkConnectionStats.conf.in Add Thunder config generation template.
networkstats/plugin/Module.h Add networkstats module header for Thunder build integration.
networkstats/plugin/Module.cpp Add module declaration for networkstats.
networkstats/plugin/INetworkData.h Define abstract provider interface used by NetworkConnectionStatsImplementation.
networkstats/plugin/CMakeLists.txt Add build rules for plugin + OOP implementation, options for telemetry/RFC.
networkstats/interface/INetworkConnectionStats.h Add COM-RPC interface definition for NetworkConnectionStats.
networkstats/interface/CMakeLists.txt Add ProxyStub generation and install rules for the interface.
networkstats/definition/NetworkConnectionStats.json Add JSON-RPC API definition (currently not built by top-level CMake).
networkstats/definition/CMakeLists.txt Add JsonGenerator docs generation for the definition (currently not built).
networkstats/THUNDER_PLUGIN_QUICK_REFERENCE.md Add quick-reference documentation for plugin architecture/usage.
networkstats/THUNDER_PLUGIN_CONVERSION.md Add conversion notes documenting migration to Thunder plugin structure.
networkstats/README_INTERNAL_PLUGIN.md Add internal-only plugin README (runtime behavior/config).
networkstats/NetworkStatsDesign_ver1.md Add design document describing architecture/sequence diagrams.
networkstats/CMakeLists.txt Add networkstats subproject build entrypoint.
legacy/LegacyWiFiManagerAPIs.cpp Add null-check after iterator creation.
legacy/LegacyNetworkAPIs.cpp Add null-check after iterator creation.
CMakeLists.txt Add add_subdirectory(networkstats) to top-level build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread networkstats/CMakeLists.txt
Comment thread networkstats/plugin/ThunderJsonRPCProvider.cpp
Comment thread networkstats/README_INTERNAL_PLUGIN.md
Comment thread networkstats/plugin/NetworkConnectionStatsImplementation.cpp
Comment thread plugin/gnome/NetworkManagerGnomeProxy.cpp
Comment thread plugin/rdk/NetworkManagerRDKProxy.cpp
Copilot AI review requested due to automatic review settings April 24, 2026 21:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the functionality previously handled by NetworkconnectionRecovery.sh into a new out-of-process Thunder plugin/module (NetworkConnectionStats), and updates NetworkManager internals for safer default-interface handling and lifecycle cleanup across backends.

Changes:

  • Added a new networkstats/ Thunder plugin (in-process wrapper + out-of-process implementation) that subscribes to NetworkManager events, performs periodic diagnostics, emits telemetry, and triggers WiFi reassociation on gateway packet-loss thresholds.
  • Refactored NetworkManager default-interface state to use mutex-protected accessors and updated multiple backends/callers accordingly.
  • Improved lifecycle/robustness in several places (platform deinit hooks, iterator null checks, GLib context cleanup paths, minor test fixes).

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/l2Test/libnm/l2_test_libnmproxyWifi.cpp Minor test formatting cleanup (whitespace removal).
tests/l2Test/libnm/l2_test_libnmproxy.cpp Fixes a duplicated EXPECT_CALL chain line and normalizes closing brace formatting.
plugin/rdk/NetworkManagerRDKProxy.cpp Uses locked default-interface accessors; adds platform deinit stub; adds iterator null check.
plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp Adds platform deinit stub; switches to locked default-interface setter/getter; adds iterator null check.
plugin/gnome/NetworkManagerGnomeWIFI.cpp Fixes log typo; ensures GMainContext cleanup on error paths; logs scan request failures.
plugin/gnome/NetworkManagerGnomeProxy.cpp Replaces global NMClient with per-instance client/context; adds platform_deinit cleanup; drains isolated context before reads; improves IP address handling; adds iterator null check.
plugin/NetworkManagerJsonRpc.cpp Adds null checks after creating iterators in JSON-RPC handlers.
plugin/NetworkManagerImplementation.h Adds platform_deinit(), adds mutex-protected default-interface accessors, and stores NMClient/GMainContext for GNOME backend.
plugin/NetworkManagerImplementation.cpp Calls platform_deinit() during shutdown; switches default-interface access to accessor methods; adds iterator creation null checks.
plugin/NetworkManagerConnectivity.cpp Switches default-interface usage to accessor; threads default iface through connectivity monitor logic.
networkstats/plugin/ThunderJsonRPCProvider.h Introduces JSON-RPC-based NetworkManager provider interface for networkstats.
networkstats/plugin/ThunderJsonRPCProvider.cpp Implements JSON-RPC NetworkManager calls for IP settings, interface, ping, and event subscription.
networkstats/plugin/ThunderComRPCProvider.h Introduces COM-RPC-based NetworkManager provider interface for networkstats.
networkstats/plugin/ThunderComRPCProvider.cpp Implements COM-RPC NetworkManager calls for IP settings, interface, ping, and event subscription.
networkstats/plugin/NetworkDataProviderFactory.h Adds factory for selecting COM-RPC vs JSON-RPC provider at runtime.
networkstats/plugin/NetworkConnectionStatsLogger.h Adds logging API/macros for the new networkstats plugin.
networkstats/plugin/NetworkConnectionStatsLogger.cpp Implements logging backend (stdout/RDK logger) used by networkstats.
networkstats/plugin/NetworkConnectionStatsImplementation.h Declares out-of-process implementation: diagnostics, state machine, threads, subscriptions.
networkstats/plugin/NetworkConnectionStatsImplementation.cpp Implements periodic diagnostics, event subscription/retry, packet-loss reassociation logic, and telemetry.
networkstats/plugin/NetworkConnectionStats.h Adds in-process plugin wrapper to spawn/own out-of-process implementation.
networkstats/plugin/NetworkConnectionStats.cpp Implements plugin lifecycle for NetworkConnectionStats and configuration forwarding.
networkstats/plugin/NetworkConnectionStats.config Adds plugin config template (callsign/out-of-process locator + reporting interval/provider type).
networkstats/plugin/NetworkConnectionStats.conf.in Adds config generation template for build-time substitution.
networkstats/plugin/Module.h Adds module header for NetworkConnectionStats plugin build.
networkstats/plugin/Module.cpp Adds module declaration for NetworkConnectionStats plugin.
networkstats/plugin/INetworkData.h Adds provider abstraction used by NetworkConnectionStatsImplementation.
networkstats/plugin/CMakeLists.txt Adds build/install rules for in-process + out-of-process NetworkConnectionStats libraries and config variables.
networkstats/interface/INetworkConnectionStats.h Adds COM-RPC interface definition for NetworkConnectionStats.
networkstats/interface/CMakeLists.txt Adds ProxyStub generation/build for NetworkConnectionStats COM-RPC interface.
networkstats/definition/NetworkConnectionStats.json Adds JSON definition file for NetworkConnectionStats (documentation/spec generation).
networkstats/definition/CMakeLists.txt Adds JsonGenerator invocation for the NetworkConnectionStats definition.
networkstats/THUNDER_PLUGIN_QUICK_REFERENCE.md Adds architecture/reference documentation for the new plugin.
networkstats/THUNDER_PLUGIN_CONVERSION.md Adds conversion notes describing migration into Thunder plugin architecture.
networkstats/README_INTERNAL_PLUGIN.md Adds internal-only plugin design/readme for NetworkConnectionStats.
networkstats/NetworkStatsDesign_ver1.md Adds design document describing networkstats behavior/sequence flows.
networkstats/CMakeLists.txt Adds subproject CMake entry for networkstats.
legacy/LegacyWiFiManagerAPIs.cpp Adds iterator null check in legacy WiFi path.
legacy/LegacyNetworkAPIs.cpp Adds iterator null check in legacy network path.
CMakeLists.txt Adds add_subdirectory(networkstats) to build the new plugin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +28
cmake_minimum_required(VERSION 3.3)

project(NetworkConnectionStats)

find_package(WPEFramework QUIET CONFIG)

message("Building ${PROJECT_NAME} Thunder Plugin (Internal-only, no external APIs)")

# Set project version
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
Comment on lines +386 to +488
void NetworkConnectionStatsImplementation::gatewayPacketLossCheck()
{
if (!m_provider) {
return;
}

// Get RFC threshold for WiFi reassociation tolerance (default: 100%)
int reassocTolerance = 100;
#ifdef USE_RFCAPI
{
RFC_ParamData_t rfcParam = {0};
WDMP_STATUS wdmpStatus = getRFCParameter("NetworkStats",
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.WiFiReset.ReassociateTolerance",
&rfcParam);
if (wdmpStatus == WDMP_SUCCESS || wdmpStatus == WDMP_ERR_DEFAULT_VALUE) {
int rfcValue = atoi(rfcParam.value);
if (rfcValue > 0 && rfcValue <= 100) {
reassocTolerance = rfcValue;
NSLOG_INFO("RFC WiFiReset.ReassociateTolerance = %d%%", reassocTolerance);
} else {
NSLOG_WARNING("RFC ReassociateTolerance value '%s' is out of range, using default %d%%",
rfcParam.value, reassocTolerance);
}
} else {
NSLOG_WARNING("getRFCParameter for ReassociateTolerance failed (status=%d), using default %d%%",
wdmpStatus, reassocTolerance);
}
}
#endif

bool ipv4PacketLoss100 = false;
bool ipv6PacketLoss100 = false;

// Check IPv4 gateway packet loss
if (!m_ipv4Route.empty() && m_ipv4Route != "0.0.0.0") {
NSLOG_INFO("Pinging IPv4 gateway: %s", m_ipv4Route.c_str());
bool success = m_provider->pingToGatewayCheck(m_ipv4Route, "IPv4", 10);
std::string packetLoss = m_provider->getPacketLoss();
std::string avgRtt = m_provider->getAvgRtt();

// Check if packet loss meets or exceeds RFC reassociation threshold
try {
if (static_cast<int>(std::stof(packetLoss)) >= reassocTolerance) {
ipv4PacketLoss100 = true;
}
} catch (...) {}

if (success) {
NSLOG_INFO("IPv4 gateway ping Loss: %s%%, RTT: %s",
packetLoss.c_str(), avgRtt.c_str());

logTelemetry("IPv4_Gateway_Packet_Loss", packetLoss);
logTelemetry("IPv4_Gateway_RTT", avgRtt);
} else {
NSLOG_ERROR("IPv4 gateway ping failed");
logTelemetry("IPv4_Gateway_Packet_Loss", packetLoss);
logTelemetry("IPv4_Gateway_RTT", avgRtt);
}
}

// Check IPv6 gateway packet loss
if (!m_ipv6Route.empty() && m_ipv6Route != "::") {
// Append zone ID for link-local IPv6 addresses
std::string ipv6Gateway = m_ipv6Route;
if (ipv6Gateway.find("fe80::") == 0 && !m_interface.empty()) {
ipv6Gateway += "%" + m_interface;
}
NSLOG_INFO("Pinging IPv6 gateway: %s", ipv6Gateway.c_str());
bool success = m_provider->pingToGatewayCheck(ipv6Gateway, "IPv6", 10);
std::string packetLoss = m_provider->getPacketLoss();
std::string avgRtt = m_provider->getAvgRtt();

// Check if packet loss meets or exceeds RFC reassociation threshold
try {
if (static_cast<int>(std::stof(packetLoss)) >= reassocTolerance) {
ipv6PacketLoss100 = true;
}
} catch (...) {}

if (success) {
NSLOG_INFO("IPv6 gateway ping Loss: %s%%, RTT: %s",
packetLoss.c_str(), avgRtt.c_str());

logTelemetry("IPv6_Gateway_Packet_Loss", packetLoss);
logTelemetry("IPv6_Gateway_RTT", avgRtt);
} else {
NSLOG_ERROR("IPv6 gateway ping failed");
logTelemetry("IPv6_Gateway_Packet_Loss", packetLoss);
logTelemetry("IPv6_Gateway_RTT", avgRtt);
}
}

// WiFi reassociation logic
// Trigger reassociation if:
// 1. Connection type is WiFi
// 2. Both IPv4 and IPv6 packet loss meets or exceeds RFC threshold
std::string connType = m_provider->getConnectionType();

if ((connType == "WIFI" || connType == "WiFi" || connType == "wifi") &&
ipv4PacketLoss100 && ipv6PacketLoss100) {
NSLOG_WARNING("WiFi connection: Both IPv4 and IPv6 gateways have packet loss >= %d%%", reassocTolerance);
sendMessage(NetworkEvent::GATEWAY_PACKET_LOSS, nullptr);
}
Comment on lines +402 to +403
if(getDefaultInterface() != iface.name)
ReportActiveInterfaceChange(getDefaultInterface(), iface.name);
Comment on lines +318 to +320
if (m_nmContext) {
for (int i = 0; i < 100 && g_main_context_iteration(m_nmContext, FALSE); ++i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants