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