diff options
author | Nagaraju Goruganti <ngorugan@in.ibm.com> | 2018-02-05 20:32:45 -0600 |
---|---|---|
committer | Nagaraju Goruganti <ngorugan@in.ibm.com> | 2018-02-15 02:42:49 -0600 |
commit | e8fca1d5c14f3b665bcfe65de629d3a01f16f274 (patch) | |
tree | 0f41cbd29e0019bd1b72284bcec6167d817f4c38 | |
parent | 250011e6d1fa3905f228fbc853e4a8f37b091b32 (diff) | |
download | phosphor-networkd-e8fca1d5c14f3b665bcfe65de629d3a01f16f274.tar.gz phosphor-networkd-e8fca1d5c14f3b665bcfe65de629d3a01f16f274.zip |
Add more DHCP attributes while writing the configuration file
Added the attribute "SendHostname", when it is true machine's hostname
will be included in DHCP packet.
Change-Id: I9bf5f76980f152d48f7f3acf7448c8bc199905bb
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
-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"; } } |