diff options
-rw-r--r-- | dhcp_configuration.cpp | 13 | ||||
-rw-r--r-- | dhcp_configuration.hpp | 12 | ||||
-rw-r--r-- | ethernet_interface.cpp | 4 |
3 files changed, 28 insertions, 1 deletions
diff --git a/dhcp_configuration.cpp b/dhcp_configuration.cpp index 9e88e7c..9eeea1e 100644 --- a/dhcp_configuration.cpp +++ b/dhcp_configuration.cpp @@ -9,6 +9,19 @@ namespace network namespace dhcp { +bool Configuration::sendHostNameEnabled(bool value) +{ + if (value == sendHostNameEnabled()) + { + return value; + } + + auto name = ConfigIntf::sendHostNameEnabled(value); + manager.writeToConfigurationFile(); + + return name; +} + bool Configuration::hostNameEnabled(bool value) { if (value == hostNameEnabled()) diff --git a/dhcp_configuration.hpp b/dhcp_configuration.hpp index e952073..a550077 100644 --- a/dhcp_configuration.hpp +++ b/dhcp_configuration.hpp @@ -56,6 +56,7 @@ class Configuration : public Iface ConfigIntf::dNSEnabled(true); ConfigIntf::nTPEnabled(true); ConfigIntf::hostNameEnabled(true); + ConfigIntf::sendHostNameEnabled(true); emit_object_added(); } @@ -82,13 +83,22 @@ class Configuration : public Iface */ bool hostNameEnabled(bool value) override; + /** @brief if true then it will cause an Option 12 field, i.e machine's + * hostname, will be included in the DHCP packet. + * @param[in] value - true if machine's host name needs to be included + * in the DHCP packet. + */ + bool sendHostNameEnabled(bool value) override; + /* @brief Network Manager needed the below function to know the - * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled). + * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled + sendHostNameEnabled). * */ using ConfigIntf::dNSEnabled; using ConfigIntf::nTPEnabled; using ConfigIntf::hostNameEnabled; + using ConfigIntf::sendHostNameEnabled; private: diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp index 1e873c2..6b6948a 100644 --- a/ethernet_interface.cpp +++ b/ethernet_interface.cpp @@ -649,6 +649,10 @@ void EthernetInterface::writeDHCPSection(std::fstream& stream) value = manager.getDHCPConf()->hostNameEnabled() ? "true"s : "false"s; stream << "UseHostname="s + value + "\n"; + + value = + manager.getDHCPConf()->sendHostNameEnabled() ? "true"s : "false"s; + stream << "SendHostname="s + value + "\n"; } } |