|
join 1.0
lightweight network framework library
|
ARP / NDP neighbor manager class. More...
#include <neighbormanager.hpp>


Public Types | |
| using | NeighborNotify = std::function<void (const NeighborInfo& info)> |
Public Member Functions | |
| NeighborManager (Reactor *reactor=nullptr) | |
| create instance. | |
| NeighborManager (const NeighborManager &other)=delete | |
| create instance by copy. | |
| NeighborManager (NeighborManager &&other)=delete | |
| create instance by move. | |
| NeighborManager & | operator= (const NeighborManager &other)=delete |
| assign instance by copy. | |
| NeighborManager & | operator= (NeighborManager &&other)=delete |
| assign instance by move. | |
| ~NeighborManager () | |
| destroy instance. | |
| Neighbor::Ptr | findByIndex (uint32_t index, const IpAddress &ipAddress) |
| find a neighbor entry by interface index and IP address. | |
| Neighbor::Ptr | findByName (const std::string &interfaceName, const IpAddress &ipAddress) |
| find a neighbor entry by interface name and IP address. | |
| NeighborList | enumerate () |
| enumerate all cached neighbor entries. | |
| NeighborList | enumerate (uint32_t index) |
| enumerate all cached neighbor entries for a given interface. | |
| NeighborList | enumerate (const std::string &interfaceName) |
| enumerate all cached neighbor entries for a given interface. | |
| int | refresh () |
| refresh all data. | |
| uint64_t | addNeighborListener (const NeighborNotify &cb) |
| register a callback invoked on any neighbor table change. | |
| void | removeNeighborListener (uint64_t id) |
| unregister a previously registered callback. | |
| 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. | |
| int | addNeighbor (const std::string &interfaceName, const IpAddress &ipAddress, const MacAddress &macAddress, uint16_t state=NUD_PERMANENT, bool sync=false) |
| add or replace a neighbor entry in the kernel table. | |
| int | removeNeighbor (uint32_t index, const IpAddress &ipAddress, bool sync=false) |
| remove a neighbor entry from the kernel table. | |
| int | removeNeighbor (const std::string &interfaceName, const IpAddress &ipAddress, bool sync=false) |
| remove a neighbor entry from the kernel table. | |
| int | flushNeighbors (uint32_t index, bool sync=false) |
| flush all neighbor entries for a given interface. | |
| int | flushNeighbors (const std::string &interfaceName, bool sync=false) |
| flush all neighbor entries for a given interface. | |
Public Member Functions inherited from join::NetlinkManager | |
| NetlinkManager (uint32_t groups, Reactor *reactor=nullptr) | |
| create instance. | |
| NetlinkManager (const NetlinkManager &)=delete | |
| create instance by copy. | |
| NetlinkManager (NetlinkManager &&)=delete | |
| create instance by move. | |
| NetlinkManager & | operator= (const NetlinkManager &)=delete |
| assign instance by copy. | |
| NetlinkManager & | operator= (NetlinkManager &&)=delete |
| assign instance by move. | |
| virtual | ~NetlinkManager ()=default |
| destroy instance. | |
| Reactor * | reactor () const noexcept |
| get the event loop reactor. | |
Static Public Member Functions | |
| static NeighborManager & | instance () |
| get the a singleton instance. | |
Friends | |
| class | Neighbor |
Additional Inherited Members | |
Protected Member Functions inherited from join::NetlinkManager | |
| void | start () |
| start listening for netlink events. | |
| void | stop () |
| stop listening for netlink events. | |
| int | sendRequest (struct nlmsghdr *nlh, bool sync, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| send a netlink request, optionally waiting for the ack. | |
| template<class Rep , class Period > | |
| int | waitResponse (ScopedLock< Mutex > &lock, uint32_t seq, std::chrono::duration< Rep, Period > timeout) |
| wait for specific netlink response. | |
| virtual void | onReceive (int fd) override final |
| method called when data are ready to be read on handle. | |
| void | notifyRequest (uint32_t seq, int error=0) |
| notify a pending synchronous request. | |
Static Protected Member Functions inherited from join::NetlinkManager | |
| static void | addAttributes (struct nlmsghdr *nlh, int type, const void *data, int alen) |
| add an attribute to a netlink message. | |
| static struct rtattr * | startNestedAttributes (struct nlmsghdr *nlh, int type) |
| open a nested attribute block. | |
| static int | stopNestedAttributes (struct nlmsghdr *nlh, struct rtattr *nested) |
| close a nested attribute block. | |
| template<typename T , typename Flag > | |
| static Flag | updateValue (T &oldVal, const T &newVal, Flag changed) |
| update a value in place and report whether it changed. | |
Protected Attributes inherited from join::NetlinkManager | |
| std::unique_ptr< char[]> | _buffer |
| internal read buffer. | |
| std::atomic< uint32_t > | _seq |
| sequence number. | |
| std::unordered_map< uint32_t, std::unique_ptr< PendingRequest > > | _pending |
| synchronous requests indexed by sequence number. | |
| Mutex | _syncMutex |
| protection mutex. | |
| Reactor * | _reactor |
| event loop reactor. | |
Static Protected Attributes inherited from join::NetlinkManager | |
| static constexpr size_t | _bufferSize = 16384 |
| internal buffer size. | |
ARP / NDP neighbor manager class.
| using join::NeighborManager::NeighborNotify = std::function<void (const NeighborInfo& info)> |
|
explicit |
create instance.
| reactor | event loop reactor (uses ReactorThread if nullptr). |
|
delete |
create instance by copy.
| other | other interface to copy. |
|
delete |
create instance by move.
| other | other interface to move. |
| NeighborManager::~NeighborManager | ( | ) |
destroy instance.
| int NeighborManager::addNeighbor | ( | const std::string & | interfaceName, |
| const IpAddress & | ipAddress, | ||
| const MacAddress & | macAddress, | ||
| uint16_t | state = NUD_PERMANENT, | ||
| bool | sync = false ) |
add or replace a neighbor entry in the kernel table.
| interfaceName | interface name. |
| ipAddress | destination address. |
| macAddress | address to associate. |
| state | NUD state (default: NUD_PERMANENT). |
| sync | wait for completion. |
| int NeighborManager::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.
| index | interface index. |
| ipAddress | destination address. |
| macAddress | address to associate. |
| state | NUD state (default: NUD_PERMANENT). |
| sync | wait for completion. |
| uint64_t NeighborManager::addNeighborListener | ( | const NeighborNotify & | cb | ) |
register a callback invoked on any neighbor table change.
| cb | callback to register. |
| NeighborList NeighborManager::enumerate | ( | ) |
enumerate all cached neighbor entries.
| NeighborList NeighborManager::enumerate | ( | const std::string & | interfaceName | ) |
enumerate all cached neighbor entries for a given interface.
| interfaceName | interface name. |
| NeighborList NeighborManager::enumerate | ( | uint32_t | index | ) |
enumerate all cached neighbor entries for a given interface.
| index | interface index. |
| Neighbor::Ptr NeighborManager::findByIndex | ( | uint32_t | index, |
| const IpAddress & | ipAddress ) |
find a neighbor entry by interface index and IP address.
| index | interface index. |
| ipAddress | destination address. |
| Neighbor::Ptr NeighborManager::findByName | ( | const std::string & | interfaceName, |
| const IpAddress & | ipAddress ) |
find a neighbor entry by interface name and IP address.
| interfaceName | interface name. |
| ipAddress | destination address. |
| int NeighborManager::flushNeighbors | ( | const std::string & | interfaceName, |
| bool | sync = false ) |
flush all neighbor entries for a given interface.
| interfaceName | interface name. |
| sync | wait for completion. |
| int NeighborManager::flushNeighbors | ( | uint32_t | index, |
| bool | sync = false ) |
flush all neighbor entries for a given interface.
| index | interface index. |
| sync | wait for completion. |
|
static |
get the a singleton instance.
|
delete |
assign instance by copy.
| other | other interface to copy. |
|
delete |
assign instance by move.
| other | other interface to move. |
| int NeighborManager::refresh | ( | ) |
refresh all data.
| int NeighborManager::removeNeighbor | ( | const std::string & | interfaceName, |
| const IpAddress & | ipAddress, | ||
| bool | sync = false ) |
remove a neighbor entry from the kernel table.
| interfaceName | interface name. |
| ipAddress | destination address. |
| sync | wait for completion. |
| int NeighborManager::removeNeighbor | ( | uint32_t | index, |
| const IpAddress & | ipAddress, | ||
| bool | sync = false ) |
remove a neighbor entry from the kernel table.
| index | interface index. |
| ipAddress | destination address. |
| sync | wait for completion. |
| void NeighborManager::removeNeighborListener | ( | uint64_t | id | ) |
unregister a previously registered callback.
| id | unique id of the callback function to remove. |
|
friend |