Commit d0affeff authored by Robert Lubos's avatar Robert Lubos Committed by Christopher Friedt
Browse files

net: sockets: tls: Return ENOTCONN when DTLS client session ends



Notify the application when DTLS client session ends by returning
ENOTCONN on such event. Additionally, reset the mbed TLS session
structures, allowing to reinstante the session on the next send() call.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent b999c474
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1812,7 +1812,13 @@ static ssize_t recvfrom_dtls_client(struct tls_context *ctx, void *buf,
	switch (ret) {
	case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY:
		/* Peer notified that it's closing the connection. */
		return 0;
		ret = tls_mbedtls_reset(ctx);
		if (ret == 0) {
			ret = -ENOTCONN;
		} else {
			ret = -ENOMEM;
		}
		break;

	case MBEDTLS_ERR_SSL_TIMEOUT:
		(void)mbedtls_ssl_close_notify(&ctx->ssl);