10#ifndef FLEXPTP_PTP_TYPES_H_
11#define FLEXPTP_PTP_TYPES_H_
24#include <flexptp_options.h>
29typedef enum PTPMessageType {
43typedef enum PTPControl {
157#define MAX_PTP_MSG_SIZE (128)
162typedef struct RawPtpMessage_ {
168 void (*pTxCb)(
const struct RawPtpMessage_ *pMsg);
231#define PTP_VARIANCE_HAS_NOT_BEEN_COMPUTED (0xFFFF)
311typedef struct _PtpProfileAdditionalData {
315 struct _PtpProfileAdditionalData *
next;
373#define PTP_TLV_HEADER \
In this module are the core and user events defined.
In here reside a multitude of fundamental PTP-related constants and definitions.
#define PTP_MAX_TLV_PRESET_NAME_LENGTH
Maximum TLV preset name length.
This module defines the context object of a full synchronization cycle. In SLAVE mode four timestamps...
BmcaCandidateState
BMCA candidate states.
@ BMCA_CANDIDATE_COLLECTION
Collecting candidates, we are in the candidate collection time window.
@ BMCA_NO_CANDIDATE
No candidate on the network.
PtpControl
PTP header control field values.
@ PTP_CON_Delay_Req
Delay Request.
@ PTP_CON_Follow_Up
Follow Up.
@ PTP_CON_Delay_Resp
Delay Response.
PtpTransportType
PTP transport type enumeration.
@ PTP_TP_IPv4
IPv4 Transport Type.
@ PTP_TP_802_3
Ethernet Transport Type.
PtpLogMsgPeriods
Enumeration for logarithmic message period boundaries.
@ PTP_LOGPER_MAX
Maximal logarithmic messaging period.
@ PTP_LOGPER_MIN
Minimal logarithmic messaging period.
@ PTP_LOGPER_SYNCMATCHED
Messaging occurs whenever a Sync arrives.
void(* PtpUserEventCallback)(PtpUserEventCode uev)
void(* PtpSyncCallback)(int64_t time_error, const PtpSyncCycleData *pSCD, uint32_t freqCodeWord)
PtpClockClass
Standard PTP clock classes.
@ PTP_CC_PRIMARY_REFERENCE_DEGRAD_B
A Primary reference operating off the holdover specification, can be a slave.
@ PTP_CC_APPLICATION_SPECIFIC_DEGRAD_A
An Application specific class clock operating off the holdover specification.
@ PTP_CC_DEFAULT
Default clock class.
@ PTP_CC_APPLICATION_SPECIFIC_DEGRAD_B
An Application specific class clock operating off the holdover specification, can be a slave.
@ PTP_CC_PRIMARY_REFERENCE_HOLDOVER
Normally a Primary reference clock, but now working in holdover mode.
@ PTP_CC_PRIMARY_REFERENCE
Primary reference clock, cannot be a slave.
@ PTP_CC_APPLICATION_SPECIFIC
Application specific reference clock, ARB timescale, cannot be a slave.
@ PTP_CC_SLAVE_ONLY
The clock is slave ony.
@ PTP_CC_APPLICAION_SPECIFIC_HOLDOVER
An Application specific class clock that operates in holdover.
@ PTP_CC_PRIMARY_REFERENCE_DEGRAD_A
A Primary reference operating off the holdover specification.
@ PTP_TLV_ALTERNATE_TIME_OFFSET_INDICATOR
@ PTP_TLV_ACKNOWLEDGE_CANCEL_UNICAST_TRANSMISSION
@ PTP_TLV_CUM_FREQ_SCALE_FACTOR_OFFSET
@ PTP_TLV_AUTHENTICATION_CHALLENGE
@ PTP_TLV_MANAGEMENT_ERROR_STATUS
Management error status.
@ PTP_TLV_MANAGEMENT
Management extension.
@ PTP_TLV_GRANT_UNICAST_TRANSMISSION
@ PTP_TLV_ORGANIZATION_EXTENSION
Organization extension.
@ PTP_TLV_SECURITY_ASSOCIATION_UPDATE
@ PTP_TLV_CANCEL_UNICAST_TRANSMISSION
@ PTP_TLV_REQUEST_UNICAST_TRANSMISSION
PtpAnnounceBody PtpMasterProperties
PtpMessageClass
Enumeration for different PTP message classes.
@ PTP_MC_EVENT
Event Message Class.
@ PTP_MC_GENERAL
General Message Class.
PtpClockAccuracy
Standard clock accuray definitions.
@ PTP_CA_2_5US
Accurate to within 2.5us.
@ PTP_CA_250MS
Accurate to within 250ms.
@ PTP_CA_GT10S
Accurate to > 10s.
@ PTP_CA_100US
Accurate to within 100us.
@ PTP_CA_250NS
Accurate to within 250ns.
@ PTP_CA_10S
Accurate to within 10s.
@ PTP_CA_1MS
Accurate to within 1ms.
@ PTP_CA_UNKNOWN
Accuracy is unknown.
@ PTP_CA_100MS
Accurate to within 100ms.
@ PTP_CA_250US
Accurate to within 250us.
@ PTP_CA_25NS
Accurate to within 25ns.
@ PTP_CA_1US
Accurate to within 1us.
@ PTP_CA_25US
Accurate to within 25us.
@ PTP_CA_10US
Accurate to within 10us.
@ PTP_CA_100NS
Accurate to within 100ns.
@ PTP_CA_25MS
Accurate to within 25ms.
@ PTP_CA_1S
Accurate to within 1s.
@ PTP_CA_2_5MS
Accurate to within 2.5ms.
@ PTP_CA_10MS
Accurate to within 10ms.
PtpM2SState
Core state machine states.
@ SWaitFollowUp
Waiting for a Follow Up message.
PtpMessageType
PTP packet type enumeration.
@ PTP_MT_Delay_Resp
Delay Response.
@ PTP_MT_PDelay_Resp
Peer Delay Response.
@ PTP_MT_PDelay_Req
Peer Delay Request.
@ PTP_MT_Announce
Announce.
@ PTP_MT_Delay_Req
Delay Request.
@ PTP_MT_PDelay_Resp_Follow_Up
Peer Delay Response Follow Up.
@ PTP_MT_Follow_Up
Follow Up.
PtpDelayMechanism
PTP Delay mechanism enumeration.
@ PTP_DM_E2E
End-to-End Delay Mechanism.
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
#define MAX_PTP_MSG_SIZE
Maximum PTP message size.
BmcaMasterState
BMCA master states.
@ BMCA_MASTER_ME
I am the best master, yeey!
@ BMCA_NO_MASTER
No master.
@ BMCA_MASTER_REMOTE
A remote master is found to be the best.
PtpP2PSlaveState
PTP P2P slave state viewed from the MASTER.
@ PTP_P2PSS_ESTABLISHED
The slave is considered stable and ready.
@ PTP_P2PSS_NONE
No slave is detected.
@ PTP_P2PSS_CANDIDATE
A slave has reported in at least once, now being checked on.
PtpTransportSpecific
PTP transport specific enumeration.
@ PTP_TSPEC_GPTP_8021AS
802.1AS Transport Specific Flag
@ PTP_TSPEC_UNKNOWN_DEF
Unkown Transport Specific Flag (default)
PtpProfileFlags
PTP profile flags.
@ PTP_PF_N
Number of available PTP profile flags.
@ PTP_PF_SLAVE_ONLY
Operating only in SLAVE mode.
@ PTP_PF_NONE
Empty profile flags.
@ PTP_PF_ISSUE_SYNC_FOR_COMPLIANT_SLAVE_ONLY_IN_P2P
Send Sync messages only for a compliant peer in P2P mode.
PtpTimeSource
Standard PTP time source definitions.
@ PTP_TSRC_ATOMIC_CLOCK
The clock is directly connected to such a device and using the PTP timescale.
@ PTP_TSRC_PTP
The clock is synchronized to a different PTP domain.
@ PTP_TSRC_NTP
The clock is synchronized via NTP or SNTP.
@ PTP_TSRC_INTERNAL_OSCILLATOR
Undisciplined, free running oscillator.
@ PTP_TSRC_GPS
The clock is synchronized to a satellite system that distribtues time and frequency tied to internati...
@ PTP_TSRC_OTHER
Any of source not covered by other values.
@ PTP_TSRC_TERRESTRIAL_RADIO
The clock is synchronized via any type of radio distribution system that is tied to international sta...
@ PTP_TSRC_HAND_SET
The clock has been set by means of a human interface based on observation of an international standar...
Contents of a PTP Announce message without the common PTP header.
uint16_t currentUTCOffset
Current UTC Offset.
uint64_t grandmasterClockIdentity
Grandmaster Clock Identity.
uint8_t grandmasterClockClass
Grandmaster Clock Class.
uint8_t grandmasterClockAccuracy
Grandmaster Clock Accuracy.
uint16_t localStepsRemoved
Local Steps Removed.
uint16_t grandmasterClockVariance
Grandmaster Clock Variance.
uint8_t priority2
Priority 2.
uint8_t timeSource
Time Source.
uint8_t priority1
Priority 1.
uint32_t stateDuration
Heartbeat cycles since last state transition.
PtpMasterProperties masterProps
Master clock properties.
uint16_t masterTOCntr
Current master announce dropout counter.
PtpBmcaFsmState state
BMCA state.
bool preventMasterSwitchOver
Set if master switchover is prohibited.
uint16_t masterAnnPer_ms
Message period of current master.
Giant PTP core state object.
TimestampI offset
PPS signal offset.
bool bmca
BMCA state change.
PtpBmcaState bmca
BMCA state.
PtpSyncCycleData scd
Sync cycle data.
bool locked
clock lock state change
uint32_t syncTmr
Counter for scheduling Sync transmission.
PtpUserEventCallback userEventCb
User event callback pointer.
uint32_t delReqTmr
Timer counting ticks for Delay_Req transmissions.
PtpP2PSlaveInfo p2pSlave
Information on the connected P2P slave (only used in P2P modes)
PtpHWClockState hwclock
Hardware clock state.
uint32_t pdelay_reqSequenceID
Sequence number of the last PDelay_Request sent.
PtpSyncCallback syncCb
Sync callback invoked in every synchronization cycle.
uint64_t clockIdentity
clockIdentity calculated from MAC address
TimestampI prevSyncMa
T1 from the previous cycle.
PtpProfile profile
PTP profile.
PtpMasterMessagingState messaging
Messaging state.
uint32_t syncTickPeriod
Sync transmission period in ticks.
PtpMasterProperties capabilities
The capabilities of this device.
PtpSlaveMessagingState messaging
Messaging state.
uint32_t announceTmr
Counter to schedule Announce transmission.
bool enabled
Slave module is enabled.
bool corr
correction fields
PtpStats stats
Statistics.
bool timestamps
timestamps
bool info
informative messages
uint32_t pdelayReqTickPeriod
PDelayReq transmission period in ticks.
uint32_t pdelayReqTmr
Counter for PDelayReq transmission scheduling.
PtpNetworkState network
Network state.
uint32_t announceTickPeriod
Announce transmission in ticks.
uint64_t coarseLimit
time error limit above coarse correction is engaged
uint32_t delReqTickPeriod
ticks between Delay_Req transmissions
TimerHandle_t heartbeat
timer for managing SBMC operations
Identification carrying Delay_Resp message.
uint64_t requestingSourceClockIdentity
Requesting Source Clock Identity.
uint16_t requestingSourcePortIdentity
Requesting Source Port Identity.
bool TIME_TRACEABLE
Time Traceable.
bool PTP_LI_59
Leap Second (59)
bool PTP_ProfileSpecific_2
Profile Specific 2.
bool PTP_UTC_REASONABLE
UTC Reasonable.
bool PTP_LI_61
Leap Second (61)
bool FREQUENCY_TRACEABLE
Frequency Traceable.
bool PTP_TIMESCALE
Timescale.
bool PTP_SECURITY
Security.
bool PTP_ProfileSpecific_1
Profile Specific 1.
bool PTP_TWO_STEP
Two Step.
bool PTP_ALTERNATE_MASTER
Alternate Master.
uint32_t addend
hardware clock addend value
PTP master messaging state structure.
uint16_t announceSequenceID
Sequence ID of the next Announce message.
uint16_t syncSequenceID
Sequence ID of the coming Sync.
TimestampI meanPathDelay
mean path delay
PTP P2P slave info structure;.
uint16_t reportCount
Number of times the slave had reported in.
uint16_t dropoutCntr
Dropout watchdog counter for resetting the state machine if the slave went silent.
uint64_t identity
The clock identity of the connected, operating P2P slave.
PtpP2PSlaveState state
Indicates that a slave is responding to our PDELAY_REQ messages.
PtpDelayMechanism delayMechanism
delay mechanism
PtpTransportSpecific transportSpecific
majorSdoId ('transportSpecific')
int8_t logSyncPeriod
logarithm of the Sync transmission period (MASTER only)
int8_t logAnnouncePeriod
logarithm of the Announce period (MASTER only)
uint8_t flags
Flags associated with this profile.
int8_t logDelayReqPeriod
logarithm of (P)DelayReq period (SLAVE and MASTER)
PtpTransportType transportType
transport layer
uint8_t domainNumber
PTP domain number.
PTP profile additional data list element.
PtpMessageType msgType
Message type into which this extension should be inserted.
const void * data
Pointer to the data block.
struct _PtpProfileAdditionalData * next
Pointer to the next element of the list.
uint16_t size
Size of the data block.
PTP slave messaging state structure.
uint16_t syncPeriodMs
Sync interval in milliseconds.
uint16_t delay_reqSequenceID
last sequence IDs
int8_t logSyncPeriod
logarithm of Sync interval
PtpM2SState m2sState
Sync-FollowUp state.
uint16_t lastRespondedDelReqId
ID of the last (P)Delay_Req got responded.
Structure for statistics.
bool locked
is the PTP locked to defined limit?
double filtTimeErr
0.1Hz lowpass-filtered time error
PTP synchronization cycle data.
Raw PTP message structure.
PtpDelayMechanism tx_dm
transmit transport type
PtpMessageClass tx_mc
transmit message class
uint32_t size
Packet size.
TimestampI * pTs
pointer to timestamp
This module defines storage classes for timestamps and operations on time values.