mirror of
https://github.com/espressif/openthread.git
synced 2026-09-22 08:57:39 +00:00
Ensure to set Extended Address's local bit (#1711)
* Create a new `GenerateExtAddress()` method; * Fix the issue that the extended address U/L bit may not be set, which is generated after join success.
This commit is contained in:
+12
-7
@@ -154,13 +154,7 @@ Mac::Mac(ThreadNetif &aThreadNetif):
|
||||
mTxFrame(static_cast<Frame *>(otPlatRadioGetTransmitBuffer(aThreadNetif.GetInstance()))),
|
||||
mKeyIdMode2FrameCounter(0)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(mExtAddress); i++)
|
||||
{
|
||||
mExtAddress.m8[i] = static_cast<uint8_t>(otPlatRandomGet());
|
||||
}
|
||||
|
||||
mExtAddress.SetGroup(false);
|
||||
mExtAddress.SetLocal(true);
|
||||
GenerateExtAddress(&mExtAddress);
|
||||
|
||||
ClearNoiseFloorAverage(mNoiseFloor);
|
||||
|
||||
@@ -434,6 +428,17 @@ void Mac::SetRxOnWhenIdle(bool aRxOnWhenIdle)
|
||||
}
|
||||
}
|
||||
|
||||
void Mac::GenerateExtAddress(ExtAddress *aExtAddress)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(ExtAddress); i++)
|
||||
{
|
||||
aExtAddress->m8[i] = static_cast<uint8_t>(otPlatRandomGet());
|
||||
}
|
||||
|
||||
aExtAddress->SetGroup(false);
|
||||
aExtAddress->SetLocal(true);
|
||||
}
|
||||
|
||||
void Mac::SetExtAddress(const ExtAddress &aExtAddress)
|
||||
{
|
||||
uint8_t buf[sizeof(aExtAddress)];
|
||||
|
||||
@@ -348,6 +348,14 @@ public:
|
||||
*/
|
||||
ThreadError SendFrameRequest(Sender &aSender);
|
||||
|
||||
/**
|
||||
* This method generates a random IEEE 802.15.4 Extended Address.
|
||||
*
|
||||
* @param[out] aExtAddress A pointer to where the generated Extended Address is placed.
|
||||
*
|
||||
*/
|
||||
void GenerateExtAddress(ExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the IEEE 802.15.4 Extended Address.
|
||||
*
|
||||
|
||||
@@ -508,11 +508,7 @@ void Joiner::HandleTimer(void)
|
||||
case kStateJoined:
|
||||
Mac::ExtAddress extAddress;
|
||||
|
||||
for (size_t i = 0; i < sizeof(extAddress); i++)
|
||||
{
|
||||
extAddress.m8[i] = static_cast<uint8_t>(otPlatRandomGet());
|
||||
}
|
||||
|
||||
mNetif.GetMac().GenerateExtAddress(&extAddress);
|
||||
mNetif.GetMac().SetExtAddress(extAddress);
|
||||
mNetif.GetMle().UpdateLinkLocalAddress();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user