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 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 
56     /** @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      */
61     bool ntpEnabled(bool value) override;
62 
63     /** @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;
70 
71     /** @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;
77 
78     /* @brief Ethernet Interface needed the below function to know the
79      *        value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
80               sendHostNameEnabled).
81      *
82      */
83     using ConfigIntf::dnsEnabled;
84     using ConfigIntf::domainEnabled;
85     using ConfigIntf::hostNameEnabled;
86     using ConfigIntf::ntpEnabled;
87     using ConfigIntf::sendHostNameEnabled;
88 
89   private:
90     /** @brief Ethernet Interface object. */
91     stdplus::PinnedRef<EthernetInterface> parent;
92 };
93 
94 } // namespace dhcp
95 } // namespace network
96 } // namespace phosphor
97