RAII wrapper around an oveRTOS network interface.
More...
#include <net.hpp>
|
| | NetIf () |
| | Constructs and initialises the network interface.
|
| |
|
| ~NetIf () noexcept |
| | De-initialises the network interface.
|
| |
|
| NetIf (const NetIf &)=delete |
| |
|
NetIf & | operator= (const NetIf &)=delete |
| |
| | NetIf (NetIf &&other) noexcept |
| | Move constructor — transfers ownership of the handle.
|
| |
| NetIf & | operator= (NetIf &&other) noexcept |
| | Move-assignment operator — transfers ownership of the handle.
|
| |
| Result< void > | up (const NetIfConfig &cfg) noexcept |
| | Brings the network interface up.
|
| |
| void | down () |
| | Tears down the network interface.
|
| |
| Result< void > | get_addr (Address *ip=nullptr, Address *gateway=nullptr, Address *netmask=nullptr) noexcept |
| | Query the current addresses of the network interface.
|
| |
| bool | valid () const |
| | Returns true if the underlying handle is non-null.
|
| |
| ove_netif_t | handle () const |
| | Returns the raw oveRTOS network interface handle.
|
| |
RAII wrapper around an oveRTOS network interface.
The interface is initialised on construction and de-initialised on destruction. Call up() with a configuration to activate the link and down() to tear it down.
- Note
- Non-copyable. Move-only when heap allocation is enabled.
◆ NetIf() [1/2]
Constructs and initialises the network interface.
Asserts at startup if initialisation fails.
◆ NetIf() [2/2]
| ove::NetIf::NetIf |
( |
NetIf && |
other | ) |
|
|
inlinenoexcept |
Move constructor — transfers ownership of the handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
◆ operator=()
Move-assignment operator — transfers ownership of the handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
- Returns
- Reference to this object.
◆ up()
Brings the network interface up.
- Parameters
-
| [in] | cfg | Interface configuration (DHCP or static). |
- Returns
- Empty
Result<void> on success; unexpected with the appropriate Error on failure.
◆ down()
| void ove::NetIf::down |
( |
| ) |
|
|
inline |
Tears down the network interface.
Idempotent. Safe to call on an already-down interface — the call is silently a no-op in that case. The destructor calls this as part of cleanup, so explicit down() is rarely needed unless you intend to bring the interface back up later.
Effect on pending I/O. Sockets bound to this interface that are mid-operation (e.g. blocked on recv) will unblock with a backend-specific error code — typically OVE_ERR_NET_CLOSED or OVE_ERR_NOT_REGISTERED. Callers should treat any blocking socket call as fallible during interface lifecycle transitions.
Thread-safety. Not safe to call concurrently with up on the same handle. Concurrent calls with socket operations on the same interface are safe — sockets observe the teardown via their error path.
◆ get_addr()
Query the current addresses of the network interface.
Three out-params are kept (rather than folded into the Result value side) because callers commonly want to query a subset — each Address* may be nullptr to skip it.
- Parameters
-
| [out] | ip | Current IP address (may be nullptr). |
| [out] | gateway | Current gateway (may be nullptr). |
| [out] | netmask | Current subnet mask (may be nullptr). |
- Returns
- Empty
Result<void> on success; unexpected with the appropriate Error on failure.
◆ valid()
| bool ove::NetIf::valid |
( |
| ) |
const |
|
inline |
Returns true if the underlying handle is non-null.
- Returns
true when the interface was successfully initialised.
◆ handle()
| ove_netif_t ove::NetIf::handle |
( |
| ) |
const |
|
inline |
Returns the raw oveRTOS network interface handle.
- Returns
- The opaque
ove_netif_t handle.
The documentation for this class was generated from the following file: