src/net.c: Support RFC8323 for empty messages and rate limit RSTs

Do not send back a RST is there is receipt of an empty message and using
TCP.

Otherwise, rate limit RST packets to 4 a second when receiving empty
messages
This commit is contained in:
Jon Shallow committed 2018-03-09 15:08:14 +00:00
1 parent c4bd74040c
commit f453902425
1 file changed
+13 -1
+13 -1
View File
@@ -2144,7 +2144,19 @@ coap_dispatch(coap_context_t *context, coap_session_t *session,
pdu->code & 0x1f);
if (!coap_is_mcast(&session->local_addr)) {
coap_send_message_type(session, pdu, COAP_MESSAGE_RST);
if (COAP_PDU_IS_EMPTY(pdu)) {
if (session->proto != COAP_PROTO_TCP && session->proto != COAP_PROTO_TLS) {
coap_tick_t now;
coap_ticks(&now);
if (session->last_tx_rst + COAP_TICKS_PER_SECOND/4 < now) {
coap_send_message_type(session, pdu, COAP_MESSAGE_RST);
session->last_tx_rst = now;
}
}
}
else {
coap_send_message_type(session, pdu, COAP_MESSAGE_RST);
}
}
}