William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 1 | #pragma once |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 2 | #include "types.hpp" |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 3 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
William A. Kennington III | 434a943 | 2022-11-04 18:38:46 -0700 | [diff] [blame] | 5 | #include <sdbusplus/message/native_types.hpp> |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 6 | #include <sdbusplus/server/object.hpp> |
William A. Kennington III | c920bdb | 2019-04-19 14:23:06 -0700 | [diff] [blame] | 7 | #include <string_view> |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 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 | |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 18 | using NeighborObj = sdbusplus::server::object_t< |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 19 | NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>; |
| 20 | |
| 21 | class EthernetInterface; |
| 22 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 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. |
William A. Kennington III | 434a943 | 2022-11-04 18:38:46 -0700 | [diff] [blame] | 42 | * @param[in] objRoot - Path to attach at. |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 43 | * @param[in] parent - Parent object. |
William A. Kennington III | 434a943 | 2022-11-04 18:38:46 -0700 | [diff] [blame] | 44 | * @param[in] addr - IP address. |
| 45 | * @param[in] lladdr - Low level MAC address. |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 46 | * @param[in] state - The state of the neighbor entry. |
| 47 | */ |
William A. Kennington III | 434a943 | 2022-11-04 18:38:46 -0700 | [diff] [blame] | 48 | Neighbor(sdbusplus::bus_t& bus, std::string_view objRoot, |
| 49 | EthernetInterface& parent, InAddrAny addr, ether_addr lladdr, |
| 50 | State state); |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 51 | |
| 52 | /** @brief Delete this d-bus object. |
| 53 | */ |
| 54 | void delete_() override; |
| 55 | |
William A. Kennington III | 8e61ca9 | 2022-09-01 13:28:33 -0700 | [diff] [blame] | 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 | |
William A. Kennington III | 434a943 | 2022-11-04 18:38:46 -0700 | [diff] [blame] | 63 | inline const auto& getObjPath() const |
| 64 | { |
| 65 | return objPath; |
| 66 | } |
| 67 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 68 | private: |
| 69 | /** @brief Parent Object. */ |
| 70 | EthernetInterface& parent; |
William A. Kennington III | 434a943 | 2022-11-04 18:38:46 -0700 | [diff] [blame] | 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); |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 80 | } // namespace network |
| 81 | } // namespace phosphor |