diff --git a/sys/net/gnrc/sock/include/gnrc_sock_internal.h b/sys/net/gnrc/sock/include/gnrc_sock_internal.h index 897351f3b2fa..ea0a13e17566 100644 --- a/sys/net/gnrc/sock/include/gnrc_sock_internal.h +++ b/sys/net/gnrc/sock/include/gnrc_sock_internal.h @@ -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 * diff --git a/sys/net/gnrc/sock/udp/gnrc_sock_udp.c b/sys/net/gnrc/sock/udp/gnrc_sock_udp.c index 2d8f4a6abe15..23d62eb16612 100644 --- a/sys/net/gnrc/sock/udp/gnrc_sock_udp.c +++ b/sys/net/gnrc/sock/udp/gnrc_sock_udp.c @@ -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;