mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 16:09:51 +00:00
Implement MLE Discovery Request Joiner flag filter. (#1665)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user