blob: e103d95d648ffc1f1b220a0a8da021b362b2218e [file] [log] [blame]
William A. Kennington III08505792019-01-30 16:00:04 -08001#pragma once
2
3#include "types.hpp"
4#include "util.hpp"
5
6#include <netinet/in.h>
7
8#include <optional>
9#include <sdbusplus/bus.hpp>
10#include <sdbusplus/server/object.hpp>
11#include <string>
12#include <vector>
13#include <xyz/openbmc_project/Network/Neighbor/server.hpp>
14#include <xyz/openbmc_project/Object/Delete/server.hpp>
15
16namespace phosphor
17{
18namespace network
19{
20
21using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor;
22
23using NeighborObj = sdbusplus::server::object::object<
24 NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
25
26class EthernetInterface;
27
28/** @class NeighborInfo
29 * @brief Information about a neighbor from the kernel
30 */
31struct NeighborInfo
32{
33 std::string interface;
34 InAddrAny address;
35 std::optional<MacAddr> mac;
36 bool permanent;
37};
38
39/** @brief Returns a list of the current system neighbor table
40 */
41std::vector<NeighborInfo> getCurrentNeighbors();
42
43/** @class Neighbor
44 * @brief OpenBMC network neighbor implementation.
45 * @details A concrete implementation for the
46 * xyz.openbmc_project.Network.Neighbor dbus interface.
47 */
48class Neighbor : public NeighborObj
49{
50 public:
51 using State = NeighborIntf::State;
52
53 Neighbor() = delete;
54 Neighbor(const Neighbor&) = delete;
55 Neighbor& operator=(const Neighbor&) = delete;
56 Neighbor(Neighbor&&) = delete;
57 Neighbor& operator=(Neighbor&&) = delete;
58 virtual ~Neighbor() = default;
59
60 /** @brief Constructor to put object onto bus at a dbus path.
61 * @param[in] bus - Bus to attach to.
62 * @param[in] objPath - Path to attach at.
63 * @param[in] parent - Parent object.
64 * @param[in] ipAddress - IP address.
65 * @param[in] macAddress - Low level MAC address.
66 * @param[in] state - The state of the neighbor entry.
67 */
68 Neighbor(sdbusplus::bus::bus& bus, const char* objPath,
69 EthernetInterface& parent, const std::string& ipAddress,
70 const std::string& macAddress, State state);
71
72 /** @brief Delete this d-bus object.
73 */
74 void delete_() override;
75
76 private:
77 /** @brief Parent Object. */
78 EthernetInterface& parent;
79};
80
81} // namespace network
82} // namespace phosphor