-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Area: pkgArea: External package portsArea: External package portsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)The issue reports a bug / The PR fixes a bug (including spelling errors)
Description
Description
When using tinyDTLS and the sock/dtls API with asynchronous sockets the event for a finished session does not indicate which session has been closed. It makes it impossible to keep the session for a long time because you cannot track sessions properly without touching the internals of tinydtls.
The following code block is the part in sock_dtls.c which handles this part. The internal event gets the correct closed session it is just not passed to the callback. I'm not quite sure what sock->async_cb(sock, SOCK_ASYNC_CONN_FIN, sock->async_cb_arg);
hands over to the cb function. sock->async_cb_arg? Whats that?
pkg/tinydtls/contrib/sock_dtls.c
static int _event(struct dtls_context_t *ctx, session_t *session,
dtls_alert_level_t level, unsigned short code)
{
(void)level;
(void)session;
sock_dtls_t *sock = dtls_get_app_data(ctx);
msg_t msg = { .type = code, .content.ptr = session };
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (code) {
case DTLS_EVENT_CONNECT:
DEBUG("sock_dtls: event connect\n");
break;
case DTLS_EVENT_CONNECTED:
DEBUG("sock_dtls: event connected\n");
break;
case DTLS_EVENT_RENEGOTIATE:
DEBUG("sock_dtls: event renegotiate\n");
break;
}
}
if (!level && (code != DTLS_EVENT_CONNECT)) {
mbox_put(&sock->mbox, &msg);
}
#ifdef SOCK_HAS_ASYNC
if (sock->async_cb != NULL) {
switch (code) {
case DTLS_ALERT_CLOSE_NOTIFY:
/* peer closed their session */
if(session) {
printf("session is != null!\n");
printf("Port: %d\n", session->port);
}
sock->async_cb(sock, SOCK_ASYNC_CONN_FIN, sock->async_cb_arg);
break;
case DTLS_EVENT_CONNECTED:
/* we received a session handshake initialization */
sock->async_cb(sock, SOCK_ASYNC_CONN_RECV,
sock->async_cb_arg);
break;
default:
break;
}
} else {
printf("not existing\n");
}
#endif
return 0;
}
Steps to reproduce the issue
Expected results
Argument of the callback event points to the closed session.
Actual results
The argument is currently null.
Versions
Metadata
Metadata
Assignees
Labels
Area: pkgArea: External package portsArea: External package portsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)The issue reports a bug / The PR fixes a bug (including spelling errors)