diff --git a/port.c b/port.c index 3984b78..ef2686d 100644 --- a/port.c +++ b/port.c @@ -163,10 +163,15 @@ static int msg_current(struct ptp_message *m, struct timespec now) t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec; t2 = now.tv_sec * NSEC2SEC + now.tv_nsec; - if (m->header.logMessageInterval < 0) + if (m->header.logMessageInterval < -63) { + tmo = 0; + } else if (m->header.logMessageInterval > 31) { + tmo = INT64_MAX; + } else if (m->header.logMessageInterval < 0) { tmo = 4LL * NSEC2SEC / (1 << -m->header.logMessageInterval); - else + } else { tmo = 4LL * (1 << m->header.logMessageInterval) * NSEC2SEC; + } return t2 - t1 < tmo; }