
On Thu, Oct 22, 2009 at 04:46:51PM +0200, Daniel Veillard wrote:
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. [..] commit d5ab523c72242d76184838d8215aa0ebe720c08e Author: Daniel Veillard <veillard@redhat.com> Date: Thu Oct 22 16:34:43 2009 +0200
Set of new network related utilities
* src/util/network.h src/util/network.c: utilities to parse network addresses, check netmask and compute ranges
Okay I have pushed this, I will need to update the internal symbols list and adapt my patch 2 and 3 to solve the original bug on dnsmasq that I was aiming at, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/