join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Arp Class Reference

ARP protocol class. More...

#include <arp.hpp>

Inheritance diagram for join::Arp:
Collaboration diagram for join::Arp:

Public Member Functions

 Arp ()=delete
 create the Arp instance.
 
 Arp (const std::string &interface, NeighborManager &neighbors=NeighborManager::instance())
 create the Arp instance.
 
 Arp (const Arp &other)=delete
 create instance by copy.
 
 Arp (Arp &&other)=delete
 create instance by move.
 
Arpoperator= (const Arp &other)=delete
 assign instance by copy.
 
Arpoperator= (Arp &&other)=delete
 assign instance by move.
 
 ~Arp ()
 destroy the Arp instance.
 
template<typename Rep , typename Period >
MacAddress get (const IpAddress &ip, std::chrono::duration< Rep, Period > timeout)
 get the MAC address for the given IP address using netlink neighbor cache or ARP request.
 
MacAddress get (const IpAddress &ip)
 get the MAC address for the given IP address using ARP cache or ARP request.
 
template<typename Rep , typename Period >
MacAddress request (const IpAddress &ip, std::chrono::duration< Rep, Period > timeout)
 get the MAC address for the given IP address using ARP request.
 
MacAddress request (const IpAddress &ip)
 get the MAC address for the given IP address using ARP request.
 
int add (const MacAddress &mac, const IpAddress &ip)
 add entry the MAC address of the given IP address to ARP cache.
 
int remove (const IpAddress &ip)
 remove the MAC address of the given IP address from ARP cache.
 
MacAddress cache (const IpAddress &ip)
 get the MAC address for the given IP address using ARP cache.
 
- Public Member Functions inherited from join::EventHandler
 EventHandler ()=default
 create instance.
 
 EventHandler (const EventHandler &other)=default
 copy constructor.
 
EventHandleroperator= (const EventHandler &other)=default
 copy assignment operator.
 
 EventHandler (EventHandler &&other)=default
 move constructor.
 
EventHandleroperator= (EventHandler &&other)=default
 move assignment operator.
 
virtual ~EventHandler ()=default
 destroy instance.
 

Static Public Member Functions

template<typename Rep , typename Period >
static MacAddress get (const std::string &interface, const IpAddress &ip, std::chrono::duration< Rep, Period > timeout)
 discover the MAC address for the given internet layer address.
 
static MacAddress get (const std::string &interface, const IpAddress &ip)
 discover the MAC address for the given internet layer address.
 
template<typename Rep , typename Period >
static MacAddress request (const std::string &interface, const IpAddress &ip, std::chrono::duration< Rep, Period > timeout)
 get the MAC address for the given IP address using ARP request.
 
static MacAddress request (const std::string &interface, const IpAddress &ip)
 get the MAC address for the given IP address using ARP request.
 
static int add (const std::string &interface, const MacAddress &mac, const IpAddress &ip)
 add entry the MAC address of the given IP address to ARP cache.
 
static int remove (const std::string &interface, const IpAddress &ip)
 remove the MAC address of the given IP address from ARP cache.
 
static MacAddress cache (const std::string &interface, const IpAddress &ip)
 get the MAC address for the given IP address using ARP cache.
 

Additional Inherited Members

- Protected Member Functions inherited from join::EventHandler
virtual void onEvent (int fd, uint32_t revents)
 method called when events are reported on handle.
 
virtual void onWriteable (int fd)
 method called when data are ready to be written on handle.
 
virtual void onClose (int fd)
 method called when handle was closed by the peer.
 
virtual void onError (int fd)
 method called when an error occurred on handle.
 

Detailed Description

ARP protocol class.

Constructor & Destructor Documentation

◆ Arp() [1/4]

join::Arp::Arp ( )
delete

create the Arp instance.

◆ Arp() [2/4]

Arp::Arp ( const std::string & interface,
NeighborManager & neighbors = NeighborManager::instance () )

create the Arp instance.

Parameters
interfaceinterface name.
neighborsneighbor manager to use (uses NeighborManager::instance if nullptr).
Exceptions
std::system_errorif the interface is unknown or the socket could not be bound to it.

◆ Arp() [3/4]

join::Arp::Arp ( const Arp & other)
delete

create instance by copy.

Parameters
otherother interface to copy.

◆ Arp() [4/4]

join::Arp::Arp ( Arp && other)
delete

create instance by move.

Parameters
otherother interface to move.

◆ ~Arp()

Arp::~Arp ( )

destroy the Arp instance.

Member Function Documentation

◆ add() [1/2]

int Arp::add ( const MacAddress & mac,
const IpAddress & ip )

add entry the MAC address of the given IP address to ARP cache.

Parameters
macMAC address.
ipIP address.
Returns
0 on success, -1 on failure.

◆ add() [2/2]

int Arp::add ( const std::string & interface,
const MacAddress & mac,
const IpAddress & ip )
static

add entry the MAC address of the given IP address to ARP cache.

Parameters
interfaceinterface name.
macMAC address.
ipIP address.
Returns
0 on success, -1 on failure.

◆ cache() [1/2]

MacAddress Arp::cache ( const IpAddress & ip)

get the MAC address for the given IP address using ARP cache.

Parameters
ipIP address.
Returns
the MAC address.

◆ cache() [2/2]

MacAddress Arp::cache ( const std::string & interface,
const IpAddress & ip )
static

get the MAC address for the given IP address using ARP cache.

Parameters
interfaceinterface name.
ipIP address.
Returns
the MAC address.

◆ get() [1/4]

MacAddress join::Arp::get ( const IpAddress & ip)
inline

get the MAC address for the given IP address using ARP cache or ARP request.

Parameters
ipIP address.
Returns
the MAC address.

◆ get() [2/4]

template<typename Rep , typename Period >
MacAddress join::Arp::get ( const IpAddress & ip,
std::chrono::duration< Rep, Period > timeout )
inline

get the MAC address for the given IP address using netlink neighbor cache or ARP request.

Parameters
ipIP address.
timeoutrequest timeout.
Returns
the MAC address.

◆ get() [3/4]

static MacAddress join::Arp::get ( const std::string & interface,
const IpAddress & ip )
inlinestatic

discover the MAC address for the given internet layer address.

Parameters
interfaceinterface name.
ipIP address.
Returns
the MAC address.

◆ get() [4/4]

template<typename Rep , typename Period >
static MacAddress join::Arp::get ( const std::string & interface,
const IpAddress & ip,
std::chrono::duration< Rep, Period > timeout )
inlinestatic

discover the MAC address for the given internet layer address.

Parameters
interfaceinterface name.
ipIP address.
timeoutrequest timeout.
Returns
the MAC address.

◆ operator=() [1/2]

Arp & join::Arp::operator= ( Arp && other)
delete

assign instance by move.

Parameters
otherother interface to move.
Returns
A reference of the current object.

◆ operator=() [2/2]

Arp & join::Arp::operator= ( const Arp & other)
delete

assign instance by copy.

Parameters
otherother interface to copy.
Returns
A reference of the current object.

◆ remove() [1/2]

int Arp::remove ( const IpAddress & ip)

remove the MAC address of the given IP address from ARP cache.

Parameters
ipIP address.
Returns
0 on success, -1 on failure.

◆ remove() [2/2]

int Arp::remove ( const std::string & interface,
const IpAddress & ip )
static

remove the MAC address of the given IP address from ARP cache.

Parameters
interfaceinterface name.
ipIP address.
Returns
0 on success, -1 on failure.

◆ request() [1/4]

MacAddress join::Arp::request ( const IpAddress & ip)
inline

get the MAC address for the given IP address using ARP request.

Parameters
ipIP address.
Returns
the MAC address.

◆ request() [2/4]

template<typename Rep , typename Period >
MacAddress join::Arp::request ( const IpAddress & ip,
std::chrono::duration< Rep, Period > timeout )
inline

get the MAC address for the given IP address using ARP request.

Parameters
ipIP address.
timeoutrequest timeout.
Returns
the MAC address.

◆ request() [3/4]

static MacAddress join::Arp::request ( const std::string & interface,
const IpAddress & ip )
inlinestatic

get the MAC address for the given IP address using ARP request.

Parameters
interfaceinterface name.
ipIP address.
Returns
the MAC address.

◆ request() [4/4]

template<typename Rep , typename Period >
static MacAddress join::Arp::request ( const std::string & interface,
const IpAddress & ip,
std::chrono::duration< Rep, Period > timeout )
inlinestatic

get the MAC address for the given IP address using ARP request.

Parameters
interfaceinterface name.
ipIP address.
timeoutrequest timeout.
Returns
the MAC address.

The documentation for this class was generated from the following files: