[net-data-leader] check stable sub-tlvs when comparing in IsStableUpdated() (#2184)

This commit changes `IsStableUpdated()` to ensure the stable
BorderRouter and/or HasRoute sub-tlvs are used when comparing
two network-data.
This commit is contained in:
Abtin Keshavarzian
2017-09-12 09:20:34 -07:00
committed by Jonathan Hui
parent ce2bc59c87
commit 2f429f6d88
2 changed files with 8 additions and 11 deletions
+7 -9
View File
@@ -519,8 +519,7 @@ exit:
return error;
}
bool Leader::IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aTlvsBase,
uint8_t aTlvsBaseLength)
bool Leader::IsStableUpdated(uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aTlvsBase, uint8_t aTlvsBaseLength)
{
bool rval = false;
NetworkDataTlv *cur = reinterpret_cast<NetworkDataTlv *>(aTlvs);
@@ -534,8 +533,8 @@ bool Leader::IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLeng
{
PrefixTlv *prefix = static_cast<PrefixTlv *>(cur);
ContextTlv *context = FindContext(*prefix);
BorderRouterTlv *borderRouter = FindBorderRouter(*prefix);
HasRouteTlv *hasRoute = FindHasRoute(*prefix);
BorderRouterTlv *borderRouter = FindBorderRouter(*prefix, true);
HasRouteTlv *hasRoute = FindHasRoute(*prefix, true);
if (cur->IsStable() && (!context || borderRouter))
{
@@ -549,7 +548,7 @@ bool Leader::IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLeng
if (borderRouter)
{
BorderRouterTlv *borderRouterBase = FindBorderRouter(*prefixBase);
BorderRouterTlv *borderRouterBase = FindBorderRouter(*prefixBase, true);
if (!borderRouterBase || memcmp(borderRouter, borderRouterBase, borderRouter->GetLength()) != 0)
{
@@ -559,7 +558,7 @@ bool Leader::IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLeng
if (hasRoute)
{
HasRouteTlv *hasRouteBase = FindHasRoute(*prefixBase);
HasRouteTlv *hasRouteBase = FindHasRoute(*prefixBase, true);
if (!hasRouteBase || (memcmp(hasRoute, hasRouteBase, hasRoute->GetLength()) != 0))
{
@@ -573,7 +572,6 @@ bool Leader::IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLeng
}
exit:
OT_UNUSED_VARIABLE(aRloc16);
return rval;
}
@@ -588,8 +586,8 @@ otError Leader::RegisterNetworkData(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aT
if (rlocIn)
{
if (IsStableUpdated(aRloc16, aTlvs, aTlvsLength, mTlvs, mLength) ||
IsStableUpdated(aRloc16, mTlvs, mLength, aTlvs, aTlvsLength))
if (IsStableUpdated(aTlvs, aTlvsLength, mTlvs, mLength) ||
IsStableUpdated(mTlvs, mLength, aTlvs, aTlvsLength))
{
stableUpdated = true;
}
+1 -2
View File
@@ -169,8 +169,7 @@ private:
otError RemoveRloc(PrefixTlv &aPrefix, BorderRouterTlv &aBorderRouter, uint16_t aRloc16);
otError RlocLookup(uint16_t aRloc16, bool &aIn, bool &aStable, uint8_t *aTlvs, uint8_t aTlvsLength);
bool IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aTlvsBase,
uint8_t aTlvsBaseLength);
bool IsStableUpdated(uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aTlvsBase, uint8_t aTlvsBaseLength);
static void HandleCommissioningSet(void *aContext, otCoapHeader *aHeader, otMessage *aMessage,
const otMessageInfo *aMessageInfo);