Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
52699d7
RDK-55826: Implement T2 Eventing in Network Manager Plugin
gururaajar Feb 20, 2026
ff035cb
RDK-55826: Implement T2 Eventing in Network Manager Plugin
gururaajar Feb 20, 2026
186f0d8
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
83fcf38
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
c12ec05
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
2ae7116
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
d9ece30
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
f8c8374
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
d489419
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
d922d3c
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
ec96f54
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
5e4741a
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 24, 2026
9675698
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
8c8dd0b
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
95e646e
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
e276f75
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
29db318
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
ec68798
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
10e5403
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
689d218
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
a059df8
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
e067d31
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 25, 2026
d0c864f
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 26, 2026
9eb1f93
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Feb 26, 2026
06ec81a
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 2, 2026
9f5b815
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 2, 2026
c2000ba
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 2, 2026
51a0569
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 2, 2026
98b2003
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 2, 2026
66785df
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 2, 2026
5a1bb0c
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 3, 2026
a3008ea
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 3, 2026
089419d
Merge branch 'topic/RDK-55826' of github.com:rdkcentral/networkmanage…
gururaajar Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ get_directory_property(SEVICES_DEFINES COMPILE_DEFINITIONS)
option(ENABLE_LEGACY_PLUGINS "Enable Legacy Plugins" ON)
option(USE_RDK_LOGGER "Enable RDK Logger for logging" OFF )
option(ENABLE_UNIT_TESTING "Enable unit tests" OFF)
option(USE_TELEMETRY "Enable Telemetry T2 support" OFF)

if (USE_TELEMETRY)
find_package(T2 REQUIRED)
add_compile_definitions(USE_TELEMETRY=1)
message("Telemetry support enabled")
endif(USE_TELEMETRY)

add_subdirectory(interface)
add_subdirectory(definition)
Expand All @@ -70,4 +76,3 @@ if(ENABLE_UNIT_TESTING)
add_subdirectory(tests/l1Test)
add_subdirectory(tests/l2Test)
endif(ENABLE_UNIT_TESTING)

9 changes: 8 additions & 1 deletion plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ if (USE_RDK_LOGGER)
include_directories(${RDKLOGGER_INCLUDE_DIRS})
endif (USE_RDK_LOGGER)


if (USE_TELEMETRY)
include_directories(${T2_INCLUDE_DIRS})
endif (USE_TELEMETRY)

if(ENABLE_GNOME_NETWORKMANAGER)
pkg_check_modules(GLIB REQUIRED glib-2.0)
Expand Down Expand Up @@ -141,6 +143,11 @@ if (USE_RDK_LOGGER)
target_link_libraries(${MODULE_IMPL_NAME} PRIVATE ${RDKLOGGER_LIBRARIES})
endif (USE_RDK_LOGGER)

if (USE_TELEMETRY)
target_link_libraries(${MODULE_NAME} PRIVATE ${T2_LIBRARIES})
target_link_libraries(${MODULE_IMPL_NAME} PRIVATE ${T2_LIBRARIES})
endif (USE_TELEMETRY)

install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE_DIRECTORY}/plugins)
install(TARGETS ${MODULE_IMPL_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE_DIRECTORY}/plugins)

Expand Down
55 changes: 55 additions & 0 deletions plugin/NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#include <thread>
#include <chrono>
#include "NetworkManagerImplementation.h"

#if USE_TELEMETRY
#include "NetworkManagerJsonEnum.h"
#include <telemetry_busmessage_sender.h>
#endif

using namespace WPEFramework;
using namespace WPEFramework::Plugin;
using namespace NetworkManagerLogger;
Expand Down Expand Up @@ -56,6 +62,10 @@ namespace WPEFramework
NetworkManagerLogger::Init();
NMLOG_INFO((_T("NWMgrPlugin Out-Of-Process Instantiation; SHA: " _T(EXPAND_AND_QUOTE(PLUGIN_BUILD_REFERENCE)))));
m_processMonThread = std::thread(&NetworkManagerImplementation::processMonitor, this, NM_PROCESS_MONITOR_INTERVAL_SEC);
#if USE_TELEMETRY
// Initialize Telemetry T2 for NwMgrPlugin
t2_init("NwMgrPlugin");
#endif
}

NetworkManagerImplementation::~NetworkManagerImplementation()
Expand Down Expand Up @@ -357,6 +367,13 @@ namespace WPEFramework
interface = m_defaultInterface;

ipaddress = result.public_ip;
#if USE_TELEMETRY
if(ipversion == "IPv4")
{
NMLOG_INFO("NM_PUBLIC_IPV4 = %s", ipaddress.c_str());
logTelemetry("NM_PUBLIC_IPV4", ipaddress);
}
#endif
return Core::ERROR_NONE;
}
else
Expand Down Expand Up @@ -710,6 +727,10 @@ namespace WPEFramework
for (const auto callback : _notificationCallbacks) {
callback->onActiveInterfaceChange(prevActiveInterface, currentActiveinterface);
}
#if USE_TELEMETRY
NMLOG_INFO("NM_INTERFACE_STATUS = Active Interface changed");
logTelemetry("NM_INTERFACE_STATUS", "Interface changed to " + currentActiveinterface);
#endif
_notificationLock.Unlock();
}

Expand Down Expand Up @@ -756,9 +777,24 @@ namespace WPEFramework
{
_notificationLock.Lock();
NMLOG_INFO("Posting onInternetStatusChange with current state as %u", (unsigned)currState);
#if USE_TELEMETRY
// Log error only when ethernet is down and there's no internet
if(currState == Exchange::INetworkManager::INTERNET_NOT_AVAILABLE &&
!m_ethConnected.load() &&
prevState != Exchange::INetworkManager::INTERNET_NOT_AVAILABLE)
{
NMLOG_INFO("NM_ETHERNET_FAILED = Ethernet is down, no internet");
logTelemetry("NM_ETHERNET_FAILED", "Ethernet is down, no internet");
Copy link

Choose a reason for hiding this comment

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

change the marker name to clearly indicate ethernet connectivity failed.

}
#endif
for (const auto callback : _notificationCallbacks) {
callback->onInternetStatusChange(prevState, currState, interface);
}
#if USE_TELEMETRY
string stateStr = Core::EnumerateType<Exchange::INetworkManager::InternetStatus>(currState).Data();
NMLOG_INFO("NM_INTERNET_STATUS = %s", stateStr.c_str());
logTelemetry("NM_INTERNET_STATUS", stateStr);
#endif
_notificationLock.Unlock();
}

Expand Down Expand Up @@ -1107,6 +1143,14 @@ namespace WPEFramework

_notificationLock.Lock();
NMLOG_INFO("Posting onWiFiStateChange (%d)", state);
#if USE_TELEMETRY
string stateStr = Core::EnumerateType<Exchange::INetworkManager::WiFiState>(state).Data();
Copy link

Choose a reason for hiding this comment

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

log always, dont need to check for state.

if(INetworkManager::WiFiState::WIFI_STATE_CONNECTED == state)
NMLOG_INFO("NM_WIFI_STATUS = %s", stateStr.c_str());
else if(INetworkManager::WiFiState::WIFI_STATE_DISCONNECTED == state)
NMLOG_INFO("NM_WIFI_STATUS = %s", stateStr.c_str());
logTelemetry("NM_WIFI_STATUS", stateStr);
#endif
for (const auto callback : _notificationCallbacks) {
callback->onWiFiStateChange(state);
}
Expand All @@ -1122,5 +1166,16 @@ namespace WPEFramework
}
_notificationLock.Unlock();
}

void NetworkManagerImplementation::logTelemetry(const std::string& eventName, const std::string& message)
{
#if USE_TELEMETRY
T2ERROR t2error = t2_event_s(eventName.c_str(), const_cast<char*>(message.c_str()));
if (t2error != T2ERROR_SUCCESS) {
NMLOG_ERROR("t2_event_s(\"%s\", \"%s\") failed with error %d",
eventName.c_str(), message.c_str(), t2error);
}
#endif
}
}
}
1 change: 1 addition & 0 deletions plugin/NetworkManagerImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ namespace WPEFramework
void ReportAvailableSSIDs(const JsonArray &arrayofWiFiScanResults);
void ReportWiFiStateChange(const Exchange::INetworkManager::WiFiState state);
void ReportWiFiSignalQualityChange(const string ssid, const int strength, const int noise, const int snr, const Exchange::INetworkManager::WiFiSignalQuality quality);
void logTelemetry(const std::string& eventName, const std::string& message);

private:
void platform_init(void);
Expand Down
29 changes: 28 additions & 1 deletion plugin/gnome/NetworkManagerGnomeEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,35 @@ namespace WPEFramework
}
if (nm_ip_address_get_family(address) == AF_INET) {
const char *ipAddress = nm_ip_address_get_address(address);
if(ipAddress != NULL)
if(ipAddress != NULL) {
GnomeNetworkManagerEvents::onAddressChangeCb(iface, ipAddress, true, false);
// Get gateway MAC address for WiFi and Ethernet after IP is acquired
if(ifname == nmUtils::wlanIface() || ifname == nmUtils::ethIface()) {
static std::map<std::string, std::string> gatewayMacCache;
NMClient *client = nm_object_get_client(NM_OBJECT(device));
if (client != NULL) {
std::string gatewayMac = nmUtils::getGatewayMacAddress(client, ifname);
if (!gatewayMac.empty()) {
// Only log when MAC changes or is first time
if (gatewayMacCache[ifname] != gatewayMac) {
gatewayMacCache[ifname] = gatewayMac;
#if USE_TELEMETRY
if(ifname == nmUtils::wlanIface()
{
NMLOG_INFO("NM_WIFI_GW_MAC = %s", gatewayMac.c_str());
_instance->logTelemetry("NM_WIFI_GW_MAC", gatewayMac);
}
else if(ifname == nmUtils::ethIface())
{
NMLOG_INFO("NM_ETHERNET_GW_MAC = %s", gatewayMac.c_str());
_instance->logTelemetry("NM_ETHERNET_GW_MAC", gatewayMac);
}
#endif
}
}
}
}
}
}
}
}
Expand Down
97 changes: 97 additions & 0 deletions plugin/gnome/NetworkManagerGnomeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <thread>
#include <string>
#include <map>
#include <sstream>
#include <fstream>
#include <NetworkManager.h>
#include <libnm/NetworkManager.h>
#include "Module.h"
Expand Down Expand Up @@ -389,5 +391,100 @@ namespace WPEFramework
return false;
}

std::string nmUtils::resolveGatewayMac(const std::string& gatewayIp)
{
std::string mac = "";
std::string arpFile = "/proc/net/arp";
std::ifstream file(arpFile);
std::string line;

if (!file.is_open()) {
NMLOG_ERROR("Failed to open %s", arpFile.c_str());
return mac;
}

// Skip header
std::getline(file, line);

while (std::getline(file, line)) {
std::istringstream iss(line);
std::string ip, hwType, flags, hwAddr;

if (iss >> ip >> hwType >> flags >> hwAddr) {
if (ip == gatewayIp && hwAddr != "00:00:00:00:00:00") {
mac = hwAddr;
NMLOG_INFO("Resolved gateway IP %s to MAC %s", gatewayIp.c_str(), mac.c_str());
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

This function logs the resolved gateway MAC at INFO level. MAC addresses are typically treated as sensitive identifiers; consider lowering this to DEBUG and/or avoid logging the full MAC unless needed for diagnostics.

Suggested change
NMLOG_INFO("Resolved gateway IP %s to MAC %s", gatewayIp.c_str(), mac.c_str());
NMLOG_DEBUG("Resolved gateway IP %s to MAC %s", gatewayIp.c_str(), mac.c_str());

Copilot uses AI. Check for mistakes.
break;
}
}
}

if (mac.empty()) {
NMLOG_WARNING("Could not resolve gateway IP %s to MAC address", gatewayIp.c_str());
}

return mac;
}

std::string nmUtils::getGatewayMacAddress(NMClient* client, const std::string& interface)
{
std::string gatewayMac = "";

if (client == NULL) {
NMLOG_ERROR("NMClient is NULL");
return gatewayMac;
}

if (interface.empty()) {
NMLOG_ERROR("Interface name is empty");
return gatewayMac;
}

// Get all active connections and find the one for our interface
const GPtrArray *activeConnections = nm_client_get_active_connections(client);
if (!activeConnections) {
NMLOG_WARNING("No active connections found");
return gatewayMac;
}

for (guint i = 0; i < activeConnections->len; i++) {
NMActiveConnection *activeConn = NM_ACTIVE_CONNECTION(g_ptr_array_index(activeConnections, i));
if (!activeConn) continue;

// Get devices for this connection
const GPtrArray *devices = nm_active_connection_get_devices(activeConn);
if (!devices) continue;

// Check if this connection belongs to our interface
for (guint j = 0; j < devices->len; j++) {
NMDevice *device = NM_DEVICE(g_ptr_array_index(devices, j));
if (!device) continue;

const char *ifname = nm_device_get_iface(device);
if (ifname && interface == ifname) {
// Found the connection for our interface
NMIPConfig *ip4Config = nm_active_connection_get_ip4_config(activeConn);
if (ip4Config) {
const char *gateway = nm_ip_config_get_gateway(ip4Config);
if (gateway) {
NMLOG_DEBUG("Found gateway IP for %s: %s", interface.c_str(), gateway);
// Use ARP to resolve gateway IP to MAC address
gatewayMac = resolveGatewayMac(gateway);
return gatewayMac;
} else {
NMLOG_WARNING("No gateway found for %s", interface.c_str());
}
} else {
NMLOG_WARNING("No IPv4 configuration found for %s", interface.c_str());
}
return gatewayMac;
}
}
}

NMLOG_WARNING("No active connection found for interface %s", interface.c_str());
return gatewayMac;
}

} // Plugin
} // WPEFramework
2 changes: 2 additions & 0 deletions plugin/gnome/NetworkManagerGnomeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace WPEFramework
static bool isInterfaceEnabled(const std::string& interface);
static bool writePersistentHostname(const std::string& hostname);
static bool readPersistentHostname(std::string& hostname);
static std::string resolveGatewayMac(const std::string& gatewayIp);
static std::string getGatewayMacAddress(NMClient* client, const std::string& interface);
};
}
}
1 change: 0 additions & 1 deletion plugin/gnome/NetworkManagerGnomeWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,6 @@ namespace WPEFramework
std::string activeSSID{};

NMLOG_DEBUG("wifi connect ssid: %s, security %d persist %d", ssidInfoParam.ssid.c_str(), ssidInfoParam.security, ssidInfoParam.persist);

Exchange::INetworkManager::WiFiConnectTo ssidInfo = ssidInfoParam;
m_isSuccess = false;
if(!createClientNewConnection())
Expand Down
2 changes: 1 addition & 1 deletion tools/plugincli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if(ENABLE_GNOME_GDBUS)

target_compile_options(${PLUGIN_GDBUS_CLI} PRIVATE ${COMMON_COMPILE_OPTIONS})
target_include_directories(${PLUGIN_GDBUS_CLI} PRIVATE ${COMMON_INCLUDES})
target_link_libraries(${PLUGIN_GDBUS_CLI} PRIVATE ${COMMON_LIBS} uuid)
target_link_libraries(${PLUGIN_GDBUS_CLI} PRIVATE ${COMMON_LIBS} ${LIBNM_LIBRARIES} uuid)

install(TARGETS ${PLUGIN_GDBUS_CLI} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

Expand Down
4 changes: 1 addition & 3 deletions tools/upnp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ if (NOT GUPNP_FOUND)
endif ()

if (USE_TELEMETRY)
find_package(T2 REQUIRED)
add_definitions(-DUSE_TELEMETRY)
include_directories(${TELEMETRY_INCLUDE_DIRS})
include_directories(${T2_INCLUDE_DIRS})
endif (USE_TELEMETRY)

add_definitions(-DENABLE_ROUTER_DISCOVERY_MAIN)
Expand Down
Loading