From eeb0dc2390de7c4170a3806d1d9a6a834a0f12aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Inostroza?= Date: Sat, 2 Dec 2017 16:43:52 -0300 Subject: [PATCH] Fix style and add reference to timestamps struct offset. --- candump.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/candump.c b/candump.c index 2f3f76d..76262bf 100644 --- a/candump.c +++ b/candump.c @@ -713,11 +713,13 @@ int main(int argc, char **argv) struct timespec *stamp = (struct timespec *)CMSG_DATA(cmsg); - stamp += 2; - tv.tv_sec = stamp->tv_sec; - tv.tv_usec = stamp->tv_nsec/1000; - } - else if (cmsg->cmsg_type == SO_RXQ_OVFL) + // stamp[0] is the software timestamp + // stamp[1] is deprecated + // stamp[2] is the raw hardware timestamp + // See 2.1.2 in doc/Documentation/networking/timestamping.txt + tv.tv_sec = stamp[2].tv_sec; + tv.tv_usec = stamp[2].tv_nsec/1000; + } else if (cmsg->cmsg_type == SO_RXQ_OVFL) memcpy(&dropcnt[i], CMSG_DATA(cmsg), sizeof(__u32)); }