blob: e103d95d648ffc1f1b220a0a8da021b362b2218e [file] [log] [blame]
#pragma once
#include "types.hpp"
#include "util.hpp"
#include <netinet/in.h>
#include <optional>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <string>
#include <vector>
#include <xyz/openbmc_project/Network/Neighbor/server.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>
namespace phosphor
{
namespace network
{
using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor;
using NeighborObj = sdbusplus::server::object::object<
NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
class EthernetInterface;
/** @class NeighborInfo
* @brief Information about a neighbor from the kernel
*/
struct NeighborInfo
{
std::string interface;
InAddrAny address;
std::optional<MacAddr> mac;
bool permanent;
};
/** @brief Returns a list of the current system neighbor table
*/
std::vector<NeighborInfo> getCurrentNeighbors();
/** @class Neighbor
* @brief OpenBMC network neighbor implementation.
* @details A concrete implementation for the
* xyz.openbmc_project.Network.Neighbor dbus interface.
*/
class Neighbor : public NeighborObj
{
public:
using State = NeighborIntf::State;
Neighbor() = delete;
Neighbor(const Neighbor&) = delete;
Neighbor& operator=(const Neighbor&) = delete;
Neighbor(Neighbor&&) = delete;
Neighbor& operator=(Neighbor&&) = delete;
virtual ~Neighbor() = default;
/** @brief Constructor to put object onto bus at a dbus path.
* @param[in] bus - Bus to attach to.
* @param[in] objPath - Path to attach at.
* @param[in] parent - Parent object.
* @param[in] ipAddress - IP address.
* @param[in] macAddress - Low level MAC address.
* @param[in] state - The state of the neighbor entry.
*/
Neighbor(sdbusplus::bus::bus& bus, const char* objPath,
EthernetInterface& parent, const std::string& ipAddress,
const std::string& macAddress, State state);
/** @brief Delete this d-bus object.
*/
void delete_() override;
private:
/** @brief Parent Object. */
EthernetInterface& parent;
};
} // namespace network
} // namespace phosphor