Created
June 18, 2020 09:07
-
-
Save pokgak/e4a13c84a3ab8d693a3a64b319921771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pkg/tinydtls/contrib/sock_dtls.c b/pkg/tinydtls/contrib/sock_dtls.c | |
index f688cdcf3..4a8d45945 100644 | |
--- a/pkg/tinydtls/contrib/sock_dtls.c | |
+++ b/pkg/tinydtls/contrib/sock_dtls.c | |
@@ -82,6 +82,7 @@ static int _read(struct dtls_context_t *ctx, session_t *session, uint8_t *buf, | |
DEBUG("sock_dtls: decrypted message arrived\n"); | |
sock->buf = buf; | |
sock->buflen = len; | |
+ sock->buf_session = session; | |
#ifdef SOCK_HAS_ASYNC | |
if (sock->async_cb != NULL) { | |
sock->async_cb(sock, SOCK_ASYNC_MSG_RECV, sock->async_cb_arg); | |
@@ -437,6 +438,8 @@ static ssize_t _copy_buffer(sock_dtls_t *sock, sock_dtls_session_t *remote, | |
{ | |
uint8_t *buf = sock->buf; | |
size_t buflen = sock->buflen; | |
+ memcpy(&remote->dtls_session, sock->buf_session, sizeof(remote->dtls_session)); | |
+ _session_to_ep(&remote->dtls_session, &remote->ep); | |
sock->buf = NULL; | |
if (buflen > max_len) { | |
diff --git a/pkg/tinydtls/include/sock_dtls_types.h b/pkg/tinydtls/include/sock_dtls_types.h | |
index 0eb046ebc..0faa3d526 100644 | |
--- a/pkg/tinydtls/include/sock_dtls_types.h | |
+++ b/pkg/tinydtls/include/sock_dtls_types.h | |
@@ -70,6 +70,7 @@ struct sock_dtls { | |
uint8_t *buf; /**< Buffer to pass decrypted data | |
back to user */ | |
size_t buflen; /**< Size of buffer */ | |
+ session_t *buf_session; | |
credman_tag_t tag; /**< Credential tag of a registered | |
(D)TLS credential */ | |
dtls_peer_type role; /**< DTLS role of the socket */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment