|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Network interface handle. More...
Public Member Functions | |
| ~interface () | |
| interface (const interface &)=delete | |
| interface & | operator= (const interface &)=delete |
| interface (interface &&other) noexcept | |
| Move constructs an interface, transferring ownership state. | |
| interface & | operator= (interface &&other) noexcept |
| Move assigns an interface, transferring ownership state. | |
| esp_netif_t * | idf_handle () const noexcept |
| Returns the underlying ESP-NETIF handle. | |
| bool | is_up () const |
| Checks if the network interface is up. | |
| const char * | key () const |
| Returns the interface key string. | |
| const char * | description () const |
| Returns the interface description string. | |
| int | get_route_priority () const |
| Returns the route priority of this interface. | |
| void | set_route_priority (int priority) |
| Sets the route priority of this interface. | |
| flags< flag > | get_flags () const |
| Returns the flags set on this interface. | |
| idfxx::event< ip_event_id, ip4_event_data > | got_ip4_event () const |
| Returns the typed "got IP" event for this interface. | |
| idfxx::event< ip_event_id > | lost_ip4_event () const |
| Returns the typed "lost IP" event for this interface. | |
| mac_address | get_mac () const |
| Returns the MAC address. | |
| void | set_mac (const mac_address &mac) |
| Sets the MAC address. | |
| result< mac_address > | try_get_mac () const |
| Returns the MAC address of this interface. | |
| result< void > | try_set_mac (const mac_address &mac) |
| Sets the MAC address of this interface. | |
| std::string | get_hostname () const |
| Returns the hostname. | |
| void | set_hostname (std::string_view hostname) |
| Sets the hostname. | |
| result< std::string > | try_get_hostname () const |
| Returns the hostname of this interface. | |
| result< void > | try_set_hostname (std::string_view hostname) |
| Sets the hostname of this interface. | |
| net::ip4_info | get_ip4_info () const |
| Returns the current IPv4 information of this interface. | |
| void | set_ip4_info (const net::ip4_info &info) |
| Sets the IPv4 information. | |
| result< void > | try_set_ip4_info (const net::ip4_info &info) |
| Sets the IPv4 information of this interface. | |
| void | create_ip6_linklocal () |
| Creates an IPv6 link-local address for this interface. | |
| net::ip6_addr | get_ip6_linklocal () const |
| Returns the IPv6 link-local address. | |
| net::ip6_addr | get_ip6_global () const |
| Returns the IPv6 global address. | |
| result< void > | try_create_ip6_linklocal () |
| Creates an IPv6 link-local address for this interface. | |
| result< net::ip6_addr > | try_get_ip6_linklocal () const |
| Returns the IPv6 link-local address of this interface. | |
| result< net::ip6_addr > | try_get_ip6_global () const |
| Returns the IPv6 global address of this interface. | |
| std::vector< net::ip6_addr > | get_all_ip6 () const |
| Returns all IPv6 addresses of this interface. | |
| std::vector< net::ip6_addr > | get_all_preferred_ip6 () const |
| Returns all preferred IPv6 addresses of this interface. | |
| void | dhcp_client_start () |
| Starts the DHCP client on this interface. | |
| void | dhcp_client_stop () |
| Stops the DHCP client on this interface. | |
| result< void > | try_dhcp_client_start () |
| Starts the DHCP client on this interface. | |
| result< void > | try_dhcp_client_stop () |
| Stops the DHCP client on this interface. | |
| bool | is_dhcp_client_running () const |
| Checks if the DHCP client is running on this interface. | |
| void | dhcp_server_start () |
| Starts the DHCP server on this interface. | |
| void | dhcp_server_stop () |
| Stops the DHCP server on this interface. | |
| result< void > | try_dhcp_server_start () |
| Starts the DHCP server on this interface. | |
| result< void > | try_dhcp_server_stop () |
| Stops the DHCP server on this interface. | |
| bool | is_dhcp_server_running () const |
| Checks if the DHCP server is running on this interface. | |
| void | set_dns (dns_type type, const dns_info &info) |
| Sets the DNS server information. | |
| dns_info | get_dns (dns_type type) const |
| Returns the DNS server information. | |
| result< void > | try_set_dns (dns_type type, const dns_info &info) |
| Sets the DNS server information for this interface. | |
| result< dns_info > | try_get_dns (dns_type type) const |
| Returns the DNS server information for this interface. | |
| void | napt_enable (bool enable=true) |
| Enables or disables NAPT on this interface. | |
| result< void > | try_napt_enable (bool enable=true) |
| Enables or disables NAPT (Network Address Port Translation) on this interface. | |
Static Public Member Functions | |
| static interface | take (esp_netif_t *handle) |
Constructs an owning interface from an esp_netif_t handle. | |
| static interface | wrap (esp_netif_t *handle) |
Constructs a non-owning interface from an esp_netif_t handle. | |
Network interface handle.
Provides access to IP configuration, DHCP, DNS, hostname, and other interface properties.
An interface may be owning or non-owning. Owning interfaces (e.g. from idfxx::wifi::create_default_sta_netif()) stop any running DHCP client/server and release the underlying resource on destruction. Non-owning interfaces (e.g. from get_default() or find_by_key()) provide the same API but do not manage the lifetime — the caller must ensure the underlying interface outlives the wrapper.
| idfxx::netif::interface::~interface | ( | ) |
|
inlinenoexcept |
|
inline |
Creates an IPv6 link-local address for this interface.
| std::system_error | on failure. |
Definition at line 567 of file netif.hpp.
References idfxx::unwrap().
Returns the interface description string.
|
inline |
Starts the DHCP client on this interface.
| std::system_error | on failure. |
Definition at line 620 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Stops the DHCP client on this interface.
| std::system_error | on failure. |
Definition at line 624 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Starts the DHCP server on this interface.
| std::system_error | on failure. |
Definition at line 657 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Stops the DHCP server on this interface.
| std::system_error | on failure. |
Definition at line 661 of file netif.hpp.
References idfxx::unwrap().
| std::vector< net::ip6_addr > idfxx::netif::interface::get_all_ip6 | ( | ) | const |
Returns all IPv6 addresses of this interface.
| std::vector< net::ip6_addr > idfxx::netif::interface::get_all_preferred_ip6 | ( | ) | const |
Returns all preferred IPv6 addresses of this interface.
Returns the DNS server information.
| std::system_error | on failure. |
Definition at line 699 of file netif.hpp.
References idfxx::unwrap().
Returns the flags set on this interface.
|
inline |
Returns the hostname.
| std::system_error | on failure. |
Definition at line 511 of file netif.hpp.
References idfxx::unwrap().
| net::ip4_info idfxx::netif::interface::get_ip4_info | ( | ) | const |
Returns the current IPv4 information of this interface.
|
inline |
Returns the IPv6 global address.
| std::system_error | on failure. |
Definition at line 575 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Returns the IPv6 link-local address.
| std::system_error | on failure. |
Definition at line 571 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Returns the MAC address.
Not supported on PPP interfaces.
| std::system_error | on failure. |
Definition at line 478 of file netif.hpp.
References idfxx::unwrap().
| int idfxx::netif::interface::get_route_priority | ( | ) | const |
Returns the route priority of this interface.
| idfxx::event< ip_event_id, ip4_event_data > idfxx::netif::interface::got_ip4_event | ( | ) | const |
Returns the typed "got IP" event for this interface.
The returned event can be used to register a listener that fires when this interface acquires an IPv4 address, regardless of interface type.
|
inlinenoexcept |
| bool idfxx::netif::interface::is_dhcp_client_running | ( | ) | const |
Checks if the DHCP client is running on this interface.
| bool idfxx::netif::interface::is_dhcp_server_running | ( | ) | const |
Checks if the DHCP server is running on this interface.
| bool idfxx::netif::interface::is_up | ( | ) | const |
Checks if the network interface is up.
Returns the interface key string.
| idfxx::event< ip_event_id > idfxx::netif::interface::lost_ip4_event | ( | ) | const |
Returns the typed "lost IP" event for this interface.
The returned event can be used to register a listener that fires when this interface loses its IPv4 address, regardless of interface type.
Enables or disables NAPT on this interface.
| std::system_error | on failure. |
Definition at line 726 of file netif.hpp.
References idfxx::unwrap().
Move assigns an interface, transferring ownership state.
| other | The interface to move from. Left in a moved-from state. |
Sets the DNS server information.
| std::system_error | on failure. |
Definition at line 695 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Sets the hostname.
| std::system_error | on failure. |
Definition at line 515 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Sets the IPv4 information.
Fails if DHCP is running.
| std::system_error | on failure. |
Definition at line 547 of file netif.hpp.
References idfxx::unwrap().
|
inline |
Sets the MAC address.
Not supported on PPP interfaces.
| std::system_error | on failure. |
Definition at line 482 of file netif.hpp.
References idfxx::unwrap().
Sets the route priority of this interface.
| priority | The route priority value to set. |
|
static |
Constructs an owning interface from an esp_netif_t handle.
Takes ownership of the handle and will destroy it on destruction. The handle must not be null.
| handle | A non-null esp_netif_t handle. |
Creates an IPv6 link-local address for this interface.
Starts the DHCP client on this interface.
| dhcp_already_started | if the DHCP client is already running. |
Stops the DHCP client on this interface.
| dhcp_already_stopped | if the DHCP client is not running. |
Starts the DHCP server on this interface.
| dhcps_start_failed | if the DHCP server failed to start. |
| dhcp_already_started | if the DHCP server is already running. |
Stops the DHCP server on this interface.
| dhcp_already_stopped | if the DHCP server is not running. |
Returns the DNS server information for this interface.
| type | The DNS server type to query. |
| result< std::string > idfxx::netif::interface::try_get_hostname | ( | ) | const |
Returns the hostname of this interface.
| result< net::ip6_addr > idfxx::netif::interface::try_get_ip6_global | ( | ) | const |
Returns the IPv6 global address of this interface.
| result< net::ip6_addr > idfxx::netif::interface::try_get_ip6_linklocal | ( | ) | const |
Returns the IPv6 link-local address of this interface.
| result< mac_address > idfxx::netif::interface::try_get_mac | ( | ) | const |
Returns the MAC address of this interface.
Not supported on point-to-point (PPP) interfaces.
Enables or disables NAPT (Network Address Port Translation) on this interface.
| enable | True to enable NAPT, false to disable. |
Sets the DNS server information for this interface.
| type | The DNS server type (main, backup, or fallback). |
| info | The DNS server information. |
Sets the hostname of this interface.
| hostname | The hostname to set. |
| result< void > idfxx::netif::interface::try_set_ip4_info | ( | const net::ip4_info & | info | ) |
Sets the IPv4 information of this interface.
Fails if the DHCP client or server is running on this interface.
| info | The IP info to set. |
| result< void > idfxx::netif::interface::try_set_mac | ( | const mac_address & | mac | ) |
Sets the MAC address of this interface.
Not supported on point-to-point (PPP) interfaces.
| mac | The MAC address to set. |
|
static |
Constructs a non-owning interface from an esp_netif_t handle.
Does not take ownership. The caller must ensure the handle remains valid for the lifetime of this object.
| handle | A non-null esp_netif_t handle. |
References idfxx::wrap().