mirror of
https://github.com/espressif/openthread.git
synced 2026-08-23 18:59:51 +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:
@@ -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