Ordering IP addresses [Non trivial]

2005-05-25 Thread Rafael Martinez Torres

Your atention, please...

At ACLIP.cc there is a function setting up a order relationship given two
IP addresses/networks...


aclIPaddrNetworkCompare()

struct IN_ADDR A = p-addr1;

const struct IN_ADDR B = q-addr1;

const struct IN_ADDR C = q-addr2;
A.s_addr = q-mask.s_addr; /* apply netmask */

if (C.s_addr == 0) {/* single address check */

if (ntohl(A.s_addr)  ntohl(B.s_addr))
return 1;
else if (ntohl(A.s_addr)  ntohl(B.s_addr))
return -1;
else
return 0;
} else {/* range address check */

if (ntohl(A.s_addr)  ntohl(C.s_addr))
return  1;
else if (ntohl(A.s_addr)  ntohl(B.s_addr))
return -1;
else
return 0;
}

Bassically they mask the first address, and after that they reuse the
underlying 32 bits integers, referring to integer order relation ship...

NOTES:
--

- Solved the masking on IPv6,  I cannot compare 128 bits integers, unless
I define it. (squid128_int_t)

- I can redefine the address ordering to byte-to-byte comparing (memcmp)
on the two memory areas A B , but  on IPv4 and i386 boxes§ they would
invert the actual order, since  network order inverts the bytes on host order 
(ntohl) , so...

- The rest of calling software will not be ready to support this new
ordering  (-1,0,1) -- (1,0,-1)  Would be very difficult to change it into
this new order ?

- If not answer available in a short time, given the close date to
benchmarking IPv6, were can I order Squid to bypass all the ACLIP
constraints
on squid.conf ?



--
PGP public key: http://www.ngn.euro6ix.org/IPv6/rafael.martinez.gpg



Re: Ordering IP addresses [Non trivial]

2005-05-25 Thread Rafael Martinez Torres

 - I can redefine the address ordering to byte-to-byte comparing (memcmp)
 on the two memory areas A B , but  on IPv4 and i386 boxes§ they would
 invert the actual order, since  network order inverts the bytes on host order 
 (ntohl) , so...

OK. As I see, the only purpose of previous function was to provide a
function to short the nodes of balanced tree SplayV ...

No other semantics beyond that is intended...

typedef Splayacl_ip_data * IPsplay ;


 - The rest of calling software will not be ready to support this new
 ordering  (-1,0,1) -- (1,0,-1)  Would be very difficult to change it into
 this new order ?

Changed the order relationship, the logics for the abstract balanced tree
is
kept...
So, it is not dangerous to redefine the relation in terms of memcmp(...)

Cleaner, even.

 - If not answer available in a short time, given the close date to
 benchmarking IPv6, were can I order Squid to bypass all the ACLIP
 constraints
 on squid.conf ?


Brrr

It's my second obsessed mistake in terms of  IPv6'fied 128 bits numbers...

ASN has to do just rigth with BGP4+ , and aclIPAddrNetworkCompare is
just a order relationship for the nodes of an abstract balanced tree...

Things are easier than thought... I should interpret the meaning of
variables, not just is type




 --
 PGP public key: http://www.ngn.euro6ix.org/IPv6/rafael.martinez.gpg





Re: [Squid-cvs] squid3-ipv6 squid3/src ACLIP.cc,1.8.2.4,1.8.2.5

2005-05-25 Thread Henrik Nordstrom



On Wed, 25 May 2005, Rafael Martinez Torres wrote:


Index: ACLIP.cc
-if (ntohl(A.s_addr)  ntohl(C.s_addr))
+if (memcmp(A, C, sizeof(struct IN_ADDR)) 0)


Hmm.. this has quite different semantics. The original looks at the 
addresses in host byte order, while the memcmp looks at the addresses in 
network byte order...


are you sure this change is OK here?

Regards
Henrik


Re: Ordering IP addresses [Non trivial]

2005-05-25 Thread Henrik Nordstrom

On Wed, 25 May 2005, Rafael Martinez Torres wrote:


NOTES:
--

- Solved the masking on IPv6,  I cannot compare 128 bits integers, unless
I define it. (squid128_int_t)

- I can redefine the address ordering to byte-to-byte comparing (memcmp)
on the two memory areas A B , but  on IPv4 and i386 boxes§ they would
invert the actual order, since  network order inverts the bytes on host order 
(ntohl) , so...

- The rest of calling software will not be ready to support this new
ordering  (-1,0,1) -- (1,0,-1)  Would be very difficult to change it into
this new order ?


Either should be fine, as long as you are consistent, but if this is the 
only problem then all you need is to return the negated result.


Thinking.. memcmp() will actually compare correctly. memcmp() is the same 
as comparing ntohl values as integers thanks to network byte order being 
most significant octet first. So the second point above (and my separate 
comment) is a non-issue.


- If not answer available in a short time, given the close date to 
benchmarking IPv6, were can I order Squid to bypass all the ACLIP 
constraints on squid.conf ?


It's all there in ACLIP.cc.

acl_ip_data::NetworkCompare()

but I fail to see why this would be an issue.

Regards
Henrik


Re: [Squid-cvs] squid3-ipv6 squid3/src ACLIP.cc,1.8.2.4,1.8.2.5

2005-05-25 Thread Henrik Nordstrom



On Thu, 26 May 2005, Henrik Nordstrom wrote:




On Wed, 25 May 2005, Rafael Martinez Torres wrote:


Index: ACLIP.cc
-if (ntohl(A.s_addr)  ntohl(C.s_addr))
+if (memcmp(A, C, sizeof(struct IN_ADDR)) 0)


Hmm.. this has quite different semantics. The original looks at the addresses 
in host byte order, while the memcmp looks at the addresses in network byte 
order...


Err.. both methods looks at the addresses in the correct order. It's just 
my brain trying to compose emails while asleep.


Regards
Henrik