mirror of
https://github.com/espressif/openthread.git
synced 2026-09-07 01:30:11 +00:00
[ip6] rename methods fully initializing an Ip6::Address/Prefix (#13169)
This commit renames several methods in `Ip6::Address`, `Ip6::InterfaceIdentifier`, `Ip6::Prefix`, and `Ip4::Address` that fully initialize the object from `Set...()` to `Init...()`. This creates a clear semantic distinction in the API: - `Init...()`: Fully (re-)initializing the object. - `Set...()`: Modifies a specific property or a sub-component of the object (e.g., `SetPrefix()`, `SetLocator()`, `SetSubnetId()`). Some examples of renames include: - `SetFromExtAddress()` -> `InitFromExtAddress()` - `SetToLocator()` -> `InitAsLocator()` - `SetToLinkLocalAddress()` -> `InitAsLinkLocalAddress()` - `SetToRoutingLocator()` -> `InitAsRoutingLocator()` - `SetToAnycastLocator()` -> `InitAsAnycastLocator()` - `SetToIp4Mapped()` -> `InitAsIp4Mapped()` All calls to these methods across the codebase have been updated to reflect the new names.
This commit is contained in:
@@ -275,7 +275,8 @@ void Core::SaveTestInfo(const char *aFilename, Node *aLeaderNode)
|
||||
if (leaderNode != nullptr)
|
||||
{
|
||||
Ip6::Prefix prefix;
|
||||
prefix.Set(leaderNode->Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
|
||||
prefix.InitFrom(leaderNode->Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
fprintf(file, " \"mesh_local_prefix\": \"%s\"%s\n", prefix.ToString().AsCString(),
|
||||
mTestVars.IsEmpty() ? "" : ",");
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void InfraIf::AfterInit(void)
|
||||
GetLinkLayerAddress(mac);
|
||||
SuccessOrQuit(mac.ConvertToIid(iid));
|
||||
|
||||
address.SetToLinkLocalAddress(iid);
|
||||
address.InitAsLinkLocalAddress(iid);
|
||||
|
||||
AddAddress(address);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ void Test9_2_13(void)
|
||||
Ip6::NetworkPrefix networkPrefix;
|
||||
|
||||
SuccessOrQuit(prefix.FromString("fd00:7d1:a11:1::/64"));
|
||||
SuccessOrQuit(networkPrefix.SetFrom(prefix));
|
||||
SuccessOrQuit(networkPrefix.InitFrom(prefix));
|
||||
|
||||
/** Network 1 on Primary Channel. */
|
||||
{
|
||||
|
||||
@@ -272,7 +272,7 @@ void Test9_2_16(void)
|
||||
Ip6::NetworkPrefix networkPrefix;
|
||||
|
||||
SuccessOrQuit(prefix.FromString(kMeshLocalPrefixStep3));
|
||||
SuccessOrQuit(networkPrefix.SetFrom(prefix));
|
||||
SuccessOrQuit(networkPrefix.InitFrom(prefix));
|
||||
SuccessOrQuit(Tlv::Append<MeshCoP::MeshLocalPrefixTlv>(*message, networkPrefix));
|
||||
}
|
||||
SuccessOrQuit(Tlv::Append<MeshCoP::DelayTimerTlv>(*message, kDelayTimerStep3));
|
||||
@@ -425,7 +425,7 @@ void Test9_2_16(void)
|
||||
Ip6::NetworkPrefix networkPrefix;
|
||||
|
||||
SuccessOrQuit(prefix.FromString(kMeshLocalPrefixStep11));
|
||||
SuccessOrQuit(networkPrefix.SetFrom(prefix));
|
||||
SuccessOrQuit(networkPrefix.InitFrom(prefix));
|
||||
SuccessOrQuit(Tlv::Append<MeshCoP::MeshLocalPrefixTlv>(*message, networkPrefix));
|
||||
}
|
||||
SuccessOrQuit(Tlv::Append<MeshCoP::NetworkNameTlv>(*message, kNetworkNameStep13));
|
||||
|
||||
@@ -162,7 +162,7 @@ void TestDiagTc1(const char *aJsonFileName)
|
||||
* - N/A
|
||||
*/
|
||||
Ip6::Address dutRloc;
|
||||
dutRloc.SetToRoutingLocator(leader.Get<Mle::Mle>().GetMeshLocalPrefix(), router1.Get<Mle::Mle>().GetRloc16());
|
||||
dutRloc.InitAsRoutingLocator(leader.Get<Mle::Mle>().GetMeshLocalPrefix(), router1.Get<Mle::Mle>().GetRloc16());
|
||||
|
||||
uint8_t tlvTypesStep2[] = {
|
||||
NetDiag::Tlv::kMaxChildTimeout, NetDiag::Tlv::kEui64, NetDiag::Tlv::kVersion,
|
||||
|
||||
@@ -150,7 +150,7 @@ void TestDiagTc2(const char *aJsonFile)
|
||||
* - N/A
|
||||
*/
|
||||
Ip6::Address td1Rloc;
|
||||
td1Rloc.SetToRoutingLocator(leader1.Get<Mle::Mle>().GetMeshLocalPrefix(), td1.Get<Mle::Mle>().GetRloc16());
|
||||
td1Rloc.InitAsRoutingLocator(leader1.Get<Mle::Mle>().GetMeshLocalPrefix(), td1.Get<Mle::Mle>().GetRloc16());
|
||||
|
||||
uint8_t tlvTypesStep2[] = {
|
||||
NetDiag::Tlv::kMaxChildTimeout, NetDiag::Tlv::kEui64, NetDiag::Tlv::kVersion,
|
||||
|
||||
@@ -130,7 +130,7 @@ void Test_1_3_DPR_TC_2(void)
|
||||
Ip6::NetworkPrefix networkPrefix;
|
||||
|
||||
SuccessOrQuit(prefix.FromString("fd00:db8::/64"));
|
||||
SuccessOrQuit(networkPrefix.SetFrom(prefix));
|
||||
SuccessOrQuit(networkPrefix.InitFrom(prefix));
|
||||
br1.Get<Mle::Mle>().SetMeshLocalPrefix(networkPrefix);
|
||||
br2.Get<Mle::Mle>().SetMeshLocalPrefix(networkPrefix);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ void Test_1_3_GEN_TC_1(Topology aTopology, const char *aJsonFileName)
|
||||
* - N/A
|
||||
*/
|
||||
Ip6::Address br1Rloc;
|
||||
br1Rloc.SetToRoutingLocator(router1.Get<Mle::Mle>().GetMeshLocalPrefix(), br1.Get<Mle::Mle>().GetRloc16());
|
||||
br1Rloc.InitAsRoutingLocator(router1.Get<Mle::Mle>().GetMeshLocalPrefix(), br1.Get<Mle::Mle>().GetRloc16());
|
||||
uint8_t tlvTypes[] = {NetDiag::Tlv::kVersion};
|
||||
SuccessOrQuit(
|
||||
router1.Get<NetDiag::Client>().SendDiagnosticGet(br1Rloc, tlvTypes, sizeof(tlvTypes), nullptr, nullptr));
|
||||
@@ -312,7 +312,7 @@ void Test_1_3_GEN_TC_1(Topology aTopology, const char *aJsonFileName)
|
||||
* - N/A
|
||||
*/
|
||||
Ip6::Address router1Rloc;
|
||||
router1Rloc.SetToRoutingLocator(br1.Get<Mle::Mle>().GetMeshLocalPrefix(), router1.Get<Mle::Mle>().GetRloc16());
|
||||
router1Rloc.InitAsRoutingLocator(br1.Get<Mle::Mle>().GetMeshLocalPrefix(), router1.Get<Mle::Mle>().GetRloc16());
|
||||
SuccessOrQuit(
|
||||
br1.Get<NetDiag::Client>().SendDiagnosticGet(router1Rloc, tlvTypes, sizeof(tlvTypes), nullptr, nullptr));
|
||||
|
||||
@@ -343,7 +343,7 @@ void Test_1_3_GEN_TC_1(Topology aTopology, const char *aJsonFileName)
|
||||
* - N/A
|
||||
*/
|
||||
Ip6::Address ed1Rloc;
|
||||
ed1Rloc.SetToRoutingLocator(router1.Get<Mle::Mle>().GetMeshLocalPrefix(), ed1.Get<Mle::Mle>().GetRloc16());
|
||||
ed1Rloc.InitAsRoutingLocator(router1.Get<Mle::Mle>().GetMeshLocalPrefix(), ed1.Get<Mle::Mle>().GetRloc16());
|
||||
SuccessOrQuit(
|
||||
router1.Get<NetDiag::Client>().SendDiagnosticGet(ed1Rloc, tlvTypes, sizeof(tlvTypes), nullptr, nullptr));
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ void Test_1_4_DNS_TC_5(const char *aJsonFileName)
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().SetEnabled(true, 1));
|
||||
|
||||
SuccessOrQuit(ip4Addr.FromString("192.168.217.100"));
|
||||
eth1Ip4Addr.SetToIp4Mapped(ip4Addr);
|
||||
eth1Ip4Addr.InitAsIp4Mapped(ip4Addr);
|
||||
eth1.mInfraIf.AddAddress(eth1Ip4Addr);
|
||||
eth1.mMdns.SignalIfAddresses(eth1.GetInstance());
|
||||
|
||||
|
||||
@@ -1859,7 +1859,7 @@ void TestBorderAdmitterJoinerEnrollerInteraction(void)
|
||||
/* aCallback */ nullptr,
|
||||
/* aContext */ nullptr));
|
||||
|
||||
joinerIids[0].SetFromExtAddress(joiners[0]->Get<Joiner>().GetId());
|
||||
joinerIids[0].InitFromExtAddress(joiners[0]->Get<Joiner>().GetId());
|
||||
|
||||
nexus.AdvanceTime(8 * Time::kOneSecondInMsec);
|
||||
|
||||
@@ -2008,7 +2008,7 @@ void TestBorderAdmitterJoinerEnrollerInteraction(void)
|
||||
/* aCallback */ nullptr,
|
||||
/* aContext */ nullptr));
|
||||
|
||||
joinerIids[1].SetFromExtAddress(joiners[1]->Get<Joiner>().GetId());
|
||||
joinerIids[1].InitFromExtAddress(joiners[1]->Get<Joiner>().GetId());
|
||||
|
||||
nexus.AdvanceTime(8 * Time::kOneSecondInMsec);
|
||||
|
||||
@@ -2154,7 +2154,7 @@ void TestBorderAdmitterJoinerEnrollerInteraction(void)
|
||||
/* aCallback */ nullptr,
|
||||
/* aContext */ nullptr));
|
||||
|
||||
joinerIids[1].SetFromExtAddress(joiners[1]->Get<Joiner>().GetId());
|
||||
joinerIids[1].InitFromExtAddress(joiners[1]->Get<Joiner>().GetId());
|
||||
|
||||
nexus.AdvanceTime(8 * Time::kOneSecondInMsec);
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ void TestPbbrAloc(void)
|
||||
|
||||
// 2. PBBR ALOC
|
||||
aloc.SetPrefix(leader.Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
aloc.GetIid().SetToLocator(Mle::Aloc16::ForPrimaryBackboneRouter());
|
||||
aloc.GetIid().InitAsLocator(Mle::Aloc16::ForPrimaryBackboneRouter());
|
||||
Log("Pinging PBBR ALOC %s from ROUTER", aloc.ToString().AsCString());
|
||||
nexus.SendAndVerifyEchoRequest(router, aloc);
|
||||
|
||||
|
||||
@@ -110,8 +110,8 @@ void TestService(void)
|
||||
Ip6::Address aloc0;
|
||||
Ip6::Address aloc1;
|
||||
|
||||
aloc0.SetToAnycastLocator(leader.Get<Mle::Mle>().GetMeshLocalPrefix(), Mle::Aloc16::FromServiceId(0));
|
||||
aloc1.SetToAnycastLocator(leader.Get<Mle::Mle>().GetMeshLocalPrefix(), Mle::Aloc16::FromServiceId(1));
|
||||
aloc0.InitAsAnycastLocator(leader.Get<Mle::Mle>().GetMeshLocalPrefix(), Mle::Aloc16::FromServiceId(0));
|
||||
aloc1.InitAsAnycastLocator(leader.Get<Mle::Mle>().GetMeshLocalPrefix(), Mle::Aloc16::FromServiceId(1));
|
||||
|
||||
// Initial check: no ALOCs
|
||||
for (Node &node : nexus.GetNodes())
|
||||
|
||||
@@ -109,7 +109,7 @@ void TestChildIp6Address(void)
|
||||
const uint8_t meshLocalIidArray[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
|
||||
Ip6::InterfaceIdentifier meshLocalIid;
|
||||
|
||||
meshLocalIid.SetBytes(meshLocalIidArray);
|
||||
meshLocalIid.InitFrom(meshLocalIidArray);
|
||||
|
||||
sInstance = testInitInstance();
|
||||
VerifyOrQuit(sInstance != nullptr);
|
||||
|
||||
@@ -406,7 +406,7 @@ void TestIp6AddressSetPrefix(void)
|
||||
for (size_t prefixLength = 0; prefixLength <= sizeof(Ip6::Address) * kBitsPerByte; prefixLength++)
|
||||
{
|
||||
ip6Prefix.Clear();
|
||||
ip6Prefix.Set(prefix, prefixLength);
|
||||
ip6Prefix.InitFrom(prefix, prefixLength);
|
||||
|
||||
address = allZeroAddress;
|
||||
address.SetPrefix(ip6Prefix);
|
||||
@@ -442,7 +442,7 @@ Ip6::Prefix PrefixFrom(const char *aAddressString, uint8_t aPrefixLength)
|
||||
Ip6::Address address;
|
||||
|
||||
SuccessOrQuit(address.FromString(aAddressString));
|
||||
prefix.Set(address.GetBytes(), aPrefixLength);
|
||||
prefix.InitFrom(address.GetBytes(), aPrefixLength);
|
||||
|
||||
return prefix;
|
||||
}
|
||||
@@ -466,7 +466,7 @@ void TestIp6Prefix(void)
|
||||
|
||||
for (uint8_t prefixLength = 1; prefixLength <= Ip6::Prefix::kMaxLength; prefixLength++)
|
||||
{
|
||||
prefix.Set(prefixBytes, prefixLength);
|
||||
prefix.InitFrom(prefixBytes, prefixLength);
|
||||
|
||||
printf("Prefix %s\n", prefix.ToString().AsCString());
|
||||
|
||||
@@ -484,7 +484,7 @@ void TestIp6Prefix(void)
|
||||
{
|
||||
Ip6::Prefix subPrefix;
|
||||
|
||||
subPrefix.Set(prefixBytes, subPrefixLength);
|
||||
subPrefix.InitFrom(prefixBytes, subPrefixLength);
|
||||
|
||||
VerifyOrQuit(prefix.ContainsPrefix(subPrefix));
|
||||
|
||||
@@ -740,7 +740,7 @@ void TestIp6PrefixTidy(void)
|
||||
Ip6::Prefix prefix, answer;
|
||||
|
||||
SuccessOrQuit(answer.FromString(test.prefixStringAfterTidy[i]));
|
||||
prefix.Set(test.originalPrefix, i);
|
||||
prefix.InitFrom(test.originalPrefix, i);
|
||||
prefix.Tidy();
|
||||
|
||||
{
|
||||
@@ -774,10 +774,10 @@ void TestIp4MappedIp6Address(void)
|
||||
|
||||
printf("\nTestIp4MappedIp6Address()\n");
|
||||
|
||||
expectedIp4Address.SetBytes(kIp4Address);
|
||||
expectedIp4Address.InitFrom(kIp4Address);
|
||||
|
||||
SuccessOrQuit(expectedIp6Address.FromString("::ffff:192.0.2.33"));
|
||||
ip6Address.SetToIp4Mapped(expectedIp4Address);
|
||||
ip6Address.InitAsIp4Mapped(expectedIp4Address);
|
||||
|
||||
printf("IPv4-mapped IPv6 address: %s\n", ip6Address.ToString().AsCString());
|
||||
|
||||
@@ -823,7 +823,7 @@ void TestIp4Ip6Translation(void)
|
||||
|
||||
printf("\nTestIp4Ip6Translation()\n");
|
||||
|
||||
ip4Address.SetBytes(kIp4Address);
|
||||
ip4Address.InitFrom(kIp4Address);
|
||||
|
||||
for (const TestCase &testCase : kTestCases)
|
||||
{
|
||||
@@ -832,7 +832,7 @@ void TestIp4Ip6Translation(void)
|
||||
Ip6::Address expectedAddress;
|
||||
|
||||
SuccessOrQuit(address.FromString(testCase.mPrefix));
|
||||
prefix.Set(address.GetBytes(), testCase.mLength);
|
||||
prefix.InitFrom(address.GetBytes(), testCase.mLength);
|
||||
|
||||
SuccessOrQuit(expectedAddress.FromString(testCase.mIp6Address));
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ void UnitTester::TestLinkMetricsManager(void)
|
||||
}
|
||||
|
||||
// subject1 received a response with a success status code
|
||||
linkLocalAddr.SetToLinkLocalAddress(AsCoreType(&mTestChildList[0].mExtAddress));
|
||||
linkLocalAddr.InitAsLinkLocalAddress(AsCoreType(&mTestChildList[0].mExtAddress));
|
||||
linkMetricsMgr->HandleMgmtResponse(&linkLocalAddr, MapEnum(LinkMetrics::Status::kStatusSuccess));
|
||||
VerifyOrQuit(subject1->mState == LinkMetricsManager::SubjectState::kActive);
|
||||
|
||||
|
||||
@@ -2271,7 +2271,7 @@ void TestLocalHost(void)
|
||||
|
||||
SuccessOrQuit(ip4Address.FromString("200.1.5.6"));
|
||||
SuccessOrQuit(localHost.mIp4Addrs.PushBack(ip4Address));
|
||||
ip6Address.SetToIp4Mapped(ip4Address);
|
||||
ip6Address.InitAsIp4Mapped(ip4Address);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
|
||||
AdvanceTime(4);
|
||||
@@ -2436,17 +2436,17 @@ void TestLocalHost(void)
|
||||
|
||||
SuccessOrQuit(ip4Address.FromString("200.1.5.7"));
|
||||
SuccessOrQuit(localHost.mIp4Addrs.PushBack(ip4Address));
|
||||
ip6Address.SetToIp4Mapped(ip4Address);
|
||||
ip6Address.InitAsIp4Mapped(ip4Address);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
|
||||
SuccessOrQuit(ip4Address.FromString("200.1.2.100"));
|
||||
SuccessOrQuit(localHost.mIp4Addrs.PushBack(ip4Address));
|
||||
ip6Address.SetToIp4Mapped(ip4Address);
|
||||
ip6Address.InitAsIp4Mapped(ip4Address);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
|
||||
SuccessOrQuit(ip4Address.FromString("200.1.4.0"));
|
||||
SuccessOrQuit(localHost.mIp4Addrs.PushBack(ip4Address));
|
||||
ip6Address.SetToIp4Mapped(ip4Address);
|
||||
ip6Address.InitAsIp4Mapped(ip4Address);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
|
||||
Log("Validate the announcements");
|
||||
@@ -2481,7 +2481,7 @@ void TestLocalHost(void)
|
||||
|
||||
for (Ip4::Address &ip4Addr : localHost.mIp4Addrs)
|
||||
{
|
||||
ip6Address.SetToIp4Mapped(ip4Addr);
|
||||
ip6Address.InitAsIp4Mapped(ip4Addr);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
}
|
||||
|
||||
@@ -2510,7 +2510,7 @@ void TestLocalHost(void)
|
||||
|
||||
for (Ip4::Address &ip4Addr : localHost.mIp4Addrs)
|
||||
{
|
||||
ip6Address.SetToIp4Mapped(ip4Addr);
|
||||
ip6Address.InitAsIp4Mapped(ip4Addr);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
}
|
||||
|
||||
@@ -2562,7 +2562,7 @@ void TestLocalHost(void)
|
||||
|
||||
for (Ip4::Address &ip4Addr : localHost.mIp4Addrs)
|
||||
{
|
||||
ip6Address.SetToIp4Mapped(ip4Addr);
|
||||
ip6Address.InitAsIp4Mapped(ip4Addr);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ true, kInfraIfIndex);
|
||||
}
|
||||
|
||||
@@ -2589,7 +2589,7 @@ void TestLocalHost(void)
|
||||
|
||||
for (const Ip4::Address &ip4Addr : localHost.mIp4Addrs)
|
||||
{
|
||||
ip6Address.SetToIp4Mapped(ip4Addr);
|
||||
ip6Address.InitAsIp4Mapped(ip4Addr);
|
||||
otPlatMdnsHandleHostAddressEvent(sInstance, &ip6Address, /* aAdded */ false, kInfraIfIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -4997,7 +4997,7 @@ void TestDhcp6Pd(void)
|
||||
|
||||
prefix = PrefixFromString("2001:db8:cafe:0::", 64);
|
||||
|
||||
shortPrefix.Set(prefix.GetBytes(), 48);
|
||||
shortPrefix.InitFrom(prefix.GetBytes(), 48);
|
||||
ReportPdPrefixesAsRa({Pio(shortPrefix, kValidLitime, kPreferredLifetime)});
|
||||
|
||||
sExpectedRios.Add(prefix);
|
||||
|
||||
Reference in New Issue
Block a user