blob: f36371a1b9d1dc4da98967dea1640d97e8e7ec2a [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 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
Patrick Williams89d734b2023-05-10 07:50:25 -050011#include <string_view>
12
William A. Kennington III08505792019-01-30 16:00:04 -080013namespace phosphor
14{
15namespace network
16{
17
18using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor;
19
Patrick Williamsc38b0712022-07-22 19:26:54 -050020using NeighborObj = sdbusplus::server::object_t<
William A. Kennington III08505792019-01-30 16:00:04 -080021 NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
22
23class EthernetInterface;
24
William A. Kennington III08505792019-01-30 16:00:04 -080025/** @class Neighbor
26 * @brief OpenBMC network neighbor implementation.
27 * @details A concrete implementation for the
28 * xyz.openbmc_project.Network.Neighbor dbus interface.
29 */
30class Neighbor : public NeighborObj
31{
32 public:
William A. Kennington III08505792019-01-30 16:00:04 -080033 /** @brief Constructor to put object onto bus at a dbus path.
34 * @param[in] bus - Bus to attach to.
William A. Kennington III434a9432022-11-04 18:38:46 -070035 * @param[in] objRoot - Path to attach at.
William A. Kennington III08505792019-01-30 16:00:04 -080036 * @param[in] parent - Parent object.
William A. Kennington III434a9432022-11-04 18:38:46 -070037 * @param[in] addr - IP address.
38 * @param[in] lladdr - Low level MAC address.
William A. Kennington III08505792019-01-30 16:00:04 -080039 * @param[in] state - The state of the neighbor entry.
40 */
William A. Kennington III434a9432022-11-04 18:38:46 -070041 Neighbor(sdbusplus::bus_t& bus, std::string_view objRoot,
William A. Kennington III9ede1b72022-11-21 01:59:28 -080042 stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
43 ether_addr lladdr, State state);
William A. Kennington III08505792019-01-30 16:00:04 -080044
45 /** @brief Delete this d-bus object.
46 */
47 void delete_() override;
48
William A. Kennington III8e61ca92022-09-01 13:28:33 -070049 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 III434a9432022-11-04 18:38:46 -070056 inline const auto& getObjPath() const
57 {
58 return objPath;
59 }
60
William A. Kennington III08505792019-01-30 16:00:04 -080061 private:
62 /** @brief Parent Object. */
William A. Kennington III9ede1b72022-11-21 01:59:28 -080063 stdplus::PinnedRef<EthernetInterface> parent;
William A. Kennington III434a9432022-11-04 18:38:46 -070064
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 III9ede1b72022-11-21 01:59:28 -080069 stdplus::PinnedRef<EthernetInterface> parent, InAddrAny addr,
70 ether_addr lladdr, State state);
William A. Kennington III08505792019-01-30 16:00:04 -080071};
72
William A. Kennington III08505792019-01-30 16:00:04 -080073} // namespace network
74} // namespace phosphor