Skip to content

Commit

Permalink
nib.c: add exclude rules for static link local addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielLockau-MLPA committed Jul 15, 2024
1 parent f167618 commit 74c7498
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,42 @@ extern "C" {
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED 0
#endif

/**
* @brief Exclude certain driver types when setting static link local
* addresses
*
* This option allows to exclude netdev driver types via a bitmask.
* See @ref netdev_type_t for possible values.
* Matching NETDEV_ANY will exclude all netdev driver types.
*
* Example usage, excludes AT86RF215 and MRF24J40 driver types:
*
* @code{.c}
* #define CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK \
* ((1UL << NETDEV_AT86RF215) | (1UL << NETDEV_MRF24J40))
* @endcode
*/
#ifndef CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK 0UL
#endif

/**
* @brief Exclude certain interface numbers when setting static link local
* addresses
*
* This option allows to exclude interface types via a bitmask.
*
* Example usage, excludes interfaces 6 and 8:
*
* @code{.c}
* #define CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_IFACE_MASK \
* ((1UL << 6) | (1UL << 8))
* @endcode
*/
#ifndef CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_IFACE_MASK
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_IFACE_MASK 0UL
#endif

/**
* @brief Message queue size to use for the IPv6 thread.
*/
Expand Down
20 changes: 20 additions & 0 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ void gnrc_ipv6_nib_init(void)

static void _add_static_lladdr(gnrc_netif_t *netif)
{
#if defined(CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK) && \
CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK > 0
#ifndef MODULE_NETDEV_REGISTER
#error "CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK requires MODULE_NETDEV_REGISTER"
#endif
if (CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK & (1ULL << NETDEV_ANY) ||
CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_NETDEV_MASK & (1ULL << netif->dev->type)) {
DEBUG("nib: Interface %u is of excluded type %u, not adding static link-local address\n",
netif->pid, netif->dev->type);
return;
}
#endif
#if defined(CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_IFACE_MASK) && \
CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_IFACE_MASK > 0
if (CONFIG_GNRC_IPV6_STATIC_LLADDR_EXCLUDE_IFACE_MASK & (1ULL << netif->pid)) {
DEBUG("nib: Interface %u (type %u) in exclude list, not adding static link-local address\n",
netif->pid, netif->dev->type);
return;
}
#endif
#ifdef CONFIG_GNRC_IPV6_STATIC_LLADDR
/* parse addr from string and explicitly set a link local prefix
* if ifnum > 1 each interface will get its own link local address
Expand Down

0 comments on commit 74c7498

Please sign in to comment.