blob: 98f8e4693e9c12f910ff14773edc6bcc65f19be9 [file] [log] [blame]
Ratan Gupta935bc332017-07-11 17:47:14 +05301#pragma once
Patrick Venture189d44e2018-07-09 12:30:59 -07002#include <sdbusplus/bus.hpp>
3#include <sdbusplus/server/object.hpp>
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -07004#include <stdplus/zstring.hpp>
Patrick Venture189d44e2018-07-09 12:30:59 -07005#include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp>
Ratan Gupta935bc332017-07-11 17:47:14 +05306
7namespace phosphor
8{
9namespace network
10{
11
Ratan Gupta935bc332017-07-11 17:47:14 +053012class Manager; // forward declaration of network manager.
13
14namespace dhcp
15{
16
17using ConfigIntf =
18 sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
19
Patrick Williamsc38b0712022-07-22 19:26:54 -050020using Iface = sdbusplus::server::object_t<ConfigIntf>;
Ratan Gupta935bc332017-07-11 17:47:14 +053021
22/** @class Configuration
23 * @brief DHCP configuration.
24 * @details A concrete implementation for the
25 * xyz.openbmc_project.Network.DHCP DBus interface.
26 */
27class Configuration : public Iface
28{
Gunnar Mills57d9c502018-09-14 14:42:34 -050029 public:
30 Configuration() = default;
31 Configuration(const Configuration&) = delete;
32 Configuration& operator=(const Configuration&) = delete;
33 Configuration(Configuration&&) = delete;
34 Configuration& operator=(Configuration&&) = delete;
35 virtual ~Configuration() = default;
Ratan Gupta935bc332017-07-11 17:47:14 +053036
Gunnar Mills57d9c502018-09-14 14:42:34 -050037 /** @brief Constructor to put object onto bus at a dbus path.
38 * @param[in] bus - Bus to attach to.
39 * @param[in] objPath - Path to attach at.
40 * @param[in] parent - Parent object.
41 */
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -070042 Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
William A. Kennington IIIe94c9ff2022-08-18 20:12:27 -070043 Manager& parent);
Ratan Gupta935bc332017-07-11 17:47:14 +053044
Gunnar Mills57d9c502018-09-14 14:42:34 -050045 /** @brief If true then DNS servers received from the DHCP server
46 * will be used and take precedence over any statically
47 * configured ones.
48 * @param[in] value - true if DNS server needed from DHCP server
49 * else false.
50 */
Patrick Williams6aef7692021-05-01 06:39:41 -050051 bool dnsEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053052
Gunnar Mills57d9c502018-09-14 14:42:34 -050053 /** @brief If true then NTP servers received from the DHCP server
54 will be used by systemd-timesyncd.
55 * @param[in] value - true if NTP server needed from DHCP server
56 * else false.
57 */
Patrick Williams6aef7692021-05-01 06:39:41 -050058 bool ntpEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053059
Gunnar Mills57d9c502018-09-14 14:42:34 -050060 /** @brief If true then Hostname received from the DHCP server will
61 * be set as the hostname of the system
62 * @param[in] value - true if hostname needed from the DHCP server
63 * else false.
64 *
65 */
66 bool hostNameEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053067
Gunnar Mills57d9c502018-09-14 14:42:34 -050068 /** @brief if true then it will cause an Option 12 field, i.e machine's
69 * hostname, will be included in the DHCP packet.
70 * @param[in] value - true if machine's host name needs to be included
71 * in the DHCP packet.
72 */
73 bool sendHostNameEnabled(bool value) override;
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060074
Gunnar Mills57d9c502018-09-14 14:42:34 -050075 /* @brief Network Manager needed the below function to know the
76 * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
77 sendHostNameEnabled).
78 *
79 */
Patrick Williams6aef7692021-05-01 06:39:41 -050080 using ConfigIntf::dnsEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050081 using ConfigIntf::hostNameEnabled;
Patrick Williams6aef7692021-05-01 06:39:41 -050082 using ConfigIntf::ntpEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050083 using ConfigIntf::sendHostNameEnabled;
Ratan Gupta935bc332017-07-11 17:47:14 +053084
Gunnar Mills57d9c502018-09-14 14:42:34 -050085 private:
86 /** @brief sdbusplus DBus bus connection. */
Patrick Williamsc38b0712022-07-22 19:26:54 -050087 sdbusplus::bus_t& bus;
Ratan Gupta935bc332017-07-11 17:47:14 +053088
Gunnar Mills57d9c502018-09-14 14:42:34 -050089 /** @brief Network Manager object. */
90 phosphor::network::Manager& manager;
Ratan Gupta935bc332017-07-11 17:47:14 +053091};
92
93} // namespace dhcp
94} // namespace network
95} // namespace phosphor