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

interface manager class. More...

#include <interfacemanager.hpp>

Inheritance diagram for join::InterfaceManager:
Collaboration diagram for join::InterfaceManager:

Public Types

using LinkNotify = std::function <void (const LinkInfo& info)>
 
using AddressNotify = std::function <void (const AddressInfo& info)>
 
using RouteNotify = std::function <void (const RouteInfo& info)>
 

Public Member Functions

 InterfaceManager (const InterfaceManager &other)=delete
 create instance by copy.
 
 InterfaceManager (InterfaceManager &&other)=delete
 create instance by move.
 
InterfaceManageroperator= (const InterfaceManager &other)=delete
 assign instance by copy.
 
InterfaceManageroperator= (InterfaceManager &&other)=delete
 assign instance by move.
 
 ~InterfaceManager ()
 destroy instance.
 
Interface::Ptr findByIndex (uint32_t interfaceIndex)
 find interface by index.
 
Interface::Ptr findByName (const std::string &interfaceName)
 find interface by name.
 
InterfaceList enumerate ()
 enumerate all interfaces.
 
int refresh (bool sync=true)
 refresh all data by dumping link, address, and route data.
 
void addLinkListener (const LinkNotify &cb)
 registers a callback to be invoked when a link update occurs.
 
void removeLinkListener (const LinkNotify &cb)
 unregisters a previously registered link update callback.
 
void addAddressListener (const AddressNotify &cb)
 registers a callback to be invoked when a address update occurs.
 
void removeAddressListener (const AddressNotify &cb)
 unregisters a previously registered address update callback.
 
void addRouteListener (const RouteNotify &cb)
 registers a callback to be invoked when a route update occurs.
 
void removeRouteListener (const RouteNotify &cb)
 unregisters a previously registered route update callback.
 
int createDummyInterface (const std::string &interfaceName, bool sync=false)
 creates a dummy interface.
 
int createBridgeInterface (const std::string &interfaceName, bool sync=false)
 creates a bridge interface.
 
int createVlanInterface (const std::string &interfaceName, uint32_t parentIndex, uint16_t id, uint16_t proto=ETH_P_8021Q, bool sync=false)
 creates a VLAN interface.
 
int createVlanInterface (const std::string &interfaceName, const std::string &parentName, uint16_t id, uint16_t proto=ETH_P_8021Q, bool sync=false)
 creates a VLAN interface.
 
int createVethInterface (const std::string &hostName, const std::string &peerName, pid_t *pid=nullptr, bool sync=false)
 creates a Virtual Ethernet nterface pair.
 
int createGreInterface (const std::string &tunnelName, uint32_t parentIndex, const IpAddress &localAddress, const IpAddress &remoteAddress, const uint32_t *ikey=nullptr, const uint32_t *okey=nullptr, uint8_t ttl=64, bool sync=false)
 creates a a GRE tunnel interface.
 
int createGreInterface (const std::string &tunnelName, const std::string &parentName, const IpAddress &localAddress, const IpAddress &remoteAddress, const uint32_t *ikey=nullptr, const uint32_t *okey=nullptr, uint8_t ttl=64, bool sync=false)
 creates a a GRE tunnel interface.
 
int removeInterface (uint32_t interfaceIndex, bool sync=false)
 deletes the specified network interface.
 
int removeInterface (const std::string &interfaceName, bool sync=false)
 deletes the specified network interface.
 

Static Public Member Functions

static InterfaceManagerinstance ()
 create the InterfaceManager instance.
 

Friends

class Interface
 

Detailed Description

interface manager class.

Member Typedef Documentation

◆ AddressNotify

using join::InterfaceManager::AddressNotify = std::function <void (const AddressInfo& info)>

◆ LinkNotify

using join::InterfaceManager::LinkNotify = std::function <void (const LinkInfo& info)>

◆ RouteNotify

using join::InterfaceManager::RouteNotify = std::function <void (const RouteInfo& info)>

Constructor & Destructor Documentation

◆ InterfaceManager() [1/2]

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

create instance by copy.

Parameters
otherother interface to copy.

◆ InterfaceManager() [2/2]

join::InterfaceManager::InterfaceManager ( InterfaceManager && other)
delete

create instance by move.

Parameters
otherother interface to move.

◆ ~InterfaceManager()

InterfaceManager::~InterfaceManager ( )

destroy instance.

Member Function Documentation

◆ addAddressListener()

void InterfaceManager::addAddressListener ( const AddressNotify & cb)

registers a callback to be invoked when a address update occurs.

Parameters
cbthe callback function to register.

◆ addLinkListener()

void InterfaceManager::addLinkListener ( const LinkNotify & cb)

registers a callback to be invoked when a link update occurs.

Parameters
cbthe callback function to register.

◆ addRouteListener()

void InterfaceManager::addRouteListener ( const RouteNotify & cb)

registers a callback to be invoked when a route update occurs.

Parameters
cbthe callback function to register.

◆ createBridgeInterface()

int InterfaceManager::createBridgeInterface ( const std::string & interfaceName,
bool sync = false )

creates a bridge interface.

Parameters
interfaceNamename of the bridge interface to be created.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ createDummyInterface()

int InterfaceManager::createDummyInterface ( const std::string & interfaceName,
bool sync = false )

creates a dummy interface.

Parameters
interfaceNamename of the dummy interface to be created.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ createGreInterface() [1/2]

int InterfaceManager::createGreInterface ( const std::string & tunnelName,
const std::string & parentName,
const IpAddress & localAddress,
const IpAddress & remoteAddress,
const uint32_t * ikey = nullptr,
const uint32_t * okey = nullptr,
uint8_t ttl = 64,
bool sync = false )

creates a a GRE tunnel interface.

Parameters
tunnelNamename of the GRE tunnel interface to be created.
parentNamename of the physical interface to bind the tunnel to.
localAddresslocal endpoint IP address for the tunnel.
remoteAddressremote endpoint IP address for the tunnel.
ikeyoptional inbound GRE key.
okeyoptional outbound GRE key.
ttlttl/hop Limit for encapsulated packets (0-255)
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ createGreInterface() [2/2]

int InterfaceManager::createGreInterface ( const std::string & tunnelName,
uint32_t parentIndex,
const IpAddress & localAddress,
const IpAddress & remoteAddress,
const uint32_t * ikey = nullptr,
const uint32_t * okey = nullptr,
uint8_t ttl = 64,
bool sync = false )

creates a a GRE tunnel interface.

Parameters
tunnelNamename of the GRE tunnel interface to be created.
parentIndexindex of the physical interface to bind the tunnel to.
localAddresslocal endpoint IP address for the tunnel.
remoteAddressremote endpoint IP address for the tunnel.
ikeyoptional inbound GRE key.
okeyoptional outbound GRE key.
ttlttl/hop Limit for encapsulated packets (0-255)
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ createVethInterface()

int InterfaceManager::createVethInterface ( const std::string & hostName,
const std::string & peerName,
pid_t * pid = nullptr,
bool sync = false )

creates a Virtual Ethernet nterface pair.

Parameters
hostNamename of the interface to be created in the current namespace.
peerNamename of the interface to be created in the target namespace.
pidprocess id of target namespace.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ createVlanInterface() [1/2]

int InterfaceManager::createVlanInterface ( const std::string & interfaceName,
const std::string & parentName,
uint16_t id,
uint16_t proto = ETH_P_8021Q,
bool sync = false )

creates a VLAN interface.

Parameters
interfaceNamename of the VLAN interface to be created.
parentNamename of the physical interface to create VLAN on.
idVLAN id (must be unique on the parent interface).
protoVLAN protocol type.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ createVlanInterface() [2/2]

int InterfaceManager::createVlanInterface ( const std::string & interfaceName,
uint32_t parentIndex,
uint16_t id,
uint16_t proto = ETH_P_8021Q,
bool sync = false )

creates a VLAN interface.

Parameters
interfaceNamename of the VLAN interface to be created.
parentIndexindex of the physical interface to create VLAN on.
idVLAN id (must be unique on the parent interface).
protoVLAN protocol type.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ enumerate()

InterfaceList InterfaceManager::enumerate ( )

enumerate all interfaces.

Returns
all interfaces.

◆ findByIndex()

Interface::Ptr InterfaceManager::findByIndex ( uint32_t interfaceIndex)

find interface by index.

Parameters
interfaceIndexinterface index.
Returns
interface.

◆ findByName()

Interface::Ptr InterfaceManager::findByName ( const std::string & interfaceName)

find interface by name.

Parameters
interfaceNameinterface name.
Returns
interface.

◆ instance()

InterfaceManager * InterfaceManager::instance ( )
static

create the InterfaceManager instance.

Returns
InterfaceManager instance pointer.

◆ operator=() [1/2]

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

assign instance by copy.

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

◆ operator=() [2/2]

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

assign instance by move.

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

◆ refresh()

int InterfaceManager::refresh ( bool sync = true)

refresh all data by dumping link, address, and route data.

Parameters
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ removeAddressListener()

void InterfaceManager::removeAddressListener ( const AddressNotify & cb)

unregisters a previously registered address update callback.

Parameters
cbthe callback function to remove.

◆ removeInterface() [1/2]

int InterfaceManager::removeInterface ( const std::string & interfaceName,
bool sync = false )

deletes the specified network interface.

Parameters
interfaceNameinterface name.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ removeInterface() [2/2]

int InterfaceManager::removeInterface ( uint32_t interfaceIndex,
bool sync = false )

deletes the specified network interface.

Parameters
interfaceIndexinterface index.
syncwait for completion.
Returns
0 on success, -1 on failure.

◆ removeLinkListener()

void InterfaceManager::removeLinkListener ( const LinkNotify & cb)

unregisters a previously registered link update callback.

Parameters
cbthe callback function to remove.

◆ removeRouteListener()

void InterfaceManager::removeRouteListener ( const RouteNotify & cb)

unregisters a previously registered route update callback.

Parameters
cbthe callback function to remove.

Friends And Related Symbol Documentation

◆ Interface

friend class Interface
friend

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