drivers: Update drivers to use new multicast monitor API

Update drivers regarding latest multicast group join/leave monitor
changes which now supports both IPv6 and IPv4 multicast addresses.

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
This commit is contained in:
Markus Fuchs 2021-09-16 17:33:21 +02:00 committed by Christopher Friedt
parent 7926657b27
commit a283cb3311
2 changed files with 14 additions and 6 deletions

View file

@ -170,7 +170,7 @@ static inline int attach_mcast_filter(struct net_can_context *ctx,
return filter_id;
}
static void mcast_cb(struct net_if *iface, const struct in6_addr *addr,
static void mcast_cb(struct net_if *iface, const struct net_addr *addr,
bool is_joined)
{
const struct device *dev = net_if_get_device(iface);
@ -178,22 +178,26 @@ static void mcast_cb(struct net_if *iface, const struct in6_addr *addr,
struct mcast_filter_mapping *filter_mapping;
int filter_id;
if (addr->family != AF_INET6) {
return;
}
if (is_joined) {
filter_mapping = can_get_mcast_filter(ctx, NULL);
if (!filter_mapping) {
NET_ERR("Can't get a free filter_mapping");
}
filter_id = attach_mcast_filter(ctx, addr);
filter_id = attach_mcast_filter(ctx, addr->in6_addr);
if (filter_id < 0) {
NET_ERR("Can't attach mcast filter");
return;
}
filter_mapping->addr = addr;
filter_mapping->addr = addr->in6_addr;
filter_mapping->filter_id = filter_id;
} else {
filter_mapping = can_get_mcast_filter(ctx, addr);
filter_mapping = can_get_mcast_filter(ctx, addr->in6_addr);
if (!filter_mapping) {
NET_ERR("No filter mapping found");
return;

View file

@ -1030,14 +1030,18 @@ static int eth_init(const struct device *dev)
#if defined(CONFIG_NET_IPV6)
static void net_if_mcast_cb(struct net_if *iface,
const struct in6_addr *addr,
const struct net_addr *addr,
bool is_joined)
{
const struct device *dev = net_if_get_device(iface);
struct eth_context *context = dev->data;
struct net_eth_addr mac_addr;
net_eth_ipv6_mcast_to_mac_addr(addr, &mac_addr);
if (addr->family != AF_INET6) {
return;
}
net_eth_ipv6_mcast_to_mac_addr(&addr->in6_addr, &mac_addr);
if (is_joined) {
ENET_AddMulticastGroup(context->base, mac_addr.addr);