SatCat5
satcat5::net::Dispatch Class Referenceabstract

Detailed Description

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:

  • Know their own address, and any other required parameters.
  • Allow registration of one or more Protocols, each tied to a specific traffic stream (e.g., an EtherType or UDP port).
  • Accept incoming frames and read header information.
  • Apply filtering as needed for invalid frame headers.
  • Route the remaining data to one of several Protocol objects, comparing header field(s) until a suitable match is found.
  • Allow Protocol objects to send simple replies.

Definition at line 36 of file net_dispatch.h.

#include <net_dispatch.h>

Inheritance diagram for satcat5::net::Dispatch:
[legend]
Collaboration diagram for satcat5::net::Dispatch:
[legend]

Public Member Functions

virtual satcat5::io::Writeableopen_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::Protocolm_list
 Linked list of Protocol objects.
 

Member Function Documentation

◆ deliver()

bool Dispatch::deliver ( const satcat5::net::Type type,
satcat5::io::Readable src,
unsigned  len 
)
protected

Deliver current message by calling Protocol::frame_rcvd(...).

Note: Caller is responsible for read_finalize(), if required.

Returns
True if a matching Protocol is found.

Definition at line 25 of file net_dispatch.cc.

◆ open_reply()

virtual satcat5::io::Writeable* satcat5::net::Dispatch::open_reply ( const satcat5::net::Type type,
unsigned  len 
)
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.


The documentation for this class was generated from the following files: