|
join 1.0
lightweight network framework library
|
interface class. More...
#include <interface.hpp>
Public Types | |
| using | Ptr = std::shared_ptr <Interface> |
| using | Address = std::tuple <IpAddress, uint32_t, IpAddress> |
| using | AddressList = std::vector <Address> |
| using | Route = std::tuple <IpAddress, uint32_t, IpAddress, uint32_t> |
| using | RouteList = std::vector <Route> |
Public Member Functions | |
| Interface ()=delete | |
| create instance. | |
| ~Interface ()=default | |
| destroy instance. | |
| uint32_t | index () const noexcept |
| get interface index. | |
| uint32_t | master () const noexcept |
| get master index if bridged. | |
| const std::string & | name () const noexcept |
| get interface name. | |
| int | mtu (uint32_t mtuBytes, bool sync=false) |
| set interface mtu. | |
| uint32_t | mtu () const noexcept |
| get interface mtu. | |
| const std::string & | kind () const noexcept |
| get interface kind. | |
| int | mac (const MacAddress &macAddress, bool sync=false) |
| set interface mac address. | |
| const MacAddress & | mac () const noexcept |
| get interface mac address. | |
| int | addAddress (const IpAddress &ipAddress, uint32_t prefix, const IpAddress &broadcast={}, bool sync=false) |
| add address to interface. | |
| int | addAddress (const Address &address, bool sync=false) |
| add address to interface. | |
| int | removeAddress (const IpAddress &ipAddress, uint32_t prefix, const IpAddress &broadcast={}, bool sync=false) |
| remove address from interface. | |
| int | removeAddress (const Address &address, bool sync=false) |
| remove address from interface. | |
| const AddressList & | addressList () const noexcept |
| get interface ip addresses. | |
| bool | hasAddress (const IpAddress &ipAddress) |
| check if interface has address stored. | |
| bool | hasLocalAddress () |
| check if interface has link local address stored. | |
| int | addRoute (const IpAddress &dest, uint32_t prefix, const IpAddress &gateway={}, uint32_t metric=0, bool sync=false) |
| add route to interface. | |
| int | addRoute (const Route &route, bool sync=false) |
| add route to interface. | |
| int | removeRoute (const IpAddress &dest, uint32_t prefix, const IpAddress &gateway={}, uint32_t metric=0, bool sync=false) |
| remove route from interface. | |
| int | removeRoute (const Route &route, bool sync=false) |
| remove route from interface. | |
| const RouteList & | routeList () const noexcept |
| get interface routes. | |
| bool | hasRoute (const IpAddress &dest, uint32_t prefix, const IpAddress &gateway, uint32_t metric) |
| check if interface has route stored. | |
| bool | hasRoute (const Route &route) |
| check if interface has route stored. | |
| int | addToBridge (uint32_t masterIndex, bool sync=false) |
| add interface to bridge. | |
| int | addToBridge (const std::string &masterName, bool sync=false) |
| add interface to bridge. | |
| int | removeFromBridge (bool sync=false) |
| remove interface from bridge. | |
| uint32_t | flags () const noexcept |
| get interface flags. | |
| int | enable (bool enabled=true, bool sync=false) |
| enable interface. | |
| bool | isEnabled () const noexcept |
| is interface enabled. | |
| bool | isRunning () const noexcept |
| is interface running. | |
| bool | isLoopback () const noexcept |
| is interface a loopback interface. | |
| bool | isPointToPoint () const noexcept |
| is interface a point to point interface. | |
| bool | isDummy () const noexcept |
| is interface a dummy interface. | |
| bool | isBridge () const noexcept |
| is interface a bridge interface. | |
| bool | isVlan () const noexcept |
| is interface a vlan interface. | |
| bool | isVeth () const noexcept |
| is interface a veth interface. | |
| bool | isGre () const noexcept |
| is interface a gre interface. | |
| bool | isTun () const noexcept |
| is interface a tun interface. | |
| bool | supportsBroadcast () const noexcept |
| is interface supporting broadcast. | |
| bool | supportsMulticast () const noexcept |
| is interface supporting multicast. | |
| bool | supportsIpv4 () |
| is interface supporting IPv4. | |
| bool | supportsIpv6 () |
| is interface supporting IPv6. | |
Friends | |
| class | InterfaceManager |
| bool | operator== (const Interface::Ptr &lhs, const Interface::Ptr &rhs) |
| compare if two interfaces are equals. | |
| bool | operator< (const Interface::Ptr &lhs, const Interface::Ptr &rhs) |
| compare if interface is inferior. | |
interface class.
| using join::Interface::Address = std::tuple <IpAddress, uint32_t, IpAddress> |
| using join::Interface::AddressList = std::vector <Address> |
| using join::Interface::Ptr = std::shared_ptr <Interface> |
| using join::Interface::Route = std::tuple <IpAddress, uint32_t, IpAddress, uint32_t> |
| using join::Interface::RouteList = std::vector <Route> |
|
delete |
create instance.
|
default |
destroy instance.
| int Interface::addAddress | ( | const Address & | address, |
| bool | sync = false ) |
add address to interface.
| address | address to add. |
| sync | wait for operation completion if true. |
| int Interface::addAddress | ( | const IpAddress & | ipAddress, |
| uint32_t | prefix, | ||
| const IpAddress & | broadcast = {}, | ||
| bool | sync = false ) |
add address to interface.
| ipAddress | ip address to add. |
| prefix | prefix length. |
| broadcast | broadcast address . |
| sync | wait for operation completion if true. |
|
noexcept |
get interface ip addresses.
| int Interface::addRoute | ( | const IpAddress & | dest, |
| uint32_t | prefix, | ||
| const IpAddress & | gateway = {}, | ||
| uint32_t | metric = 0, | ||
| bool | sync = false ) |
add route to interface.
| dest | destination network. |
| prefix | prefix length. |
| gateway | gateway address. |
| metric | route metric. |
| sync | wait for operation completion if true. |
| int Interface::addRoute | ( | const Route & | route, |
| bool | sync = false ) |
add route to interface.
| route | route. |
| sync | wait for operation completion if true. |
| int Interface::addToBridge | ( | const std::string & | masterName, |
| bool | sync = false ) |
add interface to bridge.
| masterName | bridge name. |
| sync | wait for operation completion if true. |
| int Interface::addToBridge | ( | uint32_t | masterIndex, |
| bool | sync = false ) |
add interface to bridge.
| masterIndex | bridge index. |
| sync | wait for operation completion if true. |
| int Interface::enable | ( | bool | enabled = true, |
| bool | sync = false ) |
enable interface.
| enabled | true to enable interface, false otherwise. |
| sync | wait for operation completion if true. |
|
noexcept |
get interface flags.
| bool Interface::hasAddress | ( | const IpAddress & | ipAddress | ) |
check if interface has address stored.
| ipAddress | ip address to delete. |
| bool Interface::hasLocalAddress | ( | ) |
check if interface has link local address stored.
| bool Interface::hasRoute | ( | const IpAddress & | dest, |
| uint32_t | prefix, | ||
| const IpAddress & | gateway, | ||
| uint32_t | metric ) |
check if interface has route stored.
| dest | destination network. |
| prefix | prefix length. |
| gateway | gateway address. |
| metric | route metric. |
| bool Interface::hasRoute | ( | const Route & | route | ) |
check if interface has route stored.
| route | route. |
|
noexcept |
get interface index.
|
noexcept |
is interface a bridge interface.
|
noexcept |
is interface a dummy interface.
|
noexcept |
is interface enabled.
|
noexcept |
is interface a gre interface.
|
noexcept |
is interface a loopback interface.
|
noexcept |
is interface a point to point interface.
|
noexcept |
is interface running.
|
noexcept |
is interface a tun interface.
|
noexcept |
is interface a veth interface.
|
noexcept |
is interface a vlan interface.
|
noexcept |
get interface kind.
|
noexcept |
get interface mac address.
| int Interface::mac | ( | const MacAddress & | macAddress, |
| bool | sync = false ) |
set interface mac address.
| macAddress | new mac address. |
| sync | wait for operation completion if true. |
|
noexcept |
get master index if bridged.
|
noexcept |
get interface mtu.
| int Interface::mtu | ( | uint32_t | mtuBytes, |
| bool | sync = false ) |
set interface mtu.
| mtuBytes | new mtu value. |
| sync | wait for operation completion if true. |
|
noexcept |
get interface name.
| int Interface::removeAddress | ( | const Address & | address, |
| bool | sync = false ) |
remove address from interface.
| address | address to delete. |
| sync | wait for operation completion if true. |
| int Interface::removeAddress | ( | const IpAddress & | ipAddress, |
| uint32_t | prefix, | ||
| const IpAddress & | broadcast = {}, | ||
| bool | sync = false ) |
remove address from interface.
| ipAddress | ip address to delete. |
| prefix | prefix length. |
| broadcast | broadcast address . |
| sync | wait for operation completion if true. |
| int Interface::removeFromBridge | ( | bool | sync = false | ) |
remove interface from bridge.
| sync | wait for operation completion if true. |
| int Interface::removeRoute | ( | const IpAddress & | dest, |
| uint32_t | prefix, | ||
| const IpAddress & | gateway = {}, | ||
| uint32_t | metric = 0, | ||
| bool | sync = false ) |
remove route from interface.
| dest | destination network. |
| prefix | prefix length. |
| gateway | gateway address. |
| metric | route metric. |
| sync | wait for operation completion if true. |
| int Interface::removeRoute | ( | const Route & | route, |
| bool | sync = false ) |
remove route from interface.
| route | route. |
| sync | wait for operation completion if true. |
|
noexcept |
get interface routes.
|
noexcept |
is interface supporting broadcast.
| bool Interface::supportsIpv4 | ( | ) |
is interface supporting IPv4.
| bool Interface::supportsIpv6 | ( | ) |
is interface supporting IPv6.
|
noexcept |
is interface supporting multicast.
|
friend |
|
friend |
|
friend |