1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_sock/udp: add option to disable remote address check

If a server has e.g. multiple global IPv6 addresses, it might
respond with a different address that the one it received the request on.

This is against the CoAP spec, but that doesn't stop existing implementations
from doing it.
This commit is contained in:
Benjamin Valentin 2024-04-10 12:25:49 +02:00
parent 43f010c751
commit 0fb153daca
2 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,14 @@ extern "C" {
*/
#define GNRC_SOCK_DYN_PORTRANGE_ERR (0)
/**
* @brief Check if remote address of a UDP packet matches the address the socket
* is bound to.
*/
#ifndef CONFIG_GNRC_SOCK_UDP_CHECK_REMOTE_ADDR
#define CONFIG_GNRC_SOCK_UDP_CHECK_REMOTE_ADDR (1)
#endif
/**
* @brief Structure to retrieve auxiliary data from @ref gnrc_sock_recv
*

View File

@ -231,7 +231,9 @@ static bool _accept_remote(const sock_udp_t *sock, const udp_hdr_t *hdr,
ipv6_addr_to_str(addr_str, (ipv6_addr_t *)&sock->remote.addr, sizeof(addr_str)));
DEBUG(", source (%s) does not match\n",
ipv6_addr_to_str(addr_str, (ipv6_addr_t *)&remote->addr, sizeof(addr_str)));
return false;
if (CONFIG_GNRC_SOCK_UDP_CHECK_REMOTE_ADDR) {
return false;
}
}
return true;