TSDuck v3.40-4025
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::NetworkInterface Class Reference

Description of a network interface. More...

#include <tsNetworkInterface.h>

Inheritance diagram for ts::NetworkInterface:
Collaboration diagram for ts::NetworkInterface:

Public Member Functions

 NetworkInterface ()=default
 Default constructor.
 
virtual UString toString () const override
 Convert to a string object.
 

Static Public Member Functions

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.
 

Public Attributes

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 Public Attributes

static constexpr int AnyIndex = 0
 Interface index value meaning "any interface" in IPv6 system API.
 

Detailed Description

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.

Member Function Documentation

◆ toString()

virtual UString ts::NetworkInterface::toString ( ) const
overridevirtual

Convert to a string object.

Returns
This object, converted as a string.

Implements ts::StringifyInterface.

◆ GetAll() [1/3]

static bool ts::NetworkInterface::GetAll ( NetworkInterfaceVector addresses,
bool  loopback = true,
IP  gen = IP::Any,
bool  force_reload = false,
Report report = (ts::CerrReport::Instance()) 
)
static

Get the list of all local network interfaces in the system.

Parameters
[out]addressesReceives the list of all local IP interfaces.
[in]loopbackIf false, the loopback addresses are skipped.
[in]genReport addresses for the specified generations only.
[in]force_reloadIf 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]reportWhere to report errors.
Returns
True on success, false on error.

◆ GetAll() [2/3]

static bool ts::NetworkInterface::GetAll ( IPAddressVector addresses,
bool  loopback = true,
IP  gen = IP::Any,
bool  force_reload = false,
Report report = (ts::CerrReport::Instance()) 
)
static

Get the list of all local IP addresses in the system.

Parameters
[out]addressesA vector of IPAddress which receives the list of all local IP addresses.
[in]loopbackIf false, the loopback addresses are skipped.
[in]genReport addresses for the specified generations only.
[in]force_reloadIf 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]reportWhere to report errors.
Returns
True on success, false on error.

◆ GetAll() [3/3]

static bool ts::NetworkInterface::GetAll ( std::set< int > &  indexes,
bool  loopback = true,
IP  gen = IP::Any,
bool  force_reload = false,
Report report = (ts::CerrReport::Instance()) 
)
static

Get the list of all local network interfaces by index.

Parameters
[out]indexesReceives 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]loopbackIf false, the loopback addresses are skipped.
[in]genReport addresses for the specified generations only.
[in]force_reloadIf 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]reportWhere to report errors.
Returns
True on success, false on error.

◆ IsLocal()

static bool ts::NetworkInterface::IsLocal ( const IPAddress address,
bool  force_reload = false,
Report report = (ts::CerrReport::Instance()) 
)
static

Check if a local system interface has a specified IP address.

Parameters
[in]addressThe IP address to check.
[in]force_reloadIf 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]reportWhere to report errors.
Returns
True is address is the address of a local system interface, false otherwise.

◆ ToIndex()

static int ts::NetworkInterface::ToIndex ( const IPAddress address,
bool  force_reload = false,
Report report = (ts::CerrReport::Instance()) 
)
static

Find the interface index for a local system interface identified by IP address.

Parameters
[in]addressThe IP address to check.
[in]force_reloadIf 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]reportWhere to report errors.
Returns
Interface index for address, -1 if address if not a local interface.

◆ ToAddress()

static bool ts::NetworkInterface::ToAddress ( IPAddress address,
int  index,
IP  gen = IP::Any,
bool  force_reload = false,
Report report = (ts::CerrReport::Instance()) 
)
static

Find the first IP address of a network interface identified by its index.

Parameters
[out]addressThe returned IP address.
[in]indexThe interface index to find.
[in]genReport addresses for the specified generations only.
[in]force_reloadIf 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]reportWhere to report errors.
Returns
True on success, false on error.

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