idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::netif Namespace Reference

Namespaces

namespace  detail
 
namespace  sntp
 

Classes

struct  ap_sta_ip4_assigned_event_data
 Information about an IP assigned to a station connected to an AP. More...
 
struct  dns_info
 DNS server information. More...
 
class  error_category
 Error category for network interface errors. More...
 
class  interface
 Network interface handle. More...
 
struct  ip4_event_data
 Information about an acquired IPv4 address. More...
 
struct  ip6_event_data
 Information about an acquired IPv6 address. More...
 

Enumerations

enum class  dhcp_option_id : int {
  subnet_mask = 1 ,
  domain_name_server = 6 ,
  router_solicitation_address = 32 ,
  requested_ip_address = 50 ,
  ip_address_lease_time = 51 ,
  ip_request_retry_time = 52 ,
  vendor_class_identifier = 60 ,
  vendor_specific_info = 43 ,
  captiveportal_uri = 114
}
 DHCP option identifiers. More...
 
enum class  dns_type : int {
  main = 0 ,
  backup = 1 ,
  fallback = 2
}
 DNS server type. More...
 
enum class  flag : uint32_t {
  dhcp_client = 1u << 0 ,
  dhcp_server = 1u << 1 ,
  autoup = 1u << 2 ,
  garp = 1u << 3 ,
  event_ip_modified = 1u << 4 ,
  is_ppp = 1u << 5 ,
  is_bridge = 1u << 6 ,
  mldv6_report = 1u << 7 ,
  ipv6_autoconfig_enabled = 1u << 8
}
 Network interface flags. More...
 
enum class  ip_event_id : int32_t {
  sta_got_ip4 = 0 ,
  sta_lost_ip4 = 1 ,
  ap_sta_ip4_assigned = 2 ,
  got_ip6 = 3 ,
  eth_got_ip4 = 4 ,
  eth_lost_ip4 = 5 ,
  ppp_got_ip4 = 6 ,
  ppp_lost_ip4 = 7
}
 IP event IDs. More...
 
enum class  errc : esp_err_t {
  invalid_params = 0x5001 ,
  if_not_ready = 0x5002 ,
  dhcpc_start_failed = 0x5003 ,
  dhcp_already_started = 0x5004 ,
  dhcp_already_stopped = 0x5005 ,
  no_mem = 0x5006 ,
  dhcp_not_stopped = 0x5007 ,
  driver_attach_failed = 0x5008 ,
  init_failed = 0x5009 ,
  dns_not_configured = 0x500A ,
  mld6_failed = 0x500B ,
  ip6_addr_failed = 0x500C ,
  dhcps_start_failed = 0x500D ,
  tx_failed = 0x500E
}
 Network interface error codes. More...
 

Functions

std::error_code make_error_code (errc e) noexcept
 Creates an error code from an idfxx::netif::errc value.
 
void init ()
 Initializes the TCP/IP stack and network interface subsystem.
 
void deinit ()
 Deinitializes the network interface subsystem.
 
result< voidtry_init ()
 Initializes the TCP/IP stack and network interface subsystem.
 
result< voidtry_deinit ()
 Deinitializes the network interface subsystem.
 
size_t get_nr_of_ifs ()
 Returns the number of registered network interfaces.
 
std::optional< interfaceget_default ()
 Returns a non-owning handle to the default network interface.
 
void set_default (interface &iface)
 Sets the given interface as the default network interface.
 
std::optional< interfacefind_by_key (const char *key)
 Finds a network interface by its key string.
 

Variables

const event_base< ip_event_idip_events
 IP event base.
 
constexpr idfxx::event< ip_event_id, ip4_event_datasta_got_ip4 {ip_event_id::sta_got_ip4}
 Station received IPv4 address event with IP details.
 
constexpr idfxx::event< ip_event_idsta_lost_ip4 {ip_event_id::sta_lost_ip4}
 Station lost IPv4 address event.
 
constexpr idfxx::event< ip_event_id, ap_sta_ip4_assigned_event_dataap_sta_ip4_assigned
 Soft-AP assigned IP to a connected station event.
 
constexpr idfxx::event< ip_event_id, ip6_event_datagot_ip6 {ip_event_id::got_ip6}
 Received IPv6 address event.
 
constexpr idfxx::event< ip_event_id, ip4_event_dataeth_got_ip4 {ip_event_id::eth_got_ip4}
 Ethernet received IPv4 address event with IP details.
 
constexpr idfxx::event< ip_event_ideth_lost_ip4 {ip_event_id::eth_lost_ip4}
 Ethernet lost IPv4 address event.
 
constexpr idfxx::event< ip_event_id, ip4_event_datappp_got_ip4 {ip_event_id::ppp_got_ip4}
 PPP interface received IPv4 address event with IP details.
 
constexpr idfxx::event< ip_event_idppp_lost_ip4 {ip_event_id::ppp_lost_ip4}
 PPP interface lost IPv4 address event.
 

Enumeration Type Documentation

◆ dhcp_option_id

DHCP option identifiers.

Enumerator
subnet_mask 

Network mask.

domain_name_server 

Domain name server.

router_solicitation_address 

Solicitation router address.

requested_ip_address 

Request specific IP address.

ip_address_lease_time 

Request IP address lease time.

ip_request_retry_time 

Request IP address retry counter.

vendor_class_identifier 

Vendor Class Identifier of a DHCP client.

vendor_specific_info 

Vendor Specific Information of a DHCP server.

captiveportal_uri 

Captive Portal URI.

Definition at line 55 of file netif.hpp.

◆ dns_type

DNS server type.

Enumerator
main 

Main DNS server.

backup 

Backup DNS server.

fallback 

Fallback DNS server.

Definition at line 73 of file netif.hpp.

◆ errc

Network interface error codes.

Enumerator
invalid_params 

Invalid parameters.

if_not_ready 

Interface not ready.

dhcpc_start_failed 

DHCP client start failed.

dhcp_already_started 

DHCP already started.

dhcp_already_stopped 

DHCP already stopped.

no_mem 

Out of memory.

dhcp_not_stopped 

DHCP not stopped.

driver_attach_failed 

Driver attach failed.

init_failed 

Initialization failed.

dns_not_configured 

DNS not configured.

mld6_failed 

MLD6 operation failed.

ip6_addr_failed 

IPv6 address operation failed.

dhcps_start_failed 

DHCP server start failed.

tx_failed 

Transmit failed.

Definition at line 144 of file netif.hpp.

◆ flag

Network interface flags.

Can be combined using bitwise operators via the flags<flag> type.

Enumerator
dhcp_client 

DHCP client enabled.

dhcp_server 

DHCP server enabled.

autoup 

Interface comes up automatically.

garp 

Send gratuitous ARP on IP change.

event_ip_modified 

Generate event on IP modification.

is_ppp 

Interface is PPP.

is_bridge 

Interface is a bridge.

mldv6_report 

Send MLDv6 report on IPv6 events.

ipv6_autoconfig_enabled 

IPv6 autoconfiguration enabled.

Definition at line 87 of file netif.hpp.

◆ ip_event_id

IP event IDs.

Used with the netif::ip_events event base to register listeners for IP-related events.

[](const idfxx::netif::ip4_event_data& info) {
// use info.ip4.ip, etc.
});
constexpr idfxx::event< ip_event_id, ip4_event_data > sta_got_ip4
Station received IPv4 address event with IP details.
Definition netif.hpp:299
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120
Information about an acquired IPv4 address.
Definition netif.hpp:255
Enumerator
sta_got_ip4 

Station received IP address from AP.

sta_lost_ip4 

Station lost IP address.

ap_sta_ip4_assigned 

Soft-AP assigned IP to a connected station.

got_ip6 

Received IPv6 address.

eth_got_ip4 

Ethernet got IP from connected AP.

eth_lost_ip4 

Ethernet lost IP and the IP is reset to 0.

ppp_got_ip4 

PPP interface got IP.

ppp_lost_ip4 

PPP interface lost IP.

Definition at line 114 of file netif.hpp.

Function Documentation

◆ deinit()

void idfxx::netif::deinit ( )
inline

Deinitializes the network interface subsystem.

Exceptions
std::system_erroron failure.

Definition at line 780 of file netif.hpp.

References idfxx::unwrap().

◆ find_by_key()

std::optional< interface > idfxx::netif::find_by_key ( const char key)

Finds a network interface by its key string.

Parameters
keyThe interface key to search for.
Returns
A non-owning interface, or std::nullopt if not found.

References find_by_key().

Referenced by find_by_key().

◆ get_default()

std::optional< interface > idfxx::netif::get_default ( )

Returns a non-owning handle to the default network interface.

Returns
A non-owning interface, or std::nullopt if no default is set.

References get_default().

Referenced by get_default().

◆ get_nr_of_ifs()

size_t idfxx::netif::get_nr_of_ifs ( )

Returns the number of registered network interfaces.

Returns
The number of interfaces.

References get_nr_of_ifs().

Referenced by get_nr_of_ifs().

◆ init()

void idfxx::netif::init ( )
inline

Initializes the TCP/IP stack and network interface subsystem.

Exceptions
std::system_erroron failure.

Definition at line 777 of file netif.hpp.

References idfxx::unwrap().

◆ make_error_code()

std::error_code idfxx::netif::make_error_code ( errc  e)
inlinenoexcept

Creates an error code from an idfxx::netif::errc value.

Parameters
eThe netif error code enumerator.
Returns
The corresponding std::error_code.

Definition at line 211 of file netif.hpp.

References idfxx::netif_category().

◆ set_default()

void idfxx::netif::set_default ( interface iface)

Sets the given interface as the default network interface.

Parameters
ifaceThe interface to set as default.

References set_default().

Referenced by set_default().

◆ try_deinit()

result< void > idfxx::netif::try_deinit ( )

Deinitializes the network interface subsystem.

Returns
Result indicating success or an error code.

◆ try_init()

result< void > idfxx::netif::try_init ( )

Initializes the TCP/IP stack and network interface subsystem.

Must be called before creating any network interfaces.

Returns
Result indicating success or an error code.

Variable Documentation

◆ ap_sta_ip4_assigned

constexpr idfxx::event<ip_event_id, ap_sta_ip4_assigned_event_data> idfxx::netif::ap_sta_ip4_assigned
inlineconstexpr
Initial value:
{
ip_event_id::ap_sta_ip4_assigned
}

Soft-AP assigned IP to a connected station event.

Definition at line 303 of file netif.hpp.

◆ eth_got_ip4

constexpr idfxx::event<ip_event_id, ip4_event_data> idfxx::netif::eth_got_ip4 {ip_event_id::eth_got_ip4}
inlineconstexpr

Ethernet received IPv4 address event with IP details.

Definition at line 309 of file netif.hpp.

◆ eth_lost_ip4

constexpr idfxx::event<ip_event_id> idfxx::netif::eth_lost_ip4 {ip_event_id::eth_lost_ip4}
inlineconstexpr

Ethernet lost IPv4 address event.

Definition at line 311 of file netif.hpp.

◆ got_ip6

constexpr idfxx::event<ip_event_id, ip6_event_data> idfxx::netif::got_ip6 {ip_event_id::got_ip6}
inlineconstexpr

Received IPv6 address event.

Definition at line 307 of file netif.hpp.

◆ ip_events

const event_base<ip_event_id> idfxx::netif::ip_events
extern

IP event base.

Event base for IP events. Use with the idfxx event loop to register listeners for IP address acquisition, loss, and assignment events.

◆ ppp_got_ip4

constexpr idfxx::event<ip_event_id, ip4_event_data> idfxx::netif::ppp_got_ip4 {ip_event_id::ppp_got_ip4}
inlineconstexpr

PPP interface received IPv4 address event with IP details.

Definition at line 313 of file netif.hpp.

◆ ppp_lost_ip4

constexpr idfxx::event<ip_event_id> idfxx::netif::ppp_lost_ip4 {ip_event_id::ppp_lost_ip4}
inlineconstexpr

PPP interface lost IPv4 address event.

Definition at line 315 of file netif.hpp.

◆ sta_got_ip4

constexpr idfxx::event<ip_event_id, ip4_event_data> idfxx::netif::sta_got_ip4 {ip_event_id::sta_got_ip4}
inlineconstexpr

Station received IPv4 address event with IP details.

Definition at line 299 of file netif.hpp.

◆ sta_lost_ip4

constexpr idfxx::event<ip_event_id> idfxx::netif::sta_lost_ip4 {ip_event_id::sta_lost_ip4}
inlineconstexpr

Station lost IPv4 address event.

Definition at line 301 of file netif.hpp.