SatCat5
satcat5::udp::Dispatch Class Referencefinal

Detailed Description

Dispatcher sorts incoming UDP messages by port index.

Implementation of "net::Dispatch" for UDP datagrams, which accepts incoming packets from IP-dispatch.

Definition at line 17 of file udp_dispatch.h.

#include <udp_dispatch.h>

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

Public Member Functions

 Dispatch (satcat5::ip::Dispatch *iface)
 Attach this protocol handler to the parent interface.
 
satcat5::io::Writeableopen_reply (const satcat5::net::Type &type, unsigned nbytes) override
 Reply to the sender of the most recent received message. More...
 
satcat5::io::Writeableopen_write (satcat5::ip::Address &addr, const satcat5::udp::Port &src, const satcat5::udp::Port &dst, unsigned len)
 Send a datagram to the designated UDP address and port. More...
 
satcat5::eth::ProtoArparp () const
 
satcat5::eth::Dispatcheth () const
 
satcat5::ip::Dispatchiface () const
 
satcat5::ip::Addr ipaddr () const
 
satcat5::eth::MacAddr macaddr () const
 
satcat5::eth::VlanTag reply_vtag () const
 
satcat5::eth::MacAddr reply_mac () const
 
bool reply_is_multicast () const
 
satcat5::ip::Addr reply_ip () const
 
satcat5::udp::Port reply_src () const
 
satcat5::udp::Port reply_dst () const
 
satcat5::udp::Port next_free_port ()
 Get the next unclaimed dynamically-allocated port index.
 
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

void frame_rcvd (satcat5::io::LimitedRead &src) override
 Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value. More...
 
bool deliver (const satcat5::net::Type &type, satcat5::io::Readable *src, unsigned len)
 Deliver current message by calling Protocol::frame_rcvd(...). More...
 

Protected Attributes

satcat5::ip::Dispatch *const m_iface
 
u16 m_next_port
 
satcat5::udp::Port m_reply_src
 
satcat5::udp::Port m_reply_dst
 
satcat5::net::Type m_filter
 Incoming packet filter.
 
satcat5::util::List< satcat5::net::Protocolm_list
 Linked list of Protocol objects.
 

Private Attributes

satcat5::net::Protocolm_next
 Linked list of Protocols.
 

Member Function Documentation

◆ deliver()

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

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.

◆ frame_rcvd()

void Dispatch::frame_rcvd ( satcat5::io::LimitedRead src)
overrideprotectedvirtual

Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value.

The child class SHOULD read the frame contents from the provided "src" object, which is only valid until the function returns.

To send a reply:

  • Call m_iface->open_reply() to obtain a Writable object. (This also writes out any applicable frame headers.)
  • Write frame contents, then call write_finalize().

The child class MUST override this method.

Implements satcat5::net::Protocol.

Definition at line 107 of file udp_dispatch.cc.

◆ open_reply()

satcat5::io::Writeable * Dispatch::open_reply ( const satcat5::net::Type type,
unsigned  nbytes 
)
overridevirtual

Reply to the sender of the most recent received message.

Gets Writeable object for deferred write of IPv4 frame header. Note: Argument "type" is ignored for UDP replies.

Implements satcat5::net::Dispatch.

Definition at line 69 of file udp_dispatch.cc.

◆ open_write()

satcat5::io::Writeable * Dispatch::open_write ( satcat5::ip::Address addr,
const satcat5::udp::Port src,
const satcat5::udp::Port dst,
unsigned  len 
)

Send a datagram to the designated UDP address and port.

Gets Writeable object for deferred write of IPv4 frame header.

Definition at line 84 of file udp_dispatch.cc.


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