fix SteeringData process in Joiner's HandleDiscoverResult() (#1310)

This commit is contained in:
rongli
2017-02-14 18:36:16 -08:00
committed by Jonathan Hui
parent 102c677e23
commit c3cc9577fa
2 changed files with 32 additions and 3 deletions
+12 -3
View File
@@ -162,6 +162,13 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
{
otLogFuncEntryMsg("aResult = %llX", HostSwap64(*reinterpret_cast<uint64_t *>(&aResult->mExtAddress)));
// Joining is disabled if the Steering Data is not included
if (aResult->mSteeringData.mLength == 0)
{
otLogDebgMeshCoP("No steering data, joining disabled");
ExitNow();
}
SteeringDataTlv steeringData;
Mac::ExtAddress extAddress;
Crc16 ccitt(Crc16::kCcitt);
@@ -178,8 +185,9 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
steeringData.SetLength(aResult->mSteeringData.mLength);
memcpy(steeringData.GetValue(), aResult->mSteeringData.m8, steeringData.GetLength());
if (steeringData.GetBit(ccitt.Get() % steeringData.GetNumBits()) &&
steeringData.GetBit(ansi.Get() % steeringData.GetNumBits()))
if (steeringData.DoesAllowAny() ||
(steeringData.GetBit(ccitt.Get() % steeringData.GetNumBits()) &&
steeringData.GetBit(ansi.Get() % steeringData.GetNumBits())))
{
mJoinerUdpPort = aResult->mJoinerUdpPort;
mJoinerRouterPanId = aResult->mPanId;
@@ -188,7 +196,7 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
}
else
{
otLogDebgMeshCoP("Steering data not set");
otLogDebgMeshCoP("Steering data does not include this device");
}
}
else if (mJoinerRouterPanId != Mac::kPanIdBroadcast)
@@ -213,6 +221,7 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
Complete(kThreadError_NotFound);
}
exit:
otLogFuncExit();
}
+20
View File
@@ -574,6 +574,26 @@ public:
*/
void Set(void) { memset(mSteeringData, 0xff, GetLength()); }
/**
* Ths method indicates whether or not the SteeringData allows all Joiners.
*
* @retval TRUE If the SteeringData allows all Joiners.
* @retval FALSE If the SteeringData doesn't allow any Joiner.
*
*/
bool DoesAllowAny(void) {
bool rval = true;
for (uint8_t i = 0; i < GetLength(); i++) {
if (mSteeringData[i] != 0xff) {
rval = false;
break;
}
}
return rval;
}
/**
* This method returns the number of bits in the Bloom Filter.
*