Skip to content

Commit 2a2d4be

Browse files
authored
[ip6] rename methods fully initializing an Ip6::Address/Prefix (openthread#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.
1 parent e1b34bc commit 2a2d4be

52 files changed

Lines changed: 154 additions & 148 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core/api/ip6_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ bool otIp6IsLinkLocalUnicast(const otIp6Address *aAddress) { return AsCoreType(a
191191

192192
void otIp6FormLinkLocalAddressFromExtAddress(const otExtAddress *aExtAddress, otIp6Address *aAddress)
193193
{
194-
AsCoreType(aAddress).SetToLinkLocalAddress(AsCoreType(aExtAddress));
194+
AsCoreType(aAddress).InitAsLinkLocalAddress(AsCoreType(aExtAddress));
195195
}
196196

197197
void otIp6ExtractExtAddressFromIp6AddressIid(const otIp6Address *aAddress, otExtAddress *aExtAddress)

src/core/api/nat64_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ otError otIp4FromIp4MappedIp6Address(const otIp6Address *aIp6Address, otIp4Addre
142142

143143
void otIp4ToIp4MappedIp6Address(const otIp4Address *aIp4Address, otIp6Address *aIp6Address)
144144
{
145-
AsCoreType(aIp6Address).SetToIp4Mapped(AsCoreType(aIp4Address));
145+
AsCoreType(aIp6Address).InitAsIp4Mapped(AsCoreType(aIp4Address));
146146
}
147147

148148
otError otIp4AddressFromString(const char *aString, otIp4Address *aAddress)

src/core/backbone_router/bbr_local.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Local::Local(Instance &aInstance)
5757

5858
// Primary Backbone Router Aloc
5959
mBbrPrimaryAloc.InitAsThreadOriginMeshLocal();
60-
mBbrPrimaryAloc.GetAddress().GetIid().SetToLocator(Mle::Aloc16::ForPrimaryBackboneRouter());
60+
mBbrPrimaryAloc.GetAddress().GetIid().InitAsLocator(Mle::Aloc16::ForPrimaryBackboneRouter());
6161

6262
// All Network Backbone Routers Multicast Address.
6363
mAllNetworkBackboneRouters.Clear();

src/core/border_router/infra_if.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Error InfraIf::LinkLayerAddress::ConvertToIid(Ip6::InterfaceIdentifier &aIid) co
278278
ExitNow(error = kErrorNotCapable);
279279
}
280280

281-
aIid.SetFromExtAddress(extAddress);
281+
aIid.InitFromExtAddress(extAddress);
282282

283283
exit:
284284
return error;

src/core/border_router/routing_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void RoutingManager::LoadOrGenerateRandomBrUlaPrefix(void)
224224

225225
SuccessOrAssert(randomUlaPrefix.GenerateRandomUla());
226226

227-
mBrUlaPrefix.Set(randomUlaPrefix);
227+
mBrUlaPrefix.InitFrom(randomUlaPrefix);
228228
mBrUlaPrefix.SetSubnetId(0);
229229
mBrUlaPrefix.SetLength(kBrUlaPrefixLength);
230230

src/core/meshcop/border_agent_txt_data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ bool TxtData::Info::ReadOmrPrefix(const Dns::TxtEntry &aEntry, Ip6::Prefix &aPre
544544
VerifyOrExit(length <= Ip6::Prefix::kMaxLength);
545545
VerifyOrExit(aEntry.mValueLength >= sizeof(uint8_t) + Ip6::Prefix::SizeForLength(length));
546546

547-
aPrefix.Set(&aEntry.mValue[1], length);
547+
aPrefix.InitFrom(&aEntry.mValue[1], length);
548548
didRead = true;
549549

550550
exit:

src/core/meshcop/joiner_router.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ template <> void JoinerRouter::HandleTmf<kUriRelayTx>(Coap::Msg &aMsg)
168168

169169
SuccessOrExit(error = message->AppendBytesFromMessage(aMsg.mMessage, offsetRange));
170170

171-
messageInfo.GetPeerAddr().SetToLinkLocalAddress(joinerIid);
171+
messageInfo.GetPeerAddr().InitAsLinkLocalAddress(joinerIid);
172172
messageInfo.SetPeerPort(joinerPort);
173173

174174
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));

src/core/meshcop/seeker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ Error Seeker::SetUpNextConnection(Ip6::SockAddr &aSockAddr)
279279

280280
aSockAddr.Clear();
281281
aSockAddr.SetPort(entry.mJoinerUdpPort);
282-
aSockAddr.GetAddress().SetToLinkLocalAddress(entry.mExtAddr);
282+
aSockAddr.GetAddress().InitAsLinkLocalAddress(entry.mExtAddr);
283283

284284
exit:
285285
return error;

src/core/net/dhcp6_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void Client::Solicit(uint16_t aRloc16)
268268
#if OPENTHREAD_ENABLE_DHCP6_MULTICAST_SOLICIT
269269
messageInfo.SetPeerAddr(Ip6::Address::GetRealmLocalAllRoutersMulticast());
270270
#else
271-
messageInfo.GetPeerAddr().SetToRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aRloc16);
271+
messageInfo.GetPeerAddr().InitAsRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aRloc16);
272272
#endif
273273
messageInfo.SetSockAddr(Get<Mle::Mle>().GetMeshLocalRloc());
274274
messageInfo.mPeerPort = kDhcpServerPort;

src/core/net/dhcp6_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ Error Server::AppendIaAddressOption(Message &aMessage,
402402

403403
option.Init();
404404
option.GetAddress().SetPrefix(aPrefix.mFields.m8, OT_IP6_PREFIX_BITSIZE);
405-
option.GetAddress().GetIid().SetFromExtAddress(aClientAddress);
405+
option.GetAddress().GetIid().InitFromExtAddress(aClientAddress);
406406
option.SetPreferredLifetime(IaAddressOption::kDefaultPreferredLifetime);
407407
option.SetValidLifetime(IaAddressOption::kDefaultValidLifetime);
408408
SuccessOrExit(error = aMessage.Append(option));

0 commit comments

Comments
 (0)