blob: c5bcf8a266e245d138d204fd69196b203eb65ca9 [file] [log] [blame]
Ratan Gupta935bc332017-07-11 17:47:14 +05301#pragma once
Jishnu CM57dfea92023-05-05 06:07:26 -05002#include "util.hpp"
3
Patrick Venture189d44e2018-07-09 12:30:59 -07004#include <sdbusplus/bus.hpp>
5#include <sdbusplus/server/object.hpp>
William A. Kennington III9ede1b72022-11-21 01:59:28 -08006#include <stdplus/pinned.hpp>
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -07007#include <stdplus/zstring.hpp>
Patrick Venture189d44e2018-07-09 12:30:59 -07008#include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp>
Ratan Gupta935bc332017-07-11 17:47:14 +05309
10namespace phosphor
11{
12namespace network
13{
14
Jishnu CM57dfea92023-05-05 06:07:26 -050015class EthernetInterface;
Ratan Gupta935bc332017-07-11 17:47:14 +053016
17namespace dhcp
18{
19
20using ConfigIntf =
21 sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
22
Patrick Williamsc38b0712022-07-22 19:26:54 -050023using Iface = sdbusplus::server::object_t<ConfigIntf>;
Ratan Gupta935bc332017-07-11 17:47:14 +053024
25/** @class Configuration
26 * @brief DHCP configuration.
27 * @details A concrete implementation for the
28 * xyz.openbmc_project.Network.DHCP DBus interface.
29 */
30class Configuration : public Iface
31{
Gunnar Mills57d9c502018-09-14 14:42:34 -050032 public:
Gunnar Mills57d9c502018-09-14 14:42:34 -050033 /** @brief Constructor to put object onto bus at a dbus path.
34 * @param[in] bus - Bus to attach to.
35 * @param[in] objPath - Path to attach at.
36 * @param[in] parent - Parent object.
Jishnu CM57dfea92023-05-05 06:07:26 -050037 * @param[in] type - Network type.
Gunnar Mills57d9c502018-09-14 14:42:34 -050038 */
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -070039 Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
Jishnu CM57dfea92023-05-05 06:07:26 -050040 stdplus::PinnedRef<EthernetInterface> parent, DHCPType type);
Ratan Gupta935bc332017-07-11 17:47:14 +053041
Gunnar Mills57d9c502018-09-14 14:42:34 -050042 /** @brief If true then DNS servers received from the DHCP server
43 * will be used and take precedence over any statically
44 * configured ones.
45 * @param[in] value - true if DNS server needed from DHCP server
46 * else false.
47 */
Patrick Williams6aef7692021-05-01 06:39:41 -050048 bool dnsEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053049
Ravi Tejab6595b22024-02-23 05:00:23 -060050 /** @brief If true then domain names received from the DHCP server
51 * @param[in] value - true if domain names needed from DHCP server
52 * else false.
53 */
54 bool domainEnabled(bool value) override;
55
Gunnar Mills57d9c502018-09-14 14:42:34 -050056 /** @brief If true then NTP servers received from the DHCP server
57 will be used by systemd-timesyncd.
58 * @param[in] value - true if NTP server needed from DHCP server
59 * else false.
60 */
Patrick Williams6aef7692021-05-01 06:39:41 -050061 bool ntpEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053062
Gunnar Mills57d9c502018-09-14 14:42:34 -050063 /** @brief If true then Hostname received from the DHCP server will
64 * be set as the hostname of the system
65 * @param[in] value - true if hostname needed from the DHCP server
66 * else false.
67 *
68 */
69 bool hostNameEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053070
Gunnar Mills57d9c502018-09-14 14:42:34 -050071 /** @brief if true then it will cause an Option 12 field, i.e machine's
72 * hostname, will be included in the DHCP packet.
73 * @param[in] value - true if machine's host name needs to be included
74 * in the DHCP packet.
75 */
76 bool sendHostNameEnabled(bool value) override;
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060077
Jishnu CM57dfea92023-05-05 06:07:26 -050078 /* @brief Ethernet Interface needed the below function to know the
Gunnar Mills57d9c502018-09-14 14:42:34 -050079 * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
80 sendHostNameEnabled).
81 *
82 */
Patrick Williams6aef7692021-05-01 06:39:41 -050083 using ConfigIntf::dnsEnabled;
Ravi Tejab6595b22024-02-23 05:00:23 -060084 using ConfigIntf::domainEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050085 using ConfigIntf::hostNameEnabled;
Patrick Williams6aef7692021-05-01 06:39:41 -050086 using ConfigIntf::ntpEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050087 using ConfigIntf::sendHostNameEnabled;
Ratan Gupta935bc332017-07-11 17:47:14 +053088
Gunnar Mills57d9c502018-09-14 14:42:34 -050089 private:
Jishnu CM57dfea92023-05-05 06:07:26 -050090 /** @brief Ethernet Interface object. */
91 stdplus::PinnedRef<EthernetInterface> parent;
92 DHCPType type;
Ratan Gupta935bc332017-07-11 17:47:14 +053093};
94
95} // namespace dhcp
96} // namespace network
97} // namespace phosphor