SatCat5
satcat5::ptp::Dispatch Class Reference

Detailed Description

Dispatch and formatting for L2 and L3 PTP messages.

The ptp::Client class uses this helper to send and receive messages.

Because of the need for precision timestamps, the Precision Time Protocol (PTP / IEEE-1588) must often bypass the normal network stack. This class provides a minimal API used by ptp::Client, as well as basic support for:

  • Sending messages to a specific L2 address (unicast or broadcast).
  • Sending messages to a specific L3 address (unicast or multicast).
  • Sending messages as a reply to the most recent message.

Network interfaces with PTP support (e.g., port::MailMap) should inherit from ptp::Interface so they can be used with this class.

The constructor requires a pointer to an ip::Dispatch object to correctly configure the local MAC- and IP-address. It is otherwise unused, since intermediate buffering of incoming and outgoing packets is incompatible with PTP operations.

Definition at line 46 of file ptp_dispatch.h.

#include <ptp_dispatch.h>

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

Public Member Functions

 Dispatch (satcat5::ptp::Interface *iface, satcat5::ip::Dispatch *ip)
 Attach this object to the network port and IP stack.
 
satcat5::ip::Dispatchiface () const
 
satcat5::igmp::Clientigmp () const
 
satcat5::eth::MacAddr macaddr () const
 
void ptp_callback (satcat5::ptp::Client *client)
 Set the callback object for incoming messages.
 
satcat5::io::Writeableptp_send (satcat5::ptp::DispatchTo where, unsigned num_bytes, u8 ptp_msg_type)
 Send a PTP message to the designated address(es). More...
 
void request_poll ()
 Call this method to request polling at a later time. More...
 
void request_cancel ()
 Call this method to cancel a previous request_poll().
 
satcat5::ptp::Time ptp_time_now ()
 Accessors for one-step and two-step timestamps. More...
 
satcat5::ptp::Time ptp_tx_start ()
 Accessors for one-step and two-step timestamps. More...
 
satcat5::ptp::Time ptp_tx_timestamp ()
 Accessors for one-step and two-step timestamps. More...
 
satcat5::ptp::Time ptp_rx_timestamp ()
 Accessors for one-step and two-step timestamps. More...
 
void store_reply_addr ()
 Set the address for use with DispatchTo::STORED.
 
void store_addr (const satcat5::eth::MacAddr &mac, const satcat5::ip::Addr &ip=satcat5::ip::ADDR_NONE, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
 Set the address for use with DispatchTo::STORED.
 

Static Public Member Functions

static unsigned count_ondemand ()
 Count queued objects of this type (i.e., non-idle).
 

Protected Member Functions

void poll_demand () override
 Deferred event handler, called after request(). More...
 
satcat5::eth::Header get_dst_eth (satcat5::ptp::DispatchTo addr) const
 
satcat5::udp::Port get_dst_port (u8 ptp_msg_type) const
 
satcat5::ip::Addr get_dst_ip (u8 ptp_msg_type, satcat5::ptp::DispatchTo addr) const
 

Protected Attributes

satcat5::ptp::Interface *const m_iface
 
satcat5::ip::Dispatch *const m_ip
 
satcat5::ptp::Clientm_callback
 
satcat5::eth::MacAddr m_reply_mac
 
satcat5::eth::MacAddr m_stored_mac
 
satcat5::eth::VlanTag m_reply_vtag
 
satcat5::eth::VlanTag m_stored_vtag
 
satcat5::ip::Addr m_reply_ip
 
satcat5::ip::Addr m_stored_ip
 

Private Attributes

satcat5::poll::OnDemandm_next
 
bool m_idle
 

Member Function Documentation

◆ poll_demand()

void Dispatch::poll_demand ( )
overrideprotectedvirtual

Deferred event handler, called after request().

Child class MUST override this method. (Call "request_poll" to enqueue a callback to this method.)

Implements satcat5::poll::OnDemand.

Definition at line 91 of file ptp_dispatch.cc.

◆ ptp_rx_timestamp()

satcat5::ptp::Time satcat5::ptp::Dispatch::ptp_rx_timestamp ( )
inline

Accessors for one-step and two-step timestamps.

See also
"ptp_interface.h" for more information.

Definition at line 75 of file ptp_dispatch.h.

◆ ptp_send()

satcat5::io::Writeable * Dispatch::ptp_send ( satcat5::ptp::DispatchTo  where,
unsigned  num_bytes,
u8  ptp_msg_type 
)

Send a PTP message to the designated address(es).

Dispatch writes packet header, caller writes PTP message.

Definition at line 41 of file ptp_dispatch.cc.

◆ ptp_time_now()

satcat5::ptp::Time satcat5::ptp::Dispatch::ptp_time_now ( )
inline

Accessors for one-step and two-step timestamps.

See also
"ptp_interface.h" for more information.

Definition at line 69 of file ptp_dispatch.h.

◆ ptp_tx_start()

satcat5::ptp::Time satcat5::ptp::Dispatch::ptp_tx_start ( )
inline

Accessors for one-step and two-step timestamps.

See also
"ptp_interface.h" for more information.

Definition at line 71 of file ptp_dispatch.h.

◆ ptp_tx_timestamp()

satcat5::ptp::Time satcat5::ptp::Dispatch::ptp_tx_timestamp ( )
inline

Accessors for one-step and two-step timestamps.

See also
"ptp_interface.h" for more information.

Definition at line 73 of file ptp_dispatch.h.

◆ request_poll()

void satcat5::poll::OnDemand::request_poll ( )
inherited

Call this method to request polling at a later time.

Safe to stack requests, but only one call to poll().

Definition at line 208 of file polling.cc.


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