1 #pragma once
2 #include "util.hpp"
3 
4 #include <sdbusplus/bus.hpp>
5 #include <sdbusplus/server/object.hpp>
6 #include <stdplus/pinned.hpp>
7 #include <stdplus/zstring.hpp>
8 #include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp>
9 
10 namespace phosphor
11 {
12 namespace network
13 {
14 
15 class EthernetInterface;
16 
17 namespace dhcp
18 {
19 
20 using ConfigIntf =
21     sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
22 
23 using Iface = sdbusplus::server::object_t<ConfigIntf>;
24 
25 /** @class Configuration
26  *  @brief DHCP configuration.
27  *  @details A concrete implementation for the
28  *  xyz.openbmc_project.Network.DHCP DBus interface.
29  */
30 class Configuration : public Iface
31 {
32   public:
33     /** @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.
37      *  @param[in] type - Network type.
38      */
39     Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
40                   stdplus::PinnedRef<EthernetInterface> parent, DHCPType type);
41 
42     /** @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      */
48     bool dnsEnabled(bool value) override;
49 
50     /** @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      */
55     bool ntpEnabled(bool value) override;
56 
57     /** @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;
64 
65     /** @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;
71 
72     /* @brief Ethernet Interface needed the below function to know the
73      *        value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
74               sendHostNameEnabled).
75      *
76      */
77     using ConfigIntf::dnsEnabled;
78     using ConfigIntf::hostNameEnabled;
79     using ConfigIntf::ntpEnabled;
80     using ConfigIntf::sendHostNameEnabled;
81 
82   private:
83     /** @brief Ethernet Interface object. */
84     stdplus::PinnedRef<EthernetInterface> parent;
85     DHCPType type;
86 };
87 
88 } // namespace dhcp
89 } // namespace network
90 } // namespace phosphor
91