net: if: Change the iface param in net_if_ipv6_maddr_lookup

Change the handling of iface parameter in net_if_ipv6_maddr_lookup()
function:
  * If the *iface is set to NULL, then return the found
    interface to the caller.
  * If the *iface is not NULL, then use that interface
    when doing the lookup.

Change-Id: Ia1f0365170ea9f3e615d189231160614a80d241a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-02-09 09:50:50 +02:00
commit c3b0f35f6f
2 changed files with 8 additions and 2 deletions

View file

@ -607,10 +607,12 @@ struct net_if_mcast_addr *net_if_ipv6_maddr_add(struct net_if *iface,
bool net_if_ipv6_maddr_rm(struct net_if *iface, const struct in6_addr *addr); bool net_if_ipv6_maddr_rm(struct net_if *iface, const struct in6_addr *addr);
/** /**
* @brief Check if this IPv6 multicast address belongs to one of the interfaces. * @brief Check if this IPv6 multicast address belongs to a specific interface
* or one of the interfaces.
* *
* @param addr IPv6 address * @param addr IPv6 address
* @param iface Pointer to interface is returned * @param iface If *iface is null, then pointer to interface is returned,
* otherwise the *iface value needs to be matched.
* *
* @return Pointer to interface multicast address, NULL if not found. * @return Pointer to interface multicast address, NULL if not found.
*/ */

View file

@ -554,6 +554,10 @@ struct net_if_mcast_addr *net_if_ipv6_maddr_lookup(const struct in6_addr *maddr,
for (iface = __net_if_start; iface != __net_if_end; iface++) { for (iface = __net_if_start; iface != __net_if_end; iface++) {
int i; int i;
if (ret && *ret && iface != *ret) {
continue;
}
for (i = 0; i < NET_IF_MAX_IPV6_MADDR; i++) { for (i = 0; i < NET_IF_MAX_IPV6_MADDR; i++) {
if (!iface->ipv6.mcast[i].is_used || if (!iface->ipv6.mcast[i].is_used ||
iface->ipv6.mcast[i].address.family != AF_INET6) { iface->ipv6.mcast[i].address.family != AF_INET6) {