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