Warn loudly whenever event messages are missing time stamps.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-03-11 09:53:28 +01:00
parent a9e88a0a49
commit 51162c01af
2 changed files with 35 additions and 0 deletions

28
msg.c
View File

@ -23,6 +23,7 @@
#include <asm/byteorder.h>
#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;
}

7
msg.h
View File

@ -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.