gnrc_netif: remove filter parameter from _match_to_idx()

`_match_to_idx()` was removed from source address selection (which was
the only one setting the filter parameter to a non-NULL value), so it
is the parameter is not needed anymore.
This commit is contained in:
Martine S. Lenders 2019-10-09 19:05:41 +02:00
parent e787f6b60d
commit e9d75f5655

View File

@ -474,7 +474,6 @@ void gnrc_netif_release(gnrc_netif_t *netif)
} }
#ifdef MODULE_GNRC_IPV6 #ifdef MODULE_GNRC_IPV6
static inline bool _addr_anycast(const gnrc_netif_t *netif, unsigned idx);
static int _addr_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr); static int _addr_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
static int _group_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr); static int _group_idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr);
@ -501,9 +500,6 @@ static unsigned _match_to_len(const gnrc_netif_t *netif,
* *
* @param[in] netif the network interface * @param[in] netif the network interface
* @param[in] addr the address to match * @param[in] addr the address to match
* @param[in] filter a bitfield with the bits at the position equal to the
* indexes of the addresses you want to include in the
* search set to one. NULL for all addresses
* *
* @return index of the best match for @p addr * @return index of the best match for @p addr
* @return -1 if no match was found * @return -1 if no match was found
@ -511,8 +507,7 @@ static unsigned _match_to_len(const gnrc_netif_t *netif,
* @pre `netif != NULL` and `addr != NULL` * @pre `netif != NULL` and `addr != NULL`
*/ */
static int _match_to_idx(const gnrc_netif_t *netif, static int _match_to_idx(const gnrc_netif_t *netif,
const ipv6_addr_t *addr, const ipv6_addr_t *addr);
const uint8_t *filter);
/** /**
* @brief Determines the scope of the given address. * @brief Determines the scope of the given address.
* *
@ -700,7 +695,7 @@ int gnrc_netif_ipv6_addr_match(gnrc_netif_t *netif,
{ {
assert((netif != NULL) && (addr != NULL)); assert((netif != NULL) && (addr != NULL));
gnrc_netif_acquire(netif); gnrc_netif_acquire(netif);
int idx = _match_to_idx(netif, addr, NULL); int idx = _match_to_idx(netif, addr);
gnrc_netif_release(netif); gnrc_netif_release(netif);
return idx; return idx;
} }
@ -818,11 +813,6 @@ int gnrc_netif_ipv6_group_idx(gnrc_netif_t *netif, const ipv6_addr_t *addr)
return idx; return idx;
} }
static inline bool _addr_anycast(const gnrc_netif_t *netif, unsigned idx)
{
return (netif->ipv6.addrs_flags[idx] & GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST);
}
static int _idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr, bool mcast) static int _idx(const gnrc_netif_t *netif, const ipv6_addr_t *addr, bool mcast)
{ {
if (!ipv6_addr_is_unspecified(addr)) { if (!ipv6_addr_is_unspecified(addr)) {
@ -852,13 +842,12 @@ static unsigned _match_to_len(const gnrc_netif_t *netif,
{ {
assert((netif != NULL) && (addr != NULL)); assert((netif != NULL) && (addr != NULL));
int n = _match_to_idx(netif, addr, NULL); int n = _match_to_idx(netif, addr);
return (n >= 0) ? ipv6_addr_match_prefix(&(netif->ipv6.addrs[n]), addr) : 0; return (n >= 0) ? ipv6_addr_match_prefix(&(netif->ipv6.addrs[n]), addr) : 0;
} }
static int _match_to_idx(const gnrc_netif_t *netif, static int _match_to_idx(const gnrc_netif_t *netif,
const ipv6_addr_t *addr, const ipv6_addr_t *addr)
const uint8_t *filter)
{ {
assert((netif != NULL) && (addr != NULL)); assert((netif != NULL) && (addr != NULL));
@ -867,10 +856,7 @@ static int _match_to_idx(const gnrc_netif_t *netif,
for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) { for (int i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
unsigned match; unsigned match;
if ((netif->ipv6.addrs_flags[i] == 0) || if (netif->ipv6.addrs_flags[i] == 0) {
((filter != NULL) && _addr_anycast(netif, i)) ||
/* discard const intentionally */
((filter != NULL) && !(bf_isset((uint8_t *)filter, i)))) {
continue; continue;
} }
match = ipv6_addr_match_prefix(&(netif->ipv6.addrs[i]), addr); match = ipv6_addr_match_prefix(&(netif->ipv6.addrs[i]), addr);
@ -884,17 +870,15 @@ static int _match_to_idx(const gnrc_netif_t *netif,
ipv6_addr_to_str(addr_str, &netif->ipv6.addrs[idx], ipv6_addr_to_str(addr_str, &netif->ipv6.addrs[idx],
sizeof(addr_str)), sizeof(addr_str)),
netif->pid); netif->pid);
DEBUG("%s by %u bits (used as source address = %s)\n", DEBUG("%s by %u bits\n",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)), ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
best_match, best_match);
(filter != NULL) ? "true" : "false");
} }
else { else {
DEBUG("gnrc_netif: Did not found any address on interface %" PRIkernel_pid DEBUG("gnrc_netif: Did not found any address on interface %" PRIkernel_pid
" matching %s (used as source address = %s)\n", " matching %s\n",
netif->pid, netif->pid,
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)), ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)));
(filter != NULL) ? "true" : "false");
} }
return idx; return idx;
} }