Changes for v2:
- Made v2.1 as macros.
Changes for v3:
- Fixed pmc versionNumber printing issue.
> -----Original Message-----
> From: Yangbo Lu <[email protected]>
> Sent: Monday, March 1, 2021 11:41 AM
> To: [email protected]
> Cc: Y.b. Lu <[email protected]>
> Subject: [v3] Bump to IEEE 1588-2019 version
>
> IEEE 1588-2019 specified new UInteger4 type minorVersionPTP field
> in header, and minorVersionNumber data in portDS. It has the value
> 1 for IEEE 1588-2019, and has the value 0 for IEEE 1588-2008.
>
> This patch is to bump to IEEE 1588-2019 version directly in message,
> considering v2.1 and even future v2.x are all backward compatible.
>
> Signed-off-by: Yangbo Lu <[email protected]>
> ---
> msg.c | 5 +----
> msg.h | 9 +++++++--
> pmc.c | 6 ++++--
> 3 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/msg.c b/msg.c
> index d1619d4..c4516ad 100644
> --- a/msg.c
> +++ b/msg.c
> @@ -27,9 +27,6 @@
> #include "print.h"
> #include "tlv.h"
>
> -#define VERSION_MASK 0x0f
> -#define VERSION 0x02
> -
> int assume_two_step = 0;
>
> /*
> @@ -80,7 +77,7 @@ static void announce_post_recv(struct announce_msg
> *m)
>
> static int hdr_post_recv(struct ptp_header *m)
> {
> - if ((m->ver & VERSION_MASK) != VERSION)
> + if ((m->ver & MAJOR_VERSION_MASK) != PTP_MAJOR_VERSION)
> return -EPROTO;
> m->messageLength = ntohs(m->messageLength);
> m->correction = net2host64(m->correction);
> diff --git a/msg.h b/msg.h
> index a71df16..b7423ee 100644
> --- a/msg.h
> +++ b/msg.h
> @@ -30,7 +30,12 @@
> #include "tlv.h"
> #include "tmv.h"
>
> -#define PTP_VERSION 2
> +/* Version definition for IEEE 1588-2019 */
> +#define PTP_MAJOR_VERSION 2
> +#define PTP_MINOR_VERSION 1
> +#define PTP_VERSION (PTP_MINOR_VERSION << 4 |
> PTP_MAJOR_VERSION)
> +
> +#define MAJOR_VERSION_MASK 0x0f
>
> /* Values for the messageType field */
> #define SYNC 0x0
> @@ -89,7 +94,7 @@ enum controlField {
>
> struct ptp_header {
> uint8_t tsmt; /* transportSpecific | messageType */
> - uint8_t ver; /* reserved | versionPTP */
> + uint8_t ver; /* minorVersionPTP | versionPTP */
> UInteger16 messageLength;
> UInteger8 domainNumber;
> Octet reserved1;
> diff --git a/pmc.c b/pmc.c
> index 3678800..ea2af3f 100644
> --- a/pmc.c
> +++ b/pmc.c
> @@ -413,12 +413,14 @@ static void pmc_show(struct ptp_message *msg,
> FILE *fp)
> IFMT "logSyncInterval %hhd"
> IFMT "delayMechanism %hhu"
> IFMT "logMinPdelayReqInterval %hhd"
> - IFMT "versionNumber %hhu",
> + IFMT "versionNumber %u.%u",
> pid2str(&p->portIdentity), ps_str[p->portState],
> p->logMinDelayReqInterval, p->peerMeanPathDelay >> 16,
> p->logAnnounceInterval, p->announceReceiptTimeout,
> p->logSyncInterval, p->delayMechanism,
> - p->logMinPdelayReqInterval, p->versionNumber);
> + p->logMinPdelayReqInterval,
> + p->versionNumber & MAJOR_VERSION_MASK,
> + p->versionNumber >> 4);
> break;
> case TLV_PORT_DATA_SET_NP:
> pnp = (struct port_ds_np *) mgt->data;
> --
> 2.25.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel