summaryrefslogtreecommitdiffstats
path: root/network_manager.cpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-06-15 08:57:54 +0530
committerRatan Gupta <ratagupt@in.ibm.com>2017-06-21 15:34:19 +0530
commitef85eb9c0e1859f8c420e753341a18ddaa2f8cbb (patch)
tree713af0e9528027ebcf2f7ef498bc013e9449322c /network_manager.cpp
parent82e1ef999fc207b0f307f4161e95d41d3d5f014a (diff)
downloadphosphor-networkd-ef85eb9c0e1859f8c420e753341a18ddaa2f8cbb.tar.gz
phosphor-networkd-ef85eb9c0e1859f8c420e753341a18ddaa2f8cbb.zip
Create the system conf Dbus Object
Also put extra checks while writing the gateway and the destination to the conf file. Change-Id: I8f24b3f293e6f978b655f061a198a32690dd44f3 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'network_manager.cpp')
-rw-r--r--network_manager.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/network_manager.cpp b/network_manager.cpp
index a635952..aff86a0 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -8,7 +8,6 @@
#include <algorithm>
#include <bitset>
-#include <experimental/filesystem>
#include <map>
#include <fstream>
@@ -24,17 +23,25 @@ namespace network
{
using namespace phosphor::logging;
-namespace fs = std::experimental::filesystem;
+using namespace sdbusplus::xyz::openbmc_project::Common::Error;
Manager::Manager(sdbusplus::bus::bus& bus, const char* objPath):
details::VLANCreateIface(bus, objPath, true),
bus(bus),
objectPath(objPath)
{
+ confDir = NETWORK_CONF_DIR;
+}
+
+void Manager::setConfDir(const fs::path& dir)
+{
+ confDir = dir;
}
void Manager::createInterfaces()
{
+ //clear all the interfaces first
+ interfaces.clear();
auto interfaceInfoList = getInterfaceAddrs();
@@ -56,6 +63,18 @@ void Manager::createInterfaces()
}
}
+void Manager::createChildObjects()
+{
+ // creates the ethernet interface dbus object.
+ createInterfaces();
+ // create the system conf object.
+ fs::path objPath = objectPath;
+ objPath /= "config";
+ systemConf = std::make_unique<phosphor::network::SystemConfiguration>(
+ bus, objPath.string(), *this);
+
+}
+
void Manager::vLAN(IntfName interfaceName, uint16_t id)
{
}
@@ -216,7 +235,7 @@ void Manager::writeToConfigurationFile()
for (const auto& intf : interfaces)
{
- fs::path confPath {NETWORK_CONF_DIR};
+ fs::path confPath = confDir;
std::string fileName = "00-bmc-"s + intf.first + ".network"s;
confPath /= fileName;
std::fstream stream;
@@ -238,12 +257,16 @@ void Manager::writeToConfigurationFile()
addr.second->prefixLength());
stream << "Address=" << address << "\n";
- stream << "Gateway=" << addr.second->gateway() << "\n";
+ if (addr.second->gateway() != "0.0.0.0" &&
+ addr.second->gateway() != "")
+ {
+ stream << "Gateway=" << addr.second->gateway() << "\n";
+ }
}
}
-
- stream << "Gateway=" << this->defaultGateway << "\n";
+ stream << "Gateway=" << systemConf->defaultGateway() << "\n";
+ // write the route section
stream << "[" << "Route" << "]\n";
for(const auto& addr : addrs)
{
@@ -255,8 +278,10 @@ void Manager::writeToConfigurationFile()
addr.second->address(),
addr.second->prefixLength());
- if (addr.second->gateway() != "0.0.0.0" ||
- addr.second->gateway() != "")
+ if (addr.second->gateway() != "0.0.0.0" &&
+ addr.second->gateway() != "" &&
+ destination != "0.0.0.0" &&
+ destination != "")
{
stream << "Gateway=" << addr.second->gateway() << "\n";
OpenPOWER on IntegriCloud