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 <stdplus/pinned.hpp>
8 #include <xyz/openbmc_project/Network/Neighbor/server.hpp>
9 #include <xyz/openbmc_project/Object/Delete/server.hpp>
10 
11 #include <string_view>
12 
13 namespace phosphor
14 {
15 namespace network
16 {
17 
18 using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor;
19 
20 using NeighborObj = sdbusplus::server::object_t<
21     NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
22 
23 class EthernetInterface;
24 
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:
33     /** @brief Constructor to put object onto bus at a dbus path.
34      *  @param[in] bus - Bus to attach to.
35      *  @param[in] objRoot - Path to attach at.
36      *  @param[in] parent - Parent object.
37      *  @param[in] addr - IP address.
38      *  @param[in] lladdr - Low level MAC address.
39      *  @param[in] state - The state of the neighbor entry.
40      */
41     Neighbor(sdbusplus::bus_t& bus, std::string_view objRoot,
42              stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
43              ether_addr lladdr, State state);
44 
45     /** @brief Delete this d-bus object.
46      */
47     void delete_() override;
48 
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 
56     inline const auto& getObjPath() const
57     {
58         return objPath;
59     }
60 
61   private:
62     /** @brief Parent Object. */
63     stdplus::PinnedRef<EthernetInterface> parent;
64 
65     /** @brief Dbus object path */
66     sdbusplus::message::object_path objPath;
67 
68     Neighbor(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath,
69              stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
70              ether_addr lladdr, State state);
71 };
72 
73 } // namespace network
74 } // namespace phosphor
75