[riot-notifications] [RIOT-OS/RIOT] sock/async: add function to retrieve session object of current DTLS event (#15755)

Martine Lenders notifications at github.com
Tue Jan 19 12:40:20 CET 2021


@miri64 commented on this pull request.



> + * @note Only available with @ref SOCK_HAS_ASYNC defined.
+ *       Should only be called within a DTLS event and only for the event
+ *       types @ref SOCK_ASYNC_CONN_RDY and @ref SOCK_ASYNC_CONN_FIN.

In the specific case of `tinydtls` you could use [the `size` member of the `session_t` struct](https://github.com/eclipse/tinydtls/blob/706888256c3e03d9fcf1ec37bb1dd6499213be3c/session.h#L40-L49) as a signifier if the session is set.

```C
typedef struct {
  socklen_t size;		/**< size of addr */
  union {
    struct sockaddr     sa;
    struct sockaddr_storage st;
    struct sockaddr_in  sin;
    struct sockaddr_in6 sin6;
  } addr;
  uint8_t ifindex;
} session_t;
```

The object needs to zero'd of course. However, I would do this on read and socket init. This way, if you e.g. receive a CONN_RDY and a MSG_RECV in the same callback you don't accidentally remove the session before it can be read.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15755#discussion_r560115027
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210119/809a59a4/attachment.htm>


More information about the notifications mailing list