blob: f486f2271f016731c92f6ffd1c95e66e2767be0e [file] [log] [blame]
Ratan Gupta935bc332017-07-11 17:47:14 +05301#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
9namespace phosphor
10{
11namespace network
12{
13
14constexpr auto networkdService = "systemd-networkd.service";
15constexpr auto timeSynchdService = "systemd-timesyncd.service";
16
17class Manager; // forward declaration of network manager.
18
19namespace dhcp
20{
21
22using ConfigIntf =
23 sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
24
25using 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 */
34class 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) :
Ratan Guptac35481d2017-08-18 06:12:26 +053052 Iface(bus, objPath.c_str(), true),
Ratan Gupta935bc332017-07-11 17:47:14 +053053 bus(bus),
Ratan Guptac35481d2017-08-18 06:12:26 +053054 manager(parent)
55 {
56 // systemd default behaviour is following fields should be
57 // enabled by default.
58
59 ConfigIntf::dNSEnabled(true);
60 ConfigIntf::nTPEnabled(true);
61 ConfigIntf::hostNameEnabled(true);
62 emit_object_added();
63 }
Ratan Gupta935bc332017-07-11 17:47:14 +053064
65 /** @brief If true then DNS servers received from the DHCP server
66 * will be used and take precedence over any statically
67 * configured ones.
68 * @param[in] value - true if DNS server needed from DHCP server
69 * else false.
70 */
71 bool dNSEnabled(bool value) override;
72
73 /** @brief If true then NTP servers received from the DHCP server
74 will be used by systemd-timesyncd.
75 * @param[in] value - true if NTP server needed from DHCP server
76 * else false.
77 */
78 bool nTPEnabled(bool value) override;
79
80 /** @brief If true then Hostname received from the DHCP server will
81 * be set as the hostname of the system
82 * @param[in] value - true if hostname needed from the DHCP server
83 * else false.
84 *
85 */
86 bool hostNameEnabled(bool value) override;
87
88 /* @brief Network Manager needed the below function to know the
89 * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled).
90 *
91 */
92 using ConfigIntf::dNSEnabled;
93 using ConfigIntf::nTPEnabled;
94 using ConfigIntf::hostNameEnabled;
95
96 private:
97
98 /** @brief sdbusplus DBus bus connection. */
99 sdbusplus::bus::bus& bus;
100
101 /** @brief Network Manager object. */
102 phosphor::network::Manager& manager;
103
104};
105
106} // namespace dhcp
107} // namespace network
108} // namespace phosphor