Skip to content

Commit

Permalink
phase 1
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Nov 6, 2024
1 parent 6c3081a commit a084fc1
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 225 deletions.
2 changes: 1 addition & 1 deletion NetworkManagerLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

namespace NetworkManagerLogger {
static LogLevel gDefaultLogLevel = INFO_LEVEL;
static LogLevel gDefaultLogLevel = DEBUG_LEVEL;


#ifdef USE_RDK_LOGGER
Expand Down
248 changes: 93 additions & 155 deletions gdbus/NetworkManagerGdbusClient.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion gdbus/NetworkManagerGdbusClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace WPEFramework
{
namespace Plugin
{

class NetworkManagerClient
{
public:
Expand Down Expand Up @@ -61,7 +62,7 @@ namespace WPEFramework
NetworkManagerClient();
~NetworkManagerClient();

DbusMgr dbusConnection;
DbusMgr m_dbus;
};
} // Plugin
} // WPEFramework
11 changes: 8 additions & 3 deletions gdbus/NetworkManagerGdbusEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,11 @@ namespace WPEFramework
return; // It's link-local
}

if (ipv6Map[iface].find(ipAddress) == std::string::npos) { // same ip comes multiple time so avoding that
if (ipv6Map[iface].find(ipAddress) == std::string::npos && !ipAddress.empty()) { // same ip comes multiple time so avoding that
ipv6Map[iface] = ipAddress; // SLAAC protocol may include multip ipv6 address last one will save
}
else
return; // skip same ip event posting
return; // skip same ip event posting if empty request
}
}
else
Expand All @@ -682,7 +682,12 @@ namespace WPEFramework
ipv4Map[iface].clear();
}
else
ipv4Map[iface] = ipAddress;
{
if(!ipAddress.empty())
ipv4Map[iface] = ipAddress;
else
return;
}
}

// if(_instance != nullptr)
Expand Down
57 changes: 22 additions & 35 deletions gdbus/NetworkManagerGdbusMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,13 @@ namespace WPEFramework
namespace Plugin
{

DbusConnectionManager::DbusConnectionManager() : connection(nullptr) {
NMLOG_INFO("DbusConnectionManager created");
}

DbusConnectionManager::~DbusConnectionManager() {
DeinitializeDbusConnection();
}

bool DbusConnectionManager::InitializeBusConnection(const std::string& busName) {
GError* error = nullptr;
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error);

if (!connection) {
NMLOG_ERROR("Failed to initialize D-Bus connection: %s ", error->message);
g_error_free(error);
return false;
}

NMLOG_INFO("D-Bus connection initialized successfully for bus: %s", busName.c_str());
return true;
}

void DbusConnectionManager::DeinitializeDbusConnection() {
if (connection) {
g_object_unref(connection);
connection = nullptr;
NMLOG_INFO("D-Bus connection deinitialized successfully");
}
}

GDBusConnection* DbusConnectionManager::getConnection() const {
return connection;
}

DbusMgr::DbusMgr() : connection(nullptr)
{
GError* error = nullptr;
NMLOG_INFO("DbusMgr");
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!connection) {
NMLOG_FATAL("Error connecting to system bus: %s ", error->message);
NMLOG_FATAL("Error connecting to system D-Bus bus: %s ", error->message);
g_error_free(error);
}
}
Expand Down Expand Up @@ -143,6 +109,27 @@ namespace WPEFramework
return proxy;
}

GDBusProxy* DbusMgr::getNetworkManagerSettingsConnectionProxy(const char* connPath)
{
GError* error = nullptr;
GDBusProxy* proxy = g_dbus_proxy_new_sync(
getConnection(), flags, nullptr, "org.freedesktop.NetworkManager",
connPath,
"org.freedesktop.NetworkManager.Settings.Connection",
nullptr,
&error
);

if (error != NULL) {
g_dbus_error_strip_remote_error(error);
NMLOG_FATAL("Error creating proxy: %s", error->message);
g_clear_error(&error);
return nullptr;
}

return proxy;
}

GDBusProxy* DbusMgr::getNetworkManagerDeviceProxy(const char* devicePath)
{
GError* error = nullptr;
Expand Down
14 changes: 1 addition & 13 deletions gdbus/NetworkManagerGdbusMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,14 @@ namespace WPEFramework
{
namespace Plugin
{
class DbusConnectionManager {
public:
DbusConnectionManager();
~DbusConnectionManager();

bool InitializeBusConnection(const std::string& busName);
void DeinitializeDbusConnection();
GDBusConnection* getConnection() const;

private:
GDBusConnection* connection;
};

class DbusMgr {
public:
DbusMgr();
~DbusMgr();

GDBusProxy* getNetworkManagerProxy();
GDBusProxy* getNetworkManagerSettingsProxy();
GDBusProxy* getNetworkManagerSettingsConnectionProxy(const char* connPath);
GDBusProxy* getNetworkManagerDeviceProxy(const char* devicePath);
GDBusProxy* getNetworkManagerWirelessProxy(const char* wirelessDevPath);
GDBusProxy* getNetworkManagerIpv4Proxy(const char* ipConfigPath);
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions gdbus/NetworkManagerGdbusUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace WPEFramework
return true;
}

bool GnomeUtils::getDevicePropertiesByPath(GDBusConnection *dbusConn, const char* devicePath, deviceProperties& properties)
bool GnomeUtils::getDevicePropertiesByPath(GDBusConnection *dbusConn, const char* devicePath, deviceInfo& properties)
{
GError *error = NULL;
GVariant *devicesVar = NULL;
Expand Down Expand Up @@ -293,7 +293,7 @@ namespace WPEFramework
return true;
}

bool GnomeUtils::getDevicePropertiesByIfname(GDBusConnection *dbusConn, const char* ifaceName, deviceProperties& properties)
bool GnomeUtils::getDevicePropertiesByIfname(GDBusConnection *dbusConn, const char* ifaceName, deviceInfo& properties)
{
GError *error = NULL;
GVariant *devicesVar = NULL;
Expand Down Expand Up @@ -619,7 +619,7 @@ namespace WPEFramework

bool GnomeUtils::getDeviceState(GDBusConnection *dbusConn, const gchar *iface_name, NMDeviceState& state)
{
deviceProperties devProp;
deviceInfo devProp;
if(!GnomeUtils::getDevicePropertiesByIfname(dbusConn, iface_name, devProp))
{
NMLOG_ERROR("Interface unknow to NetworkManger Deamon");
Expand All @@ -632,7 +632,7 @@ namespace WPEFramework

bool GnomeUtils::getDeviceStateReason(GDBusConnection *dbusConn, const gchar *iface_name, NMDeviceStateReason& StateReason)
{
deviceProperties devProp;
deviceInfo devProp;
if(!GnomeUtils::getDevicePropertiesByIfname(dbusConn, iface_name, devProp))
{
NMLOG_ERROR("Interface unknow to NetworkManger Deamon");
Expand Down
26 changes: 13 additions & 13 deletions gdbus/NetworkManagerGdbusUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@

using namespace std;

struct apProperties
{
uint32_t flags;
uint32_t wpaFlags;
uint32_t rsnFlags;
uint32_t frequency;
uint32_t mode;
std::string ssid;
std::string bssid;
uint8_t strength;
struct apInfo {
string ssid;
string bssid;
NM80211ApFlags flag;
NM80211ApSecurityFlags wpaFlag;
NM80211ApSecurityFlags rsnFlag;
NM80211Mode mode;
guint32 frequency;
guint32 bitrate;
guint32 strength;
};

struct deviceProperties
struct deviceInfo
{
std::string interface;
std::string activeConnPath;
Expand All @@ -66,8 +66,8 @@ namespace WPEFramework
static bool getDeviceState(GDBusConnection *dbusConn, const gchar *iface_name, NMDeviceState& state);
static bool getDeviceStateReason(GDBusConnection *dbusConn, const gchar *iface_name, NMDeviceStateReason& StateReason);
static bool getCachedPropertyU(GDBusProxy* proxy, const char* propertiy, uint32_t *value);
static bool getDevicePropertiesByPath(GDBusConnection *dbusConn, const char* devPath, deviceProperties& properties);
static bool getDevicePropertiesByIfname(GDBusConnection *dbusConn, const char* ifname, deviceProperties& properties);
static bool getDevicePropertiesByPath(GDBusConnection *dbusConn, const char* devPath, deviceInfo& properties);
static bool getDevicePropertiesByIfname(GDBusConnection *dbusConn, const char* ifname, deviceInfo& properties);
static bool getIpv4AddrFromIP4ConfigProxy( GDBusProxy *ipProxy, std::string& ipAddr, uint32_t& prifix);
static bool getIpv6AddrFromIP6ConfigProxy( GDBusProxy *ipProxy, std::string& ipAddr, uint32_t& prifix);

Expand Down

0 comments on commit a084fc1

Please sign in to comment.