mirror of
https://github.com/espressif/openthread.git
synced 2026-09-03 07:40:10 +00:00
[mac-types] add Clear() and Fill() method to Mac::ExtAddress (#4315)
The `Clear()` method clears the address (set all bytes to zero), where as the `Fill()` method fills all bytes with a given value.
This commit is contained in:
committed by
Jonathan Hui
parent
69d5e084e0
commit
52a04dbed1
@@ -234,7 +234,7 @@ otError Filter::GetNextRssIn(Iterator &aIterator, Entry &aEntry)
|
||||
// Return the default RssIn at the end of list
|
||||
if ((aIterator == OT_ARRAY_LENGTH(mFilterEntries)) && (mDefaultRssIn != kFixedRssDisabled))
|
||||
{
|
||||
memset(&aEntry.mExtAddress, 0xff, OT_EXT_ADDRESS_SIZE);
|
||||
static_cast<ExtAddress &>(aEntry.mExtAddress).Fill(0xff);
|
||||
aEntry.mRssIn = mDefaultRssIn;
|
||||
error = OT_ERROR_NONE;
|
||||
aIterator++;
|
||||
|
||||
@@ -110,6 +110,20 @@ public:
|
||||
kReverseByteOrder, // Copy address bytes in reverse byte order.
|
||||
};
|
||||
|
||||
/**
|
||||
* This method clears the Extended Address (sets all bytes to zero).
|
||||
*
|
||||
*/
|
||||
void Clear(void) { Fill(0); }
|
||||
|
||||
/**
|
||||
* This method fills all bytes of address with a given byte value.
|
||||
*
|
||||
* @param[in] aByte A byte value to fill address with.
|
||||
*
|
||||
*/
|
||||
void Fill(uint8_t aByte) { memset(this, aByte, sizeof(*this)); }
|
||||
|
||||
/**
|
||||
* This method generates a random IEEE 802.15.4 Extended Address.
|
||||
*
|
||||
|
||||
@@ -61,7 +61,7 @@ SubMac::SubMac(Instance &aInstance)
|
||||
, mPcapCallbackContext(NULL)
|
||||
, mTimer(aInstance, &SubMac::HandleTimer, this)
|
||||
{
|
||||
memset(mExtAddress.m8, 0, sizeof(mExtAddress));
|
||||
mExtAddress.Clear();
|
||||
}
|
||||
|
||||
otRadioCaps SubMac::GetCaps(void) const
|
||||
|
||||
@@ -2609,8 +2609,8 @@ void MleRouter::SetSteeringData(const Mac::ExtAddress *aExtAddress)
|
||||
Mac::ExtAddress nullExtAddr;
|
||||
Mac::ExtAddress allowAnyExtAddr;
|
||||
|
||||
memset(nullExtAddr.m8, 0, sizeof(nullExtAddr.m8));
|
||||
memset(allowAnyExtAddr.m8, 0xFF, sizeof(allowAnyExtAddr.m8));
|
||||
nullExtAddr.Clear();
|
||||
allowAnyExtAddr.Fill(0xff);
|
||||
|
||||
mSteeringData.Init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user