/** * @brief Builds the FollowUpTLV interface */ FollowUpTLV() { tlvType = PLAT_htons(0x3); lengthField = PLAT_htons(28); organizationId[0] = '\x00'; organizationId[1] = '\x80'; organizationId[2] = '\xC2'; organizationSubType_ms = 0; organizationSubType_ls = PLAT_htons(1); cumulativeScaledRateOffset = PLAT_htonl(0); gmTimeBaseIndicator = 0; scaledLastGmFreqChange = PLAT_htonl(0); }
/** * @brief Builds the Signalling Msg Interval Request TLV interface */ SignallingTLV() { tlvType = PLAT_htons(0x3); lengthField = PLAT_htons(12); organizationId[0] = '\x00'; organizationId[1] = '\x80'; organizationId[2] = '\xC2'; organizationSubType_ms = 0; organizationSubType_ls = PLAT_htons(2); linkDelayInterval = 0; timeSyncInterval = 0; announceInterval = 0; flags = 3; reserved = PLAT_htons(0); }
bool IEEE1588Clock::isBetterThan(PTPMessageAnnounce * msg) { unsigned char this1[14]; unsigned char that1[14]; uint16_t tmp; this1[0] = priority1; that1[0] = msg->getGrandmasterPriority1(); this1[1] = clock_quality.cq_class; that1[1] = msg->getGrandmasterClockQuality()->cq_class; this1[2] = clock_quality.clockAccuracy; that1[2] = msg->getGrandmasterClockQuality()->clockAccuracy; tmp = clock_quality.offsetScaledLogVariance; tmp = PLAT_htons(tmp); memcpy(this1 + 3, &tmp, sizeof(tmp)); tmp = msg->getGrandmasterClockQuality()->offsetScaledLogVariance; tmp = PLAT_htons(tmp); memcpy(that1 + 3, &tmp, sizeof(tmp)); this1[5] = priority2; that1[5] = msg->getGrandmasterPriority2(); clock_identity.getIdentityString((char *)this1 + 6); //memcpy( this1+6, clock_identity, PTP_CLOCK_IDENTITY_LENGTH ); msg->getGrandmasterIdentity((char *)that1 + 6); #if 0 fprintf(stderr, "(Clk)Us: "); for (int i = 0; i < 14; ++i) fprintf(stderr, "%hhx ", this1[i]); fprintf(stderr, "\n"); fprintf(stderr, "(Clk)Them: "); for (int i = 0; i < 14; ++i) fprintf(stderr, "%hhx ", that1[i]); fprintf(stderr, "\n"); #endif return (memcmp(this1, that1, 14) < 0) ? true : false; }
/** * @brief Gets TLV value in a byte string format * @param byte_str [out] Output byte string * @return void */ void toByteString(uint8_t * byte_str) { IdentityList::iterator iter; *((uint16_t *)byte_str) = tlvType; // tlvType already in network byte order byte_str += sizeof(tlvType); *((uint16_t *)byte_str) = PLAT_htons ((uint16_t)identityList.size()*PTP_CLOCK_IDENTITY_LENGTH); byte_str += sizeof(uint16_t); for (iter = identityList.begin(); iter != identityList.end(); ++iter) { iter->getIdentityString(byte_str); byte_str += PTP_CLOCK_IDENTITY_LENGTH; } }
/** * @brief Gets the port number following the network byte order, i.e. * Big-Endian. * @param id [out] Port number * @return void */ void getPortNumberNO(uint16_t * id) // Network byte order { uint16_t portNumberNO = PLAT_htons(portNumber); *id = portNumberNO; }
/** * @brief Creates the PathTraceTLV interface. * Sets tlvType to PATH_TRACE_TLV_TYPE using network byte order */ PathTraceTLV() { tlvType = PLAT_htons(PATH_TRACE_TLV_TYPE); }