From: Miroslav Lichvar Date: Thu, 20 Jun 2024 07:31:31 +0000 (+0200) Subject: ntp: update NTP-over-PTP support X-Git-Tag: 4.6-pre1~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c46e0549ab7ea42dd3832281915478354a5d096b;p=thirdparty%2Fchrony.git ntp: update NTP-over-PTP support Following the latest version of the draft, accept NTP messages in both PTPv2 and PTPv2.1 messages, accept sync messages in addition to delay request messages, and check the minorSdoId field in PTPv2.1 messages. Transmitted messages are still PTPv2 delay requests. Don't switch to the organization-specific TLV yet. Wait for the NTP TLV subtype and Network Correction extension field to be assigned by IANA to avoid an additional break in compatibility. --- diff --git a/ntp_io.c b/ntp_io.c index ec2fd7b4..fc80aca2 100644 --- a/ntp_io.c +++ b/ntp_io.c @@ -513,7 +513,9 @@ NIO_UnwrapMessage(SCK_Message *message, int sock_fd, double *net_correction) msg = message->data; - if (msg->header.type != PTP_TYPE_DELAY_REQ || msg->header.version != PTP_VERSION || + if ((msg->header.type != PTP_TYPE_DELAY_REQ && msg->header.type != PTP_TYPE_SYNC) || + (msg->header.version != PTP_VERSION_2 && + (msg->header.version != PTP_VERSION_2_1 || msg->header.min_sdoid != 0)) || ntohs(msg->header.length) != message->length || msg->header.domain != PTP_DOMAIN_NTP || ntohs(msg->header.flags) != PTP_FLAG_UNICAST || @@ -561,7 +563,7 @@ wrap_message(SCK_Message *message, int sock_fd) memset(ptp_message, 0, PTP_NTP_PREFIX_LENGTH); ptp_message->header.type = PTP_TYPE_DELAY_REQ; - ptp_message->header.version = PTP_VERSION; + ptp_message->header.version = PTP_VERSION_2; ptp_message->header.length = htons(PTP_NTP_PREFIX_LENGTH + message->length); ptp_message->header.domain = PTP_DOMAIN_NTP; ptp_message->header.flags = htons(PTP_FLAG_UNICAST); diff --git a/ptp.h b/ptp.h index 8034a2c6..4330f4b3 100644 --- a/ptp.h +++ b/ptp.h @@ -31,7 +31,9 @@ #include "ntp.h" -#define PTP_VERSION 2 +#define PTP_VERSION_2 2 +#define PTP_VERSION_2_1 (2 | 1 << 4) +#define PTP_TYPE_SYNC 0 #define PTP_TYPE_DELAY_REQ 1 #define PTP_DOMAIN_NTP 123 #define PTP_FLAG_UNICAST (1 << (2 + 8))