From 51162c01af842a9aa6856b8205d9e0b0a5c2eff7 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 11 Mar 2012 09:53:28 +0100 Subject: [PATCH] Warn loudly whenever event messages are missing time stamps. Signed-off-by: Richard Cochran --- msg.c | 28 ++++++++++++++++++++++++++++ msg.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/msg.c b/msg.c index e51bcbe..b3e5bf1 100644 --- a/msg.c +++ b/msg.c @@ -23,6 +23,7 @@ #include #include "msg.h" +#include "print.h" #define VERSION_MASK 0x0f #define VERSION 0x02 @@ -192,6 +193,12 @@ int msg_post_recv(struct ptp_message *m, int cnt) default: return -1; } + + if (msg_sots_missing(m)) { + pr_err("received %s without timestamp", msg_type_string(type)); + return -1; + } + return 0; } @@ -273,3 +280,24 @@ void msg_put(struct ptp_message *m) if (!m) TAILQ_INSERT_HEAD(&msg_pool, m, list); } + +int msg_sots_missing(struct ptp_message *m) +{ + int type = msg_type(m); + switch (type) { + case SYNC: + case DELAY_REQ: + case PDELAY_REQ: + case PDELAY_RESP: + break; + case FOLLOW_UP: + case DELAY_RESP: + case PDELAY_RESP_FOLLOW_UP: + case ANNOUNCE: + case SIGNALING: + case MANAGEMENT: + default: + return 0; + } + return (!m->hwts.ts.tv_sec && !m->hwts.ts.tv_nsec) ? 1 : 0; +} diff --git a/msg.h b/msg.h index fab5907..89d99e0 100644 --- a/msg.h +++ b/msg.h @@ -236,6 +236,13 @@ void msg_print(struct ptp_message *m, FILE *fp); */ void msg_put(struct ptp_message *m); +/** + * Test whether an event message received a valid SO_TIMESTAMPING time stamp. + * @param m Message to test. + * @return One if the message is an event without a time stamp, zero otherwise. + */ +int msg_sots_missing(struct ptp_message *m); + /** * Test whether a message is one-step message. * @param m Message to test.