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

+7 -1
View File
@@ -91,7 +91,13 @@ typedef enum {
* The session will still contain valid data when the event handler is
* called.
*/
COAP_EVENT_SERVER_SESSION_DEL = 0x4002
COAP_EVENT_SERVER_SESSION_DEL = 0x4002,
/*
* Received packet formatting errors
*/
/** Triggered when badly formatted packet received */
COAP_EVENT_BAD_PACKET = 0x5001
} coap_event_t;
+2 -1
View File
@@ -71,7 +71,8 @@ typedef enum {
COAP_NACK_NOT_DELIVERABLE,
COAP_NACK_RST,
COAP_NACK_TLS_FAILED,
COAP_NACK_ICMP_ISSUE
COAP_NACK_ICMP_ISSUE,
COAP_NACK_BAD_RESPONSE
} coap_nack_reason_t;
#endif /* COAP_IO_H_ */