coap_session.c: Report COAP_NACK_ICMP_ISSUE for NON to NACK handler

This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2023-07-22 09:24:13 +01:00
1 parent 15473b037e
commit e60205e52a
3 files changed
+24 -5

No files matched your search

+7 -4
View File
@@ -345,10 +345,13 @@ static void
nack_handler(coap_session_t *session COAP_UNUSED,
const coap_pdu_t *sent,
const coap_nack_reason_t reason,
const coap_mid_t id COAP_UNUSED) {
coap_bin_const_t token = coap_pdu_get_token(sent);
if (!track_check_token(&token)) {
coap_log_err("nack_handler: Unexpected token\n");
const coap_mid_t mid COAP_UNUSED) {
if (sent) {
coap_bin_const_t token = coap_pdu_get_token(sent);
if (!track_check_token(&token)) {
coap_log_err("nack_handler: Unexpected token\n");
}
}
switch (reason) {
+1 -1
View File
@@ -1720,7 +1720,7 @@ static void
proxy_nack_handler(coap_session_t *session,
const coap_pdu_t *sent COAP_UNUSED,
const coap_nack_reason_t reason,
const coap_mid_t id COAP_UNUSED) {
const coap_mid_t mid COAP_UNUSED) {
switch (reason) {
case COAP_NACK_TOO_MANY_RETRIES:
+16
View File
@@ -859,17 +859,33 @@ coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reason) {
if (reason == COAP_NACK_ICMP_ISSUE) {
if (session->context->nack_handler) {
int sent_nack = 0;
coap_queue_t *q = session->context->sendqueue;
while (q) {
if (q->session == session) {
/* Take the first one */
coap_bin_const_t token = q->pdu->actual_token;
coap_check_update_token(session, q->pdu);
session->context->nack_handler(session, q->pdu, reason, q->id);
coap_update_token(q->pdu, token.length, token.s);
sent_nack = 1;
break;
}
q = q->next;
}
#if COAP_CLIENT_SUPPORT
if (!sent_nack && session->lg_crcv) {
/* Take the first one */
session->context->nack_handler(session, &session->lg_crcv->pdu, reason,
session->lg_crcv->pdu.mid);
sent_nack = 1;
}
#endif /* COAP_CLIENT_SUPPORT */
if (!sent_nack) {
/* Unable to determine which request ICMP issue was for */
session->context->nack_handler(session, NULL, reason, 0);
}
}
coap_log_debug("***%s: session issue (%s)\n",
coap_session_str(session), coap_nack_name(reason));