Revamping my previous patches to parse IPv4/6 numeric addresses,
adding range computation and netmask checking entries too.
As suggested I used an union for the socket address type:
typedef union {
struct sockaddr_storage stor;
struct sockaddr_in inet4;
struct sockaddr_in6 inet6;
} virSocketAddr;
typedef virSocketAddr *virSocketAddrPtr;
But I wonder if it's not better to make it a struct and add
the lenght of the address as this is usually needed when passing
one of the struct sockaddr_* and that lenght is returned as part
of parsing, keeping both together is probably more useful.
A macro to get the type AF_INET/AF_INET6 out of a virSocketAddr
might be useful instead of having the users manually guess that
->stor.ss_family is teh filed to look at.
Also I wonder how useful the Ipv6 code for netmask and ranges
really is, it seems that IPv6 mostly go with prefix and never use
netmasks, maybe that's just dead code, maybe that's just wrong,
anyway here it is.
I named the header and file network.[ch] as I think other
network related utilities like validation or generation of
MAC addresses could well be moved in that file too.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/