From a3809d74c45863c8c7fa6be4865d270395723670 Mon Sep 17 00:00:00 2001 From: Karunakaran A <48997923+karuna2git@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:02:32 -0500 Subject: [PATCH 1/3] DELIA-66775 : Handle onIPAddressChange Event (#27) Reason for change: Fixed the empty IPAddress in onIPAddressChange Event Test Procedure: as per DELIA-66775 Risks: Medium Signed-off-by: Karunakaran A --- LegacyPlugin_NetworkAPIs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LegacyPlugin_NetworkAPIs.cpp b/LegacyPlugin_NetworkAPIs.cpp index 6a86dc49..64a6c04f 100644 --- a/LegacyPlugin_NetworkAPIs.cpp +++ b/LegacyPlugin_NetworkAPIs.cpp @@ -1034,11 +1034,11 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = { if (parameters["isIPv6"].Boolean()) { - legacyParams["ip6Address"] = parameters["ipAddress"]; + legacyParams["ip6Address"] = parameters["ipaddress"]; } else { - legacyParams["ip4Address"] = parameters["ipAddress"]; + legacyParams["ip4Address"] = parameters["ipaddress"]; } legacyParams["status"] = parameters["status"]; From 24b26f5cba9bb29d7fa963baa9d2957b84027ef9 Mon Sep 17 00:00:00 2001 From: gururaajar <83449026+gururaajar@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:46:02 -0500 Subject: [PATCH 2/3] RDKE-352 - Add StartWPS in GNOME libnm (#28) * Added support for start WPS * Added support for start WPS --- NetworkManagerGnomeProxy.cpp | 12 +++++-- NetworkManagerGnomeWIFI.cpp | 69 ++++++++++++++++++++++++++++++++++-- NetworkManagerGnomeWIFI.h | 2 ++ 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/NetworkManagerGnomeProxy.cpp b/NetworkManagerGnomeProxy.cpp index 6b1fbd31..bb32fc81 100644 --- a/NetworkManagerGnomeProxy.cpp +++ b/NetworkManagerGnomeProxy.cpp @@ -687,13 +687,21 @@ namespace WPEFramework uint32_t NetworkManagerImplementation::StartWPS(const WiFiWPS& method /* @in */, const string& wps_pin /* @in */) { - uint32_t rc = Core::ERROR_RPC_CALL_FAILED; + uint32_t rc = Core::ERROR_NONE; + if(wifi->initiateWPS()) + NMLOG_INFO ("startWPS success"); + else + rc = Core::ERROR_RPC_CALL_FAILED; return rc; } uint32_t NetworkManagerImplementation::StopWPS(void) { - uint32_t rc = Core::ERROR_RPC_CALL_FAILED; + uint32_t rc = Core::ERROR_NONE; + if(wifi->cancelWPS()) + NMLOG_INFO ("cancelWPS success"); + else + rc = Core::ERROR_RPC_CALL_FAILED; return rc; } diff --git a/NetworkManagerGnomeWIFI.cpp b/NetworkManagerGnomeWIFI.cpp index 12d8e49a..b2ae798b 100644 --- a/NetworkManagerGnomeWIFI.cpp +++ b/NetworkManagerGnomeWIFI.cpp @@ -29,8 +29,23 @@ #include "NetworkManagerGnomeWIFI.h" #include "NetworkManagerGnomeUtils.h" +using namespace std; namespace WPEFramework { + class Job : public Core::IDispatch { + public: + Job(function work) + : _work(work) + { + } + void Dispatch() override + { + _work(); + } + + private: + function _work; + }; namespace Plugin { @@ -508,7 +523,7 @@ namespace WPEFramework apRsnFlags = nm_access_point_get_rsn_flags(AccessPoint); // check ap flag ty securti we supporting - if(apFlags != NM_802_11_AP_FLAGS_NONE && strlen(password_in) < 1 ) + if(apFlags != NM_802_11_AP_FLAGS_NONE && strlen(password_in) < 1 && !(apFlags & NM_802_11_AP_FLAGS_WPS)) { NMLOG_ERROR("This ap(%s) security need password please add password!", ssid_in); return false; @@ -902,9 +917,57 @@ namespace WPEFramework return true; } NMLOG_DEBUG("Last Wi-Fi scan exceeded time limit."); - return false; - } + return false; + } + + bool wifiManager::initiateWPS() + { + Core::IWorkerPool::Instance().Submit(Core::ProxyType(Core::ProxyType::Create([&]() { + const GPtrArray *aps; + int count = 1, wpsConnected = 0; + if(!createClientNewConnection()) + return; + sleep(10); /* As we will get the ap info with NM_802_11_AP_FLAGS_WPS_PBC set after pressing the PBC button. + So we are waiting for 10 seconds here*/ + do{ + if(wifiScanRequest("")) + { + aps = nm_device_wifi_get_access_points(NM_DEVICE_WIFI(getNmDevice())); + for (guint i = 0; i < aps->len; i++) { + NMAccessPoint *ap = static_cast(g_ptr_array_index(aps, i)); + + guint32 flags = nm_access_point_get_flags(ap); + + NMLOG_INFO("AP Flags: 0x%x\n", flags); + + if (flags & NM_802_11_AP_FLAGS_WPS_PBC) { + Exchange::INetworkManager::WiFiConnectTo wifiData; + GBytes *ssid; + ssid = nm_access_point_get_ssid(ap); + gsize size; + const guint8 *ssidData = static_cast(g_bytes_get_data(ssid, &size)); + std::string ssidTmp(reinterpret_cast(ssidData), size); + wifiData.ssid = ssidTmp.c_str(); + NMLOG_INFO("connected ssid: %s", ssidTmp.c_str()); + if(wifiConnect(wifiData)) + wpsConnected = 1; + break; + } + } + } + sleep(3); /* Waiting time between successive scan */ + count++; + }while(count <= 3 && !wpsConnected); + NMLOG_INFO("Completed scanning and wpsconnect status = %d", wpsConnected); + }))); + return true; + } + + bool wifiManager::cancelWPS() + { + return true; + } } // namespace Plugin } // namespace WPEFramework diff --git a/NetworkManagerGnomeWIFI.h b/NetworkManagerGnomeWIFI.h index 8762f409..9ad556b8 100644 --- a/NetworkManagerGnomeWIFI.h +++ b/NetworkManagerGnomeWIFI.h @@ -53,6 +53,8 @@ namespace WPEFramework bool removeKnownSSID(const string& ssid); bool quit(NMDevice *wifiNMDevice); bool wait(GMainLoop *loop, int timeOutMs = 10000); // default maximium set as 10 sec + bool initiateWPS(); + bool cancelWPS(); private: NMDevice *getNmDevice(); From 45d61baa76ac1518982fb620a5db902eeb7671a3 Mon Sep 17 00:00:00 2001 From: Karunakaran A <48997923+karuna2git@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:06:58 -0500 Subject: [PATCH 3/3] RDKEMW-229 : Check the empty interface & ipversion input (#30) Reason for change: Check the empty interface & ipversion input Test Procedure: Call org.rdk.NetworkManager.GetIPSettings with no input param Risks: Medium Signed-off-by: Karunakaran A --- NetworkManagerJsonRpc.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/NetworkManagerJsonRpc.cpp b/NetworkManagerJsonRpc.cpp index 1963a70a..9b0a8ed3 100644 --- a/NetworkManagerJsonRpc.cpp +++ b/NetworkManagerJsonRpc.cpp @@ -290,8 +290,14 @@ namespace WPEFramework uint32_t rc = Core::ERROR_GENERAL; Exchange::INetworkManager::IPAddress address{}; - string interface = parameters["interface"].String(); - string ipversion = parameters["ipversion"].String(); + string interface{}; + string ipversion{}; + + if (parameters.HasLabel("interface")) + interface = parameters["interface"].String(); + + if (parameters.HasLabel("ipversion")) + ipversion = parameters["ipversion"].String(); if (_networkManager) rc = _networkManager->GetIPSettings(interface, ipversion, address);