mirror of
https://github.com/espressif/openthread.git
synced 2026-07-12 15:14:09 +00:00
Fix Commissioning dataset update. (#1363)
This commit is contained in:
committed by
Jonathan Hui
parent
bd161d5750
commit
40ee47b516
@@ -508,6 +508,7 @@ ThreadError Commissioner::SendPetition(void)
|
||||
|
||||
mNetif.GetMle().GetLeaderAloc(*static_cast<Ip6::Address *>(&messageInfo.mPeerAddr));
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetSockAddr(mNetif.GetMle().GetMeshLocal16());
|
||||
SuccessOrExit(error = mNetif.GetCoapClient().SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleLeaderPetitionResponse, this));
|
||||
|
||||
|
||||
@@ -229,20 +229,30 @@ void Leader::HandleCommissioningSet(Coap::Header &aHeader, Message &aMessage, co
|
||||
// verify whether or not MGMT_COMM_SET.req includes at least one valid TLV
|
||||
VerifyOrExit(hasValidTlv, state = MeshCoP::StateTlv::kReject);
|
||||
|
||||
for (MeshCoP::Tlv *cur = reinterpret_cast<MeshCoP::Tlv *>(mTlvs + sizeof(CommissioningDataTlv));
|
||||
cur < reinterpret_cast<MeshCoP::Tlv *>(mTlvs + mLength);
|
||||
cur = cur->GetNext())
|
||||
// Find Commissioning Data TLV
|
||||
for (NetworkDataTlv *netDataTlv = reinterpret_cast<NetworkDataTlv *>(mTlvs);
|
||||
netDataTlv < reinterpret_cast<NetworkDataTlv *>(mTlvs + mLength);
|
||||
netDataTlv = netDataTlv->GetNext())
|
||||
{
|
||||
if (cur->GetType() == MeshCoP::Tlv::kCommissionerSessionId)
|
||||
if (netDataTlv->GetType() == NetworkDataTlv::kTypeCommissioningData)
|
||||
{
|
||||
VerifyOrExit(sessionId ==
|
||||
static_cast<MeshCoP::CommissionerSessionIdTlv *>(cur)->GetCommissionerSessionId(),
|
||||
state = MeshCoP::StateTlv::kReject);
|
||||
}
|
||||
else if (cur->GetType() == MeshCoP::Tlv::kBorderAgentLocator)
|
||||
{
|
||||
memcpy(tlvs + length, reinterpret_cast<uint8_t *>(cur), cur->GetLength() + sizeof(MeshCoP::Tlv));
|
||||
length += (cur->GetLength() + sizeof(MeshCoP::Tlv));
|
||||
// Iterate over MeshCoP TLVs and extract desired data
|
||||
for (MeshCoP::Tlv *cur = reinterpret_cast<MeshCoP::Tlv *>(netDataTlv->GetValue());
|
||||
cur < reinterpret_cast<MeshCoP::Tlv *>(netDataTlv->GetValue() + netDataTlv->GetLength());
|
||||
cur = cur->GetNext())
|
||||
{
|
||||
if (cur->GetType() == MeshCoP::Tlv::kCommissionerSessionId)
|
||||
{
|
||||
VerifyOrExit(sessionId ==
|
||||
static_cast<MeshCoP::CommissionerSessionIdTlv *>(cur)->GetCommissionerSessionId(),
|
||||
state = MeshCoP::StateTlv::kReject);
|
||||
}
|
||||
else if (cur->GetType() == MeshCoP::Tlv::kBorderAgentLocator)
|
||||
{
|
||||
memcpy(tlvs + length, reinterpret_cast<uint8_t *>(cur), cur->GetLength() + sizeof(MeshCoP::Tlv));
|
||||
length += (cur->GetLength() + sizeof(MeshCoP::Tlv));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user