blob: 95aa2035c53c409407600cc610e5842a29626f05 [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
Gunnar Mills57d9c502018-09-14 14:42:34 -050050 /** @brief If true then NTP servers received from the DHCP server
51 will be used by systemd-timesyncd.
52 * @param[in] value - true if NTP server needed from DHCP server
53 * else false.
54 */
Patrick Williams6aef7692021-05-01 06:39:41 -050055 bool ntpEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053056
Gunnar Mills57d9c502018-09-14 14:42:34 -050057 /** @brief If true then Hostname received from the DHCP server will
58 * be set as the hostname of the system
59 * @param[in] value - true if hostname needed from the DHCP server
60 * else false.
61 *
62 */
63 bool hostNameEnabled(bool value) override;
Ratan Gupta935bc332017-07-11 17:47:14 +053064
Gunnar Mills57d9c502018-09-14 14:42:34 -050065 /** @brief if true then it will cause an Option 12 field, i.e machine's
66 * hostname, will be included in the DHCP packet.
67 * @param[in] value - true if machine's host name needs to be included
68 * in the DHCP packet.
69 */
70 bool sendHostNameEnabled(bool value) override;
Nagaraju Gorugantie8fca1d2018-02-05 20:32:45 -060071
Jishnu CM57dfea92023-05-05 06:07:26 -050072 /* @brief Ethernet Interface needed the below function to know the
Gunnar Mills57d9c502018-09-14 14:42:34 -050073 * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
74 sendHostNameEnabled).
75 *
76 */
Patrick Williams6aef7692021-05-01 06:39:41 -050077 using ConfigIntf::dnsEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050078 using ConfigIntf::hostNameEnabled;
Patrick Williams6aef7692021-05-01 06:39:41 -050079 using ConfigIntf::ntpEnabled;
Gunnar Mills57d9c502018-09-14 14:42:34 -050080 using ConfigIntf::sendHostNameEnabled;
Ratan Gupta935bc332017-07-11 17:47:14 +053081
Gunnar Mills57d9c502018-09-14 14:42:34 -050082 private:
Jishnu CM57dfea92023-05-05 06:07:26 -050083 /** @brief Ethernet Interface object. */
84 stdplus::PinnedRef<EthernetInterface> parent;
85 DHCPType type;
Ratan Gupta935bc332017-07-11 17:47:14 +053086};
87
88} // namespace dhcp
89} // namespace network
90} // namespace phosphor