From a77d0dd9c5971867fe0be30ceccb2723c0b73ea9 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 12 Mar 2020 17:24:26 +0100 Subject: [PATCH] gnrc/nib: Move GNRC_IPV6_NIB_OFFL_NUMOF to 'CONFIG_' namespace --- examples/gnrc_minimal/Makefile | 2 +- sys/include/net/gnrc/ipv6/nib/conf.h | 6 +++--- .../network_layer/ipv6/nib/_nib-internal.c | 14 ++++++------- .../network_layer/ipv6/nib/_nib-internal.h | 2 +- .../tests-gnrc_ipv6_nib/Makefile.include | 2 +- .../tests-gnrc_ipv6_nib-ft.c | 18 ++++++++--------- .../tests-gnrc_ipv6_nib-internal.c | 18 ++++++++--------- .../tests-gnrc_ipv6_nib-pl.c | 20 +++++++++---------- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/gnrc_minimal/Makefile b/examples/gnrc_minimal/Makefile index 24dea96fc8..aae86ca5e8 100644 --- a/examples/gnrc_minimal/Makefile +++ b/examples/gnrc_minimal/Makefile @@ -26,7 +26,7 @@ USEMODULE += prng_minstd CFLAGS += -DLOG_LEVEL=LOG_NONE # disable log output CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=2 \ -DGNRC_NETIF_IPV6_GROUPS_NUMOF=2 -DCONFIG_GNRC_IPV6_NIB_NUMOF=1 \ - -DGNRC_IPV6_NIB_OFFL_NUMOF=1 # be able to configure at least one route + -DCONFIG_GNRC_IPV6_NIB_OFFL_NUMOF=1 # be able to configure at least one route # Enable single interface optimization. Set to 0 if more than one interface is # present diff --git a/sys/include/net/gnrc/ipv6/nib/conf.h b/sys/include/net/gnrc/ipv6/nib/conf.h index 9302557811..5d6b8fdd0d 100644 --- a/sys/include/net/gnrc/ipv6/nib/conf.h +++ b/sys/include/net/gnrc/ipv6/nib/conf.h @@ -255,7 +255,7 @@ extern "C" { * neighbors and duplicate address detection table entries */ #ifndef CONFIG_GNRC_IPV6_NIB_NUMOF -#define CONFIG_GNRC_IPV6_NIB_NUMOF (4) +#define CONFIG_GNRC_IPV6_NIB_NUMOF (4) #endif /** @@ -264,8 +264,8 @@ extern "C" { * @attention This number is equal to the maximum number of forwarding table * and prefix list entries in NIB */ -#ifndef GNRC_IPV6_NIB_OFFL_NUMOF -#define GNRC_IPV6_NIB_OFFL_NUMOF (8) +#ifndef CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF +#define CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF (8) #endif #if CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C || defined(DOXYGEN) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c index 97e4d86190..3da882b54d 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c @@ -37,7 +37,7 @@ _nib_dr_entry_t *_prime_def_router = NULL; static clist_node_t _next_removable = { NULL }; static _nib_onl_entry_t _nodes[CONFIG_GNRC_IPV6_NIB_NUMOF]; -static _nib_offl_entry_t _dsts[GNRC_IPV6_NIB_OFFL_NUMOF]; +static _nib_offl_entry_t _dsts[CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF]; static _nib_dr_entry_t _def_routers[CONFIG_GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF]; #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C) @@ -480,7 +480,7 @@ _nib_offl_entry_t *_nib_offl_alloc(const ipv6_addr_t *next_hop, unsigned iface, iface); DEBUG("pfx = %s/%u)\n", ipv6_addr_to_str(addr_str, pfx, sizeof(addr_str)), pfx_len); - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { _nib_offl_entry_t *tmp = &_dsts[i]; _nib_onl_entry_t *tmp_node = tmp->next_hop; @@ -519,7 +519,7 @@ _nib_offl_entry_t *_nib_offl_alloc(const ipv6_addr_t *next_hop, unsigned iface, static inline bool _in_dsts(const _nib_offl_entry_t *dst) { - return (dst < (_dsts + GNRC_IPV6_NIB_OFFL_NUMOF)); + return (dst < (_dsts + CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF)); } #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C) @@ -662,7 +662,7 @@ void _nib_pl_remove(_nib_offl_entry_t *nib_offl) _nib_offl_remove(nib_offl, _PL); #if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C) unsigned idx = _idx_dsts(nib_offl); - if (idx < GNRC_IPV6_NIB_OFFL_NUMOF) { + if (idx < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF) { for (_nib_abr_entry_t *abr = _abrs; _in_abrs(abr); abr++) { if (bf_isset(abr->pfxs, idx)) { DEBUG("nib: Removing prefix %s/%u ", @@ -717,7 +717,7 @@ void _nib_abr_remove(const ipv6_addr_t *addr) sizeof(addr_str))); for (_nib_abr_entry_t *abr = _abrs; _in_abrs(abr); abr++) { if (ipv6_addr_equal(addr, &abr->addr)) { - for (int i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (int i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { if (bf_isset(abr->pfxs, i)) { _nib_pl_remove(&_dsts[i]); } @@ -744,7 +744,7 @@ void _nib_abr_add_pfx(_nib_abr_entry_t *abr, const _nib_offl_entry_t *offl) offl->pfx_len); DEBUG("came from border router %s\n", ipv6_addr_to_str(addr_str, &abr->addr, sizeof(addr_str))); - if (idx < GNRC_IPV6_NIB_OFFL_NUMOF) { + if (idx < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF) { bf_set(abr->pfxs, idx); } } @@ -753,7 +753,7 @@ _nib_offl_entry_t *_nib_abr_iter_pfx(const _nib_abr_entry_t *abr, const _nib_offl_entry_t *last) { if ((last == NULL) || - (_idx_dsts(last) < GNRC_IPV6_NIB_OFFL_NUMOF)) { + (_idx_dsts(last) < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF)) { /* we don't change `ptr`, so dropping const qualifier for now is okay */ _nib_offl_entry_t *ptr = (_nib_offl_entry_t *)last; diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h index 5b2d888b68..786fafb550 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h @@ -234,7 +234,7 @@ typedef struct { * @brief Bitfield marking the prefixes in the NIB's off-link entries * disseminated by _nib_abr_entry_t::addr */ - BITFIELD(pfxs, GNRC_IPV6_NIB_OFFL_NUMOF); + BITFIELD(pfxs, CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF); /** * @brief Bitfield marking the contexts disseminated by * _nib_abr_entry_t::addr diff --git a/tests/unittests/tests-gnrc_ipv6_nib/Makefile.include b/tests/unittests/tests-gnrc_ipv6_nib/Makefile.include index e63296af2d..8eeb84f2c3 100644 --- a/tests/unittests/tests-gnrc_ipv6_nib/Makefile.include +++ b/tests/unittests/tests-gnrc_ipv6_nib/Makefile.include @@ -3,7 +3,7 @@ USEMODULE += gnrc_sixlowpan_nd # required for CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C CFLAGS += -DCONFIG_GNRC_IPV6_NIB_ROUTER=1 CFLAGS += -DCONFIG_GNRC_IPV6_NIB_NUMOF=16 -CFLAGS += -DGNRC_IPV6_NIB_OFFL_NUMOF=25 +CFLAGS += -DCONFIG_GNRC_IPV6_NIB_OFFL_NUMOF=25 CFLAGS += -DCONFIG_GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF=4 CFLAGS += -DGNRC_IPV6_NIB_ABR_NUMOF=4 CFLAGS += -DCONFIG_GNRC_IPV6_NIB_6LBR=1 diff --git a/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-ft.c b/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-ft.c index 7b5a3a9415..2c74b2887c 100644 --- a/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-ft.c +++ b/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-ft.c @@ -212,10 +212,10 @@ static void test_nib_ft_add__EINVAL_iface0(void) &next_hop, 0, 0)); } -#if CONFIG_GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF +#if CONFIG_GNRC_IPV6_NIB_NUMOF < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF #define MAX_NUMOF (CONFIG_GNRC_IPV6_NIB_NUMOF) -#else /* CONFIG_GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF */ -#define MAX_NUMOF (GNRC_IPV6_NIB_OFFL_NUMOF) +#else /* CONFIG_GNRC_IPV6_NIB_NUMOF < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF */ +#define MAX_NUMOF (CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF) #endif /* @@ -238,7 +238,7 @@ static void test_nib_ft_add__ENOMEM_diff_def_router(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF routes with different destinations of same + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF routes with different destinations of same * prefix lengths to the same next hop and then tries to create another one * Expected result: gnrc_ipv6_nib_ft_add() returns -ENOMEM */ @@ -246,7 +246,7 @@ static void test_nib_ft_add__ENOMEM_diff_dst(void) { ipv6_addr_t dst = { .u64 = { { .u8 = GLOBAL_PREFIX } } }; - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN, NULL, IFACE, 0)); dst.u16[0].u16--; @@ -256,7 +256,7 @@ static void test_nib_ft_add__ENOMEM_diff_dst(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF routes with destinations of different + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF routes with destinations of different * prefix lengths to the same next hop and then tries to create another one * Expected result: gnrc_ipv6_nib_ft_add() returns -ENOMEM */ @@ -265,7 +265,7 @@ static void test_nib_ft_add__ENOMEM_diff_dst_len(void) static const ipv6_addr_t dst = { .u64 = { { .u8 = GLOBAL_PREFIX } } }; unsigned dst_len = GLOBAL_PREFIX_LEN; - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len, NULL, IFACE, 0)); dst_len--; @@ -275,7 +275,7 @@ static void test_nib_ft_add__ENOMEM_diff_dst_len(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF routes with different destination of + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF routes with different destination of * different prefix lengths to the same next hop and then tries to create * another one * Expected result: gnrc_ipv6_nib_ft_add() returns -ENOMEM @@ -285,7 +285,7 @@ static void test_nib_ft_add__ENOMEM_diff_dst_dst_len(void) ipv6_addr_t dst = { .u64 = { { .u8 = GLOBAL_PREFIX } } }; unsigned dst_len = GLOBAL_PREFIX_LEN; - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len, NULL, IFACE, 0)); dst.u16[0].u16--; diff --git a/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-internal.c b/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-internal.c index eeca88f376..da3d2e3ed5 100644 --- a/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-internal.c +++ b/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-internal.c @@ -1021,10 +1021,10 @@ static void test_nib_drl_get_dr__success4(void) TEST_ASSERT(nib_res != node2); } -#if CONFIG_GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF +#if CONFIG_GNRC_IPV6_NIB_NUMOF < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF #define MAX_NUMOF (CONFIG_GNRC_IPV6_NIB_NUMOF) -#else /* CONFIG_GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF */ -#define MAX_NUMOF (GNRC_IPV6_NIB_OFFL_NUMOF) +#else /* CONFIG_GNRC_IPV6_NIB_NUMOF < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF */ +#define MAX_NUMOF (CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF) #endif /* @@ -1099,7 +1099,7 @@ static void test_nib_offl_alloc__no_space_left_diff_next_hop_iface(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF off-link entries with different prefixes + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF off-link entries with different prefixes * of the same length and then tries to add another. * Expected result: should return NULL */ @@ -1109,7 +1109,7 @@ static void test_nib_offl_alloc__no_space_left_diff_pfx(void) { .u64 = TEST_UINT64 } } }; ipv6_addr_t pfx = { .u64 = { { .u8 = GLOBAL_PREFIX } } }; - for (int i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (int i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { _nib_offl_entry_t *dst; TEST_ASSERT_NOT_NULL((dst = _nib_offl_alloc(&next_hop, IFACE, &pfx, @@ -1198,7 +1198,7 @@ static void test_nib_offl_alloc__no_space_left_diff_next_hop_iface_pfx(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF off-link entries with different prefix + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF off-link entries with different prefix * lengths and then tries to add another. * Expected result: should return NULL */ @@ -1209,7 +1209,7 @@ static void test_nib_offl_alloc__no_space_left_diff_pfx_len(void) static const ipv6_addr_t pfx = { .u64 = { { .u8 = GLOBAL_PREFIX } } }; unsigned pfx_len = GLOBAL_PREFIX_LEN; - for (int i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (int i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { _nib_offl_entry_t *dst; TEST_ASSERT_NOT_NULL((dst = _nib_offl_alloc(&next_hop, IFACE, &pfx, pfx_len))); @@ -1294,7 +1294,7 @@ static void test_nib_offl_alloc__no_space_left_diff_next_hop_iface_pfx_len(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF off-link entries with different prefixes + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF off-link entries with different prefixes * and then tries to add another. * Expected result: should return NULL */ @@ -1305,7 +1305,7 @@ static void test_nib_offl_alloc__no_space_left_diff_pfx_pfx_len(void) ipv6_addr_t pfx = { .u64 = { { .u8 = GLOBAL_PREFIX } } }; unsigned pfx_len = GLOBAL_PREFIX_LEN; - for (int i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (int i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { _nib_offl_entry_t *dst; TEST_ASSERT_NOT_NULL((dst = _nib_offl_alloc(&next_hop, IFACE, &pfx, diff --git a/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-pl.c b/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-pl.c index ff5458db38..9cd8528033 100644 --- a/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-pl.c +++ b/tests/unittests/tests-gnrc_ipv6_nib/tests-gnrc_ipv6_nib-pl.c @@ -96,10 +96,10 @@ static void test_nib_pl_set__EINVAL_pfx_len(void) UINT32_MAX)); } -#if CONFIG_GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF +#if CONFIG_GNRC_IPV6_NIB_NUMOF < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF #define MAX_NUMOF (CONFIG_GNRC_IPV6_NIB_NUMOF) -#else /* CONFIG_GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF */ -#define MAX_NUMOF (GNRC_IPV6_NIB_OFFL_NUMOF) +#else /* CONFIG_GNRC_IPV6_NIB_NUMOF < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF */ +#define MAX_NUMOF (CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF) #endif /* @@ -126,7 +126,7 @@ static void test_nib_pl_set__ENOMEM_diff_iface(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with different prefix of + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with different prefix of * the same length and then tries to create another one * Expected result: gnrc_ipv6_nib_pl_set() returns -ENOMEM */ @@ -135,7 +135,7 @@ static void test_nib_pl_set__ENOMEM_diff_pfx(void) ipv6_addr_t pfx = { .u64 = { { .u8 = GLOBAL_PREFIX }, { .u64 = TEST_UINT64 } } }; - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_pl_set(IFACE, &pfx, GLOBAL_PREFIX_LEN, UINT32_MAX, UINT32_MAX)); @@ -148,7 +148,7 @@ static void test_nib_pl_set__ENOMEM_diff_pfx(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with different prefix of + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with different prefix of * the same length and different interfaces and then tries to create another one * Expected result: gnrc_ipv6_nib_pl_set() returns -ENOMEM */ @@ -172,7 +172,7 @@ static void test_nib_pl_set__ENOMEM_diff_iface_pfx(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with prefixes of + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with prefixes of * different length and then tries to create another one * Expected result: gnrc_ipv6_nib_pl_set() returns -ENOMEM */ @@ -182,7 +182,7 @@ static void test_nib_pl_set__ENOMEM_diff_pfx_len(void) { .u64 = TEST_UINT64 } } }; unsigned pfx_len = GLOBAL_PREFIX_LEN; - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_pl_set(IFACE, &pfx, pfx_len, UINT32_MAX, UINT32_MAX)); pfx_len--; @@ -215,7 +215,7 @@ static void test_nib_pl_set__ENOMEM_diff_iface_pfx_len(void) } /* - * Creates GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with different prefixes + * Creates CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF prefix list entries with different prefixes * and then tries to create another one * Expected result: gnrc_ipv6_nib_pl_set() returns -ENOMEM */ @@ -225,7 +225,7 @@ static void test_nib_pl_set__ENOMEM_diff_pfx_pfx_len(void) { .u64 = TEST_UINT64 } } }; unsigned pfx_len = GLOBAL_PREFIX_LEN; - for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_NIB_OFFL_NUMOF; i++) { TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_pl_set(IFACE, &pfx, pfx_len, UINT32_MAX, UINT32_MAX)); pfx_len--;