net.c: Call nack handler for badly formatted response packet

If a response packet is received that is badly formatted, invoke the
nack handler (if defined) with COAP_NACK_BAD_RESPONSE so that the
requestor knows there is an issue, rather than timing out.

However, if the response packet is so badly formatted, or it is not
possible to find the requesting packet, then this nack event will not
trigger, but an event is triggered with COAP_EVENT_BAD_PACKET.
This commit is contained in:
Jon Shallow authored and obgm committed 2022-09-20 15:12:29 +02:00
1 parent 02b76470ab
commit 2f25c950af
6 files changed
+37 -4

No files matched your search

+2
View File
@@ -360,6 +360,7 @@ event_handler(coap_session_t *session COAP_UNUSED,
case COAP_EVENT_XMIT_BLOCK_FAIL:
case COAP_EVENT_SERVER_SESSION_NEW:
case COAP_EVENT_SERVER_SESSION_DEL:
case COAP_EVENT_BAD_PACKET:
default:
break;
}
@@ -381,6 +382,7 @@ nack_handler(coap_session_t *session COAP_UNUSED,
quit = 1;
break;
case COAP_NACK_ICMP_ISSUE:
case COAP_NACK_BAD_RESPONSE:
default:
;
}
+2
View File
@@ -1645,6 +1645,7 @@ proxy_event_handler(coap_session_t *session,
case COAP_EVENT_XMIT_BLOCK_FAIL:
case COAP_EVENT_SERVER_SESSION_NEW:
case COAP_EVENT_SERVER_SESSION_DEL:
case COAP_EVENT_BAD_PACKET:
default:
break;
}
@@ -1788,6 +1789,7 @@ proxy_nack_handler(coap_session_t *session,
remove_proxy_association(session, 1);
break;
case COAP_NACK_ICMP_ISSUE:
case COAP_NACK_BAD_RESPONSE:
default:
break;
}