From 7f59858d082acfcfe944350d6411c959efaad0e5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 12 Mar 2018 12:36:31 +0000 Subject: [PATCH] msg: Represent hw_timestamp "sw" field as tmv_t Convert a software timestamp to the internal tmv_t representation at the earliest possible opportunity, to match the behaviour for hardware timestamps. Signed-off-by: Michael Brown --- msg.h | 3 ++- port.c | 4 ++-- sk.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/msg.h b/msg.h index cd07c55..5da50e1 100644 --- a/msg.h +++ b/msg.h @@ -27,6 +27,7 @@ #include "address.h" #include "ddt.h" #include "tlv.h" +#include "tmv.h" #define PTP_VERSION 2 @@ -65,7 +66,7 @@ enum timestamp_type { struct hw_timestamp { enum timestamp_type type; tmv_t ts; - struct timespec sw; + tmv_t sw; }; enum controlField { diff --git a/port.c b/port.c index 08eb363..17ae5cd 100644 --- a/port.c +++ b/port.c @@ -555,8 +555,8 @@ static void free_foreign_masters(struct port *p) static int fup_sync_ok(struct ptp_message *fup, struct ptp_message *sync) { int64_t tfup, tsync; - tfup = tmv_to_nanoseconds(timespec_to_tmv(fup->hwts.sw)); - tsync = tmv_to_nanoseconds(timespec_to_tmv(sync->hwts.sw)); + tfup = tmv_to_nanoseconds(fup->hwts.sw); + tsync = tmv_to_nanoseconds(sync->hwts.sw); /* * NB - If the sk_check_fupsync option is not enabled, then * both of these time stamps will be zero. diff --git a/sk.c b/sk.c index a1a695e..72926ab 100644 --- a/sk.c +++ b/sk.c @@ -341,7 +341,7 @@ int sk_receive(int fd, void *buf, int buflen, return -1; } sw = (struct timespec *) CMSG_DATA(cm); - hwts->sw = *sw; + hwts->sw = timespec_to_tmv(*sw); } }