|
SatCat5
|
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:
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>
Public Member Functions | |
| Dispatch (satcat5::ptp::Interface *iface, satcat5::ip::Dispatch *ip) | |
| Attach this object to the network port and IP stack. | |
| satcat5::ip::Dispatch * | iface () const |
| satcat5::igmp::Client * | igmp () const |
| satcat5::eth::MacAddr | macaddr () const |
| void | ptp_callback (satcat5::ptp::Client *client) |
| Set the callback object for incoming messages. | |
| satcat5::io::Writeable * | ptp_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::Client * | m_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::OnDemand * | m_next |
| bool | m_idle |
|
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.
|
inline |
Accessors for one-step and two-step timestamps.
Definition at line 75 of file ptp_dispatch.h.
| 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.
|
inline |
Accessors for one-step and two-step timestamps.
Definition at line 69 of file ptp_dispatch.h.
|
inline |
Accessors for one-step and two-step timestamps.
Definition at line 71 of file ptp_dispatch.h.
|
inline |
Accessors for one-step and two-step timestamps.
Definition at line 73 of file ptp_dispatch.h.
|
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.