CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
EthernetAdaptor Concept Reference

Concept for an Ethernet adaptor. More...

#include <ethernet.hh>

Concept definition

template<typename T>
concept EthernetAdaptor = requires(T adaptor,
const uint8_t *buffer,
uint16_t length,
std::array<uint8_t, 6> macAddress) {
Concept for an Ethernet adaptor.
Definition ethernet.hh:24

The default MAC address for this adaptor.

Must return a 6-byte array.

{ T::mac_address_default() } -> std::same_as<std::array<uint8_t, 6>>;

Is the default MAC address unique?

If the device (e.g. soft MAC) doesn't have its own hardware MAC address then callers may prefer to generate a locally administered MAC address randomly.

{ T::has_unique_mac_address() } -> std::convertible_to<bool>;

Set the MAC address of this adaptor.

{ adaptor.mac_address_set(macAddress) };

Set the MAC address of this adaptor to the default value.

{ adaptor.mac_address_set() };

Check if PHY link is up.

{ adaptor.phy_link_status() } -> std::convertible_to<bool>;

Receive a frame.

Returns an optional value (convertible to bool) that has a length and a buffer. The return value owns the buffer for its lifetime.

{ adaptor.receive_frame() } -> ReceivedEthernetFrame;
Helper concept for the type returned by receive_frame.
Definition ethernet.hh:14

Send a frame identified by a base and length.

Returns true if the frame was sent successfully, false otherwise.

The third argument is a hook that allows the caller to validate the packet after it's been buffered but before it's sent. This avoids time-of-check-to-time-of-use issues in egress filtering.

{
adaptor.send_frame(
buffer, length, [](const uint8_t *buffer, uint16_t length) {
return true;
})
} -> std::same_as<bool>;

Read the current interrupt counter for receive interrupts.

If this device doesn't support interrupts then this can return some other value. This is used only with receive_interrupt_complete.

{ adaptor.receive_interrupt_value() } -> std::same_as<uint32_t>;

Called after receive_frame fails to return new frames to block until a new frame is ready to receive.

TODO: This currently blocks on a single value, this may later be augmented with an interface that sets up a multiwaiter.

{ adaptor.receive_interrupt_complete(nullptr, 0) } -> std::same_as<int>;
}

Detailed Description

Concept for an Ethernet adaptor.

Definition at line 24 of file ethernet.hh.