Implement the ipaddress origin and gateway property
Resolves openbmc/openbmc#1590
Change-Id: I76328e596336f8b8f1394b1927d48ce52f819a66
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/network_manager.cpp b/network_manager.cpp
index a5ff5e3..a635952 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -242,6 +242,30 @@
}
}
+
+ stream << "Gateway=" << this->defaultGateway << "\n";
+ stream << "[" << "Route" << "]\n";
+ for(const auto& addr : addrs)
+ {
+ if (addr.second->origin() == AddressOrigin::Static)
+ {
+ int addressFamily = addr.second->type() == IP::Protocol::IPv4 ? AF_INET : AF_INET6;
+ std::string destination = getNetworkID(
+ addressFamily,
+ addr.second->address(),
+ addr.second->prefixLength());
+
+ if (addr.second->gateway() != "0.0.0.0" ||
+ addr.second->gateway() != "")
+ {
+
+ stream << "Gateway=" << addr.second->gateway() << "\n";
+ stream << "Destination=" << destination << "\n";
+ }
+
+ }
+ }
+
stream.close();
}
restartSystemdNetworkd();