From 2679fcafb1750e0d8295dfd0a5bc1e811fa826d2 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 26 Jul 2022 15:51:07 +0200 Subject: [PATCH] examples/dtls-echo: set address family for sessions d424aaedacf5e77a8310edaf1a87543d22f6e6ab introduced address families to the RIOT interpretation of tinydtls-`session_t`s. However, while fixing the naming for the `addr` field, it did not set the `family` member for the sessions in the `dtls-echo` example, having that example run into [an assertion][1]. This patch fixes that. [1]: https://github.com/eclipse/tinydtls/blob/bda40789a7c280f248eeca6d09ddd624cdaf5dc8/session.c#L146 --- examples/dtls-echo/dtls-client.c | 2 ++ examples/dtls-echo/dtls-server.c | 1 + 2 files changed, 3 insertions(+) diff --git a/examples/dtls-echo/dtls-client.c b/examples/dtls-echo/dtls-client.c index 0f0bffda70..c1563252cb 100644 --- a/examples/dtls-echo/dtls-client.c +++ b/examples/dtls-echo/dtls-client.c @@ -121,6 +121,7 @@ static int dtls_handle_read(dtls_context_t *ctx) dtls_session_init(&session); session.addr.port = remote.port; + session.addr.family = AF_INET6; if (remote.netif == SOCK_ADDR_ANY_NETIF) { session.ifindex = SOCK_ADDR_ANY_NETIF; } @@ -359,6 +360,7 @@ dtls_context_t *_init_dtls(sock_udp_t *sock, sock_udp_ep_t *local, } /* Second: We prepare the DTLS Session by means of ctx->app */ + dst->addr.family = AF_INET6; dst->addr.port = remote->port; /* NOTE: remote.addr.ipv6 and dst->addr.ipv6 are different structures. */ diff --git a/examples/dtls-echo/dtls-server.c b/examples/dtls-echo/dtls-server.c index dbde10decb..4abdf833cf 100644 --- a/examples/dtls-echo/dtls-server.c +++ b/examples/dtls-echo/dtls-server.c @@ -116,6 +116,7 @@ static int dtls_handle_read(dtls_context_t *ctx) /* (DTLS) session requires the remote peer address (IPv6:Port) and netif */ dtls_session_init(&session); session.addr.port = remote_peer->remote->port; + session.addr.family = AF_INET6; if (remote_peer->remote->netif == SOCK_ADDR_ANY_NETIF) { session.ifindex = SOCK_ADDR_ANY_NETIF; }