diff --git a/examples/drivers/windows/include/otLwfIoctl.h b/examples/drivers/windows/include/otLwfIoctl.h index 4a139a45d..daa207f06 100644 --- a/examples/drivers/windows/include/otLwfIoctl.h +++ b/examples/drivers/windows/include/otLwfIoctl.h @@ -200,7 +200,7 @@ typedef enum _OTLWF_NOTIF_TYPE #define IOCTL_OTLWF_OT_EXTENDED_ADDRESS \ OTLWF_CTL_CODE(107, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) // GUID - InterfaceGuid - // otExtAddress - aExtendedAddress + // otExtAddress - aExtAddress #define IOCTL_OTLWF_OT_EXTENDED_PANID \ OTLWF_CTL_CODE(108, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) diff --git a/examples/drivers/windows/otApi/otApi.cpp b/examples/drivers/windows/otApi/otApi.cpp index 5aabd2529..7d7675e02 100644 --- a/examples/drivers/windows/otApi/otApi.cpp +++ b/examples/drivers/windows/otApi/otApi.cpp @@ -1476,7 +1476,7 @@ otThreadSetChildTimeout( OTAPI const -uint8_t * +otExtAddress * OTCALL otLinkGetExtendedAddress( _In_ otInstance *aInstance @@ -1490,7 +1490,7 @@ otLinkGetExtendedAddress( free(Result); Result = nullptr; } - return (uint8_t*)Result; + return Result; } OTAPI @@ -1498,11 +1498,11 @@ otError OTCALL otLinkSetExtendedAddress( _In_ otInstance *aInstance, - const otExtAddress *aExtendedAddress + const otExtAddress *aExtAddress ) { if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS; - return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_ADDRESS, aExtendedAddress)); + return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_ADDRESS, aExtAddress)); } OTAPI diff --git a/examples/drivers/windows/otLwf/radio.c b/examples/drivers/windows/otLwf/radio.c index 78c26591a..eaf6f4dcc 100644 --- a/examples/drivers/windows/otLwf/radio.c +++ b/examples/drivers/windows/otLwf/radio.c @@ -210,7 +210,7 @@ void otPlatRadioSetPanId(_In_ otInstance *otCtx, uint16_t panid) } } -void otPlatRadioSetExtendedAddress(_In_ otInstance *otCtx, uint8_t *address) +void otPlatRadioSetExtendedAddress(_In_ otInstance *otCtx, const otExtAddress *address) { NT_ASSERT(otCtx); PMS_FILTER pFilter = otCtxToFilter(otCtx); @@ -223,7 +223,7 @@ void otPlatRadioSetExtendedAddress(_In_ otInstance *otCtx, uint8_t *address) for (size_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++) { - extAddr.bytes[i] = address[7 - i]; + extAddr.bytes[i] = address->m8[7 - i]; } // Indicate to the miniport @@ -654,7 +654,7 @@ otError otPlatRadioAddSrcMatchShortEntry(_In_ otInstance *otCtx, const uint16_t return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED; } -otError otPlatRadioAddSrcMatchExtEntry(_In_ otInstance *otCtx, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(_In_ otInstance *otCtx, const otExtAddress *aExtAddress) { NT_ASSERT(otCtx); PMS_FILTER pFilter = otCtxToFilter(otCtx); @@ -696,7 +696,7 @@ otError otPlatRadioClearSrcMatchShortEntry(_In_ otInstance *otCtx, const uint16_ return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED; } -otError otPlatRadioClearSrcMatchExtEntry(_In_ otInstance *otCtx, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(_In_ otInstance *otCtx, const otExtAddress *aExtAddress) { NT_ASSERT(otCtx); PMS_FILTER pFilter = otCtxToFilter(otCtx); diff --git a/examples/drivers/windows/otLwf/tunnel.c b/examples/drivers/windows/otLwf/tunnel.c index 770f635ae..e28178d51 100644 --- a/examples/drivers/windows/otLwf/tunnel.c +++ b/examples/drivers/windows/otLwf/tunnel.c @@ -596,7 +596,7 @@ otLwfTunValueInserted( NotifEntry->Notif.NotifType = OTLWF_NOTIF_ACTIVE_SCAN; NotifEntry->Notif.ActiveScanPayload.Valid = TRUE; - const uint8_t *aExtAddr = NULL; + const otExtAddress *aExtAddr = NULL; const uint8_t *aExtPanId = NULL; const char *aNetworkName = NULL; unsigned int xpanid_len = 0; diff --git a/examples/drivers/windows/otNodeApi/otNodeApi.cpp b/examples/drivers/windows/otNodeApi/otNodeApi.cpp index 48168ebc5..74707941d 100644 --- a/examples/drivers/windows/otNodeApi/otNodeApi.cpp +++ b/examples/drivers/windows/otNodeApi/otNodeApi.cpp @@ -1172,7 +1172,7 @@ OTNODEAPI const char* OTCALL otNodeGetAddr64(otNode* aNode) { aNode->mMemoryToFree.push_back(str); for (int i = 0; i < 8; i++) - sprintf_s(str + i * 2, 18 - (2 * i), "%02x", extAddr[i]); + sprintf_s(str + i * 2, 18 - (2 * i), "%02x", extAddr->m8[i]); printf("%d: extaddr\r\n%s\r\n", aNode->mId, str); } otFreeMemory(extAddr); diff --git a/examples/platforms/cc2538/radio.c b/examples/platforms/cc2538/radio.c index a0138fa19..8ac87975c 100644 --- a/examples/platforms/cc2538/radio.c +++ b/examples/platforms/cc2538/radio.c @@ -209,17 +209,17 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanid) HWREG(RFCORE_FFSM_PAN_ID1) = aPanid >> 8; } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) { (void)aInstance; otLogInfoPlat(sInstance, "ExtAddr=%X%X%X%X%X%X%X%X", - aAddress[7], aAddress[6], aAddress[5], aAddress[4], aAddress[3], - aAddress[2], aAddress[1], aAddress[0]); + aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], + aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); for (int i = 0; i < 8; i++) { - ((volatile uint32_t *)RFCORE_FFSM_EXT_ADDR0)[i] = aAddress[i]; + ((volatile uint32_t *)RFCORE_FFSM_EXT_ADDR0)[i] = aAddress->m8[i]; } } @@ -593,7 +593,7 @@ int8_t findSrcMatchShortEntry(const uint16_t aShortAddress) return entry; } -int8_t findSrcMatchExtEntry(const uint8_t *aExtAddress) +int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress) { int8_t entry = -1; uint32_t bitMask; @@ -614,7 +614,7 @@ int8_t findSrcMatchExtEntry(const uint8_t *aExtAddress) for (j = 0; j < sizeof(otExtAddress); j++) { - if (HWREG(addr + j) != aExtAddress[j]) + if (HWREG(addr + j) != aExtAddress->m8[j]) { break; } @@ -746,7 +746,7 @@ exit: return error; } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; int8_t entry = findSrcMatchAvailEntry(false); @@ -761,7 +761,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aEx for (uint8_t i = 0; i < sizeof(otExtAddress); i++) { - HWREG(addr++) = aExtAddress[i]; + HWREG(addr++) = aExtAddress->m8[i]; } setSrcMatchEntryEnableStatus(false, (uint8_t)(entry), true); @@ -786,7 +786,7 @@ exit: return error; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; int8_t entry = findSrcMatchExtEntry(aExtAddress); diff --git a/examples/platforms/cc2650/radio.c b/examples/platforms/cc2650/radio.c index fd4a2589d..5d51004f3 100644 --- a/examples/platforms/cc2650/radio.c +++ b/examples/platforms/cc2650/radio.c @@ -1468,7 +1468,7 @@ exit: /** * Function documented in platform/radio.h */ -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; (void)aInstance; @@ -1501,7 +1501,7 @@ exit: /** * Function documented in platform/radio.h */ -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; (void)aInstance; @@ -1696,7 +1696,7 @@ exit: * @note it is entirely possible for this function to fail, but there is no * valid way to return that error since the funciton prototype was changed. */ -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) { (void)aInstance; diff --git a/examples/platforms/cc2652/radio.c b/examples/platforms/cc2652/radio.c index c6c7aa0a1..c87f3ae46 100644 --- a/examples/platforms/cc2652/radio.c +++ b/examples/platforms/cc2652/radio.c @@ -1465,7 +1465,7 @@ exit: /** * Function documented in platform/radio.h */ -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; (void)aInstance; @@ -1498,7 +1498,7 @@ exit: /** * Function documented in platform/radio.h */ -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; (void)aInstance; @@ -1694,7 +1694,7 @@ exit: * @note it is entirely possible for this function to fail, but there is no * valid way to return that error since the function prototype was changed. */ -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) { (void)aInstance; diff --git a/examples/platforms/da15000/radio.c b/examples/platforms/da15000/radio.c index 9b8fc8554..daeefeebd 100644 --- a/examples/platforms/da15000/radio.c +++ b/examples/platforms/da15000/radio.c @@ -155,15 +155,15 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanid) FTDF_setValue(FTDF_PIB_PAN_ID, &aPanid); } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) { (void)aInstance; otLogInfoPlat(sInstance, "Set Extended Address: %X%X%X%X%X%X%X%X", - aAddress[7], aAddress[6], aAddress[5], aAddress[4], - aAddress[3], aAddress[2], aAddress[1], aAddress[0]); + aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], + aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); - FTDF_setValue(FTDF_PIB_EXTENDED_ADDRESS, aAddress); + FTDF_setValue(FTDF_PIB_EXTENDED_ADDRESS, aAddress->m8); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) @@ -311,7 +311,7 @@ exit: } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; @@ -320,8 +320,10 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aEx uint32_t addrL; uint64_t addrH; - addrL = (aExtAddress[3] << 24) | (aExtAddress[2] << 16) | (aExtAddress[1] << 8) | (aExtAddress[0] << 0); - addrH = (aExtAddress[7] << 24) | (aExtAddress[6] << 16) | (aExtAddress[5] << 8) | (aExtAddress[4] << 0); + addrL = (aExtAddress->m8[3] << 24) | (aExtAddress->m8[2] << 16) | + (aExtAddress->m8[1] << 8) | (aExtAddress->m8[0] << 0); + addrH = (aExtAddress->m8[7] << 24) | (aExtAddress->m8[6] << 16) | + (aExtAddress->m8[5] << 8) | (aExtAddress->m8[4] << 0); addr = addrL | (addrH << 32); // check if address already stored @@ -357,7 +359,7 @@ exit: return error; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; @@ -366,8 +368,10 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *a uint32_t addrL; uint64_t addrH; - addrL = (aExtAddress[3] << 24) | (aExtAddress[2] << 16) | (aExtAddress[1] << 8) | (aExtAddress[0] << 0); - addrH = (aExtAddress[7] << 24) | (aExtAddress[6] << 16) | (aExtAddress[5] << 8) | (aExtAddress[4] << 0); + addrL = (aExtAddress->m8[3] << 24) | (aExtAddress->m8[2] << 16) | + (aExtAddress->m8[1] << 8) | (aExtAddress->m8[0] << 0); + addrH = (aExtAddress->m8[7] << 24) | (aExtAddress->m8[6] << 16) | + (aExtAddress->m8[5] << 8) | (aExtAddress->m8[4] << 0); addr = addrL | (addrH << 32); otError error = OT_ERROR_NONE; diff --git a/examples/platforms/efr32/radio.c b/examples/platforms/efr32/radio.c index 847ff1cd6..8369e3a6d 100644 --- a/examples/platforms/efr32/radio.c +++ b/examples/platforms/efr32/radio.c @@ -201,15 +201,15 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) RAIL_IEEE802154_SetPanId(aPanId); } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) { (void)aInstance; otLogInfoPlat(sInstance, "ExtAddr=%X%X%X%X%X%X%X%X", - aAddress[7], aAddress[6], aAddress[5], aAddress[4], - aAddress[3], aAddress[2], aAddress[1], aAddress[0]); + aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], + aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); - RAIL_IEEE802154_SetLongAddress(aAddress); + RAIL_IEEE802154_SetLongAddress(aAddress->m8); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) @@ -433,15 +433,15 @@ int8_t findSrcMatchShortEntry(const uint16_t aShortAddress) return entry; } -int8_t findSrcMatchExtEntry(const uint8_t *aExtAddress) +int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress) { int8_t entry = -1; uint16_t checksum = sPanId; - checksum += (uint16_t)aExtAddress[0] | (uint16_t)(aExtAddress[1] << 8); - checksum += (uint16_t)aExtAddress[2] | (uint16_t)(aExtAddress[3] << 8); - checksum += (uint16_t)aExtAddress[4] | (uint16_t)(aExtAddress[5] << 8); - checksum += (uint16_t)aExtAddress[6] | (uint16_t)(aExtAddress[7] << 8); + checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8); + checksum += (uint16_t)aExtAddress->m8[2] | (uint16_t)(aExtAddress->m8[3] << 8); + checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8); + checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8); for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM; i++) { @@ -464,14 +464,14 @@ void addToSrcMatchShortIndirect(uint8_t entry, const uint16_t aShortAddress) srcMatchShortEntry[entry].allocated = true; } -void addToSrcMatchExtIndirect(uint8_t entry, const uint8_t *aExtAddress) +void addToSrcMatchExtIndirect(uint8_t entry, const otExtAddress *aExtAddress) { uint16_t checksum = sPanId; - checksum += (uint16_t)aExtAddress[0] | (uint16_t)(aExtAddress[1] << 8); - checksum += (uint16_t)aExtAddress[2] | (uint16_t)(aExtAddress[3] << 8); - checksum += (uint16_t)aExtAddress[4] | (uint16_t)(aExtAddress[5] << 8); - checksum += (uint16_t)aExtAddress[6] | (uint16_t)(aExtAddress[7] << 8); + checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8); + checksum += (uint16_t)aExtAddress->m8[2] | (uint16_t)(aExtAddress->m8[3] << 8); + checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8); + checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8); srcMatchExtEntry[entry].checksum = checksum; srcMatchExtEntry[entry].allocated = true; @@ -524,7 +524,7 @@ exit: return error; } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; int8_t entry = -1; @@ -568,7 +568,7 @@ exit: return error; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; int8_t entry = -1; diff --git a/examples/platforms/emsk/radio.c b/examples/platforms/emsk/radio.c index ee95ff8e6..047f55af7 100644 --- a/examples/platforms/emsk/radio.c +++ b/examples/platforms/emsk/radio.c @@ -243,10 +243,10 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) mrf24j40_set_pan(pan); } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *address) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *address) { (void)aInstance; - mrf24j40_set_eui(address); + mrf24j40_set_eui(address->m8); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t address) @@ -633,7 +633,7 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a return OT_ERROR_NONE; } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; @@ -647,7 +647,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t return OT_ERROR_NONE; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; diff --git a/examples/platforms/gp712/radio.c b/examples/platforms/gp712/radio.c index c5327914b..1bc040ef3 100644 --- a/examples/platforms/gp712/radio.c +++ b/examples/platforms/gp712/radio.c @@ -96,10 +96,10 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) otCachedSettings.panid = panid; } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *address) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *address) { (void)aInstance; - qorvoRadioSetExtendedAddress(address); + qorvoRadioSetExtendedAddress(address->m8); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t address) @@ -268,10 +268,10 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a return qorvoRadioAddSrcMatchShortEntry(aShortAddress, otCachedSettings.panid); } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; - return qorvoRadioAddSrcMatchExtEntry(aExtAddress, otCachedSettings.panid); + return qorvoRadioAddSrcMatchExtEntry(aExtAddress->m8, otCachedSettings.panid); } otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) @@ -280,10 +280,10 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t return qorvoRadioClearSrcMatchShortEntry(aShortAddress, otCachedSettings.panid); } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; - return qorvoRadioClearSrcMatchExtEntry(aExtAddress, otCachedSettings.panid); + return qorvoRadioClearSrcMatchExtEntry(aExtAddress->m8, otCachedSettings.panid); } void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) diff --git a/examples/platforms/kw41z/radio.c b/examples/platforms/kw41z/radio.c index 06e077b71..8effe74e8 100644 --- a/examples/platforms/kw41z/radio.c +++ b/examples/platforms/kw41z/radio.c @@ -151,14 +151,14 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) ZLL->MACSHORTADDRS0 |= ZLL_MACSHORTADDRS0_MACPANID0(aPanId); } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aExtendedAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { (void) aInstance; uint32_t addrLo; uint32_t addrHi; - memcpy(&addrLo, aExtendedAddress, sizeof(addrLo)); - memcpy(&addrHi, aExtendedAddress + sizeof(addrLo), sizeof(addrHi)); + memcpy(&addrLo, aExtAddress->m8, sizeof(addrLo)); + memcpy(&addrHi, aExtAddress->m8 + sizeof(addrLo), sizeof(addrHi)); ZLL->MACLONGADDRS0_LSB = addrLo; ZLL->MACLONGADDRS0_MSB = addrHi; @@ -272,10 +272,10 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a return rf_add_addr_table_entry(checksum, false); } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void) aInstance; - uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress, true, sPanId); + uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId); return rf_add_addr_table_entry(checksum, true); } @@ -288,10 +288,10 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t return rf_remove_addr_table_entry(checksum); } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void) aInstance; - uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress, true, sPanId); + uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId); return rf_remove_addr_table_entry(checksum); } diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c index 8b08dafb3..40a53b4cb 100644 --- a/examples/platforms/nrf52840/radio.c +++ b/examples/platforms/nrf52840/radio.c @@ -194,11 +194,11 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) nrf_drv_radio802154_pan_id_set(address); } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aExtendedAddress) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { (void) aInstance; - nrf_drv_radio802154_extended_address_set(aExtendedAddress); + nrf_drv_radio802154_extended_address_set(aExtAddress->m8); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress) @@ -405,13 +405,13 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a return error; } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void) aInstance; otError error; - if (nrf_drv_radio802154_pending_bit_for_addr_set(aExtAddress, true)) + if (nrf_drv_radio802154_pending_bit_for_addr_set(aExtAddress->m8, true)) { error = OT_ERROR_NONE; } @@ -444,13 +444,13 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t return error; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void) aInstance; otError error; - if (nrf_drv_radio802154_pending_bit_for_addr_clear(aExtAddress, true)) + if (nrf_drv_radio802154_pending_bit_for_addr_clear(aExtAddress->m8, true)) { error = OT_ERROR_NONE; } diff --git a/examples/platforms/posix/radio.c b/examples/platforms/posix/radio.c index 49f704c86..482025b2c 100644 --- a/examples/platforms/posix/radio.c +++ b/examples/platforms/posix/radio.c @@ -311,13 +311,13 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) sPanid = panid; } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *address) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; for (size_t i = 0; i < sizeof(sExtendedAddress); i++) { - sExtendedAddress[i] = address[sizeof(sExtendedAddress) - 1 - i]; + sExtendedAddress[i] = aExtAddress->m8[sizeof(sExtendedAddress) - 1 - i]; } } @@ -719,7 +719,7 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a return OT_ERROR_NONE; } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; @@ -733,7 +733,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t return OT_ERROR_NONE; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; diff --git a/include/openthread/link.h b/include/openthread/link.h index 1a16a8dc3..753e3de83 100644 --- a/include/openthread/link.h +++ b/include/openthread/link.h @@ -186,22 +186,22 @@ OTAPI otError OTCALL otLinkSetChannel(otInstance *aInstance, uint8_t aChannel); * * @returns A pointer to the IEEE 802.15.4 Extended Address. */ -OTAPI const uint8_t *OTCALL otLinkGetExtendedAddress(otInstance *aInstance); +OTAPI const otExtAddress *OTCALL otLinkGetExtendedAddress(otInstance *aInstance); /** * This function sets the IEEE 802.15.4 Extended Address. * * This function will only succeed when Thread protocols are disabled. * - * @param[in] aInstance A pointer to an OpenThread instance. - * @param[in] aExtendedAddress A pointer to the IEEE 802.15.4 Extended Address. + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address. * * @retval OT_ERROR_NONE Successfully set the IEEE 802.15.4 Extended Address. - * @retval OT_ERROR_INVALID_ARGS @p aExtendedAddress was NULL. + * @retval OT_ERROR_INVALID_ARGS @p aExtAddress was NULL. * @retval OT_ERROR_INVALID_STATE Thread protocols are enabled. * */ -OTAPI otError OTCALL otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtendedAddress); +OTAPI otError OTCALL otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Get the factory-assigned IEEE EUI-64. diff --git a/include/openthread/link_raw.h b/include/openthread/link_raw.h index 89e7b8e98..03464fc67 100644 --- a/include/openthread/link_raw.h +++ b/include/openthread/link_raw.h @@ -90,14 +90,14 @@ otError otLinkRawSetPanId(otInstance *aInstance, uint16_t aPanId); /** * This function sets the IEEE 802.15.4 Extended Address. * - * @param[in] aInstance A pointer to an OpenThread instance. - * @param[in] aExtendedAddress A pointer to the IEEE 802.15.4 Extended Address. + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address. * * @retval OT_ERROR_NONE If successful. * @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled. * */ -otError otLinkRawSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtendedAddress); +otError otLinkRawSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Set the Short Address for address filtering. @@ -303,7 +303,7 @@ otError otLinkRawSrcMatchAddShortEntry(otInstance *aInstance, const uint16_t aSh * @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled. * */ -otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const uint8_t *aExtAddress); +otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Removing short address to the source match table. @@ -329,7 +329,7 @@ otError otLinkRawSrcMatchClearShortEntry(otInstance *aInstance, const uint16_t a * @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled. * */ -otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const uint8_t *aExtAddress); +otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Removing all the short addresses from the source match table. diff --git a/include/openthread/platform/radio.h b/include/openthread/platform/radio.h index ce5cca252..0af620710 100644 --- a/include/openthread/platform/radio.h +++ b/include/openthread/platform/radio.h @@ -174,11 +174,12 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId); /** * Set the Extended Address for address filtering. * - * @param[in] aInstance The OpenThread instance structure. - * @param[in] aExtendedAddress A pointer to the IEEE 802.15.4 Extended Address. + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address stored in little-endian byte order. + * * */ -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aExtendedAddress); +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Set the Short Address for address filtering. @@ -304,12 +305,12 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a * Add an extended address to the source address match table. * * @param[in] aInstance The OpenThread instance structure. - * @param[in] aExtAddress The extended address to be added. + * @param[in] aExtAddress The extended address to be added stored in little-endian byte order. * * @retval OT_ERROR_NONE Successfully added extended address to the source match table. * @retval OT_ERROR_NO_BUFS No available entry in the source match table. */ -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress); +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Remove a short address from the source address match table. @@ -326,12 +327,12 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t * Remove an extended address from the source address match table. * * @param[in] aInstance The OpenThread instance structure. - * @param[in] aExtAddress The extended address to be removed. + * @param[in] aExtAddress The extended address to be removed stoerd in little-endian byte order. * * @retval OT_ERROR_NONE Successfully removed the extended address from the source match table. * @retval OT_ERROR_NO_ADDRESS The extended address is not in source address match table. */ -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress); +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress); /** * Clear all short addresses from the source address match table. diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index d6443a231..064fda62e 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -881,7 +881,7 @@ void Interpreter::ProcessExtAddress(int argc, char *argv[]) if (argc == 0) { - otBufferPtr extAddress(otLinkGetExtendedAddress(mInstance)); + otBufferPtr extAddress(reinterpret_cast(otLinkGetExtendedAddress(mInstance))); OutputBytes(extAddress, OT_EXT_ADDRESS_SIZE); mServer->OutputFormat("\r\n"); } diff --git a/src/core/api/link_api.cpp b/src/core/api/link_api.cpp index baa718c33..2c2fb4bd0 100644 --- a/src/core/api/link_api.cpp +++ b/src/core/api/link_api.cpp @@ -62,9 +62,9 @@ exit: return error; } -const uint8_t *otLinkGetExtendedAddress(otInstance *aInstance) +const otExtAddress *otLinkGetExtendedAddress(otInstance *aInstance) { - return reinterpret_cast(aInstance->mThreadNetif.GetMac().GetExtAddress()); + return reinterpret_cast(aInstance->mThreadNetif.GetMac().GetExtAddress()); } otError otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index 0b388ec28..f244f7ff2 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -72,19 +72,19 @@ exit: return error; } -otError otLinkRawSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtendedAddress) +otError otLinkRawSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; - uint8_t buf[sizeof(otExtAddress)]; + otExtAddress address; VerifyOrExit(aInstance->mLinkRaw.IsEnabled(), error = OT_ERROR_INVALID_STATE); - for (size_t i = 0; i < sizeof(buf); i++) + for (size_t i = 0; i < sizeof(address); i++) { - buf[i] = aExtendedAddress->m8[7 - i]; + address.m8[i] = aExtAddress->m8[7 - i]; } - otPlatRadioSetExtendedAddress(aInstance, buf); + otPlatRadioSetExtendedAddress(aInstance, &address); exit: return error; @@ -199,7 +199,7 @@ exit: return error; } -otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; @@ -223,7 +223,7 @@ exit: return error; } -otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index e01e38900..6e34303f8 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -464,16 +464,16 @@ void Mac::GenerateExtAddress(ExtAddress *aExtAddress) void Mac::SetExtAddress(const ExtAddress &aExtAddress) { - uint8_t buf[sizeof(aExtAddress)]; + otExtAddress address; otLogFuncEntry(); - for (size_t i = 0; i < sizeof(buf); i++) + for (size_t i = 0; i < sizeof(address); i++) { - buf[i] = aExtAddress.m8[7 - i]; + address.m8[i] = aExtAddress.m8[7 - i]; } - otPlatRadioSetExtendedAddress(&GetInstance(), buf); + otPlatRadioSetExtendedAddress(&GetInstance(), &address); mExtAddress = aExtAddress; otLogFuncExit(); diff --git a/src/core/thread/src_match_controller.cpp b/src/core/thread/src_match_controller.cpp index 3f755fd5a..be409223c 100644 --- a/src/core/thread/src_match_controller.cpp +++ b/src/core/thread/src_match_controller.cpp @@ -153,17 +153,17 @@ otError SourceMatchController::AddAddress(const Child &aChild) } else { - uint8_t addr[sizeof(aChild.GetExtAddress())]; + otExtAddress addr; for (uint8_t i = 0; i < sizeof(addr); i++) { - addr[i] = aChild.GetExtAddress().m8[sizeof(addr) - 1 - i]; + addr.m8[i] = aChild.GetExtAddress().m8[sizeof(addr) - 1 - i]; } - error = otPlatRadioAddSrcMatchExtEntry(&GetInstance(), addr); + error = otPlatRadioAddSrcMatchExtEntry(&GetInstance(), &addr); otLogDebgMac(GetInstance(), "SrcAddrMatch - Adding addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x -- %s (%d)", - addr[7], addr[6], addr[5], addr[4], addr[3], addr[2], addr[1], addr[0], + addr.m8[7], addr.m8[6], addr.m8[5], addr.m8[4], addr.m8[3], addr.m8[2], addr.m8[1], addr.m8[0], otThreadErrorToString(error), error); } @@ -190,17 +190,17 @@ void SourceMatchController::ClearEntry(Child &aChild) } else { - uint8_t addr[sizeof(aChild.GetExtAddress())]; + otExtAddress addr; for (uint8_t i = 0; i < sizeof(addr); i++) { - addr[i] = aChild.GetExtAddress().m8[sizeof(aChild.GetExtAddress()) - 1 - i]; + addr.m8[i] = aChild.GetExtAddress().m8[sizeof(aChild.GetExtAddress()) - 1 - i]; } - error = otPlatRadioClearSrcMatchExtEntry(&GetInstance(), addr); + error = otPlatRadioClearSrcMatchExtEntry(&GetInstance(), &addr); otLogDebgMac(GetInstance(), "SrcAddrMatch - Clearing addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x -- %s (%d)", - addr[7], addr[6], addr[5], addr[4], addr[3], addr[2], addr[1], addr[0], + addr.m8[7], addr.m8[6], addr.m8[5], addr.m8[4], addr.m8[3], addr.m8[2], addr.m8[1], addr.m8[0], otThreadErrorToString(error), error); } diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index d97d48823..25eee16fe 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -6346,7 +6346,7 @@ otError NcpBase::SetPropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(uint8_t aHe while (dataLen >= sizeof(otExtAddress)) { spinel_ssize_t parsedLength; - uint8_t *extAddress; + otExtAddress *extAddress; parsedLength = spinel_datatype_unpack( data, @@ -7003,7 +7003,7 @@ otError NcpBase::InsertPropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(uint8_t spinel_ssize_t parsedLength; otError error = OT_ERROR_NONE; spinel_status_t spinelError = SPINEL_STATUS_OK; - uint8_t *extAddress = NULL; + otExtAddress *extAddress = NULL; parsedLength = spinel_datatype_unpack( aValuePtr, @@ -7604,7 +7604,7 @@ otError NcpBase::RemovePropertyHandler_MAC_SRC_MATCH_EXTENDED_ADDRESSES(uint8_t spinel_ssize_t parsedLength; otError error = OT_ERROR_NONE; spinel_status_t spinelError = SPINEL_STATUS_OK; - uint8_t *extAddress; + otExtAddress *extAddress; parsedLength = spinel_datatype_unpack( aValuePtr, diff --git a/tests/fuzz/fuzzer_platform.c b/tests/fuzz/fuzzer_platform.c index a52cb3837..23427876e 100644 --- a/tests/fuzz/fuzzer_platform.c +++ b/tests/fuzz/fuzzer_platform.c @@ -84,7 +84,7 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) (void)aPanId; } -void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aExtAddr) +void otPlatRadioSetExtendedAddress(otInstance *aInstance, otExtAddress *aExtAddr) { (void)aInstance; (void)aExtAddr; @@ -177,7 +177,7 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a return OT_ERROR_NONE; } -otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; @@ -191,7 +191,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t return OT_ERROR_NONE; } -otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; diff --git a/tests/unit/test_platform.cpp b/tests/unit/test_platform.cpp index 651396bbc..22ba019bc 100644 --- a/tests/unit/test_platform.cpp +++ b/tests/unit/test_platform.cpp @@ -190,7 +190,7 @@ extern "C" { } } - void otPlatRadioSetExtendedAddress(otInstance *aInstance, uint8_t *aExtAddr) + void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddr) { if (g_testPlatRadioSetExtendedAddress) { @@ -317,7 +317,7 @@ extern "C" { return OT_ERROR_NONE; } - otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) + otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; @@ -331,7 +331,7 @@ extern "C" { return OT_ERROR_NONE; } - otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const uint8_t *aExtAddress) + otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { (void)aInstance; (void)aExtAddress; diff --git a/tests/unit/test_platform.h b/tests/unit/test_platform.h index 99fea4d8f..992fe9035 100644 --- a/tests/unit/test_platform.h +++ b/tests/unit/test_platform.h @@ -68,7 +68,7 @@ extern testPlatAlarmGetNow g_testPlatAlarmGetNow; // typedef void (*testPlatRadioSetPanId)(otInstance *, uint16_t); -typedef void (*testPlatRadioSetExtendedAddress)(otInstance *, uint8_t *); +typedef void (*testPlatRadioSetExtendedAddress)(otInstance *, const otExtAddress *); typedef void (*testPlatRadioSetShortAddress)(otInstance *, uint16_t); typedef bool(*testPlatRadioIsEnabled)(otInstance *);