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 | 9ede1b7 | 2022-11-21 01:59:28 -0800 | [diff] [blame] | 4 | #include <stdplus/pinned.hpp> |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 5 | #include <stdplus/zstring.hpp> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 6 | #include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp> |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace network |
| 11 | { |
| 12 | |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 13 | class Manager; // forward declaration of network manager. |
| 14 | |
| 15 | namespace dhcp |
| 16 | { |
| 17 | |
| 18 | using ConfigIntf = |
| 19 | sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration; |
| 20 | |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 21 | using Iface = sdbusplus::server::object_t<ConfigIntf>; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 22 | |
| 23 | /** @class Configuration |
| 24 | * @brief DHCP configuration. |
| 25 | * @details A concrete implementation for the |
| 26 | * xyz.openbmc_project.Network.DHCP DBus interface. |
| 27 | */ |
| 28 | class Configuration : public Iface |
| 29 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 30 | public: |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 31 | /** @brief Constructor to put object onto bus at a dbus path. |
| 32 | * @param[in] bus - Bus to attach to. |
| 33 | * @param[in] objPath - Path to attach at. |
| 34 | * @param[in] parent - Parent object. |
| 35 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 36 | Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath, |
William A. Kennington III | 9ede1b7 | 2022-11-21 01:59:28 -0800 | [diff] [blame] | 37 | stdplus::PinnedRef<Manager> parent); |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 38 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 39 | /** @brief If true then DNS servers received from the DHCP server |
| 40 | * will be used and take precedence over any statically |
| 41 | * configured ones. |
| 42 | * @param[in] value - true if DNS server needed from DHCP server |
| 43 | * else false. |
| 44 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 45 | bool dnsEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 46 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 47 | /** @brief If true then NTP servers received from the DHCP server |
| 48 | will be used by systemd-timesyncd. |
| 49 | * @param[in] value - true if NTP server needed from DHCP server |
| 50 | * else false. |
| 51 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 52 | bool ntpEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 53 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 54 | /** @brief If true then Hostname received from the DHCP server will |
| 55 | * be set as the hostname of the system |
| 56 | * @param[in] value - true if hostname needed from the DHCP server |
| 57 | * else false. |
| 58 | * |
| 59 | */ |
| 60 | bool hostNameEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 61 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 62 | /** @brief if true then it will cause an Option 12 field, i.e machine's |
| 63 | * hostname, will be included in the DHCP packet. |
| 64 | * @param[in] value - true if machine's host name needs to be included |
| 65 | * in the DHCP packet. |
| 66 | */ |
| 67 | bool sendHostNameEnabled(bool value) override; |
Nagaraju Goruganti | e8fca1d | 2018-02-05 20:32:45 -0600 | [diff] [blame] | 68 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 69 | /* @brief Network Manager needed the below function to know the |
| 70 | * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled |
| 71 | sendHostNameEnabled). |
| 72 | * |
| 73 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 74 | using ConfigIntf::dnsEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 75 | using ConfigIntf::hostNameEnabled; |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 76 | using ConfigIntf::ntpEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 77 | using ConfigIntf::sendHostNameEnabled; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 78 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 79 | private: |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 80 | /** @brief Network Manager object. */ |
William A. Kennington III | 9ede1b7 | 2022-11-21 01:59:28 -0800 | [diff] [blame] | 81 | stdplus::PinnedRef<Manager> manager; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } // namespace dhcp |
| 85 | } // namespace network |
| 86 | } // namespace phosphor |