Local IPV6 Multicast

I am trying to figure out how to make the equivalent of translating IPV4 using IPV6.

I am creating a non-blocking IPV6 UDP socket.

On the broadcast side, I literally just send the message "FF02 :: 1" to port 12346.

On the listener side, I found that I needed to join the group, so I did the following:

ipv6_mreq membership; memset( &membership.ipv6mr_multiaddr, 0, sizeof( in6_addr ) ); membership.ipv6mr_multiaddr.u.Word[0] = htons( 0xff02 ); membership.ipv6mr_multiaddr.u.Word[7] = htons( 0x0001 ); membership.ipv6mr_interface = 0; if( enable ) { if ( 0 != setsockopt( m_Socket, SOL_SOCKET, IPV6_JOIN_GROUP, (char*)&membership, sizeof( ipv6_mreq ) ) ) { DisplayError(); return false; } } 

However, setsockopt always returns "WSAENOPROTOOPT". What for? Can someone help me with this? I have a complete loss.

Edit: I change the level to "IPPROTO_IPV6", but now I get "WSAEINVAL".

+7
c ++ multicast ipv6 link-local
source share
2 answers

The interface must be set for local IPv6, since the addresses are unique to the interface only. Simply put, the address fe80 :: 1 can belong to both eth0 and eth1, but it is completely separate.

So this means that you need to explicitly send the multicast package to each interface that supports multicast, or provide the user with a way to specify a specific interface.

(edit) If this helps, you can check the multicast code here,

http://code.google.com/p/openpgm/source/browse/trunk/openpgm/pgm/

+4
source share

I think the problem is that you leave the ipv6mr_interface value set to zero, which is not good enough if you want to use the multicast address of the link line, for example ff02 :: 1. You need to set the ipv6mr_interface value for the number corresponding to the local network interface that you want packages to be sent / received. (You can find out which interface indices are available on the current computer by calling getaddrinfo () and reading the values ​​sin6_addr.s6_addr from (struct sockaddr_in6 *) that it gives you)

(If at this moment you were thinking about yourself, it wouldn’t be much easier if the zero interface acted as setting “all interfaces” ... yes, that would be. Alas, IPv6 does not do this for some reason :()

+1
source share

All Articles