From 755f2e84f382a61e1b3ffe1b8e5f3bf02f359a46 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 11 Aug 2021 11:50:07 +0200 Subject: [PATCH] Use 64 bit clock to prevent overflows Large offsets between nodes may overflow the previous 48 bit clock leading to an incorrect reconstructed clock value after the correction with the 64 bit offset. --- ovni.c | 8 ++------ ovni.h | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ovni.c b/ovni.c index dabcf29..f009b58 100644 --- a/ovni.c +++ b/ovni.c @@ -389,17 +389,13 @@ flush_evbuf() static void ovni_ev_set_clock(struct ovni_ev *ev) { - ev->header.clock_lo = (uint32_t) (rthread.clockvalue & 0xffffffff); - ev->header.clock_hi = (uint16_t) ((rthread.clockvalue >> 32) & 0xffff); + ev->header.clock = rthread.clockvalue; } uint64_t ovni_ev_get_clock(struct ovni_ev *ev) { - uint64_t clock; - - clock = ((uint64_t) ev->header.clock_hi) << 32 | ((uint64_t) ev->header.clock_lo); - return clock; + return ev->header.clock; } void diff --git a/ovni.h b/ovni.h index add2527..8bf666b 100644 --- a/ovni.h +++ b/ovni.h @@ -52,8 +52,7 @@ struct __attribute__((__packed__)) ovni_ev_header { uint8_t model; uint8_t class; uint8_t value; - uint32_t clock_lo; - uint16_t clock_hi; + uint64_t clock; }; struct __attribute__((__packed__)) ovni_ev {