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