mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 02:17:47 +00:00
[mle] add Status TLV check in Child Update Request and Response (#2243)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user