Use the management message memory layout for the timePropertiesDS.

Reforming the data structure in this way will greatly simplify the
implementation of the management message for this data set.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-12-02 11:24:31 +01:00
parent 61e1861e27
commit aa6708d09a
3 changed files with 12 additions and 34 deletions

24
clock.c
View File

@ -331,12 +331,11 @@ static void clock_update_grandmaster(struct clock *c)
pds->grandmasterPriority2 = c->dds.priority2;
c->dad.path_length = 0;
c->tds.currentUtcOffset = CURRENT_UTC_OFFSET;
c->tds.currentUtcOffsetValid = FALSE;
c->tds.leap61 = FALSE;
c->tds.leap59 = FALSE;
c->tds.timeTraceable = FALSE;
c->tds.frequencyTraceable = FALSE;
c->tds.ptpTimescale = c->utc_timescale ? FALSE : TRUE;
if (c->utc_timescale) {
c->tds.flags = 0;
} else {
c->tds.flags = PTP_TIMESCALE;
}
c->tds.timeSource = INTERNAL_OSCILLATOR;
}
@ -351,14 +350,9 @@ static void clock_update_slave(struct clock *c)
pds->grandmasterPriority1 = msg->announce.grandmasterPriority1;
pds->grandmasterPriority2 = msg->announce.grandmasterPriority2;
c->tds.currentUtcOffset = msg->announce.currentUtcOffset;
c->tds.currentUtcOffsetValid = field_is_set(msg, 1, UTC_OFF_VALID);
c->tds.leap61 = field_is_set(msg, 1, LEAP_61);
c->tds.leap59 = field_is_set(msg, 1, LEAP_59);
c->tds.timeTraceable = field_is_set(msg, 1, TIME_TRACEABLE);
c->tds.frequencyTraceable = field_is_set(msg, 1, FREQ_TRACEABLE);
c->tds.ptpTimescale = field_is_set(msg, 1, PTP_TIMESCALE);
c->tds.flags = msg->header.flagField[1];
c->tds.timeSource = msg->announce.timeSource;
if (!c->tds.ptpTimescale) {
if (!(c->tds.flags & PTP_TIMESCALE)) {
pr_warning("foreign master not using PTP timescale");
}
if (c->tds.currentUtcOffset < CURRENT_UTC_OFFSET) {
@ -371,9 +365,9 @@ static void clock_utc_correct(struct clock *c)
struct timespec offset;
if (!c->utc_timescale)
return;
if (!c->tds.ptpTimescale)
if (!(c->tds.flags & PTP_TIMESCALE))
return;
if (c->tds.currentUtcOffsetValid && c->tds.timeTraceable) {
if (c->tds.flags & UTC_OFF_VALID && c->tds.flags & TIME_TRACEABLE) {
offset.tv_sec = c->tds.currentUtcOffset;
} else if (c->tds.currentUtcOffset > CURRENT_UTC_OFFSET) {
offset.tv_sec = c->tds.currentUtcOffset;

9
ds.h
View File

@ -84,14 +84,9 @@ struct parent_ds {
struct timePropertiesDS {
Integer16 currentUtcOffset;
Boolean leap61;
Boolean leap59;
Boolean currentUtcOffsetValid;
Boolean ptpTimescale;
Boolean timeTraceable;
Boolean frequencyTraceable;
UInteger8 flags;
Enumeration8 timeSource;
};
} PACKED;
struct port_defaults {
Integer8 logAnnounceInterval;

13
port.c
View File

@ -669,18 +669,7 @@ static int port_tx_announce(struct port *p)
msg->header.control = CTL_OTHER;
msg->header.logMessageInterval = p->logAnnounceInterval;
if (tp->leap61)
msg->header.flagField[1] |= LEAP_61;
if (tp->leap59)
msg->header.flagField[1] |= LEAP_59;
if (tp->currentUtcOffsetValid)
msg->header.flagField[1] |= UTC_OFF_VALID;
if (tp->ptpTimescale)
msg->header.flagField[1] |= PTP_TIMESCALE;
if (tp->timeTraceable)
msg->header.flagField[1] |= TIME_TRACEABLE;
if (tp->frequencyTraceable)
msg->header.flagField[1] |= FREQ_TRACEABLE;
msg->header.flagField[1] = tp->flags;
msg->announce.currentUtcOffset = tp->currentUtcOffset;
msg->announce.grandmasterPriority1 = dad->pds.grandmasterPriority1;