]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
Add definition of an announce message. debug_print incoming messages
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Mon, 29 Mar 2021 14:36:34 +0000 (15:36 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Mon, 29 Mar 2021 14:36:34 +0000 (15:36 +0100)
nqptp.c

diff --git a/nqptp.c b/nqptp.c
index bc2c0162ab82efecd2b3748f3d01a4efd0b92c5b..cde7e461aaad006a450cd4d5814e57da43b9ba22 100644 (file)
--- a/nqptp.c
+++ b/nqptp.c
@@ -19,7 +19,7 @@
 
 // 0 means no debug messages. 3 means lots!
 
-#define DEBUG_LEVEL 0
+#define DEBUG_LEVEL 2
 
 #include "debug.h"
 #include "nqptp-shm-structures.h"
@@ -521,6 +521,19 @@ int main(void) {
     uint8_t logMessagePeriod;    // 0
   };
 
+  // this is the extra part for an Announce message
+  struct __attribute__((__packed__)) ptp_announce {
+    uint8_t originTimestamp[10];
+    uint16_t currentUtcOffset;
+    uint8_t reserved1;
+    uint8_t grandmasterPriority1;
+    uint32_t grandmasterClockQuality;
+    uint8_t grandmasterPriority2;
+    uint8_t grandmasterIdentity[8];
+    uint16_t stepsRemoved;
+    uint8_t timeSource;
+  };
+
   // this is the extra part for a Sync or Delay_Req message
   struct __attribute__((__packed__)) ptp_sync {
     uint8_t originTimestamp[10];
@@ -562,6 +575,11 @@ int main(void) {
     struct ptp_delay_resp delay_resp;
   };
 
+  struct __attribute__((__packed__)) ptp_announce_message {
+    struct ptp_common_message_header header;
+    struct ptp_announce announce;
+  };
+
   pthread_mutexattr_t shared;
   int err;
 
@@ -939,6 +957,9 @@ int main(void) {
             //              if ((sender_port == sockets[t].port) && (connection_ip_family ==
             //              AF_INET)) {
             if (sender_port == sockets[t].port) {
+
+              debug_print_buffer(1, buf, recv_len);
+
               char sender_string[256];
               memset(sender_string, 0, sizeof(sender_string));
               inet_ntop(connection_ip_family, sender_addr, sender_string, sizeof(sender_string));