blob: 861a1ec56f52f4199c8418b8bf9e48277edb5819 [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 III9ede1b72022-11-21 01:59:28 -08007#include <stdplus/pinned.hpp>
William A. Kennington IIIc920bdb2019-04-19 14:23:06 -07008#include <string_view>
William A. Kennington III08505792019-01-30 16:00:04 -08009#include <xyz/openbmc_project/Network/Neighbor/server.hpp>
10#include <xyz/openbmc_project/Object/Delete/server.hpp>
11
12namespace phosphor
13{
14namespace network
15{
16
17using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor;
18
Patrick Williamsc38b0712022-07-22 19:26:54 -050019using NeighborObj = sdbusplus::server::object_t<
William A. Kennington III08505792019-01-30 16:00:04 -080020 NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
21
22class EthernetInterface;
23
William A. Kennington III08505792019-01-30 16:00:04 -080024/** @class Neighbor
25 * @brief OpenBMC network neighbor implementation.
26 * @details A concrete implementation for the
27 * xyz.openbmc_project.Network.Neighbor dbus interface.
28 */
29class Neighbor : public NeighborObj
30{
31 public:
William A. Kennington III08505792019-01-30 16:00:04 -080032 /** @brief Constructor to put object onto bus at a dbus path.
33 * @param[in] bus - Bus to attach to.
William A. Kennington III434a9432022-11-04 18:38:46 -070034 * @param[in] objRoot - Path to attach at.
William A. Kennington III08505792019-01-30 16:00:04 -080035 * @param[in] parent - Parent object.
William A. Kennington III434a9432022-11-04 18:38:46 -070036 * @param[in] addr - IP address.
37 * @param[in] lladdr - Low level MAC address.
William A. Kennington III08505792019-01-30 16:00:04 -080038 * @param[in] state - The state of the neighbor entry.
39 */
William A. Kennington III434a9432022-11-04 18:38:46 -070040 Neighbor(sdbusplus::bus_t& bus, std::string_view objRoot,
William A. Kennington III9ede1b72022-11-21 01:59:28 -080041 stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
42 ether_addr lladdr, State state);
William A. Kennington III08505792019-01-30 16:00:04 -080043
44 /** @brief Delete this d-bus object.
45 */
46 void delete_() override;
47
William A. Kennington III8e61ca92022-09-01 13:28:33 -070048 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 III434a9432022-11-04 18:38:46 -070055 inline const auto& getObjPath() const
56 {
57 return objPath;
58 }
59
William A. Kennington III08505792019-01-30 16:00:04 -080060 private:
61 /** @brief Parent Object. */
William A. Kennington III9ede1b72022-11-21 01:59:28 -080062 stdplus::PinnedRef<EthernetInterface> parent;
William A. Kennington III434a9432022-11-04 18:38:46 -070063
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 III9ede1b72022-11-21 01:59:28 -080068 stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
69 ether_addr lladdr, State state);
William A. Kennington III08505792019-01-30 16:00:04 -080070};
71
William A. Kennington III08505792019-01-30 16:00:04 -080072} // namespace network
73} // namespace phosphor