|
SatCat5
|
The "Dispatch" is a generic interface that knows how to read a designated protocol layer and sort incoming packets to one of several protocols.
For example, the udp::Dispatch class (udp_dispatch.h) sorts packets by the UDP destination port. Most Dispatch implementations, including eth::Dispatch and ip::Dispatch, further provide a means for Protocols to send messages to an arbitrary address. However, this requires protocol-specific arguments that cannot be provided in the generic API.
Network "Dispatch" objects:
Definition at line 36 of file net_dispatch.h.
#include <net_dispatch.h>
Public Member Functions | |
| virtual satcat5::io::Writeable * | open_reply (const satcat5::net::Type &type, unsigned len)=0 |
| Open a reply to the sender of the most recent message by writing frame header(s) and returning a stream where the caller should write frame data, then call write_finalize(). More... | |
| void | add (satcat5::net::Protocol *proto) |
| Register a Protocol object. | |
| void | remove (satcat5::net::Protocol *proto) |
| Unregister a Protocol object. | |
| bool | bound (const satcat5::net::Type &type) const |
| Check if a given net::Type has a matching Protocol. | |
Protected Member Functions | |
| bool | deliver (const satcat5::net::Type &type, satcat5::io::Readable *src, unsigned len) |
| Deliver current message by calling Protocol::frame_rcvd(...). More... | |
| Dispatch () | |
| Constructor and destructor access restricted to children. | |
| ~Dispatch () | |
| Constructor and destructor access restricted to children. | |
Protected Attributes | |
| satcat5::util::List< satcat5::net::Protocol > | m_list |
| Linked list of Protocol objects. | |
|
protected |
Deliver current message by calling Protocol::frame_rcvd(...).
Note: Caller is responsible for read_finalize(), if required.
Definition at line 25 of file net_dispatch.cc.
|
pure virtual |
Open a reply to the sender of the most recent message by writing frame header(s) and returning a stream where the caller should write frame data, then call write_finalize().
The length argument is the number of bytes that will be written by the caller. (IPv4 and UDP require this information up-front.)
Returns zero if sending a reply is not currently possible.
Child MUST implement this method. Child SHOULD also provide an equivalent open_write(...) method for sending messages to other recipients, when practical. Child MAY ignore the "type" argument at its discretion.
Implemented in satcat5::udp::Dispatch, satcat5::ip::Dispatch, satcat5::eth::Dispatch, satcat5::ccsds_spp::Dispatch, and satcat5::ccsds_aos::Dispatch.