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