Include timestamp TLV (#564)

* Include timestamp TLV
* Keep one copy of timestamp
This commit is contained in:
Lu Wang
2016-09-14 21:13:43 -07:00
committed by Jonathan Hui
parent 8831217615
commit 5c28c02e40
8 changed files with 120 additions and 73 deletions
+6 -6
View File
@@ -896,12 +896,12 @@ ThreadError Mle::AppendActiveTimestamp(Message &aMessage)
{
ThreadError error;
ActiveTimestampTlv timestampTlv;
const MeshCoP::Timestamp &timestamp(mNetif.GetActiveDataset().GetNetwork().GetTimestamp());
const MeshCoP::Timestamp *timestamp(mNetif.GetActiveDataset().GetNetwork().GetTimestamp());
VerifyOrExit(timestamp.GetSeconds() != 0, error = kThreadError_None);
VerifyOrExit(timestamp && timestamp->GetSeconds() != 0, error = kThreadError_None);
timestampTlv.Init();
*static_cast<MeshCoP::Timestamp *>(&timestampTlv) = timestamp;
*static_cast<MeshCoP::Timestamp *>(&timestampTlv) = *timestamp;
error = aMessage.Append(&timestampTlv, sizeof(timestampTlv));
exit:
@@ -912,12 +912,12 @@ ThreadError Mle::AppendPendingTimestamp(Message &aMessage)
{
ThreadError error;
PendingTimestampTlv timestampTlv;
const MeshCoP::Timestamp &timestamp(mNetif.GetPendingDataset().GetNetwork().GetTimestamp());
const MeshCoP::Timestamp *timestamp(mNetif.GetPendingDataset().GetNetwork().GetTimestamp());
VerifyOrExit(timestamp.GetSeconds() != 0, error = kThreadError_None);
VerifyOrExit(timestamp && timestamp->GetSeconds() != 0, error = kThreadError_None);
timestampTlv.Init();
*static_cast<MeshCoP::Timestamp *>(&timestampTlv) = timestamp;
*static_cast<MeshCoP::Timestamp *>(&timestampTlv) = *timestamp;
error = aMessage.Append(&timestampTlv, sizeof(timestampTlv));
exit: