[torquedev] IP version-agnostic Address Representation

Donald Neal dmneal at wand.net.nz
Thu Aug 11 18:05:59 MDT 2011

There are a range of cases in Torque where an IP address is represented 
by a 32-bit object. This is something of a problem where the IP address 
may actually be 128 bits long.

I see two distinct cases here. In one the 32-bit object is being used as 
a key (as with AvlNode). In this case I propose initially to take the 
lower-order 32 bits of an IPv6 address and keep going as now. This is 
simple and effiicient, but would definitely give rise to collisions 
which will confuse people in future.

So the key does in future need to change. My inclination is to use a 
struct created for the purpose containing two uint64_t's. But there are 
definitely other ways of doing this.

In the other case, the address is not used as a key (as in struct 
pbsnode, say). That makes it viable to use either a struct containing 
the minimum fields necessary or a sockaddr*. I'm inclined towards the 
latter on the grounds that keeping down the number of struct types in 
use makes life simpler, But again there are clearly other ways of doing 

Does anyone have a view on this? Does anyone have any other reason to 
use a package like gmp, which I don't see as needed for this purpose alone?

- Donald Neal

Donald Neal                |"We're not going to have any riots around
                           | here. It doesn't matter if you're Turkish,
High Performance Computing | if you live round here we'll defend you."
The University of Waikato  | - Aykut Boyraz

More information about the torquedev mailing list