Correctly handle a negative log message interval.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-07-08 13:24:08 +02:00
parent d7a67e9f89
commit 6ad9af1a25
1 changed files with 7 additions and 1 deletions

8
port.c
View File

@ -111,9 +111,15 @@ static void announce_to_dataset(struct ptp_message *m, struct clock *c,
static int msg_current(struct ptp_message *m, struct timespec now)
{
int64_t t1, t2, tmo;
t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
tmo = 4 * (1 << m->header.logMessageInterval) * NSEC2SEC;
if (m->header.logMessageInterval < 0)
tmo = 4LL * NSEC2SEC / (1 << -m->header.logMessageInterval);
else
tmo = 4LL * (1 << m->header.logMessageInterval) * NSEC2SEC;
return t2 - t1 < tmo;
}