Implement MLE Discovery Request Joiner flag filter. (#1665)

This commit is contained in:
Jonathan Hui
2017-04-27 10:19:47 -07:00
committed by GitHub
parent 829806184e
commit b06707fc95
3 changed files with 38 additions and 0 deletions
+6
View File
@@ -2493,6 +2493,12 @@ ThreadError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6
case MeshCoP::Tlv::kDiscoveryRequest:
aMessage.Read(offset, sizeof(discoveryRequest), &discoveryRequest);
VerifyOrExit(discoveryRequest.IsValid(), error = kThreadError_Parse);
if (discoveryRequest.IsJoiner())
{
VerifyOrExit(mNetif.GetNetworkDataLeader().IsJoiningEnabled());
}
break;
case MeshCoP::Tlv::kExtendedPanId:
+22
View File
@@ -494,6 +494,28 @@ exit:
return rval;
}
bool LeaderBase::IsJoiningEnabled(void)
{
MeshCoP::Tlv *steeringData;
bool rval = false;
VerifyOrExit(GetCommissioningDataSubTlv(MeshCoP::Tlv::kBorderAgentLocator) != NULL);
steeringData = GetCommissioningDataSubTlv(MeshCoP::Tlv::kSteeringData);
VerifyOrExit(steeringData != NULL);
for (int i = 0; i < steeringData->GetLength(); i++)
{
if (steeringData->GetValue()[i] != 0)
{
ExitNow(rval = true);
}
}
exit:
return rval;
}
ThreadError LeaderBase::RemoveCommissioningData(void)
{
ThreadError error = kThreadError_NotFound;
+10
View File
@@ -187,6 +187,16 @@ public:
*/
MeshCoP::Tlv *GetCommissioningDataSubTlv(MeshCoP::Tlv::Type aType);
/**
* This method indicates whether or not the Commissioning Data TLV indicates Joining is enabled.
*
* Joining is enabled if a Border Agent Locator TLV exist and the Steering Data TLV is non-zero.
*
* @returns TRUE if the Commissioning Data TLV says Joining is enabled, FALSE otherwise.
*
*/
bool IsJoiningEnabled(void);
/**
* This method adds Commissioning Data to the Thread Network Data.
*