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