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