Populate address origin based on ifa_flags

Currently origin of ip address is populated based on DHCP enabled flag
so when DHCP is enabled then all static addresses are marked as DHCP
addresses and when DHCP is disabled all static addresses marked as
Static addresses.

This commit populates address origin based on ifa_flags from rtnetlink
message to fix this address origin issue.

Tested by: Check origin of D-bus object for different type of v4/v6
addresses Verified DHCPv4/v6 enable, disable with static addresses
configured.

Change-Id: I554e9353107ba62b638654d91b5dfe2c6ee90a03
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index c01e1c7..7a17208 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -174,10 +174,6 @@
 void EthernetInterface::addAddr(const AddressInfo& info)
 {
     IP::AddressOrigin origin = IP::AddressOrigin::Static;
-    if (dhcpIsEnabled(info.ifaddr.getAddr()))
-    {
-        origin = IP::AddressOrigin::DHCP;
-    }
 #ifdef LINK_LOCAL_AUTOCONFIGURATION
     if (info.scope == RT_SCOPE_LINK)
     {
@@ -185,6 +181,22 @@
     }
 #endif
 
+    if ((info.scope == RT_SCOPE_UNIVERSE) && (info.flags & IFA_F_PERMANENT))
+    {
+        origin = IP::AddressOrigin::Static;
+    }
+    if ((info.scope == RT_SCOPE_UNIVERSE) &&
+        ((info.flags & IFA_F_NOPREFIXROUTE) &&
+         (info.flags & IFA_F_MANAGETEMPADDR)))
+    {
+        origin = IP::AddressOrigin::SLAAC;
+    }
+    else if ((info.scope == RT_SCOPE_UNIVERSE) &&
+             ((info.flags & IFA_F_NOPREFIXROUTE)))
+    {
+        origin = IP::AddressOrigin::DHCP;
+    }
+
     auto it = addrs.find(info.ifaddr);
     if (it == addrs.end())
     {