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 <mbrown@fensystems.co.uk>
master
Michael Brown 2018-03-12 12:36:31 +00:00 committed by Richard Cochran
parent 29a99ad513
commit 7f59858d08
3 changed files with 5 additions and 4 deletions

3
msg.h
View File

@ -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 {

4
port.c
View File

@ -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.

2
sk.c
View File

@ -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);
}
}