Description of a network interface.
More...
#include <tsNetworkInterface.h>
|
| NetworkInterface ()=default |
| Default constructor.
|
|
virtual UString | toString () const override |
| Convert to a string object.
|
|
|
static bool | GetAll (IPAddressVector &addresses, bool loopback=true, IP gen=IP::Any, bool force_reload=false, Report &report=(ts::CerrReport::Instance())) |
| Get the list of all local IP addresses in the system.
|
|
static bool | GetAll (NetworkInterfaceVector &addresses, bool loopback=true, IP gen=IP::Any, bool force_reload=false, Report &report=(ts::CerrReport::Instance())) |
| Get the list of all local network interfaces in the system.
|
|
static bool | GetAll (std::set< int > &indexes, bool loopback=true, IP gen=IP::Any, bool force_reload=false, Report &report=(ts::CerrReport::Instance())) |
| Get the list of all local network interfaces by index.
|
|
static bool | IsLocal (const IPAddress &address, bool force_reload=false, Report &report=(ts::CerrReport::Instance())) |
| Check if a local system interface has a specified IP address.
|
|
static bool | ToAddress (IPAddress &address, int index, IP gen=IP::Any, bool force_reload=false, Report &report=(ts::CerrReport::Instance())) |
| Find the first IP address of a network interface identified by its index.
|
|
static int | ToIndex (const IPAddress &address, bool force_reload=false, Report &report=(ts::CerrReport::Instance())) |
| Find the interface index for a local system interface identified by IP address.
|
|
|
IPAddressMask | address {} |
| IP address and mask/prefix.
|
|
int | index = -1 |
| Interface index, system specific, negative if meaningless.
|
|
bool | loopback = false |
| This is a software loopback interface.
|
|
UString | name {} |
| Interface name, system specific.
|
|
|
static constexpr int | AnyIndex = 0 |
| Interface index value meaning "any interface" in IPv6 system API.
|
|
Description of a network interface.
The concept of "network interface" is very system-specific. There are physical and virtual interfaces, interface names and addresses. Here, a NetworkInterface instance describes one IP address. Depending on the system, several NetworkInterface instances may have the same interface name.
◆ toString()
virtual UString ts::NetworkInterface::toString |
( |
| ) |
const |
|
overridevirtual |
◆ GetAll() [1/3]
Get the list of all local network interfaces in the system.
- Parameters
-
[out] | addresses | Receives the list of all local IP interfaces. |
[in] | loopback | If false, the loopback addresses are skipped. |
[in] | gen | Report addresses for the specified generations only. |
[in] | force_reload | If true, force a reload of the list of interfaces. By default, the list is loaded once and kept in cache. If no network interface is dynamically added, there is no need to rebuild the list each time. |
[in] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ GetAll() [2/3]
Get the list of all local IP addresses in the system.
- Parameters
-
[out] | addresses | A vector of IPAddress which receives the list of all local IP addresses. |
[in] | loopback | If false, the loopback addresses are skipped. |
[in] | gen | Report addresses for the specified generations only. |
[in] | force_reload | If true, force a reload of the list of interfaces. By default, the list is loaded once and kept in cache. If no network interface is dynamically added, there is no need to rebuild the list each time. |
[in] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ GetAll() [3/3]
Get the list of all local network interfaces by index.
- Parameters
-
[out] | indexes | Receives the set of indexes of all local IP interfaces. If an interface has multiple IP addresses, the index is returned only once. If interface indexes are meaningless for that operating system, the returned set is empty. |
[in] | loopback | If false, the loopback addresses are skipped. |
[in] | gen | Report addresses for the specified generations only. |
[in] | force_reload | If true, force a reload of the list of interfaces. By default, the list is loaded once and kept in cache. If no network interface is dynamically added, there is no need to rebuild the list each time. |
[in] | report | Where to report errors. |
- Returns
- True on success, false on error.
◆ IsLocal()
Check if a local system interface has a specified IP address.
- Parameters
-
[in] | address | The IP address to check. |
[in] | force_reload | If true, force a reload of the list of interfaces. By default, the list is loaded once and kept in cache. If no network interface is dynamically added, there is no need to rebuild the list each time. |
[in] | report | Where to report errors. |
- Returns
- True is address is the address of a local system interface, false otherwise.
◆ ToIndex()
Find the interface index for a local system interface identified by IP address.
- Parameters
-
[in] | address | The IP address to check. |
[in] | force_reload | If true, force a reload of the list of interfaces. By default, the list is loaded once and kept in cache. If no network interface is dynamically added, there is no need to rebuild the list each time. |
[in] | report | Where to report errors. |
- Returns
- Interface index for address, -1 if address if not a local interface.
◆ ToAddress()
Find the first IP address of a network interface identified by its index.
- Parameters
-
[out] | address | The returned IP address. |
[in] | index | The interface index to find. |
[in] | gen | Report addresses for the specified generations only. |
[in] | force_reload | If true, force a reload of the list of interfaces. By default, the list is loaded once and kept in cache. If no network interface is dynamically added, there is no need to rebuild the list each time. |
[in] | report | Where to report errors. |
- Returns
- True on success, false on error.
The documentation for this class was generated from the following file: