Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "xyz/openbmc_project/Network/DHCPConfiguration/server.hpp" |
| 4 | #include <sdbusplus/bus.hpp> |
| 5 | #include <sdbusplus/server/object.hpp> |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace network |
| 12 | { |
| 13 | |
| 14 | constexpr auto networkdService = "systemd-networkd.service"; |
| 15 | constexpr auto timeSynchdService = "systemd-timesyncd.service"; |
| 16 | |
| 17 | class Manager; // forward declaration of network manager. |
| 18 | |
| 19 | namespace dhcp |
| 20 | { |
| 21 | |
| 22 | using ConfigIntf = |
| 23 | sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration; |
| 24 | |
| 25 | using Iface = |
| 26 | sdbusplus::server::object::object<ConfigIntf>; |
| 27 | |
| 28 | |
| 29 | /** @class Configuration |
| 30 | * @brief DHCP configuration. |
| 31 | * @details A concrete implementation for the |
| 32 | * xyz.openbmc_project.Network.DHCP DBus interface. |
| 33 | */ |
| 34 | class Configuration : public Iface |
| 35 | { |
| 36 | public: |
| 37 | Configuration() = default; |
| 38 | Configuration(const Configuration&) = delete; |
| 39 | Configuration& operator=(const Configuration&) = delete; |
| 40 | Configuration(Configuration&&) = delete; |
| 41 | Configuration& operator=(Configuration&&) = delete; |
| 42 | virtual ~Configuration() = default; |
| 43 | |
| 44 | /** @brief Constructor to put object onto bus at a dbus path. |
| 45 | * @param[in] bus - Bus to attach to. |
| 46 | * @param[in] objPath - Path to attach at. |
| 47 | * @param[in] parent - Parent object. |
| 48 | */ |
| 49 | Configuration(sdbusplus::bus::bus& bus, |
| 50 | const std::string& objPath, |
| 51 | Manager& parent) : |
| 52 | Iface(bus, objPath.c_str()), |
| 53 | bus(bus), |
| 54 | manager(parent){} |
| 55 | |
| 56 | /** @brief If true then DNS servers received from the DHCP server |
| 57 | * will be used and take precedence over any statically |
| 58 | * configured ones. |
| 59 | * @param[in] value - true if DNS server needed from DHCP server |
| 60 | * else false. |
| 61 | */ |
| 62 | bool dNSEnabled(bool value) override; |
| 63 | |
| 64 | /** @brief If true then NTP servers received from the DHCP server |
| 65 | will be used by systemd-timesyncd. |
| 66 | * @param[in] value - true if NTP server needed from DHCP server |
| 67 | * else false. |
| 68 | */ |
| 69 | bool nTPEnabled(bool value) override; |
| 70 | |
| 71 | /** @brief If true then Hostname received from the DHCP server will |
| 72 | * be set as the hostname of the system |
| 73 | * @param[in] value - true if hostname needed from the DHCP server |
| 74 | * else false. |
| 75 | * |
| 76 | */ |
| 77 | bool hostNameEnabled(bool value) override; |
| 78 | |
| 79 | /* @brief Network Manager needed the below function to know the |
| 80 | * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled). |
| 81 | * |
| 82 | */ |
| 83 | using ConfigIntf::dNSEnabled; |
| 84 | using ConfigIntf::nTPEnabled; |
| 85 | using ConfigIntf::hostNameEnabled; |
| 86 | |
| 87 | private: |
| 88 | |
| 89 | /** @brief sdbusplus DBus bus connection. */ |
| 90 | sdbusplus::bus::bus& bus; |
| 91 | |
| 92 | /** @brief Network Manager object. */ |
| 93 | phosphor::network::Manager& manager; |
| 94 | |
| 95 | }; |
| 96 | |
| 97 | } // namespace dhcp |
| 98 | } // namespace network |
| 99 | } // namespace phosphor |