- cv4 – CygNet with IP v4
- cv6 – CygNet with IP v6
The Interesting Object: CAddressBytes
In cv4 it contains a private sockaddr_in*. When you want an address, it basically deferences the relevant properties (address, port, …).
In IPv6, the
Question: do we want to support:
- IPv6 standalone (no interoperability with v4 systems)
- IPv6 with transparent v4 interoperability (use any v4 address)
- IPv6 with v4->v6 mappings (special v6 addresses that are really v6 addresses that are always distinguishable as such)
For 1, just replace sockaddr_in with sockaddr_in6 and fix up some magic-cookie constants relating to buffer lengths.
For 2, replace sockaddr_in with sockaddr_storage, a struct capable of holding both types of addresses. This is the MS recommended approach and it’s also The Right Thing. The caveat is that where we had an object before, we now have a general object holding a specific object, and thus an additional level of indirection/pointer|reference chasing.
For 3: Pretend you’re doing 1, but add a private sockaddr_in6 property and an AF_INET tag as a dispatch mechanism to the CAddressBytes class. Mmmm…did you just barf in your mouth a little? Me, too. This is basically the same as The Right Thing, except you explicitly dispatch methods/code based on the AF_FAMILY (AF_INET, AF_INET6).
The end result is probably some combination of approaches 2 and 3. It’s not reasonable to go to market with a product that only speaks IPv6, because we know from experience that the changeover will not be immediate, and doing things right will allow cv4 and cv6 to interoperate, something I can only think of as being an inarguable requirement.
I suppose you could go ahead and use both the 4 and 6 addresses, although I’m not sure if there’s any reason other than sheer perversity to do this.
In order to support both IPv4 and IPv6 on Windows XP with Service Pack 1 (SP1) and on Windows Server 2003, an application has to create two sockets, one socket for use with IPv4 and one socket for use with IPv6. These two sockets must be handled separately by the application.
Windows Vista and later offer the ability to create a single IPv6 socket which can handle both IPv6 and IPv4 traffic. For example, a TCP listening socket for IPv6 is created, put into dual stack mode, and bound to port 5001. This dual-stack socket can accept connections from IPv6 TCP clients connecting to port 5001 and from IPv4 TCP clients connecting to port 5001.
Hmmm…..so let’s say for the moment (ask Derek, Jeff, et al.) that we’re going to go with the Vista-and-later model. That simplifies things a big.