ethernet: Add origin to generateId()

Currently the code uses the ip address, prefix, and gateway to generate
the ID of the DBus object.
This results in the same DBus object path for the same IPs while they
have different address origin.
E.g. if we have the DHCP address and assign the same static address, the
DBus object paths are the same and it gets
`org.freedesktop.DBus.Error.FileExists` exception while creating the new
object.

Add origin to generateId() so they generate the two different object
paths and the above issue could be fixed.

Tested: Verify in QEMU that setting static IP is OK from DHCP.

Fixes openbmc/phosphor-networkd#41

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Iafe94cedff7e39490386be7777f3d975f1cf6b3f
diff --git a/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp
index 6f441f7..a84e0eb 100644
--- a/test/test_ethernet_interface.cpp
+++ b/test/test_ethernet_interface.cpp
@@ -90,12 +90,13 @@
     }
 
     std::string getObjectPath(const std::string& ipaddress, uint8_t subnetMask,
-                              const std::string& gateway)
+                              const std::string& gateway,
+                              IP::AddressOrigin origin)
     {
         IP::Protocol addressType = IP::Protocol::IPv4;
 
         return interface.generateObjectPath(addressType, ipaddress, subnetMask,
-                                            gateway);
+                                            gateway, origin);
     }
 
     void createIPObject(IP::Protocol addressType, const std::string& ipaddress,
@@ -147,6 +148,7 @@
     std::string ipaddress = "10.10.10.10";
     uint8_t prefix = 16;
     std::string gateway = "10.10.10.1";
+    IP::AddressOrigin origin = IP::AddressOrigin::Static;
 
     std::string expectedObjectPath = "/xyz/openbmc_test/network/test0/ipv4/";
     std::stringstream hexId;
@@ -154,11 +156,17 @@
     std::string hashString = ipaddress;
     hashString += std::to_string(prefix);
     hashString += gateway;
+    hashString += convertForMessage(origin);
 
     hexId << std::hex << ((std::hash<std::string>{}(hashString)) & 0xFFFFFFFF);
     expectedObjectPath += hexId.str();
 
-    EXPECT_EQ(expectedObjectPath, getObjectPath(ipaddress, prefix, gateway));
+    EXPECT_EQ(expectedObjectPath,
+              getObjectPath(ipaddress, prefix, gateway, origin));
+
+    origin = IP::AddressOrigin::DHCP;
+    EXPECT_NE(expectedObjectPath,
+              getObjectPath(ipaddress, prefix, gateway, origin));
 }
 
 TEST_F(TestEthernetInterface, addStaticNameServers)