mirror of
https://github.com/espressif/openthread.git
synced 2026-08-12 21:57:47 +00:00
[child] remove instance parameter from Ip6Address related methods (#4569)
Remove the now unnecessary `aInstance` parameter in `Child` methods (since `Child` is now itself an `InstanceLocator`).
This commit is contained in:
committed by
Jonathan Hui
parent
fb65c77c1a
commit
0f5edc4c89
@@ -681,7 +681,7 @@ void AddressResolver::HandleAddressError(Coap::Message &aMessage, const Ip6::Mes
|
||||
// Mesh Local EID differs, so check whether Target EID
|
||||
// matches a child address and if so remove it.
|
||||
|
||||
if (child.RemoveIp6Address(GetInstance(), targetTlv.GetTarget()) == OT_ERROR_NONE)
|
||||
if (child.RemoveIp6Address(targetTlv.GetTarget()) == OT_ERROR_NONE)
|
||||
{
|
||||
destination.Clear();
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
@@ -742,7 +742,7 @@ void AddressResolver::HandleAddressQuery(Coap::Message &aMessage, const Ip6::Mes
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child.HasIp6Address(GetInstance(), targetTlv.GetTarget()))
|
||||
if (child.HasIp6Address(targetTlv.GetTarget()))
|
||||
{
|
||||
mlIidTlv.SetIid(child.GetExtAddress());
|
||||
lastTransactionTimeTlv.SetTime(TimerMilli::GetNow() - child.GetLastHeard());
|
||||
|
||||
@@ -2021,7 +2021,7 @@ otError MleRouter::UpdateChildAddresses(const Message &aMessage, uint16_t aOffse
|
||||
// We try to accept/add as many IPv6 addresses as possible.
|
||||
// "Child ID/Update Response" will indicate the accepted
|
||||
// addresses.
|
||||
error = aChild.AddIp6Address(GetInstance(), address);
|
||||
error = aChild.AddIp6Address(address);
|
||||
|
||||
if (error == OT_ERROR_NONE)
|
||||
{
|
||||
@@ -2057,7 +2057,7 @@ otError MleRouter::UpdateChildAddresses(const Message &aMessage, uint16_t aOffse
|
||||
continue;
|
||||
}
|
||||
|
||||
IgnoreReturnValue(iter.GetChild()->RemoveIp6Address(GetInstance(), address));
|
||||
IgnoreReturnValue(iter.GetChild()->RemoveIp6Address(address));
|
||||
}
|
||||
|
||||
// Clear EID-to-RLOC cache for the unicast address registered by the child.
|
||||
@@ -3356,7 +3356,7 @@ Neighbor *MleRouter::GetNeighbor(const Ip6::Address &aAddress)
|
||||
ExitNow(rval = child);
|
||||
}
|
||||
|
||||
if (child->HasIp6Address(GetInstance(), aAddress))
|
||||
if (child->HasIp6Address(aAddress))
|
||||
{
|
||||
ExitNow(rval = child);
|
||||
}
|
||||
@@ -3539,7 +3539,7 @@ otError MleRouter::GetChildNextIp6Address(uint16_t aChildIndex
|
||||
VerifyOrExit(child != NULL, error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(child->IsStateValidOrRestoring(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
error = child->GetNextIp6Address(GetInstance(), aIterator, aAddress);
|
||||
error = child->GetNextIp6Address(aIterator, aAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -4352,7 +4352,7 @@ otError MleRouter::AppendChildAddresses(Message &aMessage, Child &aChild)
|
||||
tlv.SetType(Tlv::kAddressRegistration);
|
||||
SuccessOrExit(error = aMessage.Append(&tlv, sizeof(tlv)));
|
||||
|
||||
while (aChild.GetNextIp6Address(GetInstance(), iterator, address) == OT_ERROR_NONE)
|
||||
while (aChild.GetNextIp6Address(iterator, address) == OT_ERROR_NONE)
|
||||
{
|
||||
if (address.IsMulticast() || Get<NetworkData::Leader>().GetContext(address, context) != OT_ERROR_NONE)
|
||||
{
|
||||
@@ -4705,8 +4705,7 @@ exit:
|
||||
|
||||
bool MleRouter::IsSleepyChildSubscribed(const Ip6::Address &aAddress, Child &aChild)
|
||||
{
|
||||
return aChild.IsStateValidOrRestoring() && !aChild.IsRxOnWhenIdle() &&
|
||||
aChild.HasIp6Address(GetInstance(), aAddress);
|
||||
return aChild.IsStateValidOrRestoring() && !aChild.IsRxOnWhenIdle() && aChild.HasIp6Address(aAddress);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
|
||||
@@ -145,14 +145,13 @@ exit:
|
||||
return retval;
|
||||
}
|
||||
|
||||
otError Child::GetMeshLocalIp6Address(Instance &aInstance, Ip6::Address &aAddress) const
|
||||
otError Child::GetMeshLocalIp6Address(Ip6::Address &aAddress) const
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(!IsAllZero(mMeshLocalIid, sizeof(mMeshLocalIid)), error = OT_ERROR_NOT_FOUND);
|
||||
|
||||
memcpy(aAddress.mFields.m8, aInstance.Get<Mle::MleRouter>().GetMeshLocalPrefix().m8,
|
||||
Ip6::Address::kMeshLocalPrefixSize);
|
||||
memcpy(aAddress.mFields.m8, Get<Mle::MleRouter>().GetMeshLocalPrefix().m8, Ip6::Address::kMeshLocalPrefixSize);
|
||||
|
||||
aAddress.SetIid(mMeshLocalIid);
|
||||
|
||||
@@ -160,7 +159,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Child::GetNextIp6Address(Instance &aInstance, Ip6AddressIterator &aIterator, Ip6::Address &aAddress) const
|
||||
otError Child::GetNextIp6Address(Ip6AddressIterator &aIterator, Ip6::Address &aAddress) const
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otChildIp6AddressIterator index;
|
||||
@@ -170,7 +169,7 @@ otError Child::GetNextIp6Address(Instance &aInstance, Ip6AddressIterator &aItera
|
||||
if (aIterator.Get() == 0)
|
||||
{
|
||||
aIterator.Increment();
|
||||
VerifyOrExit(GetMeshLocalIp6Address(aInstance, aAddress) == OT_ERROR_NOT_FOUND);
|
||||
VerifyOrExit(GetMeshLocalIp6Address(aAddress) == OT_ERROR_NOT_FOUND);
|
||||
}
|
||||
|
||||
index = aIterator.Get() - 1;
|
||||
@@ -185,13 +184,13 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Child::AddIp6Address(Instance &aInstance, const Ip6::Address &aAddress)
|
||||
otError Child::AddIp6Address(const Ip6::Address &aAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(!aAddress.IsUnspecified(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
if (aInstance.Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
VerifyOrExit(IsAllZero(mMeshLocalIid, sizeof(mMeshLocalIid)), error = OT_ERROR_ALREADY);
|
||||
memcpy(mMeshLocalIid, aAddress.GetIid(), Ip6::Address::kInterfaceIdentifierSize);
|
||||
@@ -215,14 +214,14 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Child::RemoveIp6Address(Instance &aInstance, const Ip6::Address &aAddress)
|
||||
otError Child::RemoveIp6Address(const Ip6::Address &aAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NOT_FOUND;
|
||||
uint16_t index;
|
||||
|
||||
VerifyOrExit(!aAddress.IsUnspecified(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
if (aInstance.Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
if (memcmp(aAddress.GetIid(), mMeshLocalIid, Ip6::Address::kInterfaceIdentifierSize) == 0)
|
||||
{
|
||||
@@ -257,13 +256,13 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
bool Child::HasIp6Address(Instance &aInstance, const Ip6::Address &aAddress) const
|
||||
bool Child::HasIp6Address(const Ip6::Address &aAddress) const
|
||||
{
|
||||
bool retval = false;
|
||||
|
||||
VerifyOrExit(!aAddress.IsUnspecified());
|
||||
|
||||
if (aInstance.Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
retval = (memcmp(aAddress.GetIid(), mMeshLocalIid, Ip6::Address::kInterfaceIdentifierSize) == 0);
|
||||
ExitNow();
|
||||
|
||||
@@ -542,19 +542,17 @@ public:
|
||||
/**
|
||||
* This method gets the mesh-local IPv6 address.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[out] aAddress A reference to an IPv6 address to provide address (if any).
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully found the mesh-local address and updated @p aAddress.
|
||||
* @retval OT_ERROR_NOT_FOUND No mesh-local IPv6 address in the IPv6 address list.
|
||||
*
|
||||
*/
|
||||
otError GetMeshLocalIp6Address(Instance &aInstance, Ip6::Address &aAddress) const;
|
||||
otError GetMeshLocalIp6Address(Ip6::Address &aAddress) const;
|
||||
|
||||
/**
|
||||
* This method gets the next IPv6 address in the list.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[inout] aIterator A reference to an IPv6 address iterator.
|
||||
* @param[out] aAddress A reference to an IPv6 address to provide the next address (if any).
|
||||
*
|
||||
@@ -562,12 +560,11 @@ public:
|
||||
* @retval OT_ERROR_NOT_FOUND No subsequent IPv6 address exists in the IPv6 address list.
|
||||
*
|
||||
*/
|
||||
otError GetNextIp6Address(Instance &aInstance, Ip6AddressIterator &aIterator, Ip6::Address &aAddress) const;
|
||||
otError GetNextIp6Address(Ip6AddressIterator &aIterator, Ip6::Address &aAddress) const;
|
||||
|
||||
/**
|
||||
* This method adds an IPv6 address to the list.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[in] aAddress A reference to IPv6 address to be added.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully added the new address.
|
||||
@@ -576,12 +573,11 @@ public:
|
||||
* @retval OT_ERROR_INVALID_ARGS Address is invalid (it is the Unspecified Address).
|
||||
*
|
||||
*/
|
||||
otError AddIp6Address(Instance &aInstance, const Ip6::Address &aAddress);
|
||||
otError AddIp6Address(const Ip6::Address &aAddress);
|
||||
|
||||
/**
|
||||
* This method removes an IPv6 address from the list.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[in] aAddress A reference to IPv6 address to be removed.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully removed the address.
|
||||
@@ -589,19 +585,18 @@ public:
|
||||
* @retval OT_ERROR_INVALID_ARGS Address is invalid (it is the Unspecified Address).
|
||||
*
|
||||
*/
|
||||
otError RemoveIp6Address(Instance &aInstance, const Ip6::Address &aAddress);
|
||||
otError RemoveIp6Address(const Ip6::Address &aAddress);
|
||||
|
||||
/**
|
||||
* This method indicates whether an IPv6 address is in the list of IPv6 addresses of the child.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[in] aAddress A reference to IPv6 address.
|
||||
*
|
||||
* @retval TRUE The address exists on the list.
|
||||
* @retval FALSE Address was not found in the list.
|
||||
*
|
||||
*/
|
||||
bool HasIp6Address(Instance &aInstance, const Ip6::Address &aAddress) const;
|
||||
bool HasIp6Address(const Ip6::Address &aAddress) const;
|
||||
|
||||
/**
|
||||
* This method gets the child timeout.
|
||||
|
||||
+15
-15
@@ -54,7 +54,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
|
||||
for (uint8_t index = 0; index < aAddressListLength; index++)
|
||||
{
|
||||
VerifyOrQuit(aChild.HasIp6Address(*sInstance, aAddressList[index]), "HasIp6Address() failed");
|
||||
VerifyOrQuit(aChild.HasIp6Address(aAddressList[index]), "HasIp6Address() failed");
|
||||
}
|
||||
|
||||
memset(addressObserved, 0, sizeof(addressObserved));
|
||||
@@ -67,7 +67,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
}
|
||||
}
|
||||
|
||||
while (aChild.GetNextIp6Address(*sInstance, iterator, address) == OT_ERROR_NONE)
|
||||
while (aChild.GetNextIp6Address(iterator, address) == OT_ERROR_NONE)
|
||||
{
|
||||
bool addressIsInList = false;
|
||||
|
||||
@@ -90,7 +90,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
|
||||
if (sInstance->Get<Mle::MleRouter>().IsMeshLocalAddress(aAddressList[index]))
|
||||
{
|
||||
SuccessOrQuit(aChild.GetMeshLocalIp6Address(*sInstance, address),
|
||||
SuccessOrQuit(aChild.GetMeshLocalIp6Address(address),
|
||||
"Child::GetMeshLocalIp6Address() failed\n");
|
||||
VerifyOrQuit(address == aAddressList[index], "GetMeshLocalIp6Address() did not return expected address");
|
||||
hasMeshLocal = true;
|
||||
@@ -99,7 +99,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
|
||||
if (!hasMeshLocal)
|
||||
{
|
||||
VerifyOrQuit(aChild.GetMeshLocalIp6Address(*sInstance, address) == OT_ERROR_NOT_FOUND,
|
||||
VerifyOrQuit(aChild.GetMeshLocalIp6Address(address) == OT_ERROR_NOT_FOUND,
|
||||
"Child::GetMeshLocalIp6Address() returned an address not in the expected list");
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ void TestChildIp6Address(void)
|
||||
|
||||
for (uint8_t index = 0; index < numAddresses; index++)
|
||||
{
|
||||
SuccessOrQuit(child.AddIp6Address(*sInstance, addresses[index]), "AddIp6Address() failed");
|
||||
SuccessOrQuit(child.AddIp6Address(addresses[index]), "AddIp6Address() failed");
|
||||
VerifyChildIp6Addresses(child, 1, &addresses[index]);
|
||||
|
||||
child.ClearIp6Addresses();
|
||||
@@ -168,7 +168,7 @@ void TestChildIp6Address(void)
|
||||
|
||||
for (uint8_t index = 0; index < numAddresses; index++)
|
||||
{
|
||||
SuccessOrQuit(child.AddIp6Address(*sInstance, addresses[index]), "AddIp6Address() failed");
|
||||
SuccessOrQuit(child.AddIp6Address(addresses[index]), "AddIp6Address() failed");
|
||||
VerifyChildIp6Addresses(child, index + 1, addresses);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ void TestChildIp6Address(void)
|
||||
|
||||
for (uint8_t index = 0; index < numAddresses; index++)
|
||||
{
|
||||
VerifyOrQuit(child.AddIp6Address(*sInstance, addresses[index]) == OT_ERROR_ALREADY,
|
||||
VerifyOrQuit(child.AddIp6Address(addresses[index]) == OT_ERROR_ALREADY,
|
||||
"AddIp6Address() did not fail when adding same address");
|
||||
VerifyChildIp6Addresses(child, numAddresses, addresses);
|
||||
}
|
||||
@@ -191,10 +191,10 @@ void TestChildIp6Address(void)
|
||||
|
||||
for (uint8_t index = 0; index < numAddresses; index++)
|
||||
{
|
||||
SuccessOrQuit(child.RemoveIp6Address(*sInstance, addresses[index]), "RemoveIp6Address() failed");
|
||||
SuccessOrQuit(child.RemoveIp6Address(addresses[index]), "RemoveIp6Address() failed");
|
||||
VerifyChildIp6Addresses(child, numAddresses - 1 - index, &addresses[index + 1]);
|
||||
|
||||
VerifyOrQuit(child.RemoveIp6Address(*sInstance, addresses[index]) == OT_ERROR_NOT_FOUND,
|
||||
VerifyOrQuit(child.RemoveIp6Address(addresses[index]) == OT_ERROR_NOT_FOUND,
|
||||
"RemoveIp6Address() did not fail when removing an address not on the list");
|
||||
}
|
||||
|
||||
@@ -206,15 +206,15 @@ void TestChildIp6Address(void)
|
||||
|
||||
for (uint8_t index = 0; index < numAddresses; index++)
|
||||
{
|
||||
SuccessOrQuit(child.AddIp6Address(*sInstance, addresses[index]), "AddIp6Address() failed");
|
||||
SuccessOrQuit(child.AddIp6Address(addresses[index]), "AddIp6Address() failed");
|
||||
}
|
||||
|
||||
for (uint8_t index = numAddresses - 1; index > 0; index--)
|
||||
{
|
||||
SuccessOrQuit(child.RemoveIp6Address(*sInstance, addresses[index]), "RemoveIp6Address() failed");
|
||||
SuccessOrQuit(child.RemoveIp6Address(addresses[index]), "RemoveIp6Address() failed");
|
||||
VerifyChildIp6Addresses(child, index, &addresses[0]);
|
||||
|
||||
VerifyOrQuit(child.RemoveIp6Address(*sInstance, addresses[index]) == OT_ERROR_NOT_FOUND,
|
||||
VerifyOrQuit(child.RemoveIp6Address(addresses[index]) == OT_ERROR_NOT_FOUND,
|
||||
"RemoveIp6Address() did not fail when removing an address not on the list");
|
||||
}
|
||||
|
||||
@@ -229,12 +229,12 @@ void TestChildIp6Address(void)
|
||||
|
||||
for (uint8_t index = 0; index < numAddresses; index++)
|
||||
{
|
||||
SuccessOrQuit(child.AddIp6Address(*sInstance, addresses[index]), "AddIp6Address() failed");
|
||||
SuccessOrQuit(child.AddIp6Address(addresses[index]), "AddIp6Address() failed");
|
||||
}
|
||||
|
||||
SuccessOrQuit(child.RemoveIp6Address(*sInstance, addresses[indexToRemove]), "RemoveIp6Address() failed");
|
||||
SuccessOrQuit(child.RemoveIp6Address(addresses[indexToRemove]), "RemoveIp6Address() failed");
|
||||
|
||||
VerifyOrQuit(child.RemoveIp6Address(*sInstance, addresses[indexToRemove]) == OT_ERROR_NOT_FOUND,
|
||||
VerifyOrQuit(child.RemoveIp6Address(addresses[indexToRemove]) == OT_ERROR_NOT_FOUND,
|
||||
"RemoveIp6Address() did not fail when removing an address not on the list");
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user