DHCP Conf: Fix UseDomainName configuration

This commit modifies to use DomainEnabled D-bus property

Currently "UseDomainName" configuration is actually not controlling
DomainName setting in the backend networkd and networkd.
Networkd app does not have DomainName D-bus property implemented
and wrong D-bus property is being used in the bmcweb.

This fix make sure bmcweb uses DomainEnabled property and controls
UseDomainName configuration.

Here is backend networkd fix for DomainEnabled property
https://gerrit.openbmc.org/c/openbmc/phosphor-networkd/+/69604

Tested by:
Enabled DHCPv4 on one of the interface
Enable/Disable UseDomainName
Check if DHCP configured domain name configuration on BMC.

Change-Id: I68b86d4107a17db921ec463f5660a58aaa1396e3
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 03b23e1..1574d81 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -82,6 +82,8 @@
     bool autoNeg;
     bool dnsv4Enabled;
     bool dnsv6Enabled;
+    bool domainv4Enabled;
+    bool domainv6Enabled;
     bool ntpv4Enabled;
     bool ntpv6Enabled;
     bool hostNamev4Enabled;
@@ -390,6 +392,15 @@
                                 ethData.dnsv4Enabled = *dnsEnabled;
                             }
                         }
+                        else if (propertyPair.first == "DomainEnabled")
+                        {
+                            const bool* domainEnabled =
+                                std::get_if<bool>(&propertyPair.second);
+                            if (domainEnabled != nullptr)
+                            {
+                                ethData.domainv4Enabled = *domainEnabled;
+                            }
+                        }
                         else if (propertyPair.first == "NTPEnabled")
                         {
                             const bool* ntpEnabled =
@@ -431,6 +442,15 @@
                                 ethData.dnsv6Enabled = *dnsEnabled;
                             }
                         }
+                        if (propertyPair.first == "DomainEnabled")
+                        {
+                            const bool* domainEnabled =
+                                std::get_if<bool>(&propertyPair.second);
+                            if (domainEnabled != nullptr)
+                            {
+                                ethData.domainv6Enabled = *domainEnabled;
+                            }
+                        }
                         else if (propertyPair.first == "NTPEnabled")
                         {
                             const bool* ntpEnabled =
@@ -1237,8 +1257,8 @@
         nextNTPv6 = *v6dhcpParms.useNtpServers;
     }
 
-    bool nextUsev4Domain = ethData.hostNamev4Enabled;
-    bool nextUsev6Domain = ethData.hostNamev6Enabled;
+    bool nextUsev4Domain = ethData.domainv4Enabled;
+    bool nextUsev6Domain = ethData.domainv6Enabled;
     if (v4dhcpParms.useDomainName)
     {
         nextUsev4Domain = *v4dhcpParms.useDomainName;
@@ -1257,8 +1277,8 @@
     BMCWEB_LOG_DEBUG("set NTPEnabled...");
     setDHCPConfig("NTPEnabled", nextNTPv4, asyncResp, ifaceId,
                   NetworkType::dhcp4);
-    BMCWEB_LOG_DEBUG("set HostNameEnabled...");
-    setDHCPConfig("HostNameEnabled", nextUsev4Domain, asyncResp, ifaceId,
+    BMCWEB_LOG_DEBUG("set DomainEnabled...");
+    setDHCPConfig("DomainEnabled", nextUsev4Domain, asyncResp, ifaceId,
                   NetworkType::dhcp4);
     BMCWEB_LOG_DEBUG("set DNSEnabled for dhcp6...");
     setDHCPConfig("DNSEnabled", nextDNSv6, asyncResp, ifaceId,
@@ -1266,8 +1286,8 @@
     BMCWEB_LOG_DEBUG("set NTPEnabled for dhcp6...");
     setDHCPConfig("NTPEnabled", nextNTPv6, asyncResp, ifaceId,
                   NetworkType::dhcp6);
-    BMCWEB_LOG_DEBUG("set HostNameEnabled for dhcp6...");
-    setDHCPConfig("HostNameEnabled", nextUsev6Domain, asyncResp, ifaceId,
+    BMCWEB_LOG_DEBUG("set DomainEnabled for dhcp6...");
+    setDHCPConfig("DomainEnabled", nextUsev6Domain, asyncResp, ifaceId,
                   NetworkType::dhcp6);
 }