Question

In order to join a multicast group I am accustomed to having seeing code like this:

struct ip_mreqn mreq;
mreq.im_address.s_addr = INADDR_ANY
mreq.imr_ifindex = 0;

inet_aton("232.etc..", $mreq.imr_multiaddr);
setsockopt(descriptor, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));

Now I am running into an issue where someone is telling me this is a v2 igmp join request and that they require v3. Is this something that needs to be addressed in the code above or is it a hardware/network/os issue on the host running code like the above? What steps can I take to correct the above code if it is mistaken?

Was it helpful?

Solution

Now I am running into an issue where someone is telling me this is a v2 igmp join request and that they require v3.

At the moment it isn't any kind of a valid join request, as it doesn't specify a valid multicast group. INADDR_ANY is not a multicast group, it is strictly a bind-address. Multicast groups start at 224.0.0.0, but make sure you pick one that is legal for this use and available.

Whether the protocol engaged in when you get this right is V2 or V3 isn't affected by this code: it depends on what the UDP protocol stack does when you call it. You don't have any control over that. I can't see why 'someone' would require IGMP V3 either.

OTHER TIPS

Even though there is already an accepted answer I feel like it does not answer the original question.

If you are on Linux, you can force the IGMP version by changing the value in this file:

/proc/sys/net/ipv4/conf/eth1/force_igmp_version

Note that where I have "eth1" you must use the interface that you are interested in. The value 0 means auto and 1, 2 or 3 force this specific version of IGMP.

So if you want IGMPv3 on eth0, for example, you can do:

echo 3 > /proc/sys/net/ipv4/conf/eth1/force_igmp_version

On Windows, you can run regedit and on HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters create a new DWORD named IGMPVersion. Setting to 2 would mean IGMPv1, 3 would mean IGMPv2 and 4 would mean IGMPv3.

On a side note, both systems, when operating on auto, should always use the highest version available. That means that usually there is no reason to force IGMPv3. You might need to force v2 though, if you happen to be interacting with some old equipment which does not support v3.

And to conclude, the only way you could force the version of IGMP you want to send joins in on you c code (I mean without adjusting the system configurations before), is if you use a raw socket and mount the whole packet yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top