blob: 37f8d17842992dcb2e652ba643ae72a68d33314c [file] [log] [blame]
William A. Kennington III08505792019-01-30 16:00:04 -08001#pragma once
William A. Kennington III08505792019-01-30 16:00:04 -08002#include "types.hpp"
William A. Kennington III08505792019-01-30 16:00:04 -08003
William A. Kennington III08505792019-01-30 16:00:04 -08004#include <sdbusplus/bus.hpp>
William A. Kennington III434a9432022-11-04 18:38:46 -07005#include <sdbusplus/message/native_types.hpp>
William A. Kennington III08505792019-01-30 16:00:04 -08006#include <sdbusplus/server/object.hpp>
William A. Kennington IIIc920bdb2019-04-19 14:23:06 -07007#include <string_view>
William A. Kennington III08505792019-01-30 16:00:04 -08008#include <xyz/openbmc_project/Network/Neighbor/server.hpp>
9#include <xyz/openbmc_project/Object/Delete/server.hpp>
10
11namespace phosphor
12{
13namespace network
14{
15
16using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor;
17
Patrick Williamsc38b0712022-07-22 19:26:54 -050018using NeighborObj = sdbusplus::server::object_t<
William A. Kennington III08505792019-01-30 16:00:04 -080019 NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
20
21class EthernetInterface;
22
William A. Kennington III08505792019-01-30 16:00:04 -080023/** @class Neighbor
24 * @brief OpenBMC network neighbor implementation.
25 * @details A concrete implementation for the
26 * xyz.openbmc_project.Network.Neighbor dbus interface.
27 */
28class 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 III434a9432022-11-04 18:38:46 -070042 * @param[in] objRoot - Path to attach at.
William A. Kennington III08505792019-01-30 16:00:04 -080043 * @param[in] parent - Parent object.
William A. Kennington III434a9432022-11-04 18:38:46 -070044 * @param[in] addr - IP address.
45 * @param[in] lladdr - Low level MAC address.
William A. Kennington III08505792019-01-30 16:00:04 -080046 * @param[in] state - The state of the neighbor entry.
47 */
William A. Kennington III434a9432022-11-04 18:38:46 -070048 Neighbor(sdbusplus::bus_t& bus, std::string_view objRoot,
49 EthernetInterface& parent, InAddrAny addr, ether_addr lladdr,
50 State state);
William A. Kennington III08505792019-01-30 16:00:04 -080051
52 /** @brief Delete this d-bus object.
53 */
54 void delete_() override;
55
William A. Kennington III8e61ca92022-09-01 13:28:33 -070056 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 III434a9432022-11-04 18:38:46 -070063 inline const auto& getObjPath() const
64 {
65 return objPath;
66 }
67
William A. Kennington III08505792019-01-30 16:00:04 -080068 private:
69 /** @brief Parent Object. */
70 EthernetInterface& parent;
William A. Kennington III434a9432022-11-04 18:38:46 -070071
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 III08505792019-01-30 16:00:04 -080078};
79
William A. Kennington III08505792019-01-30 16:00:04 -080080} // namespace network
81} // namespace phosphor