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 <string_view> 8 #include <xyz/openbmc_project/Network/Neighbor/server.hpp> 9 #include <xyz/openbmc_project/Object/Delete/server.hpp> 10 11 namespace phosphor 12 { 13 namespace network 14 { 15 16 using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor; 17 18 using NeighborObj = sdbusplus::server::object_t< 19 NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>; 20 21 class EthernetInterface; 22 23 /** @class Neighbor 24 * @brief OpenBMC network neighbor implementation. 25 * @details A concrete implementation for the 26 * xyz.openbmc_project.Network.Neighbor dbus interface. 27 */ 28 class Neighbor : public NeighborObj 29 { 30 public: 31 using State = NeighborIntf::State; 32 33 Neighbor() = delete; 34 Neighbor(const Neighbor&) = delete; 35 Neighbor& operator=(const Neighbor&) = delete; 36 Neighbor(Neighbor&&) = delete; 37 Neighbor& operator=(Neighbor&&) = delete; 38 virtual ~Neighbor() = default; 39 40 /** @brief Constructor to put object onto bus at a dbus path. 41 * @param[in] bus - Bus to attach to. 42 * @param[in] objRoot - Path to attach at. 43 * @param[in] parent - Parent object. 44 * @param[in] addr - IP address. 45 * @param[in] lladdr - Low level MAC address. 46 * @param[in] state - The state of the neighbor entry. 47 */ 48 Neighbor(sdbusplus::bus_t& bus, std::string_view objRoot, 49 EthernetInterface& parent, InAddrAny addr, ether_addr lladdr, 50 State state); 51 52 /** @brief Delete this d-bus object. 53 */ 54 void delete_() override; 55 56 using NeighborObj::ipAddress; 57 std::string ipAddress(std::string) override; 58 using NeighborObj::macAddress; 59 std::string macAddress(std::string) override; 60 using NeighborObj::state; 61 State state(State) override; 62 63 inline const auto& getObjPath() const 64 { 65 return objPath; 66 } 67 68 private: 69 /** @brief Parent Object. */ 70 EthernetInterface& parent; 71 72 /** @brief Dbus object path */ 73 sdbusplus::message::object_path objPath; 74 75 Neighbor(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath, 76 EthernetInterface& parent, InAddrAny addr, ether_addr lladdr, 77 State state); 78 }; 79 80 } // namespace network 81 } // namespace phosphor 82