Skip to content

Commit

Permalink
updated onAddressChange Event
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Oct 30, 2024
1 parent 68afd8a commit 903e6b1
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 317 deletions.
47 changes: 30 additions & 17 deletions NetworkManagerGnomeEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,17 @@ namespace WPEFramework
for (guint i = 0; i < addresses->len; ++i) {
NMIPAddress *address = (NMIPAddress *)g_ptr_array_index(addresses, i);
if (nm_ip_address_get_family(address) == AF_INET6) {
const char *ipAddress = nm_ip_address_get_address(address);
const char *ipaddr = nm_ip_address_get_address(address);
//int prefix = nm_ip_address_get_prefix(address);
if(ipAddress != NULL) {
if(ipaddr != NULL) {
std::string ipAddress = ipaddr;
if (ipAddress.compare(0, 5, "fe80:") == 0 ||
ipAddress.compare(0, 6, "fe80::") == 0) {
NMLOG_WARNING("%s It's link-local ip", ipAddress.c_str());
continue; // It's link-local
}
GnomeNetworkManagerEvents::onAddressChangeCb(iface, ipAddress, true, true);
break; // SLAAC protocol may include multip ipv6 address posting only one Global address
}
}
}
Expand Down Expand Up @@ -393,7 +400,7 @@ namespace WPEFramework
}
}
else
NMLOG_DEBUG("device type not eth/wifi");
NMLOG_DEBUG("device type not eth/wifi %s", ifname.c_str());
}
}

Expand Down Expand Up @@ -539,28 +546,34 @@ namespace WPEFramework
static std::map<std::string, std::string> ipv6Map;
static std::map<std::string, std::string> ipv4Map;

if (isIPv6)
if(acqired)
{
if (ipAddress.empty()) {
ipAddress = ipv6Map[iface];
ipv6Map[iface].clear();
}
else {
if (isIPv6)
{
if (ipv6Map[iface].find(ipAddress) == std::string::npos) { // same ip comes multiple time so avoding that
if (!ipv6Map[iface].empty())
ipv6Map[iface] += " ";
ipv6Map[iface] += ipAddress; // SLAAC protocol may include multip ipv6 address
ipv6Map[iface] = ipAddress;
}
else
return; // skip same ip event posting
else // same ip not posting
return;
}
else
{
ipv4Map[iface] = ipAddress;
}
}
else
{
if (ipAddress.empty())
ipAddress = ipv4Map[iface];
if (isIPv6)
{
ipAddress = ipv6Map[iface];
ipv6Map[iface].clear();
}
else
ipv4Map[iface] = ipAddress;
{
ipAddress = ipv4Map[iface];
ipv4Map[iface].clear();
}

}

if(_instance != nullptr)
Expand Down
22 changes: 12 additions & 10 deletions NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace WPEFramework
NMLOG_ERROR("No active activeConn Interface found");
return Core::ERROR_GENERAL;
}

remoteConn = nm_active_connection_get_connection(activeConn);
if(remoteConn == NULL)
{
Expand Down Expand Up @@ -611,16 +612,17 @@ namespace WPEFramework
NMLOG_WARNING("ssid is invalied");
return rc;
}
// Check the last scanning time and if it exceeds 10 sec do a rescanning
// if(!wifi->isWifiScannedRecently())
// {
// nmEvent->setwifiScanOptions(false, true); // not notify scan result but print logs
// if(!wifi->wifiScanRequest(Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_WHATEVER, ssid.m_ssid))
// {
// NMLOG_WARNING("scanning failed but try to connect");
// }
// }
if(wifi->wifiConnect2(ssid))

// Check the last scanning time and if it exceeds 10 sec do a rescanning
if(!wifi->isWifiScannedRecently())
{
nmEvent->setwifiScanOptions(false, false); // not notify scan result but print logs
if(!wifi->wifiScanRequest(Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_WHATEVER, ssid.m_ssid))
{
NMLOG_WARNING("scanning failed but try to connect");
}
}
if(wifi->wifiConnect(ssid))
rc = Core::ERROR_NONE;
return rc;
}
Expand Down
Loading

0 comments on commit 903e6b1

Please sign in to comment.