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.