flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
master.c
Go to the documentation of this file.
1#include "master.h"
2
3#include "common.h"
4#include "flexptp_options.h"
5#include "format_utils.h"
6#include "msg_utils.h"
7#include "ptp_core.h"
8#include "ptp_defs.h"
10#include "ptp_sync_cycle_data.h"
11#include "ptp_types.h"
12#include "task_ptp.h"
13#include "timeutils.h"
14#include "tlv.h"
15
16#include <string.h>
17
18#ifdef MIN
19#undef MIN
20#endif
21
22#define MIN(a, b) (((a) < (b)) ? (a) : (b))
23
24#ifdef MAX
25#undef MAX
26#endif
27
28#define MAX(a, b) (((a) > (b)) ? (a) : (b))
29
31#define S (gPtpCoreState)
33
34/*
35 * Message headaers and compiled bodies. They can be statically
36 * allocated, since nothing depends on the Announce message
37 * and a Follow_Up is always triggered by the transmission of
38 * a Sync. TODO: Maybe Sync transmissions should be constrained,
39 * so that no new Sync transmission would be scheduled if the Follow_Up
40 * was in the queue.
41 */
48
51 announceHeader.transportSpecific = (uint8_t)S.profile.transportSpecific;
53 announceHeader.domainNumber = S.profile.domainNumber;
54 // announceHeader.flags.PTP_TWO_STEP = true;
58
59 memcpy(&announceHeader.clockIdentity, &S.hwoptions.clockIdentity, 8);
60
63 announceHeader.logMessagePeriod = S.profile.logAnnouncePeriod;
64
65 // insert TLVs from the profile
70
73}
74
75static void ptp_init_sync_header() {
76 syncHeader.transportSpecific = S.profile.transportSpecific;
78 syncHeader.transportSpecific = (uint8_t)S.profile.transportSpecific;
80 syncHeader.domainNumber = S.profile.domainNumber;
82 // syncHeader.flags.PTP_TIMESCALE = false;
85
86 memcpy(&syncHeader.clockIdentity, &S.hwoptions.clockIdentity, 8);
87
90 syncHeader.logMessagePeriod = S.profile.logSyncPeriod;
91
92 // insert TLVs from the profile
97
98 // save message sizes
99 sync.size = PTP_PCKT_SIZE_SYNC + tlvSize;
101}
102
104 // insert TLVs from the profile
106 tlvChain,
110}
111
113 PtpHeader header;
114
115 // set sequence ID
116 announceHeader.sequenceID = S.master.messaging.announceSequenceID++;
117 announceHeader.transportSpecific = S.profile.transportSpecific;
118
119 // fill-in fields
121 ptp_write_binary_timestamps(announce.data, &zeroTs, 1); // insert an empty timestamp
122 ptp_construct_binary_announce_message(announce.data, &S.capabilities); // insert Announce body
123
124 // setup packet
125 announce.pTs = NULL;
126 announce.pTxCb = NULL;
127 announce.tx_dm = S.profile.delayMechanism;
129
130 // send message
132}
133
134static void ptp_send_follow_up(const RawPtpMessage *pMsg) {
135 // fetch header from preceding Sync
136 PtpHeader header;
137 ptp_extract_header(&header, pMsg->data);
138 TimestampI t1 = pMsg->ts;
139
140 // modify header fields
141 header.transportSpecific = S.profile.transportSpecific;
143 header.messageLength = followUp.size;
144 header.control = PTP_CON_Follow_Up;
145 // ptp_clear_flags(&(header.flags));
146
147 // write fields
148 ptp_construct_binary_header(followUp.data, &header); // insert header
149 ptp_write_binary_timestamps(followUp.data, &t1, 1); // insert t1 timestamp
150
151 // setup packet
152 followUp.pTs = NULL;
153 followUp.pTxCb = NULL;
154 followUp.tx_dm = S.profile.delayMechanism;
156
157 // transmit
159}
160
162 PtpHeader header;
163
164 // set sequence ID
165 syncHeader.sequenceID = S.master.messaging.syncSequenceID++;
166
167 // fill-in fields
169 ptp_write_binary_timestamps(sync.data, &zeroTs, 1); // insert an empty timestamp (TWO_STEP -> "reserved")
170
171 // setup packet
172 sync.pTs = &sync.ts;
174 sync.tx_dm = S.profile.delayMechanism;
176
177 // send message
179}
180
181static void ptp_send_delay_resp_message(const RawPtpMessage *pRawMsg, const PtpHeader *pHeader) {
182 RawPtpMessage delRespMsg = {0};
183
184 PtpHeader header = *pHeader; // make a copy
185 TimestampI t4 = pRawMsg->ts; // fetch t4 timestamp
186
187 // create requestingSourcePortIdentity based on clockId from the header
188 PtpDelay_RespIdentification reqDelRespId = {header.clockIdentity, header.sourcePortID};
189
190 // modify header fields
191 header.messageType = PTP_MT_Delay_Resp; // change message type
192 ptp_clear_flags(&header.flags); // clear flags
193 header.flags.PTP_TWO_STEP = true; // set TWO_STEP flag
194 header.sourcePortID = PTP_PORT_ID; // set source port number
195 header.messageLength = PTP_PCKT_SIZE_DELAY_RESP; // set appropriate size
196 header.clockIdentity = S.hwoptions.clockIdentity; // set our clock identity
198
199 // write fields
200 ptp_construct_binary_header(delRespMsg.data, &header); // HEADER
201 ptp_write_binary_timestamps(delRespMsg.data, &t4, 1); // t4 TIMESTAMP
202 ptp_write_delay_resp_id_data(delRespMsg.data, &reqDelRespId); // REQ.SRC.PORT.ID
203
204 // setup packet
205 delRespMsg.pTs = NULL;
206 delRespMsg.size = PTP_PCKT_SIZE_DELAY_RESP;
207 delRespMsg.pTxCb = NULL;
208 delRespMsg.tx_dm = PTP_DM_E2E;
209 delRespMsg.tx_mc = PTP_MC_GENERAL;
210
211 // send packet
212 ptp_transmit_enqueue(&delRespMsg);
213}
214
215// ------------------------
216
217static char *P2P_SLAVE_STATE_HINTS[] = {
218 "NONE",
219 "CANDIDATE",
220 "ESTABLISHED"};
221
222#define PTP_MASTER_P2P_SLAVE_STATE_LOG() \
223 CLILOG(S.logging.def && (si->state != prevState), "%s -> %s\n", P2P_SLAVE_STATE_HINTS[prevState], P2P_SLAVE_STATE_HINTS[si->state])
224
230static void ptp_master_p2p_slave_reported(uint64_t slClockId) {
231 PtpP2PSlaveInfo *si = &(S.master.p2pSlave);
232 PtpP2PSlaveState prevState = si->state;
233
234 switch (si->state) {
235 case PTP_P2PSS_NONE:
236 si->reportCount = 0; // increase the report count
237 si->dropoutCntr = PTP_PDELAY_DROPOUT; // reload the dropout counter
238 si->identity = slClockId; // save the clock ID
239 si->state = PTP_P2PSS_CANDIDATE; // switch to candidate state
240 break;
243 if (si->identity == slClockId) { // if the slave candidate keep reporting in...
244 si->dropoutCntr = PTP_PDELAY_DROPOUT; // reload the counter
245 si->reportCount = MIN(PTP_PDELAY_SLAVE_QUALIFICATION + 1, si->reportCount + 1); // increase the report count
246 if (si->reportCount > PTP_PDELAY_SLAVE_QUALIFICATION) { // switch to ESTABLISHED if qualification has passed
248 }
249 } else { // if a different slave has also appeared, then it's either a fault, or the previous one had been replaced
250 si->state = PTP_P2PSS_NONE; // revert to NONE state
251 si->identity = 0; // clear the identity
252 si->dropoutCntr = 0; // clear the dropout counter
253 si->reportCount = 0; // clear the report counter
254 }
255 break;
256 }
257
259}
260
261// /**
262// * Calculate the mean path delay.
263// */
264// static void ptp_master_calculate_mean_path_delay() {
265// // fetch value arrays
266// TimestampI * pMPD = &S.network.meanPathDelay;
267// uint64_t * pCf = S.master.scd.cf;
268
269// // convert correction field values to timestamp objects
270// TimestampI * pTs = S.master.scd.t;
271// TimestampI cf = {0, 0}; // variable for accounting correction fields in
272// nsToTsI(&cf, pCf[T2] + pCf[T3]);
273
274// // compute difference between master and slave clock
275// subTime(pMPD, &pTs[T4], &pTs[T1]); // t4 - t1 ...
276// subTime(pMPD, pMPD, &pTs[T3]); // - t3 ...
277// addTime(pMPD, pMPD, &pTs[T2]); // + t2
278// subTime(pMPD, pMPD, &cf); // - CF of (PDelay_Resp + PDelay_Resp_Follow_Up)
279// divTime(pMPD, pMPD, 2); // division by 2
280// }
281
283 PtpSyncCycleData *scd = &S.master.scd;
284 TimestampI *mpd = &S.network.meanPathDelay;
285 ptp_compute_mean_path_delay_p2p(scd->t, scd->cf, mpd);
286
287 CLILOG(S.logging.timestamps,
288 "seqID: %u\n"
289 "T1: %d.%09d <- PDelay_Req TX (master)\n"
290 "T2: %d.%09d <- PDelay_Req RX (slave) \n"
291 "T3: %d.%09d <- PDelay_Resp TX (slave) \n"
292 "T4: %d.%09d <- PDelay_Resp RX (master)\n"
293 " %09lu -- %09lu <- CF in PDelay_Resp and ..._Follow_Up\n\n",
294 (uint32_t)S.master.pdelay_reqSequenceID,
295 (int32_t)scd->t[T1].sec, scd->t[T1].nanosec,
296 (int32_t)scd->t[T2].sec, scd->t[T2].nanosec,
297 (int32_t)scd->t[T3].sec, scd->t[T3].nanosec,
298 (int32_t)scd->t[T4].sec, scd->t[T4].nanosec,
299 scd->cf[T2], scd->cf[T3]);
300
301 CLILOG(S.logging.def, "%ld\n", nsI(mpd));
302}
303
305 PtpMessageType mt = pHeader->messageType;
306 PtpDelayMechanism dm = S.profile.delayMechanism;
307
308 if ((mt == PTP_MT_Delay_Req) && (dm == PTP_DM_E2E)) { // pass only Delay_Req through E2E delay mechanism
309 // dispatch DELAY_REQ_RECVED user event
311
312 // send Delay_Resp message
313 ptp_send_delay_resp_message(pRawMsg, pHeader);
314
315 // dispatch DELAY_RESP_SENT user event
317
318 } else if (((mt == PTP_MT_PDelay_Resp) || (mt == PTP_MT_PDelay_Resp_Follow_Up)) && (dm == PTP_DM_P2P)) { // let PDelay_Resp and PDelay_Resp_Follow_Up through in P2P mode
319 PtpDelay_RespIdentification delay_respID; // acquire PDelay_Resp(_Follow_Up) identification info
320 ptp_read_delay_resp_id_data(&delay_respID, pRawMsg->data);
321
322 if ((delay_respID.requestingSourceClockIdentity == S.hwoptions.clockIdentity) &&
323 (delay_respID.requestingSourcePortIdentity == PTP_PORT_ID) && (pHeader->sequenceID == S.master.pdelay_reqSequenceID)) {
324 PtpSyncCycleData *scd = &S.master.scd;
325
326 if (mt == PTP_MT_PDelay_Resp) {
327 if (S.master.p2pSlave.state != PTP_P2PSS_NONE) {
328 ptp_extract_timestamps(&(scd->t[T2]), pRawMsg->data, 1); // extract PDelay_Req reception time
329 scd->cf[T2] = pHeader->correction_ns; // correction field of the PDelay_Resp
330 scd->t[T4] = pRawMsg->ts; // save PDelay_Resp reception time
331 }
332
333 if (!pHeader->flags.PTP_TWO_STEP) {
335
336 // mean path delay calculation
337 if (S.master.p2pSlave.state != PTP_P2PSS_NONE) { // one-step mode responder
338 scd->t[T2] = scd->t[T3] = zeroTs;
339 scd->cf[T3] = 0;
341 }
342
343 // dispatch user event
345 }
346 } else if (mt == PTP_MT_PDelay_Resp_Follow_Up) {
347 if (S.master.p2pSlave.state != PTP_P2PSS_NONE) {
348 ptp_extract_timestamps(&(scd->t[T3]), pRawMsg->data, 1); // extract PDelay_Resp transmission time
349 scd->cf[T3] = pHeader->correction_ns; // correction field of the PDelay_Resp_Follow_Up
351 }
352
354
355 // dispatch user event
357 }
358 }
359 }
360}
361
362// ------------------------
363
365 // reset master module
367}
368
370 return;
371}
372
374 // load the TLV chain based on the profile
375 tlvChain = ptp_tlv_chain_preset_get(S.profile.tlvSet);
376
377 // initialize Announce message header
379
380 // initialize Sync message header
382
383 // initialze Follow_Up message
385
386 // disable the module
387 S.master.enabled = false;
388
389 // clear the messaging state
390 memset(&S.master.messaging, 0, sizeof(PtpMasterMessagingState));
391}
392
394 // enable the module
395 S.master.enabled = true;
396
397 // calculate periods
398 S.master.syncTickPeriod = ptp_logi2ms(S.profile.logSyncPeriod) / PTP_HEARTBEAT_TICKRATE_MS;
399 S.master.announceTickPeriod = ptp_logi2ms(S.profile.logAnnouncePeriod) / PTP_HEARTBEAT_TICKRATE_MS;
400 S.master.pdelayReqTickPeriod = ptp_logi2ms((S.profile.logDelayReqPeriod == PTP_LOGPER_SYNCMATCHED) ? S.profile.logSyncPeriod : S.profile.logDelayReqPeriod) / PTP_HEARTBEAT_TICKRATE_MS;
401
402 // clear counters
403 S.master.syncTmr = 0;
404 S.master.announceTmr = 0;
405 S.master.pdelayReqTmr = 0;
406
407 // reset PDelay_Request's sequence ID
408 S.master.pdelay_reqSequenceID = 0;
409
410 // clear Sync cycle data
411 memset(&S.master.scd, 0, sizeof(PtpSyncCycleData));
412
413 // clear P2P slave information
414 memset(&S.master.p2pSlave, 0, sizeof(PtpP2PSlaveInfo));
415}
416
418 S.master.enabled = false;
419}
420
422 if (!S.master.enabled) {
423 return;
424 }
425
426 PtpDelayMechanism dm = S.profile.delayMechanism; // fetch Delay Mechanism
427
428 // issue PDelay_Req messages
429 if (dm == PTP_DM_P2P) {
430 if (++S.master.pdelayReqTmr >= S.master.pdelayReqTickPeriod) {
431 S.master.pdelayReqTmr = 0;
432
433 PtpP2PSlaveInfo *si = &(S.master.p2pSlave);
434 PtpP2PSlaveState prevState = si->state;
435 si->dropoutCntr = (si->dropoutCntr > 0) ? (si->dropoutCntr - 1) : 0; // decrease the slave dropout counter
436 if (si->dropoutCntr == 0) {
437 si->state = PTP_P2PSS_NONE;
438 si->identity = 0;
439 }
441
442 ptp_send_delay_req_message(); // send a PDelay_Request message
443
444 // dispatch PDELAY_REQUEST_SENT message
446 }
447 }
448
449 // gating signal for Sync and Announce transmission
450 bool infoEn = (dm == PTP_DM_E2E) || ((dm == PTP_DM_P2P) && ((S.master.p2pSlave.state == PTP_P2PSS_ESTABLISHED) || (!(S.profile.flags & PTP_PF_ISSUE_SYNC_FOR_COMPLIANT_SLAVE_ONLY_IN_P2P))));
451
452 if (infoEn) {
453 // Sync transmission
454 if (++S.master.syncTmr >= S.master.syncTickPeriod) {
455 S.master.syncTmr = 0;
456
458
460 }
461
462 // Announce transmission
463 if (++S.master.announceTmr >= S.master.announceTickPeriod) {
464 S.master.announceTmr = 0;
465
467
469 }
470 }
471}
void ptp_compute_mean_path_delay_p2p(const TimestampI *pTs, const uint64_t *pCf, TimestampI *pMPD)
Definition: common.c:141
void ptp_send_delay_req_message()
Definition: common.c:39
This module defines messaging functions for both the slave and master modules.
@ PTP_UEV_PDELAY_RESP_FOLLOW_UP_RECVED
A PDelay_Resp_Follow_Up had been received (master/slave)
Definition: event.h:56
@ PTP_UEV_PDELAY_REQ_SENT
A PDelay_Req had been sent (master/slave)
Definition: event.h:53
@ PTP_UEV_SYNC_SENT
A Sync message has eebn sent (master)
Definition: event.h:45
@ PTP_UEV_PDELAY_RESP_RECVED
A PDelay_Resp had been received (master/slave)
Definition: event.h:54
@ PTP_UEV_DELAY_RESP_SENT
A Delay_Resp had been sent (master)
Definition: event.h:51
@ PTP_UEV_ANNOUNCE_SENT
An Announce message has been sent (master)
Definition: event.h:58
@ PTP_UEV_DELAY_REQ_RECVED
A Delay_Req had been received (master)
Definition: event.h:48
#define PTP_IUEV(uev)
Definition: event.h:77
#define CLILOG(en,...)
uint16_t ptp_logi2ms(int8_t logi)
Definition: format_utils.c:14
This module defines format conversion functions between network and host byte order and conversion fu...
static void ptp_init_sync_header()
Definition: master.c:75
void ptp_master_disable()
Definition: master.c:417
static PtpHeader syncHeader
Definition: master.c:44
void ptp_master_enable()
Definition: master.c:393
#define MIN(a, b)
Definition: master.c:22
void ptp_master_tick()
Definition: master.c:421
#define PTP_MASTER_P2P_SLAVE_STATE_LOG()
Definition: master.c:222
static void ptp_master_p2p_slave_reported(uint64_t slClockId)
Definition: master.c:230
void ptp_master_reset()
Definition: master.c:373
static void ptp_send_delay_resp_message(const RawPtpMessage *pRawMsg, const PtpHeader *pHeader)
Definition: master.c:181
void ptp_master_init()
Definition: master.c:364
static void ptp_init_follow_up_message()
Definition: master.c:103
static RawPtpMessage followUp
Definition: master.c:46
static PtpHeader announceHeader
Definition: master.c:42
static void ptp_send_follow_up(const RawPtpMessage *pMsg)
Definition: master.c:134
static void ptp_send_announce_message()
Definition: master.c:112
void ptp_master_destroy()
Definition: master.c:369
static const PtpProfileTlvElement * tlvChain
Definition: master.c:47
void ptp_master_process_message(RawPtpMessage *pRawMsg, PtpHeader *pHeader)
Definition: master.c:304
static void ptp_init_announce_header()
Definition: master.c:49
static RawPtpMessage sync
Definition: master.c:45
static RawPtpMessage announce
Definition: master.c:43
static char * P2P_SLAVE_STATE_HINTS[]
Definition: master.c:217
static void ptp_send_sync_message()
Definition: master.c:161
static void ptp_master_commence_mpd_computation()
Definition: master.c:282
This module implements the master clock functionality.
void ptp_write_delay_resp_id_data(void *pPayload, const PtpDelay_RespIdentification *pDRData)
Definition: msg_utils.c:224
void ptp_construct_binary_announce_message(void *pData, const PtpAnnounceBody *pAnnounce)
Definition: msg_utils.c:143
void ptp_extract_header(PtpHeader *pHeader, const void *pPayload)
Definition: msg_utils.c:55
void ptp_extract_timestamps(TimestampI *ts, void *pPayload, uint8_t n)
Definition: msg_utils.c:189
void ptp_read_delay_resp_id_data(PtpDelay_RespIdentification *pDRData, void *pPayload)
Definition: msg_utils.c:214
void ptp_construct_binary_header(void *pData, const PtpHeader *pHeader)
Definition: msg_utils.c:90
void ptp_write_binary_timestamps(void *pPayload, const TimestampI *ts, uint8_t n)
Definition: msg_utils.c:166
void ptp_clear_flags(PtpFlags *pFlags)
Definition: msg_utils.c:232
This module defines functions that deal with actual PTP messages; they can extract or insert headers,...
Core of the PTP implementation. Defines functions for message processing, clock tuning,...
In here reside a multitude of fundamental PTP-related constants and definitions.
#define PTP_HEARTBEAT_TICKRATE_MS
Heartbeat ticking period.
Definition: ptp_defs.h:69
#define PTP_PCKT_SIZE_FOLLOW_UP
Size of a Follow_Up message.
Definition: ptp_defs.h:46
#define PTP_PCKT_SIZE_ANNOUNCE
Size of an Announce message.
Definition: ptp_defs.h:53
#define PTP_PDELAY_DROPOUT
Maximum number of failed PDelReq-PDelResp cycles before the MASTER drops the SLAVE.
Definition: ptp_defs.h:137
#define PTP_PCKT_SIZE_DELAY_RESP
Size of a Delay_Resp message.
Definition: ptp_defs.h:48
#define PTP_PCKT_SIZE_SYNC
Size of a Sync message.
Definition: ptp_defs.h:45
#define PTP_PORT_ID
PTP port ID on the device.
Definition: ptp_defs.h:73
#define PTP_PDELAY_SLAVE_QUALIFICATION
Number of consecutive PDelReq-PDelResp iterations after the SLAVE is considered stable.
Definition: ptp_defs.h:133
const PtpProfileTlvElement * ptp_tlv_chain_preset_get(const char *pName)
This module manages predefined profile presets. It allows their fetching by name or ID.
This module defines the context object of a full synchronization cycle. In SLAVE mode four timestamps...
#define T2
#define T3
#define T4
#define T1
This module defines the fundamental PTP message and state machine type, flags, bitfields and the PTP ...
@ PTP_CON_Other
Other.
Definition: ptp_types.h:48
@ PTP_CON_Follow_Up
Follow Up.
Definition: ptp_types.h:46
@ PTP_CON_Delay_Resp
Delay Response.
Definition: ptp_types.h:47
@ PTP_CON_Sync
Sync.
Definition: ptp_types.h:44
@ PTP_LOGPER_SYNCMATCHED
Messaging occurs whenever a Sync arrives.
Definition: ptp_types.h:281
@ PTP_MC_EVENT
Event Message Class.
Definition: ptp_types.h:153
@ PTP_MC_GENERAL
General Message Class.
Definition: ptp_types.h:154
PtpMessageType
PTP packet type enumeration.
Definition: ptp_types.h:29
@ PTP_MT_Delay_Resp
Delay Response.
Definition: ptp_types.h:35
@ PTP_MT_PDelay_Resp
Peer Delay Response.
Definition: ptp_types.h:33
@ PTP_MT_Sync
Sync.
Definition: ptp_types.h:30
@ PTP_MT_Announce
Announce.
Definition: ptp_types.h:37
@ PTP_MT_Delay_Req
Delay Request.
Definition: ptp_types.h:31
@ PTP_MT_PDelay_Resp_Follow_Up
Peer Delay Response Follow Up.
Definition: ptp_types.h:36
@ PTP_MT_Follow_Up
Follow Up.
Definition: ptp_types.h:34
PtpDelayMechanism
PTP Delay mechanism enumeration.
Definition: ptp_types.h:136
@ PTP_DM_E2E
End-to-End Delay Mechanism.
Definition: ptp_types.h:137
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
Definition: ptp_types.h:138
#define MAX_PTP_MSG_SIZE
Maximum PTP message size.
Definition: ptp_types.h:157
PtpP2PSlaveState
PTP P2P slave state viewed from the MASTER.
Definition: ptp_types.h:406
@ PTP_P2PSS_ESTABLISHED
The slave is considered stable and ready.
Definition: ptp_types.h:409
@ PTP_P2PSS_NONE
No slave is detected.
Definition: ptp_types.h:407
@ PTP_P2PSS_CANDIDATE
A slave has reported in at least once, now being checked on.
Definition: ptp_types.h:408
@ PTP_PF_ISSUE_SYNC_FOR_COMPLIANT_SLAVE_ONLY_IN_P2P
Send Sync messages only for a compliant peer in P2P mode.
Definition: ptp_types.h:323
Identification carrying Delay_Resp message.
Definition: ptp_types.h:120
uint64_t requestingSourceClockIdentity
Requesting Source Clock Identity.
Definition: ptp_types.h:121
uint16_t requestingSourcePortIdentity
Requesting Source Port Identity.
Definition: ptp_types.h:122
bool PTP_TIMESCALE
Timescale.
Definition: ptp_types.h:63
bool PTP_TWO_STEP
Two Step.
Definition: ptp_types.h:59
PTP message header structure.
Definition: ptp_types.h:73
int8_t logMessagePeriod
Definition: ptp_types.h:114
uint8_t versionPTP
PTP version.
Definition: ptp_types.h:79
uint8_t messageType
ID.
Definition: ptp_types.h:75
uint64_t clockIdentity
Clock Identity.
Definition: ptp_types.h:102
uint16_t sequenceID
Sequence ID.
Definition: ptp_types.h:108
uint16_t messageLength
Length.
Definition: ptp_types.h:83
uint16_t sourcePortID
Source Port ID.
Definition: ptp_types.h:105
PtpFlags flags
Flags.
Definition: ptp_types.h:92
uint8_t control
Control.
Definition: ptp_types.h:111
uint64_t correction_ns
Correction nanoseconds.
Definition: ptp_types.h:95
uint8_t domainNumber
Domain.
Definition: ptp_types.h:86
uint32_t correction_subns
Correction subnanoseconds.
Definition: ptp_types.h:96
uint8_t transportSpecific
Transport Specific.
Definition: ptp_types.h:76
PTP master messaging state structure.
Definition: ptp_types.h:398
PTP P2P slave info structure;.
Definition: ptp_types.h:415
uint16_t reportCount
Number of times the slave had reported in.
Definition: ptp_types.h:418
uint16_t dropoutCntr
Dropout watchdog counter for resetting the state machine if the slave went silent.
Definition: ptp_types.h:419
uint64_t identity
The clock identity of the connected, operating P2P slave.
Definition: ptp_types.h:417
PtpP2PSlaveState state
Indicates that a slave is responding to our PDELAY_REQ messages.
Definition: ptp_types.h:416
PTP profile additional data list element.
Definition: ptp_types.h:311
PTP synchronization cycle data.
TimestampI t[6]
T1-T6 timestamps.
uint64_t cf[6]
T1-T6 correction fields.
Raw PTP message structure.
Definition: ptp_types.h:162
TimestampI ts
Timestamp.
Definition: ptp_types.h:163
PtpDelayMechanism tx_dm
transmit transport type
Definition: ptp_types.h:169
PtpMessageClass tx_mc
transmit message class
Definition: ptp_types.h:170
void(* pTxCb)(const struct RawPtpMessage_ *pMsg)
transmit callback function
Definition: ptp_types.h:168
uint32_t size
Packet size.
Definition: ptp_types.h:164
TimestampI * pTs
pointer to timestamp
Definition: ptp_types.h:167
uint8_t data[(128)]
raw packet data
Definition: ptp_types.h:173
Timestamp (signed)
Definition: timeutils.h:29
int32_t nanosec
nanoseconds
Definition: timeutils.h:31
int64_t sec
seconds
Definition: timeutils.h:30
bool ptp_transmit_enqueue(const RawPtpMessage *pMsg)
Definition: task_ptp.c:171
The entry point of the whole PTP-implementation. Calling reg_task_ptp() initializes the PTP-engine,...
int64_t nsI(const TimestampI *t)
Definition: timeutils.c:44
This module defines storage classes for timestamps and operations on time values.
uint16_t ptp_tlv_insert(void *dst, const PtpProfileTlvElement *pad, PtpMessageType mt, uint16_t maxLen)
Definition: tlv.c:5
This module implements the TLV-related functionality.