blob: a550077c689b09e3cd722eb887076256513eaba3 [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);
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060059 ConfigIntf::sendHostNameEnabled(true);
Ratan Guptac35481d2017-08-18 06:12:26 +053060 emit_object_added();
61 }
Ratan Gupta935bc332017-07-11 17:47:14 +053062
63 /** @brief If true then DNS servers received from the DHCP server
64 * will be used and take precedence over any statically
65 * configured ones.
66 * @param[in] value - true if DNS server needed from DHCP server
67 * else false.
68 */
69 bool dNSEnabled(bool value) override;
70
71 /** @brief If true then NTP servers received from the DHCP server
72 will be used by systemd-timesyncd.
73 * @param[in] value - true if NTP server needed from DHCP server
74 * else false.
75 */
76 bool nTPEnabled(bool value) override;
77
78 /** @brief If true then Hostname received from the DHCP server will
79 * be set as the hostname of the system
80 * @param[in] value - true if hostname needed from the DHCP server
81 * else false.
82 *
83 */
84 bool hostNameEnabled(bool value) override;
85
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060086 /** @brief if true then it will cause an Option 12 field, i.e machine's
87 * hostname, will be included in the DHCP packet.
88 * @param[in] value - true if machine's host name needs to be included
89 * in the DHCP packet.
90 */
91 bool sendHostNameEnabled(bool value) override;
92
Ratan Gupta935bc332017-07-11 17:47:14 +053093 /* @brief Network Manager needed the below function to know the
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060094 * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
95 sendHostNameEnabled).
Ratan Gupta935bc332017-07-11 17:47:14 +053096 *
97 */
98 using ConfigIntf::dNSEnabled;
99 using ConfigIntf::nTPEnabled;
100 using ConfigIntf::hostNameEnabled;
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -0600101 using ConfigIntf::sendHostNameEnabled;
Ratan Gupta935bc332017-07-11 17:47:14 +0530102
103 private:
104
105 /** @brief sdbusplus DBus bus connection. */
106 sdbusplus::bus::bus& bus;
107
108 /** @brief Network Manager object. */
109 phosphor::network::Manager& manager;
110
111};
112
113} // namespace dhcp
114} // namespace network
115} // namespace phosphor