Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 1 | #pragma once |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 2 | #include <sdbusplus/bus.hpp> |
| 3 | #include <sdbusplus/server/object.hpp> |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 4 | #include <stdplus/zstring.hpp> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 5 | #include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp> |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace network |
| 10 | { |
| 11 | |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 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 | |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 20 | using Iface = sdbusplus::server::object_t<ConfigIntf>; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 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 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 36 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 42 | Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath, |
William A. Kennington III | e94c9ff | 2022-08-18 20:12:27 -0700 | [diff] [blame] | 43 | Manager& parent); |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 44 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 51 | bool dnsEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 52 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 58 | bool ntpEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 59 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 67 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Nagaraju Goruganti | e8fca1d | 2018-02-05 20:32:45 -0600 | [diff] [blame] | 74 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 75 | /* @brief Network Manager needed the below function to know the |
| 76 | * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled |
| 77 | sendHostNameEnabled). |
| 78 | * |
| 79 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 80 | using ConfigIntf::dnsEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 81 | using ConfigIntf::hostNameEnabled; |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 82 | using ConfigIntf::ntpEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 83 | using ConfigIntf::sendHostNameEnabled; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 84 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 85 | private: |
| 86 | /** @brief sdbusplus DBus bus connection. */ |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 87 | sdbusplus::bus_t& bus; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 88 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 89 | /** @brief Network Manager object. */ |
| 90 | phosphor::network::Manager& manager; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace dhcp |
| 94 | } // namespace network |
| 95 | } // namespace phosphor |