RAVENNAKIT
Loading...
Searching...
No Matches
rav::NetworkInterfaceList Class Reference

A list of network interfaces with some convenience functions to operate on them. More...

#include <network_interface_list.hpp>

Public Member Functions

 NetworkInterfaceList ()=default
 NetworkInterfaceList (std::vector< NetworkInterface > interfaces)
 Constructor that takes a vector of network interfaces.
const NetworkInterface * get_interface (const NetworkInterface::Identifier &identifier) const
 Gets a network interface by the given identifier.
const NetworkInterface * find_by_string (const std::string_view &search_string) const
 Finds a network interface by the given string.
const NetworkInterface * find_by_address (const boost::asio::ip::address &address) const
 Finds a network interface by the given address.
const NetworkInterface * find_by_type (NetworkInterface::Type type) const
 Finds a network interface by the given type.
const std::vector< NetworkInterface > & get_interfaces () const
std::vector< NetworkInterface::Identifier > get_interface_identifiers () const

Static Public Member Functions

static const NetworkInterfaceList & get_system_interfaces (bool force_refresh=false)
 Retrieves the list of network interfaces on the system.

Detailed Description

A list of network interfaces with some convenience functions to operate on them.

Definition at line 36 of file network_interface_list.hpp.

Constructor & Destructor Documentation

◆ NetworkInterfaceList() [1/2]

rav::NetworkInterfaceList::NetworkInterfaceList ( )
default

◆ NetworkInterfaceList() [2/2]

rav::NetworkInterfaceList::NetworkInterfaceList ( std::vector< NetworkInterface > interfaces)
explicit

Constructor that takes a vector of network interfaces.

Parameters
interfacesThe vector of network interfaces.

Member Function Documentation

◆ find_by_address()

const NetworkInterface * rav::NetworkInterfaceList::find_by_address ( const boost::asio::ip::address & address) const
nodiscard

Finds a network interface by the given address.

Parameters
addressThe address to search for.
Returns
The network interface if found, otherwise nullptr.

◆ find_by_string()

const NetworkInterface * rav::NetworkInterfaceList::find_by_string ( const std::string_view & search_string) const
nodiscard

Finds a network interface by the given string.

The string can be the identifier, display name, description, MAC or an ip address. It's meant as convenience function for the user. The search is case-insensitive.

Parameters
search_stringThe string to search for.
Returns
The network interface if found, otherwise nullptr.

◆ find_by_type()

const NetworkInterface * rav::NetworkInterfaceList::find_by_type ( NetworkInterface::Type type) const
nodiscard

Finds a network interface by the given type.

Parameters
typeThe type of the interface to search for.
Returns
A pointer to a network interface if found, otherwise nullptr.

◆ get_interface()

const NetworkInterface * rav::NetworkInterfaceList::get_interface ( const NetworkInterface::Identifier & identifier) const
nodiscard

Gets a network interface by the given identifier.

Parameters
identifierThe string to search for.
Returns
The network interface if found, otherwise nullptr.

◆ get_interface_identifiers()

std::vector< NetworkInterface::Identifier > rav::NetworkInterfaceList::get_interface_identifiers ( ) const
nodiscard
Returns
The list of network interface identifiers.

◆ get_interfaces()

const std::vector< NetworkInterface > & rav::NetworkInterfaceList::get_interfaces ( ) const
nodiscard
Returns
The list of network interfaces.

◆ get_system_interfaces()

const NetworkInterfaceList & rav::NetworkInterfaceList::get_system_interfaces ( bool force_refresh = false)
static

Retrieves the list of network interfaces on the system.

This is a static function that returns a singleton instance of the NetworkInterfaceList. This will return an updated list when the ttl has expired or if the force_refresh parameter is set to true.

Exceptions
std::runtime_errorif the list cannot be retrieved.
Parameters
force_refreshIf true, the list is refreshed even if the ttl has not expired.
Returns
The list of network interfaces on the system.

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