Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e0ced9f
To test gdbus issue
gururaajar May 8, 2025
e9e9d99
To test gdbus issue
gururaajar May 8, 2025
5a9c776
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 8, 2025
f72be1c
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 8, 2025
b940b88
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 13, 2025
0ea4307
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 13, 2025
d32f53a
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 27, 2025
fc3c504
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 27, 2025
3d8de75
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 28, 2025
7bb4731
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 28, 2025
890cd40
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar May 28, 2025
952b96b
Update NetworkManagerGdbusClient.cpp
gururaajar Jun 6, 2025
edf03ff
Merge branch 'develop' into topic/gdbus_fix
gururaajar Jun 24, 2025
e1a68fb
Merge branch 'develop' into topic/gdbus_fix
karuna2git Jun 28, 2025
9b9701d
Merge branch 'develop' into topic/gdbus_fix
karuna2git Jun 28, 2025
e094b38
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar Jul 1, 2025
7c82394
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar Jul 1, 2025
783cdb6
Merge branch 'topic/gdbus_fix' of github.com:rdkcentral/networkmanage…
gururaajar Jul 1, 2025
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
82 changes: 72 additions & 10 deletions plugin/gnome/gdbus/NetworkManagerGdbusClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
#include "NetworkManagerLogger.h"
#include "NetworkManagerGdbusClient.h"
#include "NetworkManagerGdbusUtils.h"
#include "NetworkManagerImplementation.h"

namespace WPEFramework
{
namespace Plugin
{

extern NetworkManagerImplementation* _instance;
NetworkManagerClient::NetworkManagerClient() {
NMLOG_INFO("NetworkManagerClient");
}
Expand Down Expand Up @@ -541,11 +540,25 @@ namespace WPEFramework
return true;
}

bool NetworkManagerClient::getDefaultInterface(std::string& interface)
{
deviceInfo devInfo{};
std::string wifiname = GnomeUtils::getWifiIfname(), ethname = GnomeUtils::getEthIfname();
if(!GnomeUtils::getDeviceInfoByIfname(m_dbus, ethname.c_str(), devInfo))
return false;
if(devInfo.state > NM_DEVICE_STATE_DISCONNECTED && devInfo.state < NM_DEVICE_STATE_DEACTIVATING)
interface = ethname;
else
interface = wifiname; // default is wifi
return true;
}

bool NetworkManagerClient::getPrimaryInterface(std::string& interface)
{
GError* error = nullptr;
std::string primaryConnectionPath;
GDBusProxy *nmProxy = nullptr;

nmProxy = m_dbus.getNetworkManagerPropertyProxy("/org/freedesktop/NetworkManager");
if(nmProxy == nullptr)
return false;
Expand Down Expand Up @@ -753,7 +766,7 @@ namespace WPEFramework
return true;
}

bool NetworkManagerClient::getIPSettings(const std::string& interface, const std::string& ipversion, Exchange::INetworkManager::IPAddress& result)
bool NetworkManagerClient::getIPSettings(std::string& interface, const std::string& ipversion, Exchange::INetworkManager::IPAddress& result)
{
std::string devicePath;
std::string addressStr;
Expand All @@ -772,12 +785,54 @@ namespace WPEFramework
const gchar *IPv6Method = nullptr;
deviceInfo devInfo{};
GError *error = nullptr;

std::string wifiname = GnomeUtils::getWifiIfname(), ethname = GnomeUtils::getEthIfname();

if(interface.empty())
{
if(Core::ERROR_NONE != _instance->GetPrimaryInterface(interface))
{
NMLOG_WARNING("default interface get failed");
return true;
}
if(interface.empty())
{
NMLOG_DEBUG("default interface return empty default is wlan0");
interface = wifiname;
}
}
else if(wifiname != interface && ethname != interface)
{
NMLOG_ERROR("interface: %s; not valied", interface.c_str());
return false;
}

if(!GnomeUtils::getDeviceInfoByIfname(m_dbus, interface.c_str(), devInfo))
{
return false;
}

if(devInfo.state <= NM_DEVICE_STATE_DISCONNECTED)
{
NMLOG_WARNING("Device state is not a valid state: (%d)", devInfo.state);
return false;
}
else if (devInfo.state > NM_DEVICE_STATE_DISCONNECTED && devInfo.state < NM_DEVICE_STATE_IP_CHECK)
{
result.autoconfig = true;
if(ipversion.empty())
result.ipversion = "IPv4";
else
result.ipversion = ipversion;
return true;
}

if(!GnomeUtils::getDeviceByIpIface(m_dbus, interface.c_str(), devicePath))
return false;
GDBusProxy *deviceProxy = m_dbus.getNetworkManagerDeviceProxy(devicePath.c_str());
if(deviceProxy == nullptr)
return false;
if (g_strcmp0(ipversion.c_str(), "IPv4") == 0)
if(ipversion.empty() || (g_strcmp0(ipversion.c_str(), "IPv4") == 0))
{
GVariant *ip4Property = g_dbus_proxy_get_cached_property(deviceProxy, "Ip4Config");
if (ip4Property != nullptr)
Expand Down Expand Up @@ -895,6 +950,7 @@ namespace WPEFramework
if (dhcpServerIp) {
NMLOG_DEBUG("DHCP server IP address: %s", dhcpServerIp);
} else {
dhcpServerIp = nullptr;
NMLOG_DEBUG("Failed to find DHCP server IP address");
}
if (dnsAddresses) {
Expand All @@ -920,8 +976,9 @@ namespace WPEFramework
g_object_unref(dhcpv4Proxy);
}
}
result.ipversion = "IPv4";
}
else if (g_strcmp0(ipversion.c_str(), "IPv6") == 0)
if((addressStr.empty() && !(g_strcmp0(ipversion.c_str(), "IPv4") == 0)) || g_strcmp0(ipversion.c_str(), "IPV6") == 0)
{
GVariant *ip6Property = g_dbus_proxy_get_cached_property(deviceProxy, "Ip6Config");
if (ip6Property != nullptr) {
Expand Down Expand Up @@ -997,6 +1054,7 @@ namespace WPEFramework
}
else
{
gatewayIp = nullptr;
NMLOG_ERROR("Failed to get Gateway property for IPv6");
g_object_unref(ipv6Proxy);
}
Expand Down Expand Up @@ -1059,6 +1117,7 @@ namespace WPEFramework
NMLOG_ERROR("Failed to parse DNS addresses");
}
} else {
dnsList = nullptr;
std::cerr << "Failed to find DNS addresses" << std::endl;
}
}
Expand All @@ -1068,6 +1127,13 @@ namespace WPEFramework
g_object_unref(dhcpv6Proxy);
}
}
result.ipversion = "IPv6";
}
if(addressStr.empty())
{
result.autoconfig = true;
if(ipversion.empty())
result.ipversion = "IPv4";
}
std::string connectionPath;
if (!GnomeUtils::getSettingsConnectionPath(m_dbus, connectionPath, interface))
Expand All @@ -1076,13 +1142,10 @@ namespace WPEFramework
return false;
}

if(!GnomeUtils::getDeviceInfoByIfname(m_dbus, interface.c_str(), devInfo))
return false;
GDBusProxy *settingsProxy = m_dbus.getNetworkManagerSettingsConnectionProxy(connectionPath.c_str());

if (settingsProxy == nullptr) {
NMLOG_ERROR("Error creating connection settings proxy: %s",error->message);
g_error_free(error);
NMLOG_ERROR("Error creating connection settings proxy");
return false;
}

Expand Down Expand Up @@ -1129,7 +1192,6 @@ namespace WPEFramework
}
}

result.ipversion = ipversion;
result.autoconfig = true;
if(g_strcmp0(ipversion.c_str(), "IPv4") == 0)
result.autoconfig = (g_strcmp0(IPv4Method, "auto") == 0);
Expand Down
4 changes: 3 additions & 1 deletion plugin/gnome/gdbus/NetworkManagerGdbusClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "NetworkManagerLogger.h"
#include "NetworkManagerGdbusMgr.h"
#include "NetworkManagerSecretAgent.h"
#include "NetworkManagerImplementation.h"
#include "INetworkManager.h"

#define GDBUS_WPS_RETRY_WAIT_IN_MS 10 // 10 sec
Expand Down Expand Up @@ -53,8 +54,9 @@ namespace WPEFramework
bool setInterfaceState(const std::string& interface, bool enable);
bool setIPSettings(const std::string& interface, const Exchange::INetworkManager::IPAddress& address);
bool getPrimaryInterface(std::string& interface);
bool getDefaultInterface(std::string& interface);
bool getInterfaceState(const std::string& interface, bool& isEnabled);
bool getIPSettings(const std::string& interface, const std::string& ipversion, Exchange::INetworkManager::IPAddress& result);
bool getIPSettings(std::string& interface, const std::string& ipversion, Exchange::INetworkManager::IPAddress& result);
bool getKnownSSIDs(std::list<std::string>& ssids);
bool getConnectedSSID(Exchange::INetworkManager::WiFiSSIDInfo& ssidinfo);
bool addToKnownSSIDs(const Exchange::INetworkManager::WiFiConnectTo& ssidinfo);
Expand Down
14 changes: 10 additions & 4 deletions plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ namespace WPEFramework

uint32_t NetworkManagerImplementation::GetPrimaryInterface (string& interface /* @out */)
{
uint32_t rc = Core::ERROR_GENERAL;
if(_nmGdbusClient->getPrimaryInterface(interface))
rc = Core::ERROR_NONE;
return Core::ERROR_NONE;
else
NMLOG_ERROR("GetPrimaryInterface failed");
return rc;
{
if(_nmGdbusClient->getDefaultInterface(interface))
{
_instance->m_defaultInterface = interface;
return Core::ERROR_NONE;
}
else
return Core::ERROR_GENERAL;
}
}

uint32_t NetworkManagerImplementation::SetPrimaryInterface (const string& interface/* @in */)
Expand Down