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

Represents a network interface in the system. More...

#include <network_interface.hpp>

Classes

struct  Capabilities
 The capabilities of the network interface. More...

Public Types

enum class  Type {
  undefined , wired_ethernet , wifi , cellular ,
  loopback , other
}
 The type of the network interface. More...
using Identifier = std::string
 The identifier of a network interface (e.g. "en0", "eth0").

Public Member Functions

 NetworkInterface (Identifier identifier)
 Constructs a network interface with the given identifier.
const Identifier & get_identifier () const
const std::string & get_display_name () const
std::string get_extended_display_name () const
const std::string & get_description () const
const std::optional< MacAddress > & get_mac_address () const
const std::vector< boost::asio::ip::address > & get_addresses () const
boost::asio::ip::address_v4 get_first_ipv4_address () const
Type get_type () const
IF_LUID get_interface_luid ()
std::optional< uint32_t > get_interface_index () const
std::string to_string () const
auto tie () const

Static Public Member Functions

static const char * type_to_string (Type type)
 Converts the given type to a string.
static tl::expected< std::vector< NetworkInterface >, int > get_all ()

Friends

bool operator== (const NetworkInterface &lhs, const NetworkInterface &rhs)
bool operator!= (const NetworkInterface &lhs, const NetworkInterface &rhs)

Detailed Description

Represents a network interface in the system.

Definition at line 59 of file network_interface.hpp.

Member Typedef Documentation

◆ Identifier

using rav::NetworkInterface::Identifier = std::string

The identifier of a network interface (e.g. "en0", "eth0").

Definition at line 62 of file network_interface.hpp.

Member Enumeration Documentation

◆ Type

enum class rav::NetworkInterface::Type
strong

The type of the network interface.

Enumerator
undefined 
wired_ethernet 
wifi 
cellular 
loopback 
other 

Definition at line 65 of file network_interface.hpp.

Constructor & Destructor Documentation

◆ NetworkInterface()

rav::NetworkInterface::NetworkInterface ( Identifier identifier)
inlineexplicit

Constructs a network interface with the given identifier.

The identifier is used to uniquely identify the interface, and should be the BSD name on BSD-style platforms and the AdapterName on Windows platforms.

Parameters
identifierThe unique identifier of the network interface.

Definition at line 96 of file network_interface.hpp.

Member Function Documentation

◆ get_addresses()

const std::vector< boost::asio::ip::address > & rav::NetworkInterface::get_addresses ( ) const
inlinenodiscard
Returns
The addresses of the interface.

Definition at line 150 of file network_interface.hpp.

◆ get_all()

tl::expected< std::vector< NetworkInterface >, int > rav::NetworkInterface::get_all ( )
static
Returns
A list of all network interfaces on the system. Only several operating systems are supported: macOS, Windows and Linux. Not Android.

◆ get_description()

const std::string & rav::NetworkInterface::get_description ( ) const
inlinenodiscard
Returns
The description of the network interface.

Definition at line 136 of file network_interface.hpp.

◆ get_display_name()

const std::string & rav::NetworkInterface::get_display_name ( ) const
inlinenodiscard
Returns
The display name of the network interface.

Definition at line 109 of file network_interface.hpp.

◆ get_extended_display_name()

std::string rav::NetworkInterface::get_extended_display_name ( ) const
inlinenodiscard
Returns
The display name of the network interface, including the identifier and the first ipv4 address.

Definition at line 116 of file network_interface.hpp.

◆ get_first_ipv4_address()

boost::asio::ip::address_v4 rav::NetworkInterface::get_first_ipv4_address ( ) const
inlinenodiscard
Returns
The first IPv4 address of the interface, which will be unspecified if the interface has no IPv4 address.

Definition at line 157 of file network_interface.hpp.

◆ get_identifier()

const Identifier & rav::NetworkInterface::get_identifier ( ) const
nodiscard
Returns
The name of the network interface.

◆ get_interface_index()

std::optional< uint32_t > rav::NetworkInterface::get_interface_index ( ) const
nodiscard
Returns
The index of the network interface, or nullopt if the index could not be found. Note: this is the index as defined by the operating system.

◆ get_interface_luid()

IF_LUID rav::NetworkInterface::get_interface_luid ( )
Returns
The LUID of the interface.

◆ get_mac_address()

const std::optional< MacAddress > & rav::NetworkInterface::get_mac_address ( ) const
inlinenodiscard
Returns
The MAC address of the network interface, or nullopt if the interface does not have a MAC address.

Definition at line 143 of file network_interface.hpp.

◆ get_type()

Type rav::NetworkInterface::get_type ( ) const
inlinenodiscard
Returns
The type of the interface.

Definition at line 169 of file network_interface.hpp.

◆ tie()

auto rav::NetworkInterface::tie ( ) const
inlinenodiscard

Definition at line 204 of file network_interface.hpp.

◆ to_string()

std::string rav::NetworkInterface::to_string ( ) const
nodiscard
Returns
A description of the network interface as string.

◆ type_to_string()

const char * rav::NetworkInterface::type_to_string ( Type type)
static

Converts the given type to a string.

Parameters
typeThe type to convert.
Returns
The string representation of the type.

◆ operator!=

bool operator!= ( const NetworkInterface & lhs,
const NetworkInterface & rhs )
friend

Definition at line 212 of file network_interface.hpp.

◆ operator==

bool operator== ( const NetworkInterface & lhs,
const NetworkInterface & rhs )
friend

Definition at line 208 of file network_interface.hpp.


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