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

Merge pull request #20784 from ML-PA-Consulting-GmbH/dl/riot/20240715__nib__static_ll_addr_excludes

nib.c: add interface selection rules for static link local address assignment
This commit is contained in:
benpicco 2024-08-26 09:59:44 +00:00 committed by GitHub
commit 73581fa56e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View File

@ -181,6 +181,28 @@ extern "C" {
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED 0
#endif
/**
* @brief Select interfaces by driver types for setting static link local
* addresses
*
* This option allows to explicitly include interfaces by matching their
* netdev driver types, encoded in a bitmask.
* See @ref netdev_type_t for possible values of netdev driver types.
* Matching NETDEV_ANY will include all netdev driver types.
*
* Example usage, includes AT86RF215 and MRF24J40 driver types:
*
* @code{.c}
* #define CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK \
* ((1UL << NETDEV_AT86RF215) | (1UL << NETDEV_MRF24J40))
* @endcode
*
* A value of 0 will switch this selection feature off.
*/
#ifndef CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK 0ULL
#endif
/**
* @brief Message queue size to use for the IPv6 thread.
*/

View File

@ -116,6 +116,23 @@ void gnrc_ipv6_nib_init(void)
static void _add_static_lladdr(gnrc_netif_t *netif)
{
#ifdef CONFIG_GNRC_IPV6_STATIC_LLADDR
#if (CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK) > 0
#ifndef MODULE_NETDEV_REGISTER
#error "Use of CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK requires MODULE_NETDEV_REGISTER"
#endif
if (! (((CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK) & (1ULL << netif->dev->type)) ||
((CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK) & (1ULL << NETDEV_ANY)))) {
DEBUG("nib: interface #%u: not setting static link-local address "
"(netdev type %u not included)\n",
netif->pid, netif->dev->type);
return;
}
#endif
DEBUG("nib: interface #%u: adding static link-local address \"%s\"%s\n",
netif->pid,
CONFIG_GNRC_IPV6_STATIC_LLADDR,
IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED) ?
" (fixed)" : " (+ interface number)");
/* parse addr from string and explicitly set a link local prefix
* if ifnum > 1 each interface will get its own link local address
* with CONFIG_GNRC_IPV6_STATIC_LLADDR + i