From 50fad599fad14dbb49017247f500f0ee1dd00866 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 13 Dec 2018 09:04:12 -0800 Subject: [PATCH] [link-raw] update to use Mac::Address to reverse extended address (#3377) --- src/core/api/link_raw_api.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index 3c0c86fb2..278815261 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -43,6 +43,7 @@ #include "common/owner-locator.hpp" #include "common/random.hpp" #include "mac/mac.hpp" +#include "mac/mac_frame.hpp" #include "utils/parse_cmdline.hpp" #if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API @@ -158,17 +159,14 @@ exit: otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { - otExtAddress addr; + Mac::Address address; otError error = OT_ERROR_NONE; VerifyOrExit(static_cast(aInstance)->GetLinkRaw().IsEnabled(), error = OT_ERROR_INVALID_STATE); - for (uint8_t i = 0; i < sizeof(addr); i++) - { - addr.m8[i] = aExtAddress->m8[sizeof(addr) - 1 - i]; - } + address.SetExtended(aExtAddress->m8, /* aReverse */ true); - error = otPlatRadioAddSrcMatchExtEntry(aInstance, &addr); + error = otPlatRadioAddSrcMatchExtEntry(aInstance, &address.GetExtended()); exit: return error; @@ -188,17 +186,14 @@ exit: otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { - otExtAddress addr; + Mac::Address address; otError error = OT_ERROR_NONE; VerifyOrExit(static_cast(aInstance)->GetLinkRaw().IsEnabled(), error = OT_ERROR_INVALID_STATE); - for (uint8_t i = 0; i < sizeof(addr); i++) - { - addr.m8[i] = aExtAddress->m8[sizeof(addr) - 1 - i]; - } + address.SetExtended(aExtAddress->m8, /* aReverse */ true); - error = otPlatRadioClearSrcMatchExtEntry(aInstance, &addr); + error = otPlatRadioClearSrcMatchExtEntry(aInstance, &address.GetExtended()); exit: return error;