AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::device::Network Class Reference

Network interfaces. More...

#include <network.hpp>

Collaboration diagram for anch::device::Network:

Public Member Functions

 Network ()=delete

Static Public Member Functions

static std::optional< anch::device::NetworkInterface > getInterface (const std::string &ifName)
static std::map< std::string, anch::device::NetworkInterface > getInterfaces ()
static void reload ()

Detailed Description

Network interfaces.

Network interfaces are listed with getifaddrs : every interface is listed, with or without IP address, with its IPv4 and IPv6 addresses. They are loaded on first access and kept until reload .
Interfaces are returned by copy: a reload does not invalidate what has been retrieved before, and every method can be called concurrently.

Author
Vincent Lachenal

Constructor & Destructor Documentation

◆ Network()

anch::device::Network::Network ( )
delete

Utility class: no instance

Member Function Documentation

◆ getInterface()

std::optional< anch::device::NetworkInterface > anch::device::Network::getInterface ( const std::string & ifName)
static

Retrieve network interface by its name.

Parameters
ifNamethe interface name
Returns
the interface if found, std::nullopt otherwise
Exceptions
anch::device::DeviceExceptionNetwork interfaces error

◆ getInterfaces()

std::map< std::string, anch::device::NetworkInterface > anch::device::Network::getInterfaces ( )
static

Retrieve all network interfaces.

Returns
the network interfaces indexed by their names
Exceptions
anch::device::DeviceExceptionNetwork interfaces error

◆ reload()

void anch::device::Network::reload ( )
static

Reload network interfaces. On error, the previously loaded interfaces are kept.

Exceptions
anch::device::DeviceExceptionNetwork interfaces error

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