mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 16:17:47 +00:00
Include timestamp tlv in Child ID Response only when it is necessary (#794)
This commit is contained in:
+14
-21
@@ -936,12 +936,15 @@ exit:
|
||||
|
||||
ThreadError Mle::AppendActiveTimestamp(Message &aMessage)
|
||||
{
|
||||
ThreadError error;
|
||||
ActiveTimestampTlv timestampTlv;
|
||||
const MeshCoP::Timestamp *timestamp(mNetif.GetActiveDataset().GetNetwork().GetTimestamp());
|
||||
|
||||
VerifyOrExit(timestamp || mDeviceState == kDeviceStateLeader, error = kThreadError_None);
|
||||
|
||||
timestampTlv.Init();
|
||||
|
||||
// set active timestamp to 0 if there is no valid active operational dataset
|
||||
// only for Leader: set active timestamp to 0 if it is not initialized
|
||||
if (timestamp == NULL)
|
||||
{
|
||||
timestampTlv.SetSeconds(0);
|
||||
@@ -952,7 +955,10 @@ ThreadError Mle::AppendActiveTimestamp(Message &aMessage)
|
||||
*static_cast<MeshCoP::Timestamp *>(×tampTlv) = *timestamp;
|
||||
}
|
||||
|
||||
return aMessage.Append(×tampTlv, sizeof(timestampTlv));
|
||||
error = aMessage.Append(×tampTlv, sizeof(timestampTlv));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError Mle::AppendPendingTimestamp(Message &aMessage)
|
||||
@@ -1807,13 +1813,11 @@ ThreadError Mle::HandleDataResponse(const Message &aMessage, const Ip6::MessageI
|
||||
VerifyOrExit(networkData.IsValid(), error = kThreadError_Parse);
|
||||
|
||||
// Active Timestamp
|
||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kActiveTimestamp, sizeof(activeTimestamp), activeTimestamp));
|
||||
VerifyOrExit(activeTimestamp.IsValid(), error = kThreadError_Parse);
|
||||
|
||||
if (activeTimestamp.GetSeconds() != 0)
|
||||
if (Tlv::GetTlv(aMessage, Tlv::kActiveTimestamp, sizeof(activeTimestamp), activeTimestamp) == kThreadError_None)
|
||||
{
|
||||
const MeshCoP::Timestamp *timestamp;
|
||||
|
||||
VerifyOrExit(activeTimestamp.IsValid(), error = kThreadError_Parse);
|
||||
timestamp = mNetif.GetActiveDataset().GetNetwork().GetTimestamp();
|
||||
|
||||
// if received timestamp does not match the local value and message does not contain the dataset,
|
||||
@@ -2112,18 +2116,11 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
|
||||
{
|
||||
VerifyOrExit(activeTimestamp.IsValid(), error = kThreadError_Parse);
|
||||
|
||||
if (activeTimestamp.GetSeconds() != 0)
|
||||
// Active Dataset
|
||||
if (Tlv::GetOffset(aMessage, Tlv::kActiveDataset, offset) == kThreadError_None)
|
||||
{
|
||||
// Active Dataset
|
||||
if (Tlv::GetOffset(aMessage, Tlv::kActiveDataset, offset) == kThreadError_None)
|
||||
{
|
||||
aMessage.Read(offset, sizeof(tlv), &tlv);
|
||||
mNetif.GetActiveDataset().Set(activeTimestamp, aMessage, offset + sizeof(tlv), tlv.GetLength());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetif.GetActiveDataset().Clear();
|
||||
aMessage.Read(offset, sizeof(tlv), &tlv);
|
||||
mNetif.GetActiveDataset().Set(activeTimestamp, aMessage, offset + sizeof(tlv), tlv.GetLength());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2139,10 +2136,6 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
|
||||
mNetif.GetPendingDataset().Set(pendingTimestamp, aMessage, offset + sizeof(tlv), tlv.GetLength());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mNetif.GetPendingDataset().Clear();
|
||||
}
|
||||
|
||||
// Parent Attach Success
|
||||
mParentRequestTimer.Stop();
|
||||
|
||||
Reference in New Issue
Block a user