Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 1 | #pragma once |
William A. Kennington III | c2e5e0e | 2019-04-22 01:26:06 -0700 | [diff] [blame] | 2 | #include "types.hpp" |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 3 | |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
William A. Kennington III | 59e5b91 | 2022-11-02 02:49:46 -0700 | [diff] [blame] | 5 | #include <sdbusplus/message/native_types.hpp> |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 6 | #include <sdbusplus/server/object.hpp> |
William A. Kennington III | c2e5e0e | 2019-04-22 01:26:06 -0700 | [diff] [blame] | 7 | #include <string_view> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 8 | #include <xyz/openbmc_project/Network/IP/server.hpp> |
| 9 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 10 | |
| 11 | namespace phosphor |
| 12 | { |
| 13 | namespace network |
| 14 | { |
| 15 | |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 16 | using IPIfaces = sdbusplus::server::object_t< |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 17 | sdbusplus::xyz::openbmc_project::Network::server::IP, |
| 18 | sdbusplus::xyz::openbmc_project::Object::server::Delete>; |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 19 | |
| 20 | using IP = sdbusplus::xyz::openbmc_project::Network::server::IP; |
| 21 | |
| 22 | class EthernetInterface; |
| 23 | |
| 24 | /** @class IPAddress |
| 25 | * @brief OpenBMC IPAddress implementation. |
| 26 | * @details A concrete implementation for the |
| 27 | * xyz.openbmc_project.Network.IPProtocol |
| 28 | * xyz.openbmc_project.Network.IP Dbus interfaces. |
| 29 | */ |
| 30 | class IPAddress : public IPIfaces |
| 31 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 32 | public: |
| 33 | IPAddress() = delete; |
| 34 | IPAddress(const IPAddress&) = delete; |
| 35 | IPAddress& operator=(const IPAddress&) = delete; |
| 36 | IPAddress(IPAddress&&) = delete; |
| 37 | IPAddress& operator=(IPAddress&&) = delete; |
| 38 | virtual ~IPAddress() = default; |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 39 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 40 | /** @brief Constructor to put object onto bus at a dbus path. |
| 41 | * @param[in] bus - Bus to attach to. |
William A. Kennington III | 59e5b91 | 2022-11-02 02:49:46 -0700 | [diff] [blame] | 42 | * @param[in] objRoot - Path to attach at. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 43 | * @param[in] parent - Parent object. |
William A. Kennington III | 59e5b91 | 2022-11-02 02:49:46 -0700 | [diff] [blame] | 44 | * @param[in] addr - The ip address and prefix. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 45 | * @param[in] origin - origin of ipaddress(dhcp/static/SLAAC/LinkLocal). |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 46 | */ |
William A. Kennington III | 59e5b91 | 2022-11-02 02:49:46 -0700 | [diff] [blame] | 47 | IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot, |
| 48 | EthernetInterface& parent, IfAddr addr, IP::AddressOrigin origin); |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 49 | |
William A. Kennington III | 5e72d08 | 2022-09-01 13:10:17 -0700 | [diff] [blame] | 50 | std::string address(std::string ipAddress) override; |
| 51 | uint8_t prefixLength(uint8_t) override; |
| 52 | std::string gateway(std::string gateway) override; |
| 53 | IP::Protocol type(IP::Protocol type) override; |
| 54 | IP::AddressOrigin origin(IP::AddressOrigin origin) override; |
| 55 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 56 | /** @brief Delete this d-bus object. |
| 57 | */ |
| 58 | void delete_() override; |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 59 | |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 60 | using IP::address; |
| 61 | using IP::gateway; |
| 62 | using IP::origin; |
| 63 | using IP::prefixLength; |
| 64 | using IP::type; |
| 65 | |
William A. Kennington III | 59e5b91 | 2022-11-02 02:49:46 -0700 | [diff] [blame] | 66 | inline const auto& getObjPath() const |
| 67 | { |
| 68 | return objPath; |
| 69 | } |
| 70 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 71 | private: |
| 72 | /** @brief Parent Object. */ |
| 73 | EthernetInterface& parent; |
William A. Kennington III | 59e5b91 | 2022-11-02 02:49:46 -0700 | [diff] [blame] | 74 | |
| 75 | /** @brief Dbus object path */ |
| 76 | sdbusplus::message::object_path objPath; |
| 77 | |
| 78 | IPAddress(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath, |
| 79 | EthernetInterface& parent, IfAddr addr, IP::AddressOrigin origin); |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 80 | }; |
| 81 | |
Ratan Gupta | 4af3676 | 2017-04-20 19:12:29 +0530 | [diff] [blame] | 82 | } // namespace network |
| 83 | } // namespace phosphor |