From 2dadfb3971aacc81d6433ce0be3e9665b265fa7c Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 29 Mar 2021 15:36:34 +0100 Subject: [PATCH] Add definition of an announce message. debug_print incoming messages --- nqptp.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/nqptp.c b/nqptp.c index bc2c016..cde7e46 100644 --- 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)); -- 2.47.3