mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 02:00:12 +00:00
[coap] Improve behaviour of CoAP multicast requests & responses (#3967)
This commit prevents the CoAP stack from sending automatic 'Not Found' responses to multicast CoAP requests, as suggested in RFC7252 8.2: When a server is aware that a request arrived via multicast, the server MAY always ignore the request, in particular if it doesn't have anything useful to respond (e.g., if it only has an empty payload or an error response). This commit also allows CoAP requests that are sent to multicast addresses to receive multiple responses, which will all be processed by the same handler callback (For instance, a multicast GET to discover network resources).
This commit is contained in:
committed by
Jonathan Hui
parent
141437dd28
commit
6a2c3ba10c
+13
-4
@@ -555,12 +555,21 @@ void CoapBase::ProcessReceivedResponse(Message &aMessage, const Ip6::MessageInfo
|
||||
case OT_COAP_TYPE_CONFIRMABLE:
|
||||
// Send empty ACK if it is a CON message.
|
||||
SendAck(aMessage, aMessageInfo);
|
||||
|
||||
// fall through
|
||||
FinalizeCoapTransaction(*request, coapMetadata, &aMessage, &aMessageInfo, OT_ERROR_NONE);
|
||||
break;
|
||||
|
||||
case OT_COAP_TYPE_NON_CONFIRMABLE:
|
||||
// Separate response.
|
||||
FinalizeCoapTransaction(*request, coapMetadata, &aMessage, &aMessageInfo, OT_ERROR_NONE);
|
||||
|
||||
if (coapMetadata.mDestinationAddress.IsMulticast() && coapMetadata.mResponseHandler != NULL)
|
||||
{
|
||||
// If multicast non-confirmable request, allow multiple responses
|
||||
coapMetadata.mResponseHandler(coapMetadata.mResponseContext, &aMessage, &aMessageInfo, OT_ERROR_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
FinalizeCoapTransaction(*request, coapMetadata, &aMessage, &aMessageInfo, OT_ERROR_NONE);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -649,7 +658,7 @@ exit:
|
||||
{
|
||||
otLogInfoCoapErr(error, "Failed to process request");
|
||||
|
||||
if (error == OT_ERROR_NOT_FOUND)
|
||||
if (error == OT_ERROR_NOT_FOUND && !aMessageInfo.GetSockAddr().IsMulticast())
|
||||
{
|
||||
SendNotFound(aMessage, aMessageInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user