Fix code logic of setDHCPv6Property

When DHCP is IPv4 only, disabling DHCPv6 by calling setDHCPv6Property
will set DHCP to none, which also disables IPv4. This is an unexpected
behavior caused by current buggy code logic, there is no if condition
meets this situation, so the default value none will be used.

This patch fixes the issue by adopting the same logic as d5967afbbec5
("Fix unexpected change of ipsrc of ipv6").

Tested:
1. current=v4, requested=none => v4
2. Other cases work as expected

Change-Id: I6fef0e464b9789bd78f85219701a170fa9e17285
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index b2b7dce..f7585a4 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -227,29 +227,29 @@
 
     if (defaultMode)
     {
-        if ((currentDhcp == EthernetInterface::DHCPConf::v4) &&
-            (requestedDhcp == EthernetInterface::DHCPConf::v6))
+        // When calling setDHCPv6Property, requestedDhcp only has "v6" and
+        // "none".
+        // setDHCPv6Property is only for IPv6 management. It should not modify
+        // IPv4 state.
+        if (requestedDhcp == EthernetInterface::DHCPConf::v6)
         {
-            nextDhcp = EthernetInterface::DHCPConf::both;
-        }
-        else if ((currentDhcp == EthernetInterface::DHCPConf::none) &&
-                 (requestedDhcp == EthernetInterface::DHCPConf::v6))
-
-        {
-            nextDhcp = requestedDhcp;
+            if ((currentDhcp == EthernetInterface::DHCPConf::v4) ||
+                (currentDhcp == EthernetInterface::DHCPConf::both))
+                nextDhcp = EthernetInterface::DHCPConf::both;
+            else if ((currentDhcp == EthernetInterface::DHCPConf::v6) ||
+                     (currentDhcp == EthernetInterface::DHCPConf::none))
+                nextDhcp = EthernetInterface::DHCPConf::v6;
         }
         else if (requestedDhcp == EthernetInterface::DHCPConf::none)
         {
-            if (currentDhcp == EthernetInterface::DHCPConf::both)
-            {
+            if ((currentDhcp == EthernetInterface::DHCPConf::v4) ||
+                (currentDhcp == EthernetInterface::DHCPConf::both))
                 nextDhcp = EthernetInterface::DHCPConf::v4;
-            }
-            else if (currentDhcp == EthernetInterface::DHCPConf::v6)
-            {
+            else if ((currentDhcp == EthernetInterface::DHCPConf::v6) ||
+                     (currentDhcp == EthernetInterface::DHCPConf::none))
                 nextDhcp = EthernetInterface::DHCPConf::none;
-            }
         }
-        else
+        else // Stay the same.
         {
             nextDhcp = currentDhcp;
         }