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 <yangbo...@nxp.com>
---
Changes for v2:
        - Made v2.1 as macros.
---
 msg.c | 5 +----
 msg.h | 9 +++++++--
 2 files changed, 8 insertions(+), 6 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;
-- 
2.25.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to