Skip to content

Commit

Permalink
Merge pull request #578 from mrdeep1/icmp_issue_nack_handler
Browse files Browse the repository at this point in the history
ICMP reporting: Call nack handler when ICMP unreachable is received
  • Loading branch information
obgm authored Feb 24, 2021
2 parents 35dbc32 + 704057e commit 8724c0c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/coap_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,13 @@ void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reaso
&& reason == COAP_NACK_ICMP_ISSUE)
{
/* Make sure that we try a re-transmit later on ICMP error */
if (coap_wait_ack(session->context, session, q) >= 0)
if (coap_wait_ack(session->context, session, q) >= 0) {
if (session->context->nack_handler) {
session->context->nack_handler(session->context, session, q->pdu,
reason, q->id);
}
q = NULL;
}
}
if (q && q->pdu->type == COAP_MESSAGE_CON
&& session->context->nack_handler)
Expand All @@ -508,8 +513,19 @@ void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reaso
if (q)
coap_delete_node(q);
}
if (reason != COAP_NACK_ICMP_ISSUE)
if (reason != COAP_NACK_ICMP_ISSUE) {
coap_cancel_session_messages(session->context, session, reason);
}
else if (session->context->nack_handler) {
coap_queue_t *q = session->context->sendqueue;
while (q) {
if (q->session == session) {
session->context->nack_handler(session->context, session, q->pdu,
reason, q->id);
}
q = q->next;
}
}

#if !COAP_DISABLE_TCP
if (COAP_PROTO_RELIABLE(session->proto)) {
Expand Down

0 comments on commit 8724c0c

Please sign in to comment.