gnrc/nib: Move GNRC_IPV6_NIB_CONF_6LBR to 'CONFIG_' namespace

Also evaluate it using IS_ACTIVE macro.
This commit is contained in:
Leandro Lanzieri 2020-03-11 17:38:03 +01:00
parent ec296f8439
commit 40c78f1c75
No known key found for this signature in database
GPG Key ID: 39607DE6080007A3
11 changed files with 49 additions and 35 deletions

View File

@ -21,6 +21,8 @@
#ifndef NET_GNRC_IPV6_NIB_ABR_H
#define NET_GNRC_IPV6_NIB_ABR_H
#include <kernel_defines.h>
#include "net/ipv6/addr.h"
#include "net/gnrc/ipv6/nib/conf.h"
@ -39,7 +41,7 @@ typedef struct {
} gnrc_ipv6_nib_abr_t;
#if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C || defined(DOXYGEN)
#if GNRC_IPV6_NIB_CONF_6LBR || defined(DOXYGEN)
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR) || defined(DOXYGEN)
/**
* @brief Adds the address of an authoritative border router to the NIB
*
@ -47,7 +49,7 @@ typedef struct {
*
* @return 0 on success.
* @return -ENOMEM, if no space is left in the neighbor cache.
* @return -ENOTSUP, if @ref GNRC_IPV6_NIB_CONF_6LBR or
* @return -ENOTSUP, if @ref CONFIG_GNRC_IPV6_NIB_6LBR or
* @ref GNRC_IPV6_NIB_CONF_MULTIHOP_P6C is not defined
*/
int gnrc_ipv6_nib_abr_add(const ipv6_addr_t *addr);
@ -58,10 +60,10 @@ int gnrc_ipv6_nib_abr_add(const ipv6_addr_t *addr);
* @param[in] addr The address of an authoritative border router.
*/
void gnrc_ipv6_nib_abr_del(const ipv6_addr_t *addr);
#else /* GNRC_IPV6_NIB_CONF_6LBR || defined(DOXYGEN) */
#else /* CONFIG_GNRC_IPV6_NIB_6LBR || defined(DOXYGEN) */
#define gnrc_ipv6_nib_abr_add(addr) (-ENOTSUP)
#define gnrc_ipv6_nib_abr_del(addr) (void)(addr)
#endif /* GNRC_IPV6_NIB_CONF_6LBR || defined(DOXYGEN) */
#endif /* CONFIG_GNRC_IPV6_NIB_6LBR || defined(DOXYGEN) */
/**
* @brief Iterates over all authoritative border router in the NIB

View File

@ -21,14 +21,16 @@
#ifndef NET_GNRC_IPV6_NIB_CONF_H
#define NET_GNRC_IPV6_NIB_CONF_H
#include <kernel_defines.h>
#ifdef __cplusplus
extern "C" {
#endif
/* some pseudo-module based configuration, doc: see below */
#ifdef MODULE_GNRC_IPV6_NIB_6LBR
#ifndef GNRC_IPV6_NIB_CONF_6LBR
#define GNRC_IPV6_NIB_CONF_6LBR 1
#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
@ -84,15 +86,15 @@ extern "C" {
/**
* @brief enable features for 6Lo border router
*/
#ifndef GNRC_IPV6_NIB_CONF_6LBR
#define GNRC_IPV6_NIB_CONF_6LBR 0
#ifndef CONFIG_GNRC_IPV6_NIB_6LBR
#define CONFIG_GNRC_IPV6_NIB_6LBR 0
#endif
/**
* @brief enable features for 6Lo router
*/
#ifndef GNRC_IPV6_NIB_CONF_6LR
#if GNRC_IPV6_NIB_CONF_6LBR
#if CONFIG_GNRC_IPV6_NIB_6LBR
#define GNRC_IPV6_NIB_CONF_6LR 1
#else
#define GNRC_IPV6_NIB_CONF_6LR 0
@ -126,7 +128,7 @@ extern "C" {
*/
#ifndef GNRC_IPV6_NIB_CONF_ADV_ROUTER
#if GNRC_IPV6_NIB_CONF_ROUTER && \
(!GNRC_IPV6_NIB_CONF_6LR || GNRC_IPV6_NIB_CONF_6LBR)
(!GNRC_IPV6_NIB_CONF_6LR || CONFIG_GNRC_IPV6_NIB_6LBR)
#define GNRC_IPV6_NIB_CONF_ADV_ROUTER 1
#else
#define GNRC_IPV6_NIB_CONF_ADV_ROUTER 0

View File

@ -21,6 +21,8 @@
#ifndef NET_GNRC_NETIF_INTERNAL_H
#define NET_GNRC_NETIF_INTERNAL_H
#include <kernel_defines.h>
#include "net/gnrc/netif.h"
#include "net/l2util.h"
#include "net/netopt.h"
@ -430,7 +432,7 @@ static inline bool gnrc_netif_is_6lr(const gnrc_netif_t *netif)
* according to RFC 6775
*
* @attention Requires prior locking
* @note Assumed to be false, when @ref GNRC_IPV6_NIB_CONF_6LBR == 0.
* @note Assumed to be false, when @ref CONFIG_GNRC_IPV6_NIB_6LBR == 0.
*
* @param[in] netif the network interface
*
@ -441,7 +443,7 @@ static inline bool gnrc_netif_is_6lr(const gnrc_netif_t *netif)
*/
static inline bool gnrc_netif_is_6lbr(const gnrc_netif_t *netif)
{
if (IS_ACTIVE(GNRC_IPV6_NIB_CONF_6LBR)) {
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)) {
return (netif->flags & GNRC_NETIF_FLAGS_6LO_ABR) &&
gnrc_netif_is_6lr(netif);
}

View File

@ -148,7 +148,7 @@ void dhcpv6_client_conf_prefix(unsigned iface, const ipv6_addr_t *pfx,
}
gnrc_ipv6_nib_pl_set(netif->pid, pfx, pfx_len, valid, pref);
if (IS_USED(MODULE_GNRC_IPV6_NIB) &&
GNRC_IPV6_NIB_CONF_6LBR &&
IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR) &&
GNRC_IPV6_NIB_CONF_MULTIHOP_P6C &&
gnrc_netif_is_6ln(netif)) {
if (IS_USED(MODULE_GNRC_SIXLOWPAN_CTX)) {

View File

@ -6,6 +6,8 @@
* directory for more details.
*/
#include <kernel_defines.h>
#include "net/gnrc/ipv6/nib.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/netapi.h"
@ -151,7 +153,7 @@ void uhcp_handle_prefix(uint8_t *prefix, uint8_t prefix_len, uint16_t lifetime,
else if (!ipv6_addr_is_unspecified(&_prefix)) {
gnrc_netapi_set(gnrc_wireless_interface, NETOPT_IPV6_ADDR_REMOVE, 0,
&_prefix, sizeof(_prefix));
#if defined(MODULE_GNRC_IPV6_NIB) && GNRC_IPV6_NIB_CONF_6LBR && \
#if defined(MODULE_GNRC_IPV6_NIB) && IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR) && \
GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
gnrc_ipv6_nib_abr_del(&_prefix);
#endif
@ -171,7 +173,7 @@ void uhcp_handle_prefix(uint8_t *prefix, uint8_t prefix_len, uint16_t lifetime,
* list */
_update_6ctx((ipv6_addr_t *)prefix, prefix_len);
#endif
#if defined(MODULE_GNRC_IPV6_NIB) && GNRC_IPV6_NIB_CONF_6LBR && \
#if defined(MODULE_GNRC_IPV6_NIB) && IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR) && \
GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
gnrc_ipv6_nib_abr_add((ipv6_addr_t *)prefix);
#endif

View File

@ -19,6 +19,8 @@
#ifndef PRIV_NIB_ROUTER_H
#define PRIV_NIB_ROUTER_H
#include <kernel_defines.h>
#include "net/gnrc/ipv6/nib/conf.h"
#include "net/gnrc/netif/internal.h"
#include "net/gnrc/netif/ipv6.h"
@ -43,12 +45,12 @@ static inline void _init_iface_router(gnrc_netif_t *netif)
netif->ipv6.last_ra = UINT32_MAX;
netif->ipv6.ra_sent = 0;
netif->flags |= GNRC_NETIF_FLAGS_IPV6_FORWARDING;
#if !GNRC_IPV6_NIB_CONF_6LR || GNRC_IPV6_NIB_CONF_6LBR
#if !GNRC_IPV6_NIB_CONF_6LR || IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
netif->flags |= GNRC_NETIF_FLAGS_IPV6_RTR_ADV;
#endif /* !GNRC_IPV6_NIB_CONF_6LR || GNRC_IPV6_NIB_CONF_6LBR */
#if GNRC_IPV6_NIB_CONF_6LBR
#endif /* !GNRC_IPV6_NIB_CONF_6LR || CONFIG_GNRC_IPV6_NIB_6LBR */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
netif->flags |= GNRC_NETIF_FLAGS_6LO_ABR;
#endif /* GNRC_IPV6_NIB_CONF_6LBR */
#endif /* CONFIG_GNRC_IPV6_NIB_6LBR */
gnrc_netif_ipv6_group_join_internal(netif, &ipv6_addr_all_routers_link_local);
}

View File

@ -15,6 +15,7 @@
#include <errno.h>
#include <stdbool.h>
#include <kernel_defines.h>
#include "log.h"
#include "net/ipv6/addr.h"
@ -637,13 +638,13 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
byteorder_ntohs(abro->ltime) * SEC_PER_MIN *
MS_PER_SEC);
}
#if !GNRC_IPV6_NIB_CONF_6LBR
#if !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
else if (gnrc_netif_is_6lr(netif)) {
DEBUG("nib: multihop prefix and context dissemination on router activated,\n"
" but no ABRO found. Discarding router advertisement silently\n");
return;
}
#endif /* !GNRC_IPV6_NIB_CONF_6LBR */
#endif /* !CONFIG_GNRC_IPV6_NIB_6LBR */
#endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */
if (rtr_adv->ltime.u16 != 0) {
uint16_t rtr_ltime = byteorder_ntohs(rtr_adv->ltime);

View File

@ -14,6 +14,7 @@
*/
#include <stdio.h>
#include <kernel_defines.h>
#include "net/gnrc/ipv6/nib/abr.h"
@ -21,7 +22,7 @@
#include "_nib-internal.h"
#if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
#if GNRC_IPV6_NIB_CONF_6LBR
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
int gnrc_ipv6_nib_abr_add(const ipv6_addr_t *addr)
{
_nib_abr_entry_t *abr;
@ -55,7 +56,7 @@ void gnrc_ipv6_nib_abr_del(const ipv6_addr_t *addr)
_nib_abr_remove(addr);
_nib_release();
}
#endif /* GNRC_IPV6_NIB_CONF_6LBR */
#endif /* CONFIG_GNRC_IPV6_NIB_6LBR */
bool gnrc_ipv6_nib_abr_iter(void **state, gnrc_ipv6_nib_abr_t *entry)
{

View File

@ -16,6 +16,7 @@
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <kernel_defines.h>
#include "net/gnrc/ipv6/nib/pl.h"
#include "net/gnrc/netif/internal.h"
@ -71,7 +72,7 @@ int gnrc_ipv6_nib_pl_set(unsigned iface,
if (netif->ipv6.aac_mode == GNRC_NETIF_AAC_AUTO) {
dst->flags |= _PFX_SLAAC;
}
#if GNRC_IPV6_NIB_CONF_6LBR && GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR) && GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
if (gnrc_netif_is_6lbr(netif)) {
_nib_abr_entry_t *abr = NULL;

View File

@ -14,6 +14,7 @@
*/
#include <stdio.h>
#include <kernel_defines.h>
#include "net/gnrc/ipv6/nib.h"
#include "net/gnrc/netif.h"
@ -297,14 +298,14 @@ static int _nib_route(int argc, char **argv)
#if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
static void _usage_nib_abr(char **argv)
{
#if GNRC_IPV6_NIB_CONF_6LBR
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)) {
printf("usage: %s %s [show|add|del|help]\n", argv[0], argv[1]);
printf(" %s %s add <ipv6 global addr>\n",
argv[0], argv[1]);
printf(" %s %s add <ipv6 global addr>\n", argv[0], argv[1]);
printf(" %s %s del <ipv6 global addr>\n", argv[0], argv[1]);
#else /* GNRC_IPV6_NIB_CONF_6LBR */
}
else {
printf("usage: %s %s [show|help]\n", argv[0], argv[1]);
#endif /* GNRC_IPV6_NIB_CONF_6LBR */
}
printf(" %s %s show\n", argv[0], argv[1]);
}
@ -321,7 +322,7 @@ static int _nib_abr(int argc, char **argv)
else if ((argc > 2) && (strcmp(argv[2], "help") == 0)) {
_usage_nib_abr(argv);
}
#if GNRC_IPV6_NIB_CONF_6LBR
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
else if ((argc > 3) && (strcmp(argv[2], "del") == 0)) {
ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
@ -355,7 +356,7 @@ static int _nib_abr(int argc, char **argv)
return 1;
}
}
#endif /* GNRC_IPV6_NIB_CONF_6LBR */
#endif /* CONFIG_GNRC_IPV6_NIB_6LBR */
else {
_usage_nib_abr(argv);
return 1;

View File

@ -6,7 +6,7 @@ CFLAGS += -DGNRC_IPV6_NIB_NUMOF=16
CFLAGS += -DGNRC_IPV6_NIB_OFFL_NUMOF=25
CFLAGS += -DGNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF=4
CFLAGS += -DGNRC_IPV6_NIB_ABR_NUMOF=4
CFLAGS += -DGNRC_IPV6_NIB_CONF_6LBR=1
CFLAGS += -DCONFIG_GNRC_IPV6_NIB_6LBR=1
CFLAGS += -DGNRC_IPV6_NIB_CONF_MULTIHOP_P6C=1
CFLAGS += -DGNRC_IPV6_NIB_CONF_DC=1