Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 1 | #pragma once |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame^] | 2 | #include "util.hpp" |
| 3 | |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
| 5 | #include <sdbusplus/server/object.hpp> |
William A. Kennington III | 9ede1b7 | 2022-11-21 01:59:28 -0800 | [diff] [blame] | 6 | #include <stdplus/pinned.hpp> |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 7 | #include <stdplus/zstring.hpp> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 8 | #include <xyz/openbmc_project/Network/DHCPConfiguration/server.hpp> |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace network |
| 13 | { |
| 14 | |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame^] | 15 | class EthernetInterface; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 16 | |
| 17 | namespace dhcp |
| 18 | { |
| 19 | |
| 20 | using ConfigIntf = |
| 21 | sdbusplus::xyz::openbmc_project::Network::server::DHCPConfiguration; |
| 22 | |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 23 | using Iface = sdbusplus::server::object_t<ConfigIntf>; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 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 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 32 | public: |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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. |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame^] | 37 | * @param[in] type - Network type. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 38 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 39 | Configuration(sdbusplus::bus_t& bus, stdplus::const_zstring objPath, |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame^] | 40 | stdplus::PinnedRef<EthernetInterface> parent, DHCPType type); |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 41 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 48 | bool dnsEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 49 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 55 | bool ntpEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 56 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 64 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Nagaraju Goruganti | e8fca1d | 2018-02-05 20:32:45 -0600 | [diff] [blame] | 71 | |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame^] | 72 | /* @brief Ethernet Interface needed the below function to know the |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 73 | * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled |
| 74 | sendHostNameEnabled). |
| 75 | * |
| 76 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 77 | using ConfigIntf::dnsEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 78 | using ConfigIntf::hostNameEnabled; |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 79 | using ConfigIntf::ntpEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 80 | using ConfigIntf::sendHostNameEnabled; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 81 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 82 | private: |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame^] | 83 | /** @brief Ethernet Interface object. */ |
| 84 | stdplus::PinnedRef<EthernetInterface> parent; |
| 85 | DHCPType type; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace dhcp |
| 89 | } // namespace network |
| 90 | } // namespace phosphor |