Introduce a helper function to identify valid (non-zero) time stamps.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2014-12-05 23:44:38 +01:00
parent 4fb0346520
commit b295df24b5
2 changed files with 11 additions and 1 deletions

2
msg.c
View File

@ -468,5 +468,5 @@ int msg_sots_missing(struct ptp_message *m)
default: default:
return 0; return 0;
} }
return (!m->hwts.ts.tv_sec && !m->hwts.ts.tv_nsec) ? 1 : 0; return msg_sots_valid(m) ? 0 : 1;
} }

10
msg.h
View File

@ -338,6 +338,16 @@ void msg_put(struct ptp_message *m);
*/ */
int msg_sots_missing(struct ptp_message *m); int msg_sots_missing(struct ptp_message *m);
/**
* Test whether a message has a valid SO_TIMESTAMPING time stamp.
* @param m Message to test.
* @return One if the message has a valid time stamp, zero otherwise.
*/
static inline int msg_sots_valid(struct ptp_message *m)
{
return (m->hwts.ts.tv_sec || m->hwts.ts.tv_nsec) ? 1 : 0;
}
/** /**
* Work around buggy 802.1AS switches. * Work around buggy 802.1AS switches.
*/ */