25#ifndef JOIN_FABRIC_NEIGHBOR_HPP
26#define JOIN_FABRIC_NEIGHBOR_HPP
40#include <linux/neighbour.h>
46 class NeighborManager;
68 return lhs._index == rhs._index && lhs._ip == rhs._ip;
79 return std::tie (lhs._index, lhs._ip) <=> std::tie (rhs._index, rhs._ip);
96 using Ptr = std::shared_ptr<Neighbor>;
112 uint32_t
index () const noexcept;
130 uint16_t
state () const;
142 bool isStale () const noexcept;
169 int set (const
MacAddress& macAddress, uint16_t
state = NUD_PERMANENT,
bool sync = false) const;
176 int remove (
bool sync = false) const;
192 uint16_t _state = NUD_NONE;
195 mutable
Mutex _mutex;
223 return lhs->_index == rhs->_index && lhs->_ip == rhs->_ip;
236 return bool (lhs) <=> bool (rhs);
238 return std::tie (lhs->_index, lhs->_ip) <=> std::tie (rhs->_index, rhs->_ip);
255 size_t h = std::hash<uint32_t>{}(
key._index);
256 h ^= std::hash<join::IpAddress>{}(
key._ip) + 0x9e3779b9 + (h << 6) + (h >> 2);
IPv6, IPv4 address class.
Definition ip_address.hpp:52
MAC address class.
Definition mac_address.hpp:47
class used to protect shared data from being simultaneously accessed by multiple threads.
Definition mutex.hpp:37
ARP / NDP neighbor manager class.
Definition neighbor_manager.hpp:138
class representing a single ARP / NDP neighbor cache entry.
Definition neighbor.hpp:86
MacAddress mac() const
get the address resolved for this entry.
Definition neighbor.cpp:67
std::shared_ptr< Neighbor > Ptr
Definition neighbor.hpp:96
bool isPermanent() const noexcept
is the entry in NUD_PERMANENT state (static).
Definition neighbor.cpp:105
bool isIncomplete() const noexcept
is the entry in NUD_INCOMPLETE state (resolution ongoing).
Definition neighbor.cpp:114
uint32_t index() const noexcept
get interface index.
Definition neighbor.cpp:49
Neighbor()=delete
create instance.
friend std::strong_ordering operator<=>(const Neighbor::Ptr &lhs, const Neighbor::Ptr &rhs) noexcept
three-way compare neighbors.
Definition neighbor.hpp:232
uint16_t state() const
get the NUD state bitmask.
Definition neighbor.cpp:77
~Neighbor()=default
destroy instance.
bool isFailed() const noexcept
is the entry in NUD_FAILED state.
Definition neighbor.cpp:123
int set(const MacAddress &macAddress, uint16_t state=NUD_PERMANENT, bool sync=false) const
update or replace this neighbor entry in the kernel table.
Definition neighbor.cpp:132
bool isStale() const noexcept
is the entry in NUD_STALE state.
Definition neighbor.cpp:96
const IpAddress & ip() const noexcept
get the destination address.
Definition neighbor.cpp:58
int remove(bool sync=false) const
remove this neighbor entry from the kernel table.
Definition neighbor.cpp:141
bool isReachable() const noexcept
is the entry in NUD_REACHABLE state.
Definition neighbor.cpp:87
const std::string key(65, 'a')
key.
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:196
std::vector< Neighbor::Ptr > NeighborList
list of neighbors.
Definition neighbor.hpp:242
std::strong_ordering operator<=>(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
three-way compare endpoints.
Definition endpoint.hpp:208
key identifying a neighbor cache entry.
Definition neighbor.hpp:52
uint32_t _index
interface index.
Definition neighbor.hpp:54
IpAddress _ip
destination address.
Definition neighbor.hpp:57