Skip to content

Commit

Permalink
gnrc/ipv6/nib: allow for predictable static link-local addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Jan 3, 2024
1 parent 26682d8 commit ec8271e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ extern "C" {
#endif /* DOXYGEN */
/** @} */

/**
* @brief Use the same static IPv6 link local address on every network interface
*
* When GNRC_IPV6_STATIC_LLADDR is used, to not add the interface pid to the set
* static address but use the same static link local address for all interfaces.
*/
#ifndef CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED
#define CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED 0
#endif

/**
* @brief Message queue size to use for the IPv6 thread.
*/
Expand Down
4 changes: 3 additions & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ static void _add_static_lladdr(gnrc_netif_t *netif)
ipv6_addr_t lladdr;

if (ipv6_addr_from_str(&lladdr, lladdr_str) != NULL) {
lladdr.u8[15] += netif->pid;
if (!IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED)) {
lladdr.u8[15] += netif->pid;
}
assert(ipv6_addr_is_link_local(&lladdr));
gnrc_netif_ipv6_addr_add_internal(
netif, &lladdr, 64U, GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID
Expand Down

0 comments on commit ec8271e

Please sign in to comment.