Network: Implement ipv6/ipv4 default gateways on EthernetInterface
Currently ipv6/ipv4 default gateway properties on SystemConfiguration
interface which will be deprecated soon.
This commit is to add Default gateway properties implementation on
EthernetInterface.
Test by:
Set ipv4/v6 default gateway properties on ethernet interface.
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
Change-Id: I30da81d7ccf9d568a60bfdd179331b4c0d86b149
diff --git a/system_configuration.cpp b/system_configuration.cpp
index 268ea27..4fbf601 100644
--- a/system_configuration.cpp
+++ b/system_configuration.cpp
@@ -39,8 +39,22 @@
route::Table routingTable;
SystemConfigIntf::hostName(name);
- SystemConfigIntf::defaultGateway(routingTable.getDefaultGateway());
- SystemConfigIntf::defaultGateway6(routingTable.getDefaultGateway6());
+ auto gatewayList = routingTable.getDefaultGateway();
+ auto gateway6List = routingTable.getDefaultGateway6();
+ // Assign first entry of gateway list
+ std::string gateway;
+ std::string gateway6;
+ if (!gatewayList.empty())
+ {
+ gateway = gatewayList.begin()->second;
+ }
+ if (!gateway6List.empty())
+ {
+ gateway6 = gateway6List.begin()->second;
+ }
+
+ SystemConfigIntf::defaultGateway(gateway);
+ SystemConfigIntf::defaultGateway6(gateway6);
this->emit_object_added();
}