[joiner] use random extended address for discovery request (#4920)

Thread specification requires the source address of Discovery Request
to be random value. While for subsequent messages, the joiner should
use hash of EUI-64 (joiner ID) value.
This commit is contained in:
kangping
2020-05-04 11:04:05 -07:00
committed by GitHub
parent 9faa71dc3e
commit e08f5aebd9
+11 -4
View File
@@ -96,15 +96,15 @@ otError Joiner::Start(const char * aPskd,
void * aContext)
{
otError error;
Mac::ExtAddress joinerId;
Mac::ExtAddress randomAddress;
otLogInfoMeshCoP("Joiner starting");
VerifyOrExit(mState == OT_JOINER_STATE_IDLE, error = OT_ERROR_BUSY);
// Use extended address based on factory-assigned IEEE EUI-64
GetJoinerId(joinerId);
Get<Mac::Mac>().SetExtAddress(joinerId);
// Use random-generated extended address.
randomAddress.GenerateRandom();
Get<Mac::Mac>().SetExtAddress(randomAddress);
Get<Mle::MleRouter>().UpdateLinkLocalAddress();
SuccessOrExit(error = Get<Coap::CoapSecure>().Start(kJoinerUdpPort));
@@ -222,6 +222,8 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult, void *aContext)
void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
{
Mac::ExtAddress joinerId;
VerifyOrExit(mState == OT_JOINER_STATE_DISCOVER, OT_NOOP);
if (aResult != NULL)
@@ -230,6 +232,11 @@ void Joiner::HandleDiscoverResult(otActiveScanResult *aResult)
}
else
{
// Use extended address based on factory-assigned IEEE EUI-64
GetJoinerId(joinerId);
Get<Mac::Mac>().SetExtAddress(joinerId);
Get<Mle::MleRouter>().UpdateLinkLocalAddress();
mJoinerRouterIndex = 0;
TryNextJoinerRouter(OT_ERROR_NONE);
}