25#ifndef JOIN_FABRIC_NEIGHBOR_MANAGER_HPP
26#define JOIN_FABRIC_NEIGHBOR_MANAGER_HPP
250 uint16_t state = NUD_PERMANENT,
bool sync =
false);
262 uint16_t state = NUD_PERMANENT,
bool sync =
false);
296 int flushNeighbors (
const std::string& interfaceName,
bool sync =
false);
308 int setNeighbor (uint32_t index,
const IpAddress& ipAddress,
const MacAddress& macAddress, uint16_t state,
316 int dumpNeighbors (
bool sync =
false);
322 void onMessage (
struct nlmsghdr* nlh)
override;
328 void onNeighborMessage (
struct nlmsghdr* nlh);
346 std::unordered_map<NeighborKey, Neighbor::Ptr> _neighbors;
352 std::unordered_map<uint64_t, NeighborNotify> _neighborListeners;
355 std::atomic<uint64_t> _listenerCounter{0};
IPv6, IPv4 address class.
Definition ip_address.hpp:51
MAC address class.
Definition mac_address.hpp:46
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
Neighbor::Ptr findByIndex(uint32_t index, const IpAddress &ipAddress)
find a neighbor entry by interface index and IP address.
Definition neighbor_manager.cpp:72
int refresh()
refresh all data.
Definition neighbor_manager.cpp:147
Neighbor::Ptr findByName(const std::string &interfaceName, const IpAddress &ipAddress)
find a neighbor entry by interface name and IP address.
Definition neighbor_manager.cpp:89
NeighborManager(Reactor &reactor=ReactorThread::reactor())
create instance.
Definition neighbor_manager.cpp:42
static NeighborManager & instance()
get the a singleton instance.
Definition neighbor_manager.cpp:62
int addNeighbor(uint32_t index, const IpAddress &ipAddress, const MacAddress &macAddress, uint16_t state=NUD_PERMANENT, bool sync=false)
add or replace a neighbor entry in the kernel table.
Definition neighbor_manager.cpp:189
void removeNeighborListener(uint64_t id)
unregister a previously registered callback.
Definition neighbor_manager.cpp:177
std::function< void(const NeighborInfo &info)> NeighborNotify
Definition neighbor_manager.hpp:140
~NeighborManager()
destroy instance.
Definition neighbor_manager.cpp:53
uint64_t addNeighborListener(const NeighborNotify &cb)
register a callback invoked on any neighbor table change.
Definition neighbor_manager.cpp:161
NeighborManager(NeighborManager &&other)=delete
create instance by move.
int flushNeighbors(uint32_t index, bool sync=false)
flush all neighbor entries for a given interface.
Definition neighbor_manager.cpp:267
NeighborManager & operator=(const NeighborManager &other)=delete
assign instance by copy.
NeighborList enumerate()
enumerate all cached neighbor entries.
Definition neighbor_manager.cpp:98
NeighborManager(const NeighborManager &other)=delete
create instance by copy.
int removeNeighbor(uint32_t index, const IpAddress &ipAddress, bool sync=false)
remove a neighbor entry from the kernel table.
Definition neighbor_manager.cpp:232
class representing a single ARP / NDP neighbor cache entry.
Definition neighbor.hpp:88
std::shared_ptr< Neighbor > Ptr
Definition neighbor.hpp:98
base class for netlink-based managers.
Definition netlink_manager.hpp:51
Reactor & reactor() const noexcept
get the event loop reactor.
Definition netlink_manager.cpp:52
static Reactor & reactor()
get the global Reactor instance.
Definition reactor.cpp:584
Reactor class.
Definition reactor.hpp:156
Definition acceptor.hpp:32
IpAddress operator^(const IpAddress &a, const IpAddress &b)
perform XOR operation on IP address.
Definition ip_address.cpp:1719
constexpr const JsonReadMode & operator&=(JsonReadMode &a, JsonReadMode b) noexcept
perform binary AND on JsonReadMode.
Definition json.hpp:919
IpAddress operator&(const IpAddress &a, const IpAddress &b)
perform AND operation on IP address.
Definition ip_address.cpp:1665
InterfaceChangeType operator~(InterfaceChangeType a)
perform binary NOT on InterfaceChangeType.
Definition interface_manager.hpp:95
std::vector< Neighbor::Ptr > NeighborList
list of neighbors.
Definition neighbor.hpp:252
NeighborChangeType
enumeration of neighbor change types.
Definition neighbor_manager.hpp:41
constexpr const JsonReadMode & operator|=(JsonReadMode &a, JsonReadMode b) noexcept
perform binary OR on JsonReadMode.
Definition json.hpp:930
const InterfaceChangeType & operator^=(InterfaceChangeType &a, InterfaceChangeType b)
perform binary XOR assignment on InterfaceChangeType.
Definition interface_manager.hpp:128
IpAddress operator|(const IpAddress &a, const IpAddress &b)
perform OR operation on IP address.
Definition ip_address.cpp:1692
neighbor change notification payload.
Definition neighbor_manager.hpp:129
NeighborChangeType flags
Definition neighbor_manager.hpp:131
Neighbor::Ptr neighbor
Definition neighbor_manager.hpp:130