Skip to content

Commit 2491078

Browse files
committed
net: ip: route: Add support to search mcast route by iface
This commit adds the possibility to check for a multicast route on a given interface Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
1 parent a0096b7 commit 2491078

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

subsys/net/ip/route.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,30 @@ net_route_mcast_lookup(struct in6_addr *group)
957957

958958
return NULL;
959959
}
960+
961+
struct net_route_entry_mcast *
962+
net_route_mcast_lookup_by_iface(struct in6_addr *group, struct net_if *iface)
963+
{
964+
ARRAY_FOR_EACH_PTR(route_mcast_entries, route) {
965+
if (!route->is_used) {
966+
continue;
967+
}
968+
969+
ARRAY_FOR_EACH(route->ifaces, i) {
970+
if (!route->ifaces[i] || route->ifaces[i] != iface) {
971+
continue;
972+
}
973+
974+
if (net_ipv6_is_prefix(group->s6_addr,
975+
route->group.s6_addr,
976+
route->prefix_len)) {
977+
return route;
978+
}
979+
}
980+
}
981+
982+
return NULL;
983+
}
960984
#endif /* CONFIG_NET_ROUTE_MCAST */
961985

962986
bool net_route_get_info(struct net_if *iface,

subsys/net/ip/route.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ bool net_route_mcast_del(struct net_route_entry_mcast *route);
272272
struct net_route_entry_mcast *
273273
net_route_mcast_lookup(struct in6_addr *group);
274274

275+
/**
276+
* @brief Lookup a multicast routing entry on a given interface.
277+
*
278+
* @param group IPv6 multicast group address
279+
* @param iface Network interface to check
280+
*
281+
* @return Routing entry corresponding to this multicast group and interface.
282+
*/
283+
struct net_route_entry_mcast *
284+
net_route_mcast_lookup_by_iface(struct in6_addr *group, struct net_if *iface);
285+
275286
/**
276287
* @brief Add an interface to multicast routing entry.
277288
*

0 commit comments

Comments
 (0)