diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index cf8f0caf0..29ab7307e 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -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().IsEnabled(), error = kErrorInvalidState); - address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder); - error = instance.Get().AddSrcMatchExtEntry(address); + error = instance.Get().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().IsEnabled(), error = kErrorInvalidState); - address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder); - error = instance.Get().ClearSrcMatchExtEntry(address); + error = instance.Get().ClearSrcMatchExtEntry(AsCoreType(aExtAddress)); exit: return error; diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index fbe243d75..c718e6fe0 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -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().SetExtendedAddress(address); + Get().SetExtendedAddress(aExtAddress); LogDebg("RadioExtAddress: %s", mExtAddress.ToString().AsCString()); } diff --git a/src/core/radio/radio.cpp b/src/core/radio/radio.cpp index b7f419f59..846481dc4 100644 --- a/src/core/radio/radio.cpp +++ b/src/core/radio/radio.cpp @@ -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().EmitExtendedAddress(aExtAddress); + Get().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 diff --git a/src/core/radio/radio.hpp b/src/core/radio/radio.hpp index 8bf699393..9943c74c4 100644 --- a/src/core/radio/radio.hpp +++ b/src/core/radio/radio.hpp @@ -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); diff --git a/src/core/thread/src_match_controller.cpp b/src/core/thread/src_match_controller.cpp index 9c9cecad9..1347b6018 100644 --- a/src/core/thread/src_match_controller.cpp +++ b/src/core/thread/src_match_controller.cpp @@ -147,10 +147,7 @@ Error SourceMatchController::AddAddress(const Child &aChild) } else { - Mac::ExtAddress address; - - address.Set(aChild.GetExtAddress().m8, Mac::ExtAddress::kReverseByteOrder); - error = Get().AddSrcMatchExtEntry(address); + error = Get().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().ClearSrcMatchExtEntry(address); + error = Get().ClearSrcMatchExtEntry(aChild.GetExtAddress()); LogDebg("Clearing addr: %s -- %s (%d)", aChild.GetExtAddress().ToString().AsCString(), ErrorToString(error), error);