From edfb5fac849aba0bfb2689c6ca6f3d3091b0a04a Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 7 Aug 2012 09:20:55 +0200 Subject: [PATCH] Add storage fields for the path trace list. Signed-off-by: Richard Cochran --- clock.c | 4 ++++ ds.h | 2 ++ tlv.h | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/clock.c b/clock.c index ab7b9bf..fc44089 100644 --- a/clock.c +++ b/clock.c @@ -49,6 +49,7 @@ struct clock { struct currentDS cur; struct parentDS dad; struct timePropertiesDS tds; + struct ClockIdentity ptl[PATH_TRACE_MAX]; struct foreign_clock *best; struct port *port[MAX_PORTS]; struct pollfd pollfd[MAX_PORTS*N_CLOCK_PFD]; @@ -148,12 +149,14 @@ static void clock_step(clockid_t clkid, int64_t ns) static void clock_update_grandmaster(struct clock *c) { memset(&c->cur, 0, sizeof(c->cur)); + memset(c->ptl, 0, sizeof(c->ptl)); c->dad.parentPortIdentity.clockIdentity = c->dds.clockIdentity; c->dad.parentPortIdentity.portNumber = 0; c->dad.grandmasterIdentity = c->dds.clockIdentity; c->dad.grandmasterClockQuality = c->dds.clockQuality; c->dad.grandmasterPriority1 = c->dds.priority1; c->dad.grandmasterPriority2 = c->dds.priority2; + c->dad.path_length = 0; c->tds.currentUtcOffset = CURRENT_UTC_OFFSET; c->tds.currentUtcOffsetValid = FALSE; c->tds.leap61 = FALSE; @@ -260,6 +263,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, c->dad.parentStats = 0; c->dad.observedParentOffsetScaledLogVariance = 0xffff; c->dad.observedParentClockPhaseChangeRate = 0x7fffffff; + c->dad.ptl = c->ptl; for (i = 0; i < ARRAY_SIZE(c->pollfd); i++) { c->pollfd[i].fd = -1; diff --git a/ds.h b/ds.h index c214c21..1bb8d20 100644 --- a/ds.h +++ b/ds.h @@ -60,6 +60,8 @@ struct parentDS { struct ClockQuality grandmasterClockQuality; UInteger8 grandmasterPriority2; struct ClockIdentity grandmasterIdentity; + struct ClockIdentity *ptl; + unsigned int path_length; }; #define CURRENT_UTC_OFFSET 33 diff --git a/tlv.h b/tlv.h index 5256e3d..b6088d2 100644 --- a/tlv.h +++ b/tlv.h @@ -123,6 +123,21 @@ struct management_error_status { Octet data[0]; } PACKED; +#define PATH_TRACE_MAX \ + ((sizeof(struct message_data) - sizeof(struct announce_msg) - sizeof(struct TLV)) / \ + sizeof(struct ClockIdentity)) + +struct path_trace_tlv { + Enumeration16 type; + UInteger16 length; + struct ClockIdentity cid[0]; +} PACKED; + +static inline unsigned int path_length(struct path_trace_tlv *p) +{ + return p->length / sizeof(struct ClockIdentity); +} + /** * Converts recognized value sub-fields into host byte order. * @param tlv Pointer to a Type Length Value field.