From ce931f179cd84c048c0e2f0156b772a0dcc9c144 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 12 Mar 2020 14:04:20 +0100 Subject: [PATCH] gnrc/nib: Move GNRC_IPV6_NIB_CONF_SLAAC to 'CONFIG_' namespace Also evaluate it using IS_ACTIVE macro. --- examples/suit_update/README.md | 4 ++-- pkg/nimble/README.ipv6-over-ble.md | 4 ++-- sys/include/net/gnrc/ipv6/nib.h | 4 ++-- sys/include/net/gnrc/ipv6/nib/conf.h | 16 ++++++++-------- sys/include/net/gnrc/netif/ipv6.h | 4 ++-- sys/net/gnrc/netif/gnrc_netif.c | 2 +- sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c | 14 +++++++------- sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.h | 15 ++++++++------- sys/net/gnrc/network_layer/ipv6/nib/nib.c | 16 ++++++++-------- tests/gnrc_netif/Makefile | 2 +- 10 files changed, 41 insertions(+), 40 deletions(-) diff --git a/examples/suit_update/README.md b/examples/suit_update/README.md index b648b55f6c..fe2d711d46 100644 --- a/examples/suit_update/README.md +++ b/examples/suit_update/README.md @@ -213,7 +213,7 @@ the prefix (`2001:db8::`) and the EUI64 suffix, in this case `7b7e:3255:1313:8d9 - Provision the wireless ble device: ``` - $ CFLAGS=-DGNRC_IPV6_NIB_CONF_SLAAC=1 USEMODULE+=nimble_autoconn_ipsp USE_ETHOS=0 BOARD=nrf52dk make -C examples/suit_update clean flash -j4 + $ CFLAGS=-DCONFIG_GNRC_IPV6_NIB_SLAAC=1 USEMODULE+=nimble_autoconn_ipsp USE_ETHOS=0 BOARD=nrf52dk make -C examples/suit_update clean flash -j4 ``` - Open a serial terminal on the device to get its local address: @@ -237,7 +237,7 @@ the prefix (`2001:db8::`) and the EUI64 suffix, in this case `7b7e:3255:1313:8d9 **NOTE 2:** Currently, Linux does not support 6LoWPAN neighbor discovery (which RIOT uses per default with BLE), so RIOT needs to be compiled to use stateless -address auto configuration (SLAAC) -> `CFLAGS=-DGNRC_IPV6_NIB_CONF_SLAAC=1`. +address auto configuration (SLAAC) -> `CFLAGS=-DCONFIG_GNRC_IPV6_NIB_SLAAC=1`. - Use `bluetoothctl` on Linux to scan for the device. Once `bluetoothctl` has started, issue `scan on` to start scanning. The default name for the RIOT diff --git a/pkg/nimble/README.ipv6-over-ble.md b/pkg/nimble/README.ipv6-over-ble.md index 8233f311f8..240b7e3bbc 100644 --- a/pkg/nimble/README.ipv6-over-ble.md +++ b/pkg/nimble/README.ipv6-over-ble.md @@ -8,7 +8,7 @@ the moment and does suffer stability issues! **NOTE 2:** Currently, Linux does not support 6LoWPAN neighbor discovery (which RIOT uses per default with BLE), so RIOT needs to be compiled to use stateless -address auto configuration (SLAAC) -> `CFLAGS=-DGNRC_IPV6_NIB_CONF_SLAAC=1`. +address auto configuration (SLAAC) -> `CFLAGS=-DCONFIG_GNRC_IPV6_NIB_SLAAC=1`. ## Prerequisites @@ -27,7 +27,7 @@ following: First, you compile and flash the `examples/gnrc_networking` application to your RIOT device. When doing this, make sure to enable SLAAC -(`CFLAGS=-DGNRC_IPV6_NIB_CONF_SLAAC=1`), see note above. +(`CFLAGS=-DCONFIG_GNRC_IPV6_NIB_SLAAC=1`), see note above. Once the firmware is running, you can verify it by typing diff --git a/sys/include/net/gnrc/ipv6/nib.h b/sys/include/net/gnrc/ipv6/nib.h index bfb359e034..64971912af 100644 --- a/sys/include/net/gnrc/ipv6/nib.h +++ b/sys/include/net/gnrc/ipv6/nib.h @@ -209,7 +209,7 @@ extern "C" { * This message type is for performing DAD for a given address. The expected * message context is a TENTATIVE IPv6 address. * - * @note Only handled with @ref GNRC_IPV6_NIB_CONF_SLAAC != 0 + * @note Only handled with @ref CONFIG_GNRC_IPV6_NIB_SLAAC != 0 */ #define GNRC_IPV6_NIB_DAD (0x4fd1U) @@ -219,7 +219,7 @@ extern "C" { * Moves a TENTATIVE address to VALID state. The expected message context is a * TENTATIVE IPv6 address. * - * @note Only handled with @ref GNRC_IPV6_NIB_CONF_SLAAC != 0 + * @note Only handled with @ref CONFIG_GNRC_IPV6_NIB_SLAAC != 0 */ #define GNRC_IPV6_NIB_VALID_ADDR (0x4fd2U) diff --git a/sys/include/net/gnrc/ipv6/nib/conf.h b/sys/include/net/gnrc/ipv6/nib/conf.h index bb67865748..c464cb8935 100644 --- a/sys/include/net/gnrc/ipv6/nib/conf.h +++ b/sys/include/net/gnrc/ipv6/nib/conf.h @@ -32,8 +32,8 @@ extern "C" { #ifndef CONFIG_GNRC_IPV6_NIB_6LBR #define CONFIG_GNRC_IPV6_NIB_6LBR 1 #endif -#ifndef GNRC_IPV6_NIB_CONF_SLAAC -#define GNRC_IPV6_NIB_CONF_SLAAC 1 +#ifndef CONFIG_GNRC_IPV6_NIB_SLAAC +#define CONFIG_GNRC_IPV6_NIB_SLAAC 1 #endif #ifndef GNRC_IPV6_NIB_NUMOF #define GNRC_IPV6_NIB_NUMOF (16) @@ -44,8 +44,8 @@ extern "C" { #ifndef CONFIG_GNRC_IPV6_NIB_6LR #define CONFIG_GNRC_IPV6_NIB_6LR 1 #endif -#ifndef GNRC_IPV6_NIB_CONF_SLAAC -#define GNRC_IPV6_NIB_CONF_SLAAC 0 +#ifndef CONFIG_GNRC_IPV6_NIB_SLAAC +#define CONFIG_GNRC_IPV6_NIB_SLAAC 0 #endif #endif @@ -53,8 +53,8 @@ extern "C" { #ifndef CONFIG_GNRC_IPV6_NIB_6LN #define CONFIG_GNRC_IPV6_NIB_6LN 1 #endif -#ifndef GNRC_IPV6_NIB_CONF_SLAAC -#define GNRC_IPV6_NIB_CONF_SLAAC 0 +#ifndef CONFIG_GNRC_IPV6_NIB_SLAAC +#define CONFIG_GNRC_IPV6_NIB_SLAAC 0 #endif #ifndef GNRC_IPV6_NIB_CONF_QUEUE_PKT #define GNRC_IPV6_NIB_CONF_QUEUE_PKT 0 @@ -159,8 +159,8 @@ extern "C" { * * @see [RFC 4862](https://tools.ietf.org/html/rfc4862) */ -#ifndef GNRC_IPV6_NIB_CONF_SLAAC -#define GNRC_IPV6_NIB_CONF_SLAAC 1 +#ifndef CONFIG_GNRC_IPV6_NIB_SLAAC +#define CONFIG_GNRC_IPV6_NIB_SLAAC 1 #endif /** diff --git a/sys/include/net/gnrc/netif/ipv6.h b/sys/include/net/gnrc/netif/ipv6.h index 7f879c5055..d93771005d 100644 --- a/sys/include/net/gnrc/netif/ipv6.h +++ b/sys/include/net/gnrc/netif/ipv6.h @@ -152,14 +152,14 @@ typedef struct { * and @ref net_gnrc_ipv6_nib "NIB" */ evtimer_msg_event_t search_rtr; -#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || GNRC_IPV6_NIB_CONF_SLAAC || DOXYGEN +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) || DOXYGEN /** * @brief Timers for address re-registration * * @note Only available with module @ref net_gnrc_ipv6 "gnrc_ipv6" and * @ref net_gnrc_ipv6_nib "NIB" and if * @ref CONFIG_GNRC_IPV6_NIB_6LN != 0 or - * @ref GNRC_IPV6_NIB_CONF_SLAAC != 0 + * @ref CONFIG_GNRC_IPV6_NIB_SLAAC != 0 * @note Might also be usable in the later default SLAAC implementation * for NS retransmission timers. */ diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 545e6cc056..a9d36e9d49 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -637,7 +637,7 @@ int gnrc_netif_ipv6_addr_add_internal(gnrc_netif_t *netif, UINT32_MAX, UINT32_MAX); } } -#if GNRC_IPV6_NIB_CONF_SLAAC +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) else if (!gnrc_netif_is_6ln(netif)) { /* cast to remove const qualifier (will still be used NIB internally as * const) */ diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c index 19fa421eb7..55a6da233c 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c @@ -26,7 +26,7 @@ #define ENABLE_DEBUG (0) #include "debug.h" -#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || GNRC_IPV6_NIB_CONF_SLAAC +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) static char addr_str[IPV6_ADDR_MAX_STR_LEN]; void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx, @@ -36,11 +36,11 @@ void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx, int idx; uint8_t flags = GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE; -#if !GNRC_IPV6_NIB_CONF_SLAAC +#if !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) if (!gnrc_netif_is_6ln(netif)) { LOG_WARNING("SLAAC not activated; will not auto-configure IPv6 address " "for interface %u.\n" - " Use GNRC_IPV6_NIB_CONF_SLAAC=1 to activate.\n", + " Use CONFIG_GNRC_IPV6_NIB_SLAAC=1 to activate.\n", netif->pid); return; } @@ -89,9 +89,9 @@ void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx, (void)idx; #endif /* CONFIG_GNRC_IPV6_NIB_6LN */ } -#endif /* CONFIG_GNRC_IPV6_NIB_6LN || GNRC_IPV6_NIB_CONF_SLAAC */ +#endif /* CONFIG_GNRC_IPV6_NIB_6LN || CONFIG_GNRC_IPV6_NIB_SLAAC */ -#if GNRC_IPV6_NIB_CONF_SLAAC +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) static bool _try_l2addr_reconfiguration(gnrc_netif_t *netif) { uint8_t hwaddr[GNRC_NETIF_L2ADDR_MAXLEN]; @@ -217,8 +217,8 @@ void _handle_valid_addr(const ipv6_addr_t *addr) gnrc_netif_release(netif); } } -#else /* GNRC_IPV6_NIB_CONF_SLAAC */ +#else /* CONFIG_GNRC_IPV6_NIB_SLAAC */ typedef int dont_be_pedantic; -#endif /* GNRC_IPV6_NIB_CONF_SLAAC */ +#endif /* CONFIG_GNRC_IPV6_NIB_SLAAC */ /** @} */ diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.h b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.h index 139753b3af..1736f69cc7 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.h +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.h @@ -13,7 +13,7 @@ * * @file * @brief Definions related to SLAAC functionality of the NIB - * @see @ref GNRC_IPV6_NIB_CONF_SLAAC + * @see @ref CONFIG_GNRC_IPV6_NIB_SLAAC * @internal * * @author Martine Lenders @@ -21,6 +21,7 @@ #ifndef PRIV_NIB_SLAAC_H #define PRIV_NIB_SLAAC_H +#include #include #include "net/gnrc/ipv6/nib/conf.h" @@ -31,7 +32,7 @@ extern "C" { #endif -#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || GNRC_IPV6_NIB_CONF_SLAAC || defined(DOXYGEN) +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) || defined(DOXYGEN) /** * @brief Auto-configures an address from a given prefix * @@ -41,11 +42,11 @@ extern "C" { */ void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx, uint8_t pfx_len); -#else /* CONFIG_GNRC_IPV6_NIB_6LN || GNRC_IPV6_NIB_CONF_SLAAC */ +#else /* CONFIG_GNRC_IPV6_NIB_6LN || CONFIG_GNRC_IPV6_NIB_SLAAC */ #define _auto_configure_addr(netif, pfx, pfx_len) \ (void)netif; (void)pfx; (void)pfx_len; -#endif /* CONFIG_GNRC_IPV6_NIB_6LN || GNRC_IPV6_NIB_CONF_SLAAC */ -#if GNRC_IPV6_NIB_CONF_SLAAC || defined(DOXYGEN) +#endif /* CONFIG_GNRC_IPV6_NIB_6LN || CONFIG_GNRC_IPV6_NIB_SLAAC */ +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) || defined(DOXYGEN) /** * @brief Removes a tentative address from the interface and tries to * reconfigure a new address @@ -68,12 +69,12 @@ void _handle_dad(const ipv6_addr_t *addr); * @param[in] addr A TENTATIVE address. */ void _handle_valid_addr(const ipv6_addr_t *addr); -#else /* GNRC_IPV6_NIB_CONF_SLAAC */ +#else /* CONFIG_GNRC_IPV6_NIB_SLAAC */ #define _remove_tentative_addr(netif, addr) \ (void)netif; (void)addr #define _handle_dad(addr) (void)addr #define _handle_valid_addr(addr) (void)addr -#endif /* GNRC_IPV6_NIB_CONF_SLAAC */ +#endif /* CONFIG_GNRC_IPV6_NIB_SLAAC */ #ifdef __cplusplus } diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib.c b/sys/net/gnrc/network_layer/ipv6/nib/nib.c index 9c3682ff7b..5e230e5634 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c @@ -128,11 +128,11 @@ void gnrc_ipv6_nib_init_iface(gnrc_netif_t *netif) _init_iface_arsm(netif); netif->ipv6.retrans_time = NDP_RETRANS_TIMER_MS; -#if GNRC_IPV6_NIB_CONF_SLAAC || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) - /* TODO: set differently dependent on GNRC_IPV6_NIB_CONF_SLAAC if +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) + /* TODO: set differently dependent on CONFIG_GNRC_IPV6_NIB_SLAAC if * alternatives exist */ netif->ipv6.aac_mode = GNRC_NETIF_AAC_AUTO; -#endif /* GNRC_IPV6_NIB_CONF_SLAAC || CONFIG_GNRC_IPV6_NIB_6LN */ +#endif /* CONFIG_GNRC_IPV6_NIB_SLAAC || CONFIG_GNRC_IPV6_NIB_6LN */ _init_iface_router(netif); gnrc_netif_init_6ln(netif); #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) @@ -909,7 +909,7 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str))); DEBUG(" - Destination address: %s\n", ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str))); -#if GNRC_IPV6_NIB_CONF_SLAAC +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) gnrc_netif_t *tgt_netif = gnrc_netif_get_by_ipv6_addr(&nbr_sol->tgt); if (tgt_netif != NULL) { @@ -929,7 +929,7 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, return; } } -#endif /* GNRC_IPV6_NIB_CONF_SLAAC */ +#endif /* CONFIG_GNRC_IPV6_NIB_SLAAC */ if (ipv6_addr_is_unspecified(&ipv6->src)) { gnrc_ndp_nbr_adv_send(&nbr_sol->tgt, netif, &ipv6->src, false, NULL); } @@ -1041,7 +1041,7 @@ static void _handle_nbr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, (nbr_adv->flags & NDP_NBR_ADV_FLAGS_R) ? 'R' : '-', (nbr_adv->flags & NDP_NBR_ADV_FLAGS_S) ? 'S' : '-', (nbr_adv->flags & NDP_NBR_ADV_FLAGS_O) ? 'O' : '-'); -#if GNRC_IPV6_NIB_CONF_SLAAC +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) gnrc_netif_t *tgt_netif = gnrc_netif_get_by_ipv6_addr(&nbr_adv->tgt); if (tgt_netif != NULL) { @@ -1059,7 +1059,7 @@ static void _handle_nbr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, /* else case beyond scope of RFC4862: * https://tools.ietf.org/html/rfc4862#section-5.4.4 */ } -#endif /* GNRC_IPV6_NIB_CONF_SLAAC */ +#endif /* CONFIG_GNRC_IPV6_NIB_SLAAC */ if (((nce = _nib_onl_get(&nbr_adv->tgt, netif->pid)) != NULL) && (nce->mode & _NC)) { #if GNRC_IPV6_NIB_CONF_ARSM @@ -1101,7 +1101,7 @@ static void _handle_nbr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, _handle_adv_l2(netif, nce, (icmpv6_hdr_t *)nbr_adv, NULL); } #endif /* GNRC_IPV6_NIB_CONF_ARSM */ -#if GNRC_IPV6_NIB_CONF_SLAAC && IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC) && IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) /* 6Lo-ND duplicate address detection (DAD) was ignored by neighbor, try * traditional DAD */ if ((aro_status == _ADDR_REG_STATUS_UNAVAIL) && diff --git a/tests/gnrc_netif/Makefile b/tests/gnrc_netif/Makefile index 061bf00c2d..ebd8395f78 100644 --- a/tests/gnrc_netif/Makefile +++ b/tests/gnrc_netif/Makefile @@ -13,7 +13,7 @@ USEMODULE += od # deactivate automatically emitted packets from IPv6 neighbor discovery CFLAGS += -DGNRC_IPV6_NIB_CONF_ARSM=0 -CFLAGS += -DGNRC_IPV6_NIB_CONF_SLAAC=0 +CFLAGS += -DCONFIG_GNRC_IPV6_NIB_SLAAC=0 CFLAGS += -DGNRC_IPV6_NIB_CONF_NO_RTR_SOL=1 CFLAGS += -DGNRC_NETIF_ADDRS_NUMOF=16 CFLAGS += -DGNRC_NETIF_GROUPS_NUMOF=8