1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

net/gnrc/netif: Move GNRC_NETIF_IPV6_ADDRS_NUMOF to 'CONFIG_' namespace

This commit is contained in:
PeterKietzmann 2020-01-08 11:05:46 +01:00
parent 724d58b074
commit 9e83d12bc0
15 changed files with 37 additions and 37 deletions

View File

@ -24,7 +24,7 @@ USEMODULE += gnrc_icmpv6_echo
USEMODULE += prng_minstd
CFLAGS += -DLOG_LEVEL=LOG_NONE # disable log output
CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DGNRC_NETIF_IPV6_ADDRS_NUMOF=2 \
CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=2 \
-DGNRC_NETIF_IPV6_GROUPS_NUMOF=2 -DGNRC_IPV6_NIB_NUMOF=1 \
-DGNRC_IPV6_NIB_OFFL_NUMOF=1 # be able to configure at least one route

View File

@ -33,7 +33,7 @@ int main(void)
/* get interfaces and print their addresses */
gnrc_netif_t *netif = NULL;
while ((netif = gnrc_netif_iter(netif))) {
ipv6_addr_t ipv6_addrs[GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t ipv6_addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
int res = gnrc_netapi_get(netif->pid, NETOPT_IPV6_ADDR, 0, ipv6_addrs,
sizeof(ipv6_addrs));

View File

@ -296,7 +296,7 @@ gnrc_netif_t *gnrc_netif_get_by_pid(kernel_pid_t pid);
* addresses assigned to @p netif. May not be `NULL`
* @param[in] max_len Number of *bytes* available in @p addrs. Must be at
* least `sizeof(ipv6_addr_t)`. It is recommended to use
* @p GNRC_NETIF_IPV6_ADDRS_NUMOF `* sizeof(ipv6_addr_t)
* @p CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF `* sizeof(ipv6_addr_t)
* here (and have @p addrs of the according length).
*
* @return Number of addresses in @p addrs times `sizeof(ipv6_addr_t)` on

View File

@ -89,8 +89,8 @@ extern "C" {
*
* Default: 2 (1 link-local + 1 global address)
*/
#ifndef GNRC_NETIF_IPV6_ADDRS_NUMOF
#define GNRC_NETIF_IPV6_ADDRS_NUMOF (2)
#ifndef CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF
#define CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF (2)
#endif
/**
@ -100,7 +100,7 @@ extern "C" {
* address) + @ref GNRC_NETIF_RPL_ADDR + @ref GNRC_NETIF_IPV6_RTR_ADDR
*/
#ifndef GNRC_NETIF_IPV6_GROUPS_NUMOF
#define GNRC_NETIF_IPV6_GROUPS_NUMOF (GNRC_NETIF_IPV6_ADDRS_NUMOF + \
#define GNRC_NETIF_IPV6_GROUPS_NUMOF (CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF + \
GNRC_NETIF_RPL_ADDR + \
GNRC_NETIF_IPV6_RTR_ADDR + 1)
#endif

View File

@ -83,14 +83,14 @@ typedef struct {
*
* @note Only available with module @ref net_gnrc_ipv6 "gnrc_ipv6".
*/
uint8_t addrs_flags[GNRC_NETIF_IPV6_ADDRS_NUMOF];
uint8_t addrs_flags[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
/**
* @brief IPv6 unicast and anycast addresses of the interface
*
* @note Only available with module @ref net_gnrc_ipv6 "gnrc_ipv6".
*/
ipv6_addr_t addrs[GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
/**
* @brief IPv6 multicast groups of the interface
@ -162,7 +162,7 @@ typedef struct {
* @note Might also be usable in the later default SLAAC implementation
* for NS retransmission timers.
*/
evtimer_msg_event_t addrs_timers[GNRC_NETIF_IPV6_ADDRS_NUMOF];
evtimer_msg_event_t addrs_timers[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
#endif
#if GNRC_IPV6_NIB_CONF_ROUTER || DOXYGEN

View File

@ -146,7 +146,7 @@ int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
res = 0;
for (unsigned i = 0;
(res < (int)opt->data_len) && (i < GNRC_NETIF_IPV6_ADDRS_NUMOF);
(res < (int)opt->data_len) && (i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF);
i++) {
if (netif->ipv6.addrs_flags[i] != 0) {
memcpy(tgt, &netif->ipv6.addrs[i], sizeof(ipv6_addr_t));
@ -162,7 +162,7 @@ int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)
res = 0;
for (unsigned i = 0;
(res < (int)opt->data_len) && (i < GNRC_NETIF_IPV6_ADDRS_NUMOF);
(res < (int)opt->data_len) && (i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF);
i++) {
if (netif->ipv6.addrs_flags[i] != 0) {
*tgt = netif->ipv6.addrs_flags[i];
@ -581,7 +581,7 @@ int gnrc_netif_ipv6_addr_add_internal(gnrc_netif_t *netif,
flags &= ~GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE;
flags |= 0x1;
}
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_equal(&netif->ipv6.addrs[i], addr)) {
gnrc_netif_release(netif);
return i;
@ -660,7 +660,7 @@ void gnrc_netif_ipv6_addr_remove_internal(gnrc_netif_t *netif,
assert((netif != NULL) && (addr != NULL));
ipv6_addr_set_solicited_nodes(&sol_nodes, addr);
gnrc_netif_acquire(netif);
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_equal(&netif->ipv6.addrs[i], addr)) {
netif->ipv6.addrs_flags[i] = 0;
ipv6_addr_set_unspecified(&netif->ipv6.addrs[i]);
@ -713,7 +713,7 @@ ipv6_addr_t *gnrc_netif_ipv6_addr_best_src(gnrc_netif_t *netif,
{
ipv6_addr_t *best_src = NULL;
BITFIELD(candidate_set, GNRC_NETIF_IPV6_ADDRS_NUMOF);
BITFIELD(candidate_set, CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF);
assert((netif != NULL) && (dst != NULL));
DEBUG("gnrc_netif: get best source address for %s\n",
@ -824,7 +824,7 @@ static int _idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr, bool mcast)
{
if (!ipv6_addr_is_unspecified(addr)) {
const ipv6_addr_t *iplist = (mcast) ? netif->ipv6.groups : netif->ipv6.addrs;
unsigned ipmax = (mcast) ? GNRC_NETIF_IPV6_GROUPS_NUMOF : GNRC_NETIF_IPV6_ADDRS_NUMOF;
unsigned ipmax = (mcast) ? GNRC_NETIF_IPV6_GROUPS_NUMOF : CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF;
for (unsigned i = 0; i < ipmax; i++) {
if (ipv6_addr_equal(&iplist[i], addr)) {
return i;
@ -860,7 +860,7 @@ static int _match_to_idx(const gnrc_netif_t *netif,
int idx = -1;
unsigned best_match = 0;
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
unsigned match;
if (netif->ipv6.addrs_flags[i] == 0) {
@ -938,7 +938,7 @@ static int _create_candidate_set(const gnrc_netif_t *netif,
* candidates assigned to this interface. Thus we assume all addresses to be
* on interface @p netif */
(void) dst;
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
const ipv6_addr_t *tmp = &(netif->ipv6.addrs[i]);
DEBUG("Checking address: %s\n",
@ -1037,16 +1037,16 @@ static ipv6_addr_t *_src_addr_selection(gnrc_netif_t *netif,
/* create temporary set for assigning "points" to candidates winning in the
* corresponding rules.
*/
uint8_t winner_set[GNRC_NETIF_IPV6_ADDRS_NUMOF];
uint8_t winner_set[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
memset(winner_set, 0, GNRC_NETIF_IPV6_ADDRS_NUMOF);
memset(winner_set, 0, CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF);
uint8_t max_pts = 0;
/* _create_candidate_set() assures that `dst` is not unspecified and if
* `dst` is loopback rule 1 will fire anyway. */
uint8_t dst_scope = _get_scope(dst);
DEBUG("finding the best match within the source address candidates\n");
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
ipv6_addr_t *ptr = &(netif->ipv6.addrs[i]);
DEBUG("Checking address: %s\n",
@ -1116,7 +1116,7 @@ static ipv6_addr_t *_src_addr_selection(gnrc_netif_t *netif,
* rule 8: Use longest matching prefix.*/
uint8_t best_match = 0;
/* collect candidates with maximum points */
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (winner_set[i] == max_pts) {
const ipv6_addr_t *addr = &netif->ipv6.addrs[i];
unsigned match = ipv6_addr_match_prefix(addr, dst);

View File

@ -134,7 +134,7 @@ static bool _try_addr_reconfiguration(gnrc_netif_t *netif)
gnrc_netif_acquire(netif);
if (hwaddr_reconf) {
if (remove_old) {
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
ipv6_addr_t *addr = &netif->ipv6.addrs[i];
if (addr->u64[1].u64 == orig_iid.uint64.u64) {
gnrc_netif_ipv6_addr_remove_internal(netif, addr);

View File

@ -670,7 +670,7 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
if ((dr != NULL) && gnrc_netif_is_6ln(netif) &&
!gnrc_netif_is_6lbr(netif)) {
/* (register addresses already assigned but not valid yet)*/
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if ((netif->ipv6.addrs_flags[i] != 0) &&
(netif->ipv6.addrs_flags[i] != GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID)) {
_handle_rereg_address(&netif->ipv6.addrs[i]);
@ -1243,7 +1243,7 @@ static void _handle_pfx_timeout(_nib_offl_entry_t *pfx)
gnrc_netif_acquire(netif);
if (now >= pfx->valid_until) {
evtimer_del(&_nib_evtimer, &pfx->pfx_timeout.event);
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_match_prefix(&netif->ipv6.addrs[i],
&pfx->pfx) >= pfx->pfx_len) {
gnrc_netif_ipv6_addr_remove_internal(netif,
@ -1254,7 +1254,7 @@ static void _handle_pfx_timeout(_nib_offl_entry_t *pfx)
_nib_offl_clear(pfx);
}
else if (now >= pfx->pref_until) {
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_match_prefix(&netif->ipv6.addrs[i],
&pfx->pfx) >= pfx->pfx_len) {
netif->ipv6.addrs_flags[i] &= ~GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK;

View File

@ -442,7 +442,7 @@ static void _netif_list_groups(ipv6_addr_t *addr)
static void _netif_list(netif_t *iface)
{
#ifdef MODULE_GNRC_IPV6
ipv6_addr_t ipv6_addrs[GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t ipv6_addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t ipv6_groups[GNRC_NETIF_IPV6_GROUPS_NUMOF];
#endif
uint8_t hwaddr[GNRC_NETIF_L2ADDR_MAXLEN];
@ -614,7 +614,7 @@ static void _netif_list(netif_t *iface)
res = netif_get_opt(iface, NETOPT_IPV6_ADDR, 0, ipv6_addrs,
sizeof(ipv6_addrs));
if (res >= 0) {
uint8_t ipv6_addrs_flags[GNRC_NETIF_IPV6_ADDRS_NUMOF];
uint8_t ipv6_addrs_flags[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
memset(ipv6_addrs_flags, 0, sizeof(ipv6_addrs_flags));
/* assume it to succeed (otherwise array will stay 0) */

View File

@ -618,7 +618,7 @@ static int send_test_pkt(int argc, char **argv)
(void) argv;
printf("Sending UDP test packets to port %u\n", TEST_PORT);
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_is_link_local(&eth_netif->ipv6.addrs[i])) {
local_addr = &eth_netif->ipv6.addrs[i];
}

View File

@ -887,7 +887,7 @@ static uint8_t _netif_addr_count(const gnrc_netif_t *netif)
{
unsigned count = 0U;
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (netif->ipv6.addrs_flags[i] != 0) {
count++;
}

View File

@ -797,7 +797,7 @@ static uint8_t _netif_addr_count(const gnrc_netif_t *netif)
{
unsigned count = 0U;
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (int i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (netif->ipv6.addrs_flags[i] != 0) {
count++;
}

View File

@ -239,7 +239,7 @@ static void test_ipv6_addr_add__ENOMEM(void)
{
ipv6_addr_t addr = { .u8 = NETIF0_IPV6_G };
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF;
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF;
i++, addr.u16[3].u16++) {
TEST_ASSERT(0 <= gnrc_netif_ipv6_addr_add_internal(netifs[0], &addr, 64U,
GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID));
@ -509,7 +509,7 @@ static void test_ipv6_addr_best_src__deprecated_addr(void)
test_ipv6_addr_add__success(); /* adds EUI-64 based link-local address */
/* ensure that current addresses have smaller matches */
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
ipv6_addr_t *addr = &netifs[0]->ipv6.addrs[i];
TEST_ASSERT(exp_match > ipv6_addr_match_prefix(addr, &dst));
}
@ -747,7 +747,7 @@ static void test_netapi_get__HOP_LIMIT(void)
static void test_netapi_get__IPV6_ADDR(void)
{
static const ipv6_addr_t exp = { NETIF0_IPV6_LL };
ipv6_addr_t value[GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t value[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
test_ipv6_addr_add__success();
TEST_ASSERT_EQUAL_INT(sizeof(ipv6_addr_t), gnrc_netapi_get(netifs[0]->pid,
@ -759,7 +759,7 @@ static void test_netapi_get__IPV6_ADDR(void)
static void test_netapi_get__IPV6_ADDR_FLAGS(void)
{
uint8_t value[GNRC_NETIF_IPV6_ADDRS_NUMOF];
uint8_t value[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
test_ipv6_addr_add__success();
TEST_ASSERT_EQUAL_INT(sizeof(uint8_t), gnrc_netapi_get(netifs[0]->pid,

View File

@ -31,7 +31,7 @@ USEMODULE += posix_inet
LOW_MEMORY_BOARDS := nucleo-f334r8 msb-430 msb-430h
ifeq ($(BOARD),$(filter $(BOARD),$(LOW_MEMORY_BOARDS)))
CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DGNRC_NETIF_IPV6_ADDRS_NUMOF=2 \
CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=2 \
-DGNRC_NETIF_IPV6_GROUPS_NUMOF=2 -DGNRC_IPV6_NIB_NUMOF=1 \
-DNRC_IPV6_NIB_OFFL_NUMOF=1
endif

View File

@ -86,12 +86,12 @@ static int _list_all_inet6(int argc, char **argv)
unsigned addr_qty = 0;
while ((netif = gnrc_netif_iter(netif))) {
ipv6_addr_t ipv6_addrs[GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t ipv6_addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
int res = gnrc_netapi_get(netif->pid, NETOPT_IPV6_ADDR, 0, ipv6_addrs,
sizeof(ipv6_addrs));
if (res >= 0) {
uint8_t ipv6_addrs_flags[GNRC_NETIF_IPV6_ADDRS_NUMOF];
uint8_t ipv6_addrs_flags[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
memset(ipv6_addrs_flags, 0, sizeof(ipv6_addrs_flags));
/* assume it to succeed (otherwise array will stay 0) */