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