blob: 964b7d5051ead05d584d85662b76cad42751062b [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 III9ede1b72022-11-21 01:59:28 -08004#include <stdplus/pinned.hpp>
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -07005#include <stdplus/zstring.hpp>
Patrick Venture189d44e2018-07-09 12:30:59 -07006#include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp>
Ratan Gupta935bc332017-07-11 17:47:14 +05307
8namespace phosphor
9{
10namespace network
11{
12
Ratan Gupta935bc332017-07-11 17:47:14 +053013class Manager; // forward declaration of network manager.
14
15namespace dhcp
16{
17
18using ConfigIntf =
19 sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
20
Patrick Williamsc38b0712022-07-22 19:26:54 -050021using Iface = sdbusplus::server::object_t<ConfigIntf>;
Ratan Gupta935bc332017-07-11 17:47:14 +053022
23/** @class Configuration
24 * @brief DHCP configuration.
25 * @details A concrete implementation for the
26 * xyz.openbmc_project.Network.DHCP DBus interface.
27 */
28class Configuration : public Iface
29{
Gunnar Mills57d9c502018-09-14 14:42:34 -050030 public:
Gunnar Mills57d9c502018-09-14 14:42:34 -050031 /** @brief Constructor to put object onto bus at a dbus path.
32 * @param[in] bus - Bus to attach to.
33 * @param[in] objPath - Path to attach at.
34 * @param[in] parent - Parent object.
35 */
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -070036 Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
William A. Kennington III9ede1b72022-11-21 01:59:28 -080037 stdplus::PinnedRef<Manager> parent);
Ratan Gupta935bc332017-07-11 17:47:14 +053038
Gunnar Mills57d9c502018-09-14 14:42:34 -050039 /** @brief If true then DNS servers received from the DHCP server
40 * will be used and take precedence over any statically
41 * configured ones.
42 * @param[in] value - true if DNS server needed from DHCP server
43 * else false.
44 */
Patrick Williams6aef7692021-05-01 06:39:41 -050045 bool dnsEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053046
Gunnar Mills57d9c502018-09-14 14:42:34 -050047 /** @brief If true then NTP servers received from the DHCP server
48 will be used by systemd-timesyncd.
49 * @param[in] value - true if NTP server needed from DHCP server
50 * else false.
51 */
Patrick Williams6aef7692021-05-01 06:39:41 -050052 bool ntpEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053053
Gunnar Mills57d9c502018-09-14 14:42:34 -050054 /** @brief If true then Hostname received from the DHCP server will
55 * be set as the hostname of the system
56 * @param[in] value - true if hostname needed from the DHCP server
57 * else false.
58 *
59 */
60 bool hostNameEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053061
Gunnar Mills57d9c502018-09-14 14:42:34 -050062 /** @brief if true then it will cause an Option 12 field, i.e machine's
63 * hostname, will be included in the DHCP packet.
64 * @param[in] value - true if machine's host name needs to be included
65 * in the DHCP packet.
66 */
67 bool sendHostNameEnabled(bool value) override;
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060068
Gunnar Mills57d9c502018-09-14 14:42:34 -050069 /* @brief Network Manager needed the below function to know the
70 * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
71 sendHostNameEnabled).
72 *
73 */
Patrick Williams6aef7692021-05-01 06:39:41 -050074 using ConfigIntf::dnsEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050075 using ConfigIntf::hostNameEnabled;
Patrick Williams6aef7692021-05-01 06:39:41 -050076 using ConfigIntf::ntpEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050077 using ConfigIntf::sendHostNameEnabled;
Ratan Gupta935bc332017-07-11 17:47:14 +053078
Gunnar Mills57d9c502018-09-14 14:42:34 -050079 private:
Gunnar Mills57d9c502018-09-14 14:42:34 -050080 /** @brief Network Manager object. */
William A. Kennington III9ede1b72022-11-21 01:59:28 -080081 stdplus::PinnedRef<Manager> manager;
Ratan Gupta935bc332017-07-11 17:47:14 +053082};
83
84} // namespace dhcp
85} // namespace network
86} // namespace phosphor