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 | |
Ravi Teja | b6595b2 | 2024-02-23 05:00:23 -0600 | [diff] [blame] | 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 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 61 | bool ntpEnabled(bool value) override; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 62 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 70 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 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; |
Nagaraju Goruganti | e8fca1d | 2018-02-05 20:32:45 -0600 | [diff] [blame] | 77 | |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame] | 78 | /* @brief Ethernet Interface needed the below function to know the |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 79 | * value of the properties (ntpEnabled,dnsEnabled,hostnameEnabled |
| 80 | sendHostNameEnabled). |
| 81 | * |
| 82 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 83 | using ConfigIntf::dnsEnabled; |
Ravi Teja | b6595b2 | 2024-02-23 05:00:23 -0600 | [diff] [blame] | 84 | using ConfigIntf::domainEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 85 | using ConfigIntf::hostNameEnabled; |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 86 | using ConfigIntf::ntpEnabled; |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 87 | using ConfigIntf::sendHostNameEnabled; |
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 | private: |
Jishnu CM | 57dfea9 | 2023-05-05 06:07:26 -0500 | [diff] [blame] | 90 | /** @brief Ethernet Interface object. */ |
| 91 | stdplus::PinnedRef<EthernetInterface> parent; |
Ratan Gupta | 935bc33 | 2017-07-11 17:47:14 +0530 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | } // namespace dhcp |
| 95 | } // namespace network |
| 96 | } // namespace phosphor |