Skip to content

Commit

Permalink
fixup! nib.c: allow selection of interfaces for static link local add…
Browse files Browse the repository at this point in the history
…resses
  • Loading branch information
DanielLockau-MLPA committed Aug 15, 2024
1 parent 9ce1aa1 commit 6efe112
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
26 changes: 2 additions & 24 deletions sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,32 +197,10 @@ extern "C" {
* ((1UL << NETDEV_AT86RF215) | (1UL << NETDEV_MRF24J40))
* @endcode
*
* A value of 0 switches the feature off.
* 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 0UL
#endif

/**
* @brief Select interfaces by interface numbers for setting static link
* local addresses
*
* This option allows to explicitly include interfaces by matching their
* interface numbers, encoded in a bitmask.
* Please note that the interface number is the PID of the interface thread
* and may change when making changes to an application.
*
* Example usage, includes interfaces with ids 6 and 8:
*
* @code{.c}
* #define CONFIG_GNRC_IPV6_STATIC_LLADDR_IFACE_MASK \
* ((1UL << 6) | (1UL << 8))
* @endcode
*
* A value of 0 switches the feature off.
*/
#ifndef CONFIG_GNRC_IPV6_STATIC_LLADDR_IFACE_MASK
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_IFACE_MASK 0UL
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK 0ULL
#endif

/**
Expand Down
25 changes: 9 additions & 16 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,24 @@ void gnrc_ipv6_nib_init(void)

static void _add_static_lladdr(gnrc_netif_t *netif)
{
#if defined(CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK) && \
CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK > 0
#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 << NETDEV_ANY)) ||
(CONFIG_GNRC_IPV6_STATIC_LLADDR_NETDEV_MASK & (1ULL << netif->dev->type)))) {
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
#if defined(CONFIG_GNRC_IPV6_STATIC_LLADDR_IFACE_MASK) && \
CONFIG_GNRC_IPV6_STATIC_LLADDR_IFACE_MASK > 0
if (! (CONFIG_GNRC_IPV6_STATIC_LLADDR_IFACE_MASK & (1ULL << netif->pid))) {
DEBUG("nib: interface #%u: not setting static link-local address "
"(interface id not included)\n",
netif->pid);
return;
}
#endif
DEBUG("nib: interface #%u: setting static link-local address\n",
netif->pid);
#ifdef CONFIG_GNRC_IPV6_STATIC_LLADDR
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 6efe112

Please sign in to comment.