Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/libnm_proxy_L1_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: |
sudo bash -c 'echo "ETHERNET_INTERFACE=eth0
WIFI_INTERFACE=wlan0
DEVICE_NAME=rdk_test_device " > /etc/device.properties'
DEFAULT_HOSTNAME=rdk_test_device " > /etc/device.properties'

- name: Generate IARM headers
run: |
Expand Down
5 changes: 5 additions & 0 deletions plugin/gnome/NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ namespace WPEFramework
if(!nmUtils::readPersistentHostname(hostname))
{
hostname = nmUtils::deviceHostname(); // default hostname as device name
if(hostname.empty())
{
NMLOG_WARNING("default hostname is empty no modification in nm connections");
return false;
Comment on lines 153 to +157
}
}

connections = nm_client_get_connections(client);
Expand Down
4 changes: 2 additions & 2 deletions plugin/gnome/NetworkManagerGnomeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ namespace WPEFramework
}
}

if (line.find("DEVICE_NAME=") != std::string::npos) {
if (line.find("DEFAULT_HOSTNAME=") != std::string::npos) {
deviceHostname = line.substr(line.find('=') + 1);
Comment on lines +264 to 265
deviceHostname.erase(deviceHostname.find_last_not_of("\r\n\t") + 1);
deviceHostname.erase(0, deviceHostname.find_first_not_of("\r\n\t"));
if(deviceHostname.empty())
{
NMLOG_WARNING("DEVICE_NAME is empty in /etc/device.properties");
NMLOG_WARNING("DEFAULT_HOSTNAME is empty in /etc/device.properties");
deviceHostname = ""; // set empty device name
}
}
Expand Down
36 changes: 26 additions & 10 deletions plugin/gnome/NetworkManagerGnomeWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,27 @@ namespace WPEFramework
NMLOG_DEBUG("No persistent hostname found, using device hostname");
}

if(hostname.empty())
NMLOG_WARNING("dhcp hostname: <empty>");
else
NMLOG_INFO("dhcp hostname: %s", hostname.c_str());

// IPv4 settings with DHCP
NMSettingIP4Config *sIpv4 = (NMSettingIP4Config *)nm_setting_ip4_config_new();
g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL);
if(!hostname.empty()) {
g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL);
}
nm_connection_add_setting(connection, NM_SETTING(sIpv4));

// IPv6 settings with DHCP
NMSettingIP6Config *sIpv6 = (NMSettingIP6Config *)nm_setting_ip6_config_new();
g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL);
if(!hostname.empty()) {
g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL);
}
nm_connection_add_setting(connection, NM_SETTING(sIpv6));

NMLOG_DEBUG("Created minimal ethernet connection with autoconnect=true");
Expand Down Expand Up @@ -894,23 +903,30 @@ namespace WPEFramework
if(!nmUtils::readPersistentHostname(hostname))
{
hostname = nmUtils::deviceHostname();
NMLOG_DEBUG("no persistent hostname found taking device name as hostname !");
NMLOG_DEBUG("No persistent hostname found, using device hostname");
}

NMLOG_INFO("dhcp hostname: %s", hostname.c_str());
if(hostname.empty())
NMLOG_WARNING("dhcp hostname: <empty>");
else
NMLOG_INFO("dhcp hostname: %s", hostname.c_str());

/* Build up the 'IPv4' Setting */
NMSettingIP4Config *sIpv4Conf = (NMSettingIP4Config *) nm_setting_ip4_config_new();
g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); // autoconf = true
g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled
if(!hostname.empty()) {
g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled
}
nm_connection_add_setting(m_connection, NM_SETTING(sIpv4Conf));

/* Build up the 'IPv6' Setting */
NMSettingIP6Config *sIpv6Conf = (NMSettingIP6Config *) nm_setting_ip6_config_new();
g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); // autoconf = true
g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled
if(!hostname.empty()) {
g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL);
g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled
}
nm_connection_add_setting(m_connection, NM_SETTING(sIpv6Conf));
return true;
}
Expand Down
Loading