[routing-manager] persist deprecating old prefixes in Settings (#8330)

This commit adds mechanism to save deprecating old on-link prefixes
in non-volatile `Settings`. With this, if the BR is restarted, it
will remember the old prefixes and keep deprecating them (advertising
them in emitted RA and publish them in Thread Network Data).

This commit also adds `TestSavedOnLinkPrefixes()` test case in
`test_routing_manager` to cover the behavior of the newly added
mechanism.
This commit is contained in:
Abtin Keshavarzian
2022-10-27 15:12:59 -07:00
committed by GitHub
parent b9b9c19640
commit ca8799a4b8
8 changed files with 473 additions and 21 deletions
+17 -6
View File
@@ -37,8 +37,6 @@ enum
FLASH_SWAP_NUM = 2,
};
static uint8_t sFlash[FLASH_SWAP_SIZE * FLASH_SWAP_NUM];
ot::Instance *testInitInstance(void)
{
otInstance *instance = nullptr;
@@ -362,9 +360,22 @@ OT_TOOL_WEAK void otPlatSettingsWipe(otInstance *)
{
}
uint8_t *GetFlash(void)
{
static uint8_t sFlash[FLASH_SWAP_SIZE * FLASH_SWAP_NUM];
static bool sInitialized;
if (!sInitialized)
{
memset(sFlash, 0xff, sizeof(sFlash));
sInitialized = true;
}
return sFlash;
}
OT_TOOL_WEAK void otPlatFlashInit(otInstance *)
{
memset(sFlash, 0xff, sizeof(sFlash));
}
OT_TOOL_WEAK uint32_t otPlatFlashGetSwapSize(otInstance *)
@@ -380,7 +391,7 @@ OT_TOOL_WEAK void otPlatFlashErase(otInstance *, uint8_t aSwapIndex)
address = aSwapIndex ? FLASH_SWAP_SIZE : 0;
memset(sFlash + address, 0xff, FLASH_SWAP_SIZE);
memset(GetFlash() + address, 0xff, FLASH_SWAP_SIZE);
}
OT_TOOL_WEAK void otPlatFlashRead(otInstance *, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
@@ -393,7 +404,7 @@ OT_TOOL_WEAK void otPlatFlashRead(otInstance *, uint8_t aSwapIndex, uint32_t aOf
address = aSwapIndex ? FLASH_SWAP_SIZE : 0;
memcpy(aData, sFlash + address + aOffset, aSize);
memcpy(aData, GetFlash() + address + aOffset, aSize);
}
OT_TOOL_WEAK void otPlatFlashWrite(otInstance *,
@@ -412,7 +423,7 @@ OT_TOOL_WEAK void otPlatFlashWrite(otInstance *,
for (uint32_t index = 0; index < aSize; index++)
{
sFlash[address + aOffset + index] &= ((uint8_t *)aData)[index];
GetFlash()[address + aOffset + index] &= ((uint8_t *)aData)[index];
}
}