From c3b0f35f6f45ce069dca185d8083b91e744bf80d Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 9 Feb 2017 09:50:50 +0200 Subject: [PATCH] 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 --- include/net/net_if.h | 6 ++++-- subsys/net/ip/net_if.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/net/net_if.h b/include/net/net_if.h index f0877c7755e..f4731568391 100644 --- a/include/net/net_if.h +++ b/include/net/net_if.h @@ -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); /** - * @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 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. */ diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 455c8d41774..fbce9c0b85e 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -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++) { int i; + if (ret && *ret && iface != *ret) { + continue; + } + for (i = 0; i < NET_IF_MAX_IPV6_MADDR; i++) { if (!iface->ipv6.mcast[i].is_used || iface->ipv6.mcast[i].address.family != AF_INET6) {