Hi, I am writing a software to run on OpenWRT to receive and process multicast packets. However, for some reason, the software is unable to receive multicast packets. I had found old forum posts with the same issue and the solution being route add -net 224.0.0.0 netmask 224.0.0.0 <some interface>
. This did not work for me.
What could possibly be causing this?
I am using OpenWRT 24.10.
Edit 1:
Added a firewall rule to mark the multicast traffic at the input chain. From the nftables page on LuCI, I can see that the traffic reaches "mangle_input".
Edit 2:
I am also seeing IGMP membership reports from the device for the multicast groups that the software is listening for.
Edit 3:
Simplified version of the code segment for socket binding:
struct sockaddr_in _addr, *paddr;
paddr = &_addr;
_addr.sin_family = AF_INET;
_addr.sin_addr.s_addr = my_intf->sin_addr.s_addr;
_addr.sin_port = my_mcdest->sin_port;
if(::bind(my_sock, (struct sockaddr*)paddr, sizeof(struct sockaddr_in)) == 0)
{
struct ip_mreqn ipmr;
ipmr.imr_multiaddr.s_addr = my_mcdest->sin_addr.s_addr;
ipmr.imr_address.s_addr = my_intf->sin_addr.s_addr;
ipmr.imr_ifindex = 0;
if(setsockopt(my_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&ipmr, sizeof(ipmr)) == 0)
{
setsockopt(my_sock, IPPROTO_IP, IP_MULTICAST_IF, &my_intf->sin_addr, sizeof(struct in_addr));
}
}
Edit 4:
Strangly, when I bind to the multicast address instead of the interface IP address, it's able to receive. However, this also causes it to receive multicast packets on lan2, which is not desired.
Thanks in advance.