mirror of
https://github.com/espressif/openthread.git
synced 2026-08-12 13:47:47 +00:00
[radio] reverse extended address in radio layer (#10892)
This commit reverses the Extended Address in radio layer so that the reversing can be shared by multiple callers.
This commit is contained in:
@@ -137,16 +137,12 @@ exit:
|
||||
|
||||
otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
Mac::ExtAddress address;
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
AssertPointerIsNotNull(aExtAddress);
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mac::LinkRaw>().IsEnabled(), error = kErrorInvalidState);
|
||||
|
||||
address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
error = instance.Get<Radio>().AddSrcMatchExtEntry(address);
|
||||
error = instance.Get<Radio>().AddSrcMatchExtEntry(AsCoreType(aExtAddress));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -166,16 +162,12 @@ exit:
|
||||
|
||||
otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
Mac::ExtAddress address;
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
AssertPointerIsNotNull(aExtAddress);
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mac::LinkRaw>().IsEnabled(), error = kErrorInvalidState);
|
||||
|
||||
address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
error = instance.Get<Radio>().ClearSrcMatchExtEntry(address);
|
||||
error = instance.Get<Radio>().ClearSrcMatchExtEntry(AsCoreType(aExtAddress));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -180,13 +180,8 @@ exit:
|
||||
|
||||
void SubMac::SetExtAddress(const ExtAddress &aExtAddress)
|
||||
{
|
||||
ExtAddress address;
|
||||
|
||||
mExtAddress = aExtAddress;
|
||||
|
||||
// Reverse the byte order before setting on radio.
|
||||
address.Set(aExtAddress.m8, ExtAddress::kReverseByteOrder);
|
||||
Get<Radio>().SetExtendedAddress(address);
|
||||
Get<Radio>().SetExtendedAddress(aExtAddress);
|
||||
|
||||
LogDebg("RadioExtAddress: %s", mExtAddress.ToString().AsCString());
|
||||
}
|
||||
|
||||
@@ -78,10 +78,13 @@ void Radio::Init(void)
|
||||
|
||||
void Radio::SetExtendedAddress(const Mac::ExtAddress &aExtAddress)
|
||||
{
|
||||
otPlatRadioSetExtendedAddress(GetInstancePtr(), &aExtAddress);
|
||||
Mac::ExtAddress address;
|
||||
|
||||
address.Set(aExtAddress.m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
otPlatRadioSetExtendedAddress(GetInstancePtr(), &address);
|
||||
|
||||
#if (OPENTHREAD_MTD || OPENTHREAD_FTD) && OPENTHREAD_CONFIG_OTNS_ENABLE
|
||||
Get<Utils::Otns>().EmitExtendedAddress(aExtAddress);
|
||||
Get<Utils::Otns>().EmitExtendedAddress(address);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -94,6 +97,13 @@ void Radio::SetShortAddress(Mac::ShortAddress aShortAddress)
|
||||
#endif
|
||||
}
|
||||
|
||||
Error Radio::AddSrcMatchExtEntry(const Mac::ExtAddress &aExtAddress)
|
||||
{
|
||||
Mac::ExtAddress address;
|
||||
|
||||
address.Set(aExtAddress.m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
return otPlatRadioAddSrcMatchExtEntry(GetInstancePtr(), &address);
|
||||
}
|
||||
Error Radio::Transmit(Mac::TxFrame &aFrame)
|
||||
{
|
||||
#if (OPENTHREAD_MTD || OPENTHREAD_FTD) && OPENTHREAD_CONFIG_OTNS_ENABLE
|
||||
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
/**
|
||||
* Sets the Extended Address for address filtering.
|
||||
*
|
||||
* @param[in] aExtAddress The IEEE 802.15.4 Extended Address stored in little-endian byte order.
|
||||
* @param[in] aExtAddress The IEEE 802.15.4 Extended Address stored in big-endian byte order.
|
||||
*/
|
||||
void SetExtendedAddress(const Mac::ExtAddress &aExtAddress);
|
||||
|
||||
@@ -636,7 +636,7 @@ public:
|
||||
/**
|
||||
* Adds an extended address to the source address match table.
|
||||
*
|
||||
* @param[in] aExtAddress The extended address to be added stored in little-endian byte order.
|
||||
* @param[in] aExtAddress The extended address to be added stored in big-endian byte order.
|
||||
*
|
||||
* @retval kErrorNone Successfully added extended address to the source match table.
|
||||
* @retval kErrorNoBufs No available entry in the source match table.
|
||||
@@ -656,7 +656,7 @@ public:
|
||||
/**
|
||||
* Removes an extended address from the source address match table.
|
||||
*
|
||||
* @param[in] aExtAddress The extended address to be removed stored in little-endian byte order.
|
||||
* @param[in] aExtAddress The extended address to be removed stored in big-endian byte order.
|
||||
*
|
||||
* @retval kErrorNone Successfully removed the extended address from the source match table.
|
||||
* @retval kErrorNoAddress The extended address is not in source address match table.
|
||||
@@ -981,11 +981,6 @@ inline Error Radio::AddSrcMatchShortEntry(Mac::ShortAddress aShortAddress)
|
||||
return otPlatRadioAddSrcMatchShortEntry(GetInstancePtr(), aShortAddress);
|
||||
}
|
||||
|
||||
inline Error Radio::AddSrcMatchExtEntry(const Mac::ExtAddress &aExtAddress)
|
||||
{
|
||||
return otPlatRadioAddSrcMatchExtEntry(GetInstancePtr(), &aExtAddress);
|
||||
}
|
||||
|
||||
inline Error Radio::ClearSrcMatchShortEntry(Mac::ShortAddress aShortAddress)
|
||||
{
|
||||
return otPlatRadioClearSrcMatchShortEntry(GetInstancePtr(), aShortAddress);
|
||||
|
||||
@@ -147,10 +147,7 @@ Error SourceMatchController::AddAddress(const Child &aChild)
|
||||
}
|
||||
else
|
||||
{
|
||||
Mac::ExtAddress address;
|
||||
|
||||
address.Set(aChild.GetExtAddress().m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
error = Get<Radio>().AddSrcMatchExtEntry(address);
|
||||
error = Get<Radio>().AddSrcMatchExtEntry(aChild.GetExtAddress());
|
||||
|
||||
LogDebg("Adding addr: %s -- %s (%d)", aChild.GetExtAddress().ToString().AsCString(), ErrorToString(error),
|
||||
error);
|
||||
@@ -178,10 +175,7 @@ void SourceMatchController::ClearEntry(Child &aChild)
|
||||
}
|
||||
else
|
||||
{
|
||||
Mac::ExtAddress address;
|
||||
|
||||
address.Set(aChild.GetExtAddress().m8, Mac::ExtAddress::kReverseByteOrder);
|
||||
error = Get<Radio>().ClearSrcMatchExtEntry(address);
|
||||
error = Get<Radio>().ClearSrcMatchExtEntry(aChild.GetExtAddress());
|
||||
|
||||
LogDebg("Clearing addr: %s -- %s (%d)", aChild.GetExtAddress().ToString().AsCString(), ErrorToString(error),
|
||||
error);
|
||||
|
||||
Reference in New Issue
Block a user