oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::NetIf Class Reference

RAII wrapper around an oveRTOS network interface. More...

#include <net.hpp>

Public Member Functions

 NetIf ()
 Constructs and initialises the network interface.
 
 ~NetIf () noexcept
 De-initialises the network interface.
 
 NetIf (const NetIf &)=delete
 
NetIfoperator= (const NetIf &)=delete
 
 NetIf (NetIf &&other) noexcept
 Move constructor — transfers ownership of the handle.
 
NetIfoperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ NetIf() [1/2]

ove::NetIf::NetIf ( )
inline

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
otherThe source; its handle is set to null after the move.

Member Function Documentation

◆ operator=()

NetIf & ove::NetIf::operator= ( NetIf &&  other)
inlinenoexcept

Move-assignment operator — transfers ownership of the handle.

Parameters
otherThe source; its handle is set to null after the move.
Returns
Reference to this object.

◆ up()

Result< void > ove::NetIf::up ( const NetIfConfig cfg)
inlinenoexcept

Brings the network interface up.

Parameters
[in]cfgInterface 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()

Result< void > ove::NetIf::get_addr ( Address ip = nullptr,
Address gateway = nullptr,
Address netmask = nullptr 
)
inlinenoexcept

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]ipCurrent IP address (may be nullptr).
[out]gatewayCurrent gateway (may be nullptr).
[out]netmaskCurrent 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: