Thiago,

Thanks for finding that.  8 sockets it is.

John

-----Original Message-----
From: Macieira, Thiago 
Sent: Wednesday, June 17, 2015 3:24 PM
To: Light, John J
Cc: iotivity-dev at lists.iotivity.org
Subject: Re: [dev] Proposal for IP Adapter and request for feedback

On Wednesday 17 June 2015 14:16:30 Light, John J wrote:
> "I don't think you can, since you can't join an IPv4 multicast group 
> on an
> AF_INET6 socket. That means you need to have a pair of pairs of 
> sockets for multicast."
> 
> The two multicast sockets (A and B) won't be bound at all (or bound to 
> INADDR_ANY).  Multicast messages will be sent on unicast sockets, C or 
> E, respectively, so the responder will reply to the right socket.  For 
> instance, an IPv6 multicast will be sent on Socket C, so the response 
> will be returned to Socket C.  If the connection is to be secured, the 
> conversation will move to Sockets D and F.

Hi John

The problem is not the binding, it's the socket creation. You need to pass the 
address family to the socket(2) function and I don't think you can ask an
AF_INET6 socket to SOL_IP/IP_ADD_MEMBERSHIP of an IPv4 multicast address.

A quick test with Python shows it actually works, on Linux. However, this is 
exploiting the fact that that IPV6_V6ONLY was set to 0. The moment that I set 
it to 1, the socket won't receive multicasts on the IPv4 address.

And it won't work on other OSes. The same Python script on OS X "socket.error: 
[Errno 22] Invalid argument" the moment I try to IP_ADD_MEMBERSHIP. On Windows, 
I get the same problem, just with a different message.

> I agree that we may need to use IP_PKTINFO / IP_RECVIF at some point 
> to choose interfaces.  (That's not what the current interface testing 
> does.)

Right, that's the reason it has multiple sockets in the first place. Using 
those two options and their corresponding ancillary data allows one to send on 
any interface from the same socket.

The only detail is that the IPv4 interface isn't standardised. I've implemented 
it for Windows, Linux and OS X, but I know for a fact that FreeBSD is 
different. The interface for IPv6 is specified in RFC 3542.

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

Reply via email to