
On Wed, Oct 14, 2009 at 02:31:29PM +0200, Daniel Veillard wrote:
On Wed, Oct 14, 2009 at 12:33:36PM +0100, Daniel P. Berrange wrote:
It would be nice to have this in a callable function too
int virSocketAddrRange(struct sockaddr_storage *start, struct sockaddr_storage *end);
Are you supposed to look struct sockaddr_storage ? As posted in my last mail this seems a completely opaque structure at least in theory and if you want to keep the portability it's supposed to bring.
You cast to one of the address specific structs according to the ss_family field.
humpf ... okay it has to be cast to be accessed, that's weird, definitely.
Yeah, ideally it would have been in a union, but POSIX the way it was defined when sockets API were first designed, didn't allow a union to be retrofitted. We could consider a union ourselves though for our API if it might make it a little clearer, eg typedef union { struct sockaddr_storage stor; struct sockaddr_in inet4; struct sockaddr_in6 inet6; } virSocketAddr; to allow more direct access without the casting Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|