Ordering IP addresses [Non trivial]

From: Rafael Martinez Torres <rafael.martinez@dont-contact.us>
Date: Wed, 25 May 2005 12:22:27 +0200 (CEST)

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
Received on Wed May 25 2005 - 04:22:35 MDT

This archive was generated by hypermail pre-2.1.9 : Tue May 31 2005 - 12:00:03 MDT