SatCat5
ptp_tlv.h File Reference

Detailed Description

TLV metadata for the IEEE 1588-2019 Precision Time Protocol (PTP).

Type/Length/Value (TLV) extensions are optional metadata tags that may be appended to any PTP message. Any number of TLVs may be chained together, up to the maximum practical frame size. Details are defined in IEEE 1588-2019, Section 14.

This file defines a plugin API for the SatCat5 PTP client, providing an extensible "TlvHandler" framework to read and write TLV tags. Users inherit from this base class to define new TLV functionality.

When reading TLVs, the PTP Client reads the tlvType and lengthField from the TLV header (Section 14.1), and if applicable, organizationId and organizationSubType for organization-specific TLVs (Section 14.3.2). It then calls tlv_rcvd(...) for each registered TlvHandler. User-defined TlvHandlers must accept and read relevant tags (return true) and ignore all other tags (return false). Information from the PTP general header (Section 13.3.1) is also provided.

When writing TLVs, the PTP Client first calls tlv_send(NULL) for each registered TlvHandler, to query the number of bytes that will be written. Next, the Client calls tlv_send(...) again with an io::Writeable pointer, giving each the opportunity to append a TLV tag to the outgoing message.

The written length MUST match the predicted length. Each TlvHandler MUST write complete tag(s) starting with tlvType, and it must return without calling write_finalize().

Finally, whenever the PTP Client completes a two-way time transfer handshake (i.e., SYNC -> DELAY_REQ -> DELAY_RESP), it immediately calls tlv_meas(...) for each registered TlvHandler.

The provided ptp::Measurement object contains the four critical timestamps and other metadata, which can be read or modified. If the ptp::Measurement should be invalidated, the TlvHandler should set it to MEASUREMENT_NULL. Once all TlvHandlers have been notified, the Client will proceed to notify its callbacks, including clock discipline based on offsetFromMaster().

Definition in file ptp_tlv.h.

#include <satcat5/list.h>
#include <satcat5/types.h>
Include dependency graph for ptp_tlv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  satcat5::ptp::TlvHeader
 Data structure for identifying TLV headers. More...
 
class  satcat5::ptp::TlvHandler
 Users should derive custom TLV objects from this base class. More...
 

Variables

constexpr satcat5::ptp::TlvHeader satcat5::ptp::TLV_HEADER_NONE = {0, 0, 0, 0}
 
constexpr u16 satcat5::ptp::TLVTYPE_NONE = 0x0000
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_MANAGEMENT = 0x0001
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_ORG_EXT = 0x0003
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_PATH_TRACE = 0x0008
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_DOPPLER = 0x20AE
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_ORG_EXT_P = 0x4000
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_ORG_EXT_NP = 0x8000
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_PAD = 0x8008
 Define some key tlvType values. More...
 
constexpr u16 satcat5::ptp::TLVTYPE_AUTH = 0x8009
 Define some key tlvType values. More...
 

Variable Documentation

◆ TLVTYPE_AUTH

constexpr u16 satcat5::ptp::TLVTYPE_AUTH = 0x8009

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 64 of file ptp_tlv.h.

◆ TLVTYPE_DOPPLER

constexpr u16 satcat5::ptp::TLVTYPE_DOPPLER = 0x20AE

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 60 of file ptp_tlv.h.

◆ TLVTYPE_MANAGEMENT

constexpr u16 satcat5::ptp::TLVTYPE_MANAGEMENT = 0x0001

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 57 of file ptp_tlv.h.

◆ TLVTYPE_NONE

constexpr u16 satcat5::ptp::TLVTYPE_NONE = 0x0000
constexpr

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 56 of file ptp_tlv.h.

◆ TLVTYPE_ORG_EXT

constexpr u16 satcat5::ptp::TLVTYPE_ORG_EXT = 0x0003

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 58 of file ptp_tlv.h.

◆ TLVTYPE_ORG_EXT_NP

constexpr u16 satcat5::ptp::TLVTYPE_ORG_EXT_NP = 0x8000

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 62 of file ptp_tlv.h.

◆ TLVTYPE_ORG_EXT_P

constexpr u16 satcat5::ptp::TLVTYPE_ORG_EXT_P = 0x4000

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 61 of file ptp_tlv.h.

◆ TLVTYPE_PAD

constexpr u16 satcat5::ptp::TLVTYPE_PAD = 0x8008

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 63 of file ptp_tlv.h.

◆ TLVTYPE_PATH_TRACE

constexpr u16 satcat5::ptp::TLVTYPE_PATH_TRACE = 0x0008

Define some key tlvType values.

See also
ptp_tlv.h, IEEE1588 Section 14.1.1.

Definition at line 59 of file ptp_tlv.h.