1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

tinydtls: sock_dtls: only use ifindex with link-local addresses

For global addresses the out-going interface is typically decided by the
forwarding information base, so _requiring_ the user to set it with
`sock_dtls` is undesirable. This has the caveat, that now on
`sock_udp_send()` in the `_write()` method, the sock does not know via
which network interface to send a packet with a global address, but
again: this is really more a task for the underlying network stack, not
the sock layer.
This commit is contained in:
Martine Lenders 2021-09-28 17:41:41 +02:00
parent 5e81bd56b0
commit 8f5561d694
No known key found for this signature in database
GPG Key ID: 2134D77A5336DD80

View File

@ -813,7 +813,13 @@ static void _ep_to_session(const sock_udp_ep_t *ep, session_t *session)
session->port = ep->port;
session->size = sizeof(ipv6_addr_t) + /* addr */
sizeof(unsigned short); /* port */
session->ifindex = ep->netif;
if (ipv6_addr_is_link_local((ipv6_addr_t *)ep->addr.ipv6)) {
/* set ifindex for link-local addresses */
session->ifindex = ep->netif;
}
else {
session->ifindex = SOCK_ADDR_ANY_NETIF;
}
memcpy(&session->addr, &ep->addr.ipv6, sizeof(ipv6_addr_t));
}