88 while (layer->
upper_ !=
nullptr)
102 this->
callback_.add(std::forward<F>(callback));
StringRef is a reference to a string owned by something else.
A buffer class that efficiently represents a composite buffer with three sections:
A class that will transport data to and from an abstract channel.
bool has_capability(Capability capability) const
void add_on_session_state_callback(F &&callback)
With CAPABILITY_SESSION, the callback is called with true when the peer can be reached,...
size_t get_max_packet_size() const
The largest packet this layer accepts; fixed when the layer is constructed.
const char * get_name() const
PacketInterface(size_t max_packet_size)
void note_received_(bool understood)
Called by a layer for each received packet it understood, or could not make sense of.
virtual ~PacketInterface()=default
uint8_t not_understood_count_
void stack_on_(PacketInterface *lower, Capability capability)
Called by a layer's constructor to record itself as the layer above lower, adding its own capability.
PacketInterface * top()
The topmost layer stacked on this one, or this one if nothing is stacked on it.
virtual bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data)=0
Method to be implemented by child classes to send data to the interface.
LazyCallbackManager< void(const PacketBuffer &, const PacketMetaData &)> callback_
uint8_t get_capabilities() const
The capabilities of this layer and every layer below it.
void set_name(const char *name)
Name shown in log messages; a layer takes the name of the link it is stacked on.
void add_packet_interface_listener(F &&callback)
Add a listener that will be called when data is received.
void inherit_from_(PacketInterface *lower, Capability capability)
Takes the name and capabilities of lower without becoming its top, for one of several stacks on a lin...
LazyCallbackManager< void(bool)> session_callback_
void dump_config() override
const size_t max_packet_size_
virtual size_t get_send_capacity() const
How many packets send_to_interface() would accept now, so a layer above can tell before sending a ser...
void on_receive_from_interface_(const PacketBuffer &data, const PacketMetaData &meta_data)
This function should be called by implementing classes with received data to be passed to any listene...
constexpr size_t remaining_packet_size(size_t size, size_t used)
The room left for a packet of size bytes after used bytes, or 0 if it is too small.
Capability
What a stack of layers provides, as bits of PacketInterface::get_capabilities().
@ CAPABILITY_FRAGMENTATION