|
join 1.0
lightweight network framework library
|
interface manager class. More...
#include <interfacemanager.hpp>


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. | |
| InterfaceManager & | operator= (const InterfaceManager &other)=delete |
| assign instance by copy. | |
| InterfaceManager & | operator= (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 InterfaceManager * | instance () |
| create the InterfaceManager instance. | |
Friends | |
| class | Interface |
interface manager class.
| using join::InterfaceManager::AddressNotify = std::function <void (const AddressInfo& info)> |
| using join::InterfaceManager::LinkNotify = std::function <void (const LinkInfo& info)> |
| using join::InterfaceManager::RouteNotify = std::function <void (const RouteInfo& info)> |
|
delete |
create instance by copy.
| other | other interface to copy. |
|
delete |
create instance by move.
| other | other interface to move. |
| InterfaceManager::~InterfaceManager | ( | ) |
destroy instance.
| void InterfaceManager::addAddressListener | ( | const AddressNotify & | cb | ) |
registers a callback to be invoked when a address update occurs.
| cb | the callback function to register. |
| void InterfaceManager::addLinkListener | ( | const LinkNotify & | cb | ) |
registers a callback to be invoked when a link update occurs.
| cb | the callback function to register. |
| void InterfaceManager::addRouteListener | ( | const RouteNotify & | cb | ) |
registers a callback to be invoked when a route update occurs.
| cb | the callback function to register. |
| int InterfaceManager::createBridgeInterface | ( | const std::string & | interfaceName, |
| bool | sync = false ) |
creates a bridge interface.
| interfaceName | name of the bridge interface to be created. |
| sync | wait for completion. |
| int InterfaceManager::createDummyInterface | ( | const std::string & | interfaceName, |
| bool | sync = false ) |
creates a dummy interface.
| interfaceName | name of the dummy interface to be created. |
| sync | wait for completion. |
| 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.
| tunnelName | name of the GRE tunnel interface to be created. |
| parentName | name of the physical interface to bind the tunnel to. |
| localAddress | local endpoint IP address for the tunnel. |
| remoteAddress | remote endpoint IP address for the tunnel. |
| ikey | optional inbound GRE key. |
| okey | optional outbound GRE key. |
| ttl | ttl/hop Limit for encapsulated packets (0-255) |
| sync | wait for completion. |
| 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.
| tunnelName | name of the GRE tunnel interface to be created. |
| parentIndex | index of the physical interface to bind the tunnel to. |
| localAddress | local endpoint IP address for the tunnel. |
| remoteAddress | remote endpoint IP address for the tunnel. |
| ikey | optional inbound GRE key. |
| okey | optional outbound GRE key. |
| ttl | ttl/hop Limit for encapsulated packets (0-255) |
| sync | wait for completion. |
| int InterfaceManager::createVethInterface | ( | const std::string & | hostName, |
| const std::string & | peerName, | ||
| pid_t * | pid = nullptr, | ||
| bool | sync = false ) |
creates a Virtual Ethernet nterface pair.
| hostName | name of the interface to be created in the current namespace. |
| peerName | name of the interface to be created in the target namespace. |
| pid | process id of target namespace. |
| sync | wait for completion. |
| 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.
| interfaceName | name of the VLAN interface to be created. |
| parentName | name of the physical interface to create VLAN on. |
| id | VLAN id (must be unique on the parent interface). |
| proto | VLAN protocol type. |
| sync | wait for completion. |
| 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.
| interfaceName | name of the VLAN interface to be created. |
| parentIndex | index of the physical interface to create VLAN on. |
| id | VLAN id (must be unique on the parent interface). |
| proto | VLAN protocol type. |
| sync | wait for completion. |
| InterfaceList InterfaceManager::enumerate | ( | ) |
enumerate all interfaces.
| Interface::Ptr InterfaceManager::findByIndex | ( | uint32_t | interfaceIndex | ) |
find interface by index.
| interfaceIndex | interface index. |
| Interface::Ptr InterfaceManager::findByName | ( | const std::string & | interfaceName | ) |
find interface by name.
| interfaceName | interface name. |
|
static |
create the InterfaceManager instance.
|
delete |
assign instance by copy.
| other | other interface to copy. |
|
delete |
assign instance by move.
| other | other interface to move. |
| int InterfaceManager::refresh | ( | bool | sync = true | ) |
refresh all data by dumping link, address, and route data.
| sync | wait for completion. |
| void InterfaceManager::removeAddressListener | ( | const AddressNotify & | cb | ) |
unregisters a previously registered address update callback.
| cb | the callback function to remove. |
| int InterfaceManager::removeInterface | ( | const std::string & | interfaceName, |
| bool | sync = false ) |
deletes the specified network interface.
| interfaceName | interface name. |
| sync | wait for completion. |
| int InterfaceManager::removeInterface | ( | uint32_t | interfaceIndex, |
| bool | sync = false ) |
deletes the specified network interface.
| interfaceIndex | interface index. |
| sync | wait for completion. |
| void InterfaceManager::removeLinkListener | ( | const LinkNotify & | cb | ) |
unregisters a previously registered link update callback.
| cb | the callback function to remove. |
| void InterfaceManager::removeRouteListener | ( | const RouteNotify & | cb | ) |
unregisters a previously registered route update callback.
| cb | the callback function to remove. |
|
friend |