Skip to content

Commit

Permalink
error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Nov 19, 2024
1 parent c8fd19d commit cf1dc49
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 60 deletions.
4 changes: 3 additions & 1 deletion NetworkManagerGnomeEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ namespace WPEFramework
{
static bool isEthDisabled = false;
static bool isWlanDisabled = false;
if(device == nullptr)
return;
NMDeviceState deviceState;
deviceState = nm_device_get_state(device);
std::string ifname = nm_device_get_iface(device);
Expand Down Expand Up @@ -126,7 +128,7 @@ namespace WPEFramework
wifiState = "WIFI_STATE_DISABLED";
GnomeNetworkManagerEvents::onWIFIStateChanged(Exchange::INetworkManager::WIFI_STATE_DISABLED);
GnomeNetworkManagerEvents::onInterfaceStateChangeCb(Exchange::INetworkManager::INTERFACE_REMOVED, nmUtils::wlanIface());
isEthDisabled = true;
isWlanDisabled = true;
break;
case NM_DEVICE_STATE_UNAVAILABLE:
case NM_DEVICE_STATE_DISCONNECTED:
Expand Down
116 changes: 60 additions & 56 deletions NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,29 +407,35 @@ namespace WPEFramework
}

result.autoconfig = isAutoConnectEnabled(conn);
if(ipversion.empty() || ipversion == "null" || nmUtils::caseInsensitiveCompare(ipversion, "IPV4")) // default ipversion ipv4

if(ipversion.empty() || nmUtils::caseInsensitiveCompare(ipversion, "IPV4")) // default ipversion ipv4
{
ip4_config = nm_active_connection_get_ip4_config(conn);
NMIPAddress *ipAddr = NULL;
std::string ipStr;
if (ip4_config != NULL) {
const GPtrArray *ipByte;
ipByte = nm_ip_config_get_addresses(ip4_config);
for (int i = 0; i < ipByte->len; i++) {
ipAddr = static_cast<NMIPAddress*>(ipByte->pdata[i]);
if(ipAddr)
ipStr = nm_ip_address_get_address(ipAddr);
if(!ipStr.empty())
{
result.ipaddress = nm_ip_address_get_address(ipAddr);
result.prefix = nm_ip_address_get_prefix(ipAddr);
NMLOG_INFO("IPv4 addr: %s/%d", result.ipaddress.c_str(), result.prefix);
result.ipversion = "IPv4"; // if null add as default
}
if (ip4_config = nullptr) {
NMLOG_WARNING("no IPv4 configurtion on %s", interface.c_str());
return Core::ERROR_GENERAL;
}

const GPtrArray *ipByte;
ipByte = nm_ip_config_get_addresses(ip4_config);
for (int i = 0; i < ipByte->len; i++)
{
ipAddr = static_cast<NMIPAddress*>(ipByte->pdata[i]);
if(ipAddr)
ipStr = nm_ip_address_get_address(ipAddr);
if(!ipStr.empty())
{
result.ipaddress = nm_ip_address_get_address(ipAddr);
result.prefix = nm_ip_address_get_prefix(ipAddr);
NMLOG_INFO("IPv4 addr: %s/%d", result.ipaddress.c_str(), result.prefix);
result.ipversion = "IPv4"; // if null add as default
}
gateway = nm_ip_config_get_gateway(ip4_config);
}

gateway = nm_ip_config_get_gateway(ip4_config);

dnsArr = (char **)nm_ip_config_get_nameservers(ip4_config);
dhcp4_config = nm_active_connection_get_dhcp4_config(conn);
if(dhcp4_config)
Expand All @@ -453,54 +459,52 @@ namespace WPEFramework
ip6_config = nm_active_connection_get_ip6_config(conn);
if(ip6_config == nullptr)
{
NMLOG_WARNING("no ipv6 config found");
rc = Core::ERROR_GENERAL;
NMLOG_WARNING("no IPv6 configurtion on %s", interface.c_str());
return Core::ERROR_GENERAL;
}
else

std::string ipStr;
const GPtrArray *ipArray = nullptr;
ipArray = nm_ip_config_get_addresses(ip6_config);
for (int i = 0; i < ipArray->len; i++)
{
std::string ipStr;
const GPtrArray *ipArray = nullptr;
ipArray = nm_ip_config_get_addresses(ip6_config);
for (int i = 0; i < ipArray->len; i++)
ipAddr = static_cast<NMIPAddress*>(ipArray->pdata[i]);
if(ipAddr)
ipStr = nm_ip_address_get_address(ipAddr);
if(!ipStr.empty())
{
ipAddr = static_cast<NMIPAddress*>(ipArray->pdata[i]);
if(ipAddr)
ipStr = nm_ip_address_get_address(ipAddr);
if(!ipStr.empty())
{
if (ipStr.compare(0, 5, "fe80:") == 0 || ipStr.compare(0, 6, "fe80::") == 0) {
result.ula = ipStr;
NMLOG_INFO("link-local ip: %s", result.ula.c_str());
}
else {
result.prefix = nm_ip_address_get_prefix(ipAddr);
if(result.ipaddress.empty()) // SLAAC mutiple ip not added
result.ipaddress = ipStr;
NMLOG_INFO("global ip %s/%d", ipStr.c_str(), result.prefix);
}
if (ipStr.compare(0, 5, "fe80:") == 0 || ipStr.compare(0, 6, "fe80::") == 0) {
result.ula = ipStr;
NMLOG_INFO("link-local ip: %s", result.ula.c_str());
}
else {
result.prefix = nm_ip_address_get_prefix(ipAddr);
if(result.ipaddress.empty()) // SLAAC mutiple ip not added
result.ipaddress = ipStr;
NMLOG_INFO("global ip %s/%d", ipStr.c_str(), result.prefix);
}
}
}

gateway = nm_ip_config_get_gateway(ip6_config);
if(gateway)
result.gateway= gateway;
dnsArr = (char **)nm_ip_config_get_nameservers(ip6_config);
if((*(&dnsArr[0]))!= NULL)
result.primarydns = *(&dnsArr[0]);
if((*(&dnsArr[1]))!=NULL )
result.secondarydns = *(&dnsArr[1]);

dhcp6_config = nm_active_connection_get_dhcp6_config(conn);
if(dhcp6_config)
{
dhcpserver = nm_dhcp_config_get_one_option (dhcp6_config, "dhcp_server_identifier");
if(dhcpserver) {
result.dhcpserver = dhcpserver;
}
gateway = nm_ip_config_get_gateway(ip6_config);
if(gateway)
result.gateway= gateway;
dnsArr = (char **)nm_ip_config_get_nameservers(ip6_config);
if((*(&dnsArr[0]))!= NULL)
result.primarydns = *(&dnsArr[0]);
if((*(&dnsArr[1]))!=NULL )
result.secondarydns = *(&dnsArr[1]);

dhcp6_config = nm_active_connection_get_dhcp6_config(conn);
if(dhcp6_config)
{
dhcpserver = nm_dhcp_config_get_one_option (dhcp6_config, "dhcp_server_identifier");
if(dhcpserver) {
result.dhcpserver = dhcpserver;
}
result.ipversion = "IPv6";
rc = Core::ERROR_NONE;
}
result.ipversion = "IPv6";
rc = Core::ERROR_NONE;
}
else
NMLOG_WARNING("ipversion error IPv4/IPv6");
Expand Down
6 changes: 3 additions & 3 deletions NetworkManagerGnomeWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ namespace WPEFramework

NMDeviceWifi *wifiDevice = NM_DEVICE_WIFI(getNmDevice());
if(wifiDevice == NULL) {
NMLOG_DEBUG("NMDeviceWifi * NULL !");
NMLOG_FATAL("NMDeviceWifi * NULL !");
return false;
}

Expand All @@ -270,7 +270,7 @@ namespace WPEFramework

NMDeviceWifi *wifiDevice = NM_DEVICE_WIFI(getNmDevice());
if(wifiDevice == NULL) {
NMLOG_DEBUG("NMDeviceWifi * NULL !");
NMLOG_FATAL("NMDeviceWifi * NULL !");
return false;
}

Expand Down Expand Up @@ -887,7 +887,7 @@ namespace WPEFramework
return false;
NMDeviceWifi *wifiDevice = NM_DEVICE_WIFI(getNmDevice());
if(wifiDevice == NULL) {
NMLOG_DEBUG("NMDeviceWifi * NULL !");
NMLOG_FATAL("NMDeviceWifi * NULL !");
return false;
}
isSuccess = false;
Expand Down

0 comments on commit cf1dc49

Please sign in to comment.