1 #pragma once
2 #include <sdbusplus/bus.hpp>
3 #include <sdbusplus/server/object.hpp>
4 #include <stdplus/zstring.hpp>
5 #include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp>
6 
7 namespace phosphor
8 {
9 namespace network
10 {
11 
12 class Manager; // forward declaration of network manager.
13 
14 namespace dhcp
15 {
16 
17 using ConfigIntf =
18     sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration;
19 
20 using Iface = sdbusplus::server::object_t<ConfigIntf>;
21 
22 /** @class Configuration
23  *  @brief DHCP configuration.
24  *  @details A concrete implementation for the
25  *  xyz.openbmc_project.Network.DHCP DBus interface.
26  */
27 class Configuration : public Iface
28 {
29   public:
30     Configuration() = default;
31     Configuration(const Configuration&) = delete;
32     Configuration& operator=(const Configuration&) = delete;
33     Configuration(Configuration&&) = delete;
34     Configuration& operator=(Configuration&&) = delete;
35     virtual ~Configuration() = default;
36 
37     /** @brief Constructor to put object onto bus at a dbus path.
38      *  @param[in] bus - Bus to attach to.
39      *  @param[in] objPath - Path to attach at.
40      *  @param[in] parent - Parent object.
41      */
42     Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
43                   Manager& parent);
44 
45     /** @brief If true then DNS servers received from the DHCP server
46      *         will be used and take precedence over any statically
47      *         configured ones.
48      *  @param[in] value - true if DNS server needed from DHCP server
49      *                     else false.
50      */
51     bool dnsEnabled(bool value) override;
52 
53     /** @brief If true then NTP servers received from the DHCP server
54                will be used by systemd-timesyncd.
55      *  @param[in] value - true if NTP server needed from DHCP server
56      *                     else false.
57      */
58     bool ntpEnabled(bool value) override;
59 
60     /** @brief If true then Hostname received from the DHCP server will
61      *         be set as the hostname of the system
62      *  @param[in] value - true if hostname needed from the DHCP server
63      *                     else false.
64      *
65      */
66     bool hostNameEnabled(bool value) override;
67 
68     /** @brief if true then it will cause an Option 12 field, i.e machine's
69      *         hostname, will be included in the DHCP packet.
70      *  @param[in] value - true if machine's host name needs to be included
71      *         in the DHCP packet.
72      */
73     bool sendHostNameEnabled(bool value) override;
74 
75     /* @brief Network Manager needed the below function to know the
76      *        value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled
77               sendHostNameEnabled).
78      *
79      */
80     using ConfigIntf::dnsEnabled;
81     using ConfigIntf::hostNameEnabled;
82     using ConfigIntf::ntpEnabled;
83     using ConfigIntf::sendHostNameEnabled;
84 
85   private:
86     /** @brief sdbusplus DBus bus connection. */
87     sdbusplus::bus_t& bus;
88 
89     /** @brief Network Manager object. */
90     phosphor::network::Manager& manager;
91 };
92 
93 } // namespace dhcp
94 } // namespace network
95 } // namespace phosphor
96