mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 07:59:51 +00:00
[tmf] validate method as POST centrally in resource handlers (#12661)
This commit updates the central CoAP resource handlers in TMF agents (`Agent::HandleResource`, `BackboneTmfAgent::HandleResource`, and `Manager::CoapDtlsSession::HandleResource`) to verify that the incoming request method is a POST request. If the URI is recognized but the method is not POST, a `kCodeMethodNotAllowed` response is now sent. Since all TMF requests are now guaranteed to be POST requests before reaching their specific handlers, the `IsPostRequest()` checks in individual handlers are removed. Additionally, the `IsConfirmablePostRequest()` and `IsNonConfirmablePostRequest()` helper methods in `Coap::Message` are removed and their usages are simplified to `IsConfirmable()` and `IsNonConfirmable()` in the respective handlers.
This commit is contained in:
@@ -3462,7 +3462,7 @@ Error Mle::AddrSolicitInfo::ParseFrom(const Coap::Msg &aMsg)
|
||||
|
||||
Error error;
|
||||
|
||||
VerifyOrExit(aMsg.IsConfirmablePostRequest(), error = kErrorParse);
|
||||
VerifyOrExit(aMsg.IsConfirmable(), error = kErrorParse);
|
||||
|
||||
SuccessOrExit(error = Tlv::Find<ThreadExtMacAddressTlv>(aMsg.mMessage, mExtAddress));
|
||||
SuccessOrExit(error = Tlv::Find<ThreadStatusTlv>(aMsg.mMessage, mReason));
|
||||
@@ -3634,7 +3634,7 @@ template <> void Mle::HandleTmf<kUriAddressRelease>(Coap::Msg &aMsg)
|
||||
|
||||
VerifyOrExit(mRole == kRoleLeader);
|
||||
|
||||
VerifyOrExit(aMsg.IsConfirmablePostRequest());
|
||||
VerifyOrExit(aMsg.IsConfirmable());
|
||||
|
||||
Log(kMessageReceive, kTypeAddressRelease, aMsg.mMessageInfo.GetPeerAddr());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user