Skip to content

Commit

Permalink
Merge pull request #20784 from ML-PA-Consulting-GmbH/dl/riot/20240715…
Browse files Browse the repository at this point in the history
…__nib__static_ll_addr_excludes

nib.c: add interface selection rules for static link local address assignment
  • Loading branch information
benpicco authored Aug 26, 2024
2 parents 2eefc68 + 7240d37 commit 73581fa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
17 changes: 17 additions & 0 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 73581fa

Please sign in to comment.