[mle] add Status TLV check in Child Update Request and Response (#2243)

This commit is contained in:
jciupis
2017-10-10 08:42:45 -07:00
committed by Jonathan Hui
parent 3564bae6d2
commit 41e498a71c
2 changed files with 32 additions and 0 deletions
+18
View File
@@ -2846,10 +2846,12 @@ otError Mle::HandleChildUpdateRequest(const Message &aMessage, const Ip6::Messag
static const uint8_t kMaxResponseTlvs = 5;
otError error = OT_ERROR_NONE;
Mac::ExtAddress srcAddr;
SourceAddressTlv sourceAddress;
LeaderDataTlv leaderData;
NetworkDataTlv networkData;
ChallengeTlv challenge;
StatusTlv status;
TlvRequestTlv tlvRequest;
uint8_t tlvs[kMaxResponseTlvs] = {};
uint8_t numTlvs = 0;
@@ -2865,6 +2867,22 @@ otError Mle::HandleChildUpdateRequest(const Message &aMessage, const Ip6::Messag
// Leader Data, Network Data, Active Timestamp, Pending Timestamp
SuccessOrExit(error = HandleLeaderData(aMessage, aMessageInfo));
// Status
if (Tlv::GetTlv(aMessage, Tlv::kStatus, sizeof(status), status) == OT_ERROR_NONE)
{
VerifyOrExit(status.IsValid(), error = OT_ERROR_PARSE);
aMessageInfo.GetPeerAddr().ToExtAddress(srcAddr);
VerifyOrExit((memcmp(&mParent.GetExtAddress(), &srcAddr, sizeof(srcAddr)) == 0),
error = OT_ERROR_DROP);
if (status.GetStatus() == StatusTlv::kError)
{
BecomeDetached();
ExitNow();
}
}
// TLV Request
if (Tlv::GetTlv(aMessage, Tlv::kTlvRequest, sizeof(tlvRequest), tlvRequest) == OT_ERROR_NONE)
{
+14
View File
@@ -2417,6 +2417,7 @@ otError MleRouter::HandleChildUpdateResponse(const Message &aMessage, const Ip6:
TimeoutTlv timeout;
AddressRegistrationTlv address;
ResponseTlv response;
StatusTlv status;
LinkFrameCounterTlv linkFrameCounter;
MleFrameCounterTlv mleFrameCounter;
LeaderDataTlv leaderData;
@@ -2456,6 +2457,19 @@ otError MleRouter::HandleChildUpdateResponse(const Message &aMessage, const Ip6:
error = OT_ERROR_SECURITY);
}
// Status
if (Tlv::GetTlv(aMessage, Tlv::kStatus, sizeof(status), status) == OT_ERROR_NONE)
{
VerifyOrExit(status.IsValid(), error = OT_ERROR_PARSE);
if (status.GetStatus() == StatusTlv::kError)
{
RemoveStoredChild(child->GetRloc16());
child->SetState(Neighbor::kStateInvalid);
ExitNow();
}
}
// Link-Layer Frame Counter
if (Tlv::GetTlv(aMessage, Tlv::kLinkFrameCounter, sizeof(linkFrameCounter), linkFrameCounter) == OT_ERROR_NONE)
{