blob: e9520736afbd04260a45620bf395ab62c9e671a1 [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
Ratan Gupta935bc332017-07-11 17:47:14 +053014class Manager; // forward declaration of network manager.
15
16namespace dhcp
17{
18
19using ConfigIntf =
20 sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
21
22using 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 */
31class 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 Guptac35481d2017-08-18 06:12:26 +053049 Iface(bus, objPath.c_str(), true),
Ratan Gupta935bc332017-07-11 17:47:14 +053050 bus(bus),
Ratan Guptac35481d2017-08-18 06:12:26 +053051 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 Gupta935bc332017-07-11 17:47:14 +053061
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