25#ifndef JOIN_FABRIC_NEIGHBORMANAGER_HPP
26#define JOIN_FABRIC_NEIGHBORMANAGER_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 uint64_t _listenerCounter = 0;
358 Mutex _listenerMutex;
IPv6, IPv4 address class.
Definition ipaddress.hpp:51
MAC address class.
Definition macaddress.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 neighbormanager.hpp:138
Neighbor::Ptr findByIndex(uint32_t index, const IpAddress &ipAddress)
find a neighbor entry by interface index and IP address.
Definition neighbormanager.cpp:71
int refresh()
refresh all data.
Definition neighbormanager.cpp:146
Neighbor::Ptr findByName(const std::string &interfaceName, const IpAddress &ipAddress)
find a neighbor entry by interface name and IP address.
Definition neighbormanager.cpp:88
static NeighborManager & instance()
get the a singleton instance.
Definition neighbormanager.cpp:61
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 neighbormanager.cpp:180
NeighborManager(Reactor *reactor=nullptr)
create instance.
Definition neighbormanager.cpp:41
void removeNeighborListener(uint64_t id)
unregister a previously registered callback.
Definition neighbormanager.cpp:170
std::function< void(const NeighborInfo &info)> NeighborNotify
Definition neighbormanager.hpp:140
~NeighborManager()
destroy instance.
Definition neighbormanager.cpp:52
uint64_t addNeighborListener(const NeighborNotify &cb)
register a callback invoked on any neighbor table change.
Definition neighbormanager.cpp:160
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 neighbormanager.cpp:258
NeighborManager & operator=(const NeighborManager &other)=delete
assign instance by copy.
NeighborList enumerate()
enumerate all cached neighbor entries.
Definition neighbormanager.cpp:97
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 neighbormanager.cpp:223
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 netlinkmanager.hpp:49
Reactor * reactor() const noexcept
get the event loop reactor.
Definition netlinkmanager.cpp:52
Reactor class.
Definition reactor.hpp:120
Definition acceptor.hpp:32
IpAddress operator^(const IpAddress &a, const IpAddress &b)
perform XOR operation on IP address.
Definition ipaddress.cpp:1719
constexpr const JsonReadMode & operator&=(JsonReadMode &a, JsonReadMode b) noexcept
perform binary AND on JsonReadMode.
Definition json.hpp:916
IpAddress operator&(const IpAddress &a, const IpAddress &b)
perform AND operation on IP address.
Definition ipaddress.cpp:1665
InterfaceChangeType operator~(InterfaceChangeType a)
perform binary NOT on InterfaceChangeType.
Definition interfacemanager.hpp:95
std::vector< Neighbor::Ptr > NeighborList
list of neighbors.
Definition neighbor.hpp:252
NeighborChangeType
enumeration of neighbor change types.
Definition neighbormanager.hpp:41
constexpr const JsonReadMode & operator|=(JsonReadMode &a, JsonReadMode b) noexcept
perform binary OR on JsonReadMode.
Definition json.hpp:927
const InterfaceChangeType & operator^=(InterfaceChangeType &a, InterfaceChangeType b)
perform binary XOR on InterfaceChangeType.
Definition interfacemanager.hpp:128
IpAddress operator|(const IpAddress &a, const IpAddress &b)
perform OR operation on IP address.
Definition ipaddress.cpp:1692
neighbor change notification payload.
Definition neighbormanager.hpp:129
NeighborChangeType flags
Definition neighbormanager.hpp:131
Neighbor::Ptr neighbor
Definition neighbormanager.hpp:130