From 491964e9c438b2b69e951f323762a950b6d92d24 Mon Sep 17 00:00:00 2001 From: Carlos Quijano Date: Thu, 31 May 2018 09:26:28 +0200 Subject: [PATCH] coap_tinydtls.c: On DTLS error, fire and event that can be caught by upper layers --- src/coap_tinydtls.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coap_tinydtls.c b/src/coap_tinydtls.c index 7e6ad008..7ae76ced 100644 --- a/src/coap_tinydtls.c +++ b/src/coap_tinydtls.c @@ -388,13 +388,17 @@ coap_dtls_receive(coap_session_t *session, size_t data_len ) { session_t *dtls_session = (session_t *)session->tls; - int res; + int err; coap_event_dtls = -1; - res = dtls_handle_message( + err = dtls_handle_message( (struct dtls_context_t *)session->context->dtls_context, dtls_session, (uint8 *)data, (int)data_len); + if (err){ + coap_event_dtls = COAP_EVENT_DTLS_ERROR; + } + if (coap_event_dtls >= 0) { coap_handle_event(session->context, coap_event_dtls, session); if (coap_event_dtls == COAP_EVENT_DTLS_CONNECTED) @@ -403,7 +407,7 @@ coap_dtls_receive(coap_session_t *session, coap_session_disconnected(session, COAP_NACK_TLS_FAILED); } - return res; + return err; } int