[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] network utilities



On Thu, Oct 22, 2009 at 04:42:20PM -0400, Laine Stump wrote:
>> +/*
>> + * Helpers to extract the IP arrays from the virSocketAddrPtr
>> + * That part is the less portable of the module
>> + */
>> +typedef unsigned char virIPv4Addr[4];
>> +typedef virIPv4Addr *virIPv4AddrPtr;
>> +typedef unsigned short virIPv6Addr[8];
>>    
>
>
> Are you defining this an an array of short for efficiency? It's much  
> easier to deal with if you just look at it as a byte array - you don't  
> need to worry about network vs. host ordering when doing comparisons and  
> bit shifts/masks (IPv6 addresses, like IPv4 addresses, are *always* in  
> network order, even when being passed around in applications - see  
> section 3.2 of
> http://tools.ietf.org/html/rfc3493.)

  No. Those routines and structs are purely internal, and I choose to
adopt a structure which match the way addresses are serialized in
writing. So if you see 192.168.0.1 and look at the parsed array
(in code or in gdb) you see the same thing. This is mostly to make the
code understandable. For Ipv6 since in writing people use blocks of
values 0000-FFFF is was making sense for me to match that and use an
array of short. htonx and ntohx are just here to make code and debug
easier to understand.

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/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]