void SourceMatchController::AddEntry(Child &aChild) { aChild.SetIndirectSourceMatchPending(true); if (!IsEnabled()) { SuccessOrExit(AddPendingEntries()); Enable(true); } else { VerifyOrExit(AddAddress(aChild) == OT_ERROR_NONE, Enable(false)); aChild.SetIndirectSourceMatchPending(false); } exit: return; }
void SourceMatchController::ClearEntry(Child &aChild) { otError error = OT_ERROR_NONE; if (aChild.IsIndirectSourceMatchPending()) { otLogDebgMac(GetInstance(), "SrcAddrMatch - Clearing pending flag for 0x%04x", aChild.GetRloc16()); aChild.SetIndirectSourceMatchPending(false); ExitNow(); } if (aChild.IsIndirectSourceMatchShort()) { error = otPlatRadioClearSrcMatchShortEntry(&GetInstance(), aChild.GetRloc16()); otLogDebgMac(GetInstance(), "SrcAddrMatch - Clearing short address: 0x%04x -- %s (%d)", aChild.GetRloc16(), otThreadErrorToString(error), error); } else { otExtAddress addr; for (uint8_t i = 0; i < sizeof(addr); i++) { addr.m8[i] = aChild.GetExtAddress().m8[sizeof(aChild.GetExtAddress()) - 1 - i]; } error = otPlatRadioClearSrcMatchExtEntry(&GetInstance(), &addr); otLogDebgMac(GetInstance(), "SrcAddrMatch - Clearing addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x -- %s (%d)", 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); } SuccessOrExit(error); if (!IsEnabled()) { SuccessOrExit(AddPendingEntries()); Enable(true); } exit: return; }