summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--network_manager.cpp29
-rw-r--r--network_manager.hpp5
-rw-r--r--util.cpp33
-rw-r--r--util.hpp5
4 files changed, 38 insertions, 34 deletions
diff --git a/network_manager.cpp b/network_manager.cpp
index 73d76d3..3916dfb 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -1,5 +1,4 @@
#include "config.h"
-#include "config_parser.hpp"
#include "util.hpp"
#include "network_manager.hpp"
#include "network_config.hpp"
@@ -83,7 +82,7 @@ void Manager::createInterfaces()
// normal ethernet inetrface
objPath /= intfInfo.first;
- auto dhcp = getDHCPValue(intfInfo.first);
+ auto dhcp = getDHCPValue(confDir, intfInfo.first);
auto intf = std::make_shared<phosphor::network::EthernetInterface>(
bus,
@@ -178,31 +177,5 @@ void Manager::writeToConfigurationFile()
}
}
-bool Manager::getDHCPValue(const std::string& intf)
-{
- bool dhcp = false;
- // Get the interface mode value from systemd conf
- using namespace std::string_literals;
- fs::path confPath = confDir;
- std::string fileName = "00-bmc-"s + intf + ".network"s;
- confPath /= fileName;
-
- try
- {
- config::Parser parser(confPath.string());
- auto values = parser.getValues("Network","DHCP");
- // There will be only single value for DHCP key.
- if (values[0] == "true")
- {
- dhcp = true;
- }
- }
- catch (InternalFailure& e)
- {
- log<level::INFO>("Exception occured during getting of DHCP value");
- }
- return dhcp;
-}
-
}//namespace network
}//namespace phosphor
diff --git a/network_manager.hpp b/network_manager.hpp
index 4849faf..1890565 100644
--- a/network_manager.hpp
+++ b/network_manager.hpp
@@ -105,11 +105,6 @@ class Manager : public details::VLANCreateIface
/** @brief BMC network reset - resets network configuration for BMC. */
void reset() override;
- /** @brief read the DHCP value from the configuration file
- * @param[in] intf - Interface name.
- */
- bool getDHCPValue(const std::string& intf);
-
/** @brief Path of Object. */
std::string objectPath;
diff --git a/util.cpp b/util.cpp
index d96fe97..e5394ba 100644
--- a/util.cpp
+++ b/util.cpp
@@ -1,5 +1,6 @@
+#include "config_parser.hpp"
#include "util.hpp"
-
+#include "types.hpp"
#include "xyz/openbmc_project/Common/error.hpp"
#include <phosphor-logging/log.hpp>
@@ -14,6 +15,7 @@
#include <list>
#include <string>
#include <algorithm>
+#include <experimental/filesystem>
namespace phosphor
{
@@ -25,6 +27,7 @@ namespace
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+namespace fs = std::experimental::filesystem;
uint8_t toV6Cidr(const std::string& subnetMask)
{
@@ -339,5 +342,33 @@ void deleteInterface(const std::string& intf)
}
}
+bool getDHCPValue(const std::string& confDir, const std::string& intf)
+{
+ bool dhcp = false;
+ // Get the interface mode value from systemd conf
+ //using namespace std::string_literals;
+ fs::path confPath = confDir;
+ std::string fileName = systemd::config::networkFilePrefix + intf +
+ systemd::config::networkFileSuffix;
+ confPath /= fileName;
+
+ try
+ {
+ config::Parser parser(confPath.string());
+ auto values = parser.getValues("Network", "DHCP");
+ // There will be only single value for DHCP key.
+ if (values[0] == "true")
+ {
+ dhcp = true;
+ }
+ }
+ catch (InternalFailure& e)
+ {
+ log<level::INFO>("Exception occured during getting of DHCP value");
+ }
+ return dhcp;
+}
+
+
}//namespace network
}//namespace phosphor
diff --git a/util.hpp b/util.hpp
index 1d74300..2015b0c 100644
--- a/util.hpp
+++ b/util.hpp
@@ -68,6 +68,11 @@ inline void restartSystemdUnit(const std::string& unit)
*/
void deleteInterface(const std::string& intf);
+/** @brief read the DHCP value from the configuration file
+ * @param[in] confDir - Network configuration directory.
+ * @param[in] intf - Interface name.
+ */
+bool getDHCPValue(const std::string& confDir, const std::string& intf);
} //namespace network
OpenPOWER on IntegriCloud