1 #pragma once 2 #include "types.hpp" 3 4 #include <sdbusplus/bus.hpp> 5 #include <sdbusplus/message/native_types.hpp> 6 #include <sdbusplus/server/object.hpp> 7 #include <stdplus/pinned.hpp> 8 #include <string_view> 9 #include <xyz/openbmc_project/Network/IP/server.hpp> 10 #include <xyz/openbmc_project/Object/Delete/server.hpp> 11 12 namespace phosphor 13 { 14 namespace network 15 { 16 17 using IPIfaces = sdbusplus::server::object_t< 18 sdbusplus::xyz::openbmc_project::Network::server::IP, 19 sdbusplus::xyz::openbmc_project::Object::server::Delete>; 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 { 33 public: 34 /** @brief Constructor to put object onto bus at a dbus path. 35 * @param[in] bus - Bus to attach to. 36 * @param[in] objRoot - Path to attach at. 37 * @param[in] parent - Parent object. 38 * @param[in] addr - The ip address and prefix. 39 * @param[in] origin - origin of ipaddress(dhcp/static/SLAAC/LinkLocal). 40 */ 41 IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot, 42 stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr, 43 IP::AddressOrigin origin); 44 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 51 /** @brief Delete this d-bus object. 52 */ 53 void delete_() override; 54 55 using IP::address; 56 using IP::gateway; 57 using IP::origin; 58 using IP::prefixLength; 59 using IP::type; 60 61 inline const auto& getObjPath() const 62 { 63 return objPath; 64 } 65 66 private: 67 /** @brief Parent Object. */ 68 stdplus::PinnedRef<EthernetInterface> parent; 69 70 /** @brief Dbus object path */ 71 sdbusplus::message::object_path objPath; 72 73 IPAddress(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath, 74 stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr, 75 IP::AddressOrigin origin); 76 }; 77 78 } // namespace network 79 } // namespace phosphor 80