-
Notifications
You must be signed in to change notification settings - Fork 11
RDK-55826: Implement T2 Eventing in Network Manager Plugin #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
52699d7
ff035cb
186f0d8
83fcf38
c12ec05
2ae7116
d9ece30
f8c8374
d489419
d922d3c
ec96f54
5e4741a
9675698
8c8dd0b
95e646e
e276f75
29db318
ec68798
10e5403
689d218
a059df8
e067d31
d0c864f
9eb1f93
06ec81a
9f5b815
c2000ba
51a0569
98b2003
66785df
5a1bb0c
a3008ea
089419d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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() | ||
|
|
@@ -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 | ||
|
|
@@ -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(); | ||
| } | ||
|
|
||
|
|
@@ -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"); | ||
| } | ||
| #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(); | ||
| } | ||
|
|
||
|
|
@@ -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(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
|
|
@@ -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) { | ||
gururaajar marked this conversation as resolved.
Show resolved
Hide resolved
gururaajar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| NMLOG_ERROR("t2_event_s(\"%s\", \"%s\") failed with error %d", | ||
| eventName.c_str(), message.c_str(), t2error); | ||
| } | ||
| #endif | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,8 @@ | |||||
| #include <thread> | ||||||
| #include <string> | ||||||
| #include <map> | ||||||
| #include <sstream> | ||||||
| #include <fstream> | ||||||
| #include <NetworkManager.h> | ||||||
| #include <libnm/NetworkManager.h> | ||||||
| #include "Module.h" | ||||||
|
|
@@ -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; | ||||||
gururaajar marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| 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()); | ||||||
|
||||||
| 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()); |
There was a problem hiding this comment.
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.