mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 04:37:47 +00:00
[coap] rename message setup methods to use AllocateAndInit prefix (#12613)
This commit updates the names of several message allocation methods in `CoapBase` to `AllocateAndInit*()`. This change helps to clearly differentiate these methods from the `NewPriorityMessage()` and `NetMessage()` overloads, which only allocate a new `Message`. In contrast, the `AllocateAndInit` methods allocate the message and fully prepare it by initializing the CoAP header, appending the URI path option, the payload marker, leaving it ready for the payload. This change clarifies the design by explicitly indicating that these methods perform extra setup work. All calls to these methods throughout the codebase have been updated to reflect the new names.
This commit is contained in:
@@ -3264,7 +3264,7 @@ Error Mle::SendAddressSolicit(RouterUpgradeReason aReason)
|
||||
|
||||
VerifyOrExit(!mAddressSolicitPending);
|
||||
|
||||
message = Get<Tmf::Agent>().NewPriorityConfirmablePostMessage(kUriAddressSolicit);
|
||||
message = Get<Tmf::Agent>().AllocateAndInitPriorityConfirmablePostMessage(kUriAddressSolicit);
|
||||
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
|
||||
|
||||
SuccessOrExit(error = Tlv::Append<ThreadExtMacAddressTlv>(*message, Get<Mac::Mac>().GetExtAddress()));
|
||||
@@ -3298,7 +3298,7 @@ void Mle::SendAddressRelease(void)
|
||||
Coap::Message *message;
|
||||
Ip6::Address leaderRloc;
|
||||
|
||||
message = Get<Tmf::Agent>().NewPriorityConfirmablePostMessage(kUriAddressRelease);
|
||||
message = Get<Tmf::Agent>().AllocateAndInitPriorityConfirmablePostMessage(kUriAddressRelease);
|
||||
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
|
||||
|
||||
SuccessOrExit(error = Tlv::Append<ThreadRloc16Tlv>(*message, Rloc16FromRouterId(mRouterId)));
|
||||
@@ -3576,7 +3576,7 @@ template <> void Mle::HandleTmf<kUriAddressSolicit>(Coap::Msg &aMsg)
|
||||
|
||||
// Prepare and send response
|
||||
|
||||
response = Get<Tmf::Agent>().NewPriorityResponseMessage(aMsg.mMessage);
|
||||
response = Get<Tmf::Agent>().AllocateAndInitPriorityResponseFor(aMsg.mMessage);
|
||||
VerifyOrExit(response != nullptr);
|
||||
|
||||
SuccessOrExit(Tlv::Append<ThreadStatusTlv>(*response, info.mResponse));
|
||||
|
||||
Reference in New Issue
Block a user