I'm trying to write a multicast application on a linux computer with several network adapters.
To send multicast packets I rely on the operating systems routing tables, but to receive multicast traffic, I need to bind to a specific adapter. I got this working by doing:
My problem is this, I want to check the operating systems routing tables for my multicast adress, check what network adapter it will be sent out on, and then bind and receive multicast traffic on that adapter.Code:ip_mreq multicastReq; //code to add mcast address and interface to multicastReq setsockopt( socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &multicastReq, sizeof( multicastReq ) );
I have managed to get the linux kernels normal routing table using linux/netlink.h and the rtmsg struct from the code specified in the first answer here:
network programming - Getting gateway to use for a given ip in ANSI C - Stack Overflow
This does not list multicast routing, and I can't seems to figure out how to extract this from the operating system.
Is there any network wizards out there who knows how to do this, or if this is even possible?