Skip to content

Commit

Permalink
DTLS: Correctly log sending plain data size when using DTLS
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jan 6, 2025
1 parent 75b4322 commit bd2c2b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/coap_gnutls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,8 @@ coap_dtls_receive(coap_session_t *c_session, const uint8_t *data,
}
ret = gnutls_record_recv(g_env->g_session, pdu, (int)sizeof(pdu));
if (ret > 0) {
coap_log_debug("* %s: dtls: recv %4d bytes\n",
coap_session_str(c_session), ret);
return coap_handle_dgram(c_session->context, c_session, pdu, (size_t)ret);
} else if (ret == 0) {
c_session->dtls_event = COAP_EVENT_DTLS_CLOSED;
Expand Down Expand Up @@ -2542,10 +2544,6 @@ coap_dtls_receive(coap_session_t *c_session, const uint8_t *data,
ssl_data->pdu_len = 0;
ssl_data->pdu = NULL;
}
if (ret > 0) {
coap_log_debug("* %s: dtls: recv %4d bytes\n",
coap_session_str(c_session), ret);
}
return ret;
}

Expand Down
6 changes: 2 additions & 4 deletions src/coap_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,8 @@ coap_dtls_receive(coap_session_t *c_session,

ret = mbedtls_ssl_read(&m_env->ssl, pdu, sizeof(pdu));
if (ret > 0) {
coap_log_debug("* %s: dtls: recv %4d bytes\n",
coap_session_str(c_session), ret);
ret = coap_handle_dgram(c_session->context, c_session, pdu, (size_t)ret);
goto finish;
}
Expand Down Expand Up @@ -2449,10 +2451,6 @@ coap_dtls_receive(coap_session_t *c_session,
ssl_data->pdu_len = 0;
ssl_data->pdu = NULL;
}
if (ret > 0) {
coap_log_debug("* %s: dtls: recv %4d bytes\n",
coap_session_str(c_session), ret);
}
return ret;
}

Expand Down
6 changes: 2 additions & 4 deletions src/coap_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3662,6 +3662,8 @@ coap_dtls_receive(coap_session_t *session, const uint8_t *data, size_t data_len)
session->dtls_event = -1;
r = SSL_read(ssl, pdu, (int)sizeof(pdu));
if (r > 0) {
coap_log_debug("* %s: dtls: recv %4d bytes\n",
coap_session_str(session), r);
r = coap_handle_dgram(session->context, session, pdu, (size_t)r);
goto finished;
} else {
Expand Down Expand Up @@ -3701,10 +3703,6 @@ coap_dtls_receive(coap_session_t *session, const uint8_t *data, size_t data_len)
ssl_data->pdu_len = 0;
ssl_data->pdu = NULL;
}
if (r > 0) {
coap_log_debug("* %s: dtls: recv %4d bytes\n",
coap_session_str(session), r);
}
return r;
}

Expand Down

0 comments on commit bd2c2b0

Please sign in to comment.