/* compare portIdentity to an empty one */ Boolean portIdentityEmpty(PortIdentity *portIdentity) { PortIdentity zero; memset(&zero, 0, sizeof(PortIdentity)); if (!cmpPortIdentity(portIdentity, &zero)) { return TRUE; } return FALSE; }
/* compare portIdentity to all ones port identity */ Boolean portIdentityAllOnes(PortIdentity *portIdentity) { PortIdentity allOnes; memset(&allOnes, 0xFF, sizeof(PortIdentity)); if (!cmpPortIdentity(portIdentity, &allOnes)) { return TRUE; } return FALSE; }
/*Local clock is synchronized to Ebest Table 16 (9.3.5) of the spec*/ void s1(MsgHeader *header,MsgAnnounce *announce,PtpClock *ptpClock, const RunTimeOpts *rtOpts) { Boolean firstUpdate = !cmpPortIdentity(&ptpClock->parentDS.parentPortIdentity, &ptpClock->portDS.portIdentity); TimePropertiesDS tpPrevious = ptpClock->timePropertiesDS; Boolean previousLeap59 = FALSE; Boolean previousLeap61 = FALSE; Boolean leapChange = FALSE; Integer16 previousUtcOffset = 0; previousLeap59 = ptpClock->timePropertiesDS.leap59; previousLeap61 = ptpClock->timePropertiesDS.leap61; previousUtcOffset = ptpClock->timePropertiesDS.currentUtcOffset; /* Current DS */ ptpClock->currentDS.stepsRemoved = announce->stepsRemoved + 1; /* Parent DS */ copyClockIdentity(ptpClock->parentDS.parentPortIdentity.clockIdentity, header->sourcePortIdentity.clockIdentity); ptpClock->parentDS.parentPortIdentity.portNumber = header->sourcePortIdentity.portNumber; copyClockIdentity(ptpClock->parentDS.grandmasterIdentity, announce->grandmasterIdentity); ptpClock->parentDS.grandmasterClockQuality.clockAccuracy = announce->grandmasterClockQuality.clockAccuracy; ptpClock->parentDS.grandmasterClockQuality.clockClass = announce->grandmasterClockQuality.clockClass; ptpClock->parentDS.grandmasterClockQuality.offsetScaledLogVariance = announce->grandmasterClockQuality.offsetScaledLogVariance; ptpClock->parentDS.grandmasterPriority1 = announce->grandmasterPriority1; ptpClock->parentDS.grandmasterPriority2 = announce->grandmasterPriority2; /* use the granted interval if using signaling, otherwise we would try to arm a timer for 2^127! */ if(rtOpts->unicastNegotiation && ptpClock->parentGrants != NULL && ptpClock->parentGrants->grantData[ANNOUNCE_INDEXED].granted) { ptpClock->portDS.logAnnounceInterval = ptpClock->parentGrants->grantData[ANNOUNCE_INDEXED].logInterval; } else if (header->logMessageInterval != UNICAST_MESSAGEINTERVAL) { ptpClock->portDS.logAnnounceInterval = header->logMessageInterval; } /* Timeproperties DS */ ptpClock->timePropertiesDS.currentUtcOffset = announce->currentUtcOffset; if (ptpClock->portDS.portState != PTP_PASSIVE && ptpClock->timePropertiesDS.currentUtcOffsetValid && !IS_SET(header->flagField1, UTCV)) { if(rtOpts->alwaysRespectUtcOffset) WARNING("UTC Offset no longer valid and ptpengine:always_respect_utc_offset is set: continuing as normal\n"); else WARNING("UTC Offset no longer valid - clock jump expected\n"); } /* "Valid" is bit 2 in second octet of flagfield */ ptpClock->timePropertiesDS.currentUtcOffsetValid = IS_SET(header->flagField1, UTCV); /* set PTP_PASSIVE-specific state */ p1(ptpClock, rtOpts); /* only set leap flags in slave state - info from leap file takes priority*/ if (ptpClock->portDS.portState == PTP_SLAVE) { if(ptpClock->clockStatus.override) { ptpClock->timePropertiesDS.currentUtcOffset = ptpClock->clockStatus.utcOffset; ptpClock->timePropertiesDS.leap59 = ptpClock->clockStatus.leapDelete; ptpClock->timePropertiesDS.leap61 = ptpClock->clockStatus.leapInsert; } else { ptpClock->timePropertiesDS.leap59 = IS_SET(header->flagField1, LI59); ptpClock->timePropertiesDS.leap61 = IS_SET(header->flagField1, LI61); } }