23#ifndef PROTOCORE_PTP_H
24#define PROTOCORE_PTP_H
28#if PROTOCORE_ENABLE_PTP
37enum protocore_ptp_msg_type
39 PROTOCORE_PTP_SYNC = 0x0,
40 PROTOCORE_PTP_PDELAY_REQ = 0x2,
41 PROTOCORE_PTP_PDELAY_RESP = 0x3,
42 PROTOCORE_PTP_DELAY_REQ = 0x1,
43 PROTOCORE_PTP_FOLLOW_UP = 0x8,
44 PROTOCORE_PTP_DELAY_RESP = 0x9,
45 PROTOCORE_PTP_PDELAY_RESP_FOLLOW_UP = 0xA,
46 PROTOCORE_PTP_ANNOUNCE = 0xB
49#define PROTOCORE_PTP_HEADER_LEN 34
50#define PROTOCORE_PTP_TS_LEN 10
51#define PROTOCORE_PTP_PDELAY_REQ_LEN 54
52#define PROTOCORE_PTP_EVENT_PORT 319
53#define PROTOCORE_PTP_GENERAL_PORT 320
60} protocore_ptp_timestamp;
66 uint8_t transport_specific;
68 uint16_t message_length;
72 uint8_t clock_identity[8];
77} protocore_ptp_header;
82 protocore_ptp_timestamp receive;
83 uint8_t req_clock_id[8];
85} protocore_ptp_delay_resp;
90 protocore_ptp_timestamp
92 uint8_t req_clock_id[8];
94} protocore_ptp_pdelay_resp;
99 protocore_ptp_timestamp origin;
101 uint8_t gm_priority1;
102 uint8_t gm_clock_class;
103 uint8_t gm_clock_accuracy;
104 uint16_t gm_variance;
105 uint8_t gm_priority2;
106 uint8_t gm_identity[8];
107 uint16_t steps_removed;
109} protocore_ptp_announce;
122 const protocore_ptp_timestamp *ts;
129 protocore_ptp_timestamp *ts;
135 const protocore_ptp_timestamp *ts;
142 protocore_ptp_timestamp *ts;
150 const protocore_ptp_header *h;
159 protocore_ptp_header *h;
167 const protocore_ptp_header *h;
168 const protocore_ptp_timestamp *origin;
176 const protocore_ptp_header *h;
177 const protocore_ptp_timestamp *origin;
178} PtpBuildDelayReqArgs;
185 const protocore_ptp_header *h;
186 const protocore_ptp_timestamp *precise;
187} PtpBuildFollowUpArgs;
194 const protocore_ptp_header *h;
195 const protocore_ptp_timestamp *recv;
196 const uint8_t *req_clock_id;
198} PtpBuildDelayRespArgs;
205 const protocore_ptp_header *h;
206 const protocore_ptp_announce *a;
207} PtpBuildAnnounceArgs;
214 const protocore_ptp_header *h;
215 const protocore_ptp_timestamp *origin;
216} PtpBuildPdelayReqArgs;
223 const protocore_ptp_header *h;
224 const protocore_ptp_timestamp *recv;
225 const uint8_t *req_clock_id;
227} PtpBuildPdelayRespArgs;
234 const protocore_ptp_header *h;
235 const protocore_ptp_timestamp *origin;
236 const uint8_t *req_clock_id;
238} PtpBuildPdelayRespFollowUpArgs;
245 protocore_ptp_header *h;
246 protocore_ptp_timestamp *ts;
247} PtpParseTimestampMsgArgs;
254 protocore_ptp_header *h;
255 protocore_ptp_delay_resp *out;
256} PtpParseDelayRespArgs;
263 protocore_ptp_header *h;
264 protocore_ptp_announce *out;
265} PtpParseAnnounceArgs;
272 protocore_ptp_header *h;
273 protocore_ptp_timestamp *ts;
274} PtpParsePdelayReqArgs;
281 protocore_ptp_header *h;
282 protocore_ptp_pdelay_resp *out;
283} PtpParsePdelayRespArgs;
290 protocore_ptp_header *h;
291 protocore_ptp_pdelay_resp *out;
292} PtpParsePdelayRespFollowUpArgs;
301 protocore_ptp_sync *out;
311} PtpComputeLinkDelayArgs;
377 PtpTsWriteArgs ts_write_args;
378 PtpTsReadArgs ts_read_args;
379 PtpTsToNsArgs ts_to_ns_args;
380 PtpTsFromNsArgs ts_from_ns_args;
381 PtpBuildHeaderArgs build_header_args;
382 PtpParseHeaderArgs parse_header_args;
383 PtpBuildSyncArgs build_sync_args;
384 PtpBuildDelayReqArgs build_delay_req_args;
385 PtpBuildFollowUpArgs build_follow_up_args;
386 PtpBuildDelayRespArgs build_delay_resp_args;
387 PtpBuildAnnounceArgs build_announce_args;
388 PtpBuildPdelayReqArgs build_pdelay_req_args;
389 PtpBuildPdelayRespArgs build_pdelay_resp_args;
390 PtpBuildPdelayRespFollowUpArgs build_pdelay_resp_follow_up_args;
391 PtpParseTimestampMsgArgs parse_timestamp_msg_args;
392 PtpParseDelayRespArgs parse_delay_resp_args;
393 PtpParseAnnounceArgs parse_announce_args;
394 PtpParsePdelayReqArgs parse_pdelay_req_args;
395 PtpParsePdelayRespArgs parse_pdelay_resp_args;
396 PtpParsePdelayRespFollowUpArgs parse_pdelay_resp_follow_up_args;
397 PtpComputeArgs compute_args;
398 PtpComputeLinkDelayArgs compute_link_delay_args;
410 void (*
const ts_write)(uint8_t *work);
411 void (*
const ts_read)(uint8_t *work);
412 void (*
const ts_to_ns)(uint8_t *work);
413 void (*
const ts_from_ns)(uint8_t *work);
414 void (*
const build_header)(uint8_t *work);
415 void (*
const parse_header)(uint8_t *work);
416 void (*
const build_sync)(uint8_t *work);
417 void (*
const build_delay_req)(uint8_t *work);
418 void (*
const build_follow_up)(uint8_t *work);
419 void (*
const build_delay_resp)(uint8_t *work);
420 void (*
const build_announce)(uint8_t *work);
421 void (*
const build_pdelay_req)(uint8_t *work);
422 void (*
const build_pdelay_resp)(uint8_t *work);
423 void (*
const build_pdelay_resp_follow_up)(uint8_t *work);
424 void (*
const parse_timestamp_msg)(uint8_t *work);
425 void (*
const parse_delay_resp)(uint8_t *work);
426 void (*
const parse_announce)(uint8_t *work);
427 void (*
const parse_pdelay_req)(uint8_t *work);
428 void (*
const parse_pdelay_resp)(uint8_t *work);
429 void (*
const parse_pdelay_resp_follow_up)(uint8_t *work);
430 void (*
const compute)(uint8_t *work);
431 void (*
const compute_link_delay)(uint8_t *work);
436void protocore_ptp_ts_write(uint8_t *work);
437void protocore_ptp_ts_read(uint8_t *work);
438void protocore_ptp_ts_to_ns(uint8_t *work);
439void protocore_ptp_ts_from_ns(uint8_t *work);
440void protocore_ptp_build_header(uint8_t *work);
441void protocore_ptp_parse_header(uint8_t *work);
442void protocore_ptp_build_sync(uint8_t *work);
443void protocore_ptp_build_delay_req(uint8_t *work);
444void protocore_ptp_build_follow_up(uint8_t *work);
445void protocore_ptp_build_delay_resp(uint8_t *work);
446void protocore_ptp_build_announce(uint8_t *work);
447void protocore_ptp_build_pdelay_req(uint8_t *work);
448void protocore_ptp_build_pdelay_resp(uint8_t *work);
449void protocore_ptp_build_pdelay_resp_follow_up(uint8_t *work);
450void protocore_ptp_parse_timestamp_msg(uint8_t *work);
451void protocore_ptp_parse_delay_resp(uint8_t *work);
452void protocore_ptp_parse_announce(uint8_t *work);
453void protocore_ptp_parse_pdelay_req(uint8_t *work);
454void protocore_ptp_parse_pdelay_resp(uint8_t *work);
455void protocore_ptp_parse_pdelay_resp_follow_up(uint8_t *work);
456void protocore_ptp_compute(uint8_t *work);
457void protocore_ptp_compute_link_delay(uint8_t *work);
463static const PtpNs Ptp __attribute__((unused)) = {
464 .ts_write = protocore_ptp_ts_write,
465 .ts_read = protocore_ptp_ts_read,
466 .ts_to_ns = protocore_ptp_ts_to_ns,
467 .ts_from_ns = protocore_ptp_ts_from_ns,
468 .build_header = protocore_ptp_build_header,
469 .parse_header = protocore_ptp_parse_header,
470 .build_sync = protocore_ptp_build_sync,
471 .build_delay_req = protocore_ptp_build_delay_req,
472 .build_follow_up = protocore_ptp_build_follow_up,
473 .build_delay_resp = protocore_ptp_build_delay_resp,
474 .build_announce = protocore_ptp_build_announce,
475 .build_pdelay_req = protocore_ptp_build_pdelay_req,
476 .build_pdelay_resp = protocore_ptp_build_pdelay_resp,
477 .build_pdelay_resp_follow_up = protocore_ptp_build_pdelay_resp_follow_up,
478 .parse_timestamp_msg = protocore_ptp_parse_timestamp_msg,
479 .parse_delay_resp = protocore_ptp_parse_delay_resp,
480 .parse_announce = protocore_ptp_parse_announce,
481 .parse_pdelay_req = protocore_ptp_parse_pdelay_req,
482 .parse_pdelay_resp = protocore_ptp_parse_pdelay_resp,
483 .parse_pdelay_resp_follow_up = protocore_ptp_parse_pdelay_resp_follow_up,
484 .compute = protocore_ptp_compute,
485 .compute_link_delay = protocore_ptp_compute_link_delay,
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS