Skip to content
Merged
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
2 changes: 1 addition & 1 deletion definition/NetworkManager.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@
}
},
"SetHostname": {
"summary": "To configure a custom DHCP hostname instead of the default (which is typically the device name).\n\nSetting host name will take effect upon reconnect; like, device reboot, wake-up from deepsleep, while connecting to new Wi-Fi connection, WiFi On/Off, or renewal of the DHCP lease.",
"summary": "To configure a custom DHCP hostname instead of the default (which is typically the default hostname).\n\nSetting host name will take effect upon reconnect; like, device reboot, wake-up from deepsleep, while connecting to new Wi-Fi connection, WiFi On/Off, or renewal of the DHCP lease.",
"params": {
Comment thread
cmuhammedrafi marked this conversation as resolved.
"type": "object",
"properties": {
Expand Down
4 changes: 2 additions & 2 deletions docs/NetworkManagerPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ NetworkManager interface methods:
| [GetWiFiSignalQuality](#method.GetWiFiSignalQuality) | Get WiFi signal quality of currently connected SSID |
| [GetSupportedSecurityModes](#method.GetSupportedSecurityModes) | Returns the Wifi security modes that the device supports |
| [GetWifiState](#method.GetWifiState) | Returns the current Wifi State |
| [SetHostname](#method.SetHostname) | To configure a custom DHCP hostname instead of the default (which is typically the device name) |
| [SetHostname](#method.SetHostname) | To configure a custom DHCP hostname instead of the default (which is typically the default hostname) |
Comment thread
cmuhammedrafi marked this conversation as resolved.

<a name="method.SetLogLevel"></a>
## *SetLogLevel [<sup>method</sup>](#head.Methods)*
Expand Down Expand Up @@ -1729,7 +1729,7 @@ This method takes no parameters.
<a name="method.SetHostname"></a>
## *SetHostname [<sup>method</sup>](#head.Methods)*

To configure a custom DHCP hostname instead of the default (which is typically the device name).
To configure a custom DHCP hostname instead of the default (which is typically the default hostname).
Comment thread
cmuhammedrafi marked this conversation as resolved.

Setting host name will take effect upon reconnect; like, device reboot, wake-up from deepsleep, while connecting to new Wi-Fi connection, WiFi On/Off, or renewal of the DHCP lease.

Expand Down
9 changes: 8 additions & 1 deletion plugin/gnome/NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@ namespace WPEFramework
// read persistent hostname if exist
if(!nmUtils::readPersistentHostname(hostname))
{
hostname = nmUtils::deviceHostname(); // default hostname as device name
hostname = nmUtils::deviceHostname(); // default hostname as default hostname
}

// Validate hostname is non-empty regardless of source (persistent or default)
if(hostname.empty())
{
NMLOG_WARNING("Hostname is empty. No modification will be made to NM connections.");
return false;
}
Comment thread
cmuhammedrafi marked this conversation as resolved.

connections = nm_client_get_connections(client);
Expand Down
10 changes: 5 additions & 5 deletions plugin/gnome/NetworkManagerGnomeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace WPEFramework
{
static std::string m_ethifname = "eth0";
static std::string m_wlanifname = "wlan0";
static std::string m_deviceHostname = "rdk-device"; // Device name can be empty if not set in /etc/device.properties
static std::string m_deviceHostname = "rdk-device"; // default hostname can be empty if not set in /etc/device.properties

const char* nmUtils::wlanIface() {return m_wlanifname.c_str();}
const char* nmUtils::ethIface() {return m_ethifname.c_str();}
Expand Down Expand Up @@ -261,14 +261,14 @@ 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 thread
cmuhammedrafi marked this conversation as resolved.
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");
deviceHostname = ""; // set empty device name
NMLOG_WARNING("DEFAULT_HOSTNAME is empty in /etc/device.properties");
deviceHostname = ""; // set empty default hostname
Comment thread
cmuhammedrafi marked this conversation as resolved.
}
}
}
Expand All @@ -277,7 +277,7 @@ namespace WPEFramework
m_wlanifname = wifiIfname;
m_ethifname = ethIfname;
m_deviceHostname = deviceHostname;
NMLOG_INFO("/etc/device.properties eth: %s, wlan: %s, device name: %s", m_ethifname.c_str(), m_wlanifname.c_str(), m_deviceHostname.c_str());
NMLOG_INFO("/etc/device.properties eth: %s, wlan: %s, default hostname: %s", m_ethifname.c_str(), m_wlanifname.c_str(), m_deviceHostname.c_str());
Comment thread
cmuhammedrafi marked this conversation as resolved.
return true;
}

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);
}
Comment thread
cmuhammedrafi marked this conversation as resolved.
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
}
Comment thread
cmuhammedrafi marked this conversation as resolved.
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