james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "alan.gerhard" <alan.gerh...@gercom.com>
Subject CIDR and InetNetwork Classes
Date Mon, 17 Feb 2003 13:58:04 GMT
Noel -

Basic functional differences between the InetNetwork and
CIDR classes can be simply summated as 'CIDR supports CIDR

and 'InetNetwork supports IP/MASK', and each class has their
respective support/utility methods that offers the desired 

functionality ...

The primary motivation behind CIDR was to offer James user's
the ability to define sub-networks with CIDR notation; a 

standard practice among ISP's and other SMTP server
administrators, and since InetNetwork now supports CIDR and

notation, CIDR has become superfluous. 

The performance difference between the two is noticeable;
CIDR uses clumsy string mathematics for conversion to

while InetNetwork uses simpler bit wise operations on byte
arrays. The result appears to be a much faster test
operation with 

InetNetwork - and speed is crucial when validating mails in
high volume flows.

When we get down to implementation, it seems CIDR is ready -
used in a commercial situation - while InetNetwork appears 

incomplete and geared to James v3.0. It is also incompatible
with Java 1.3, the current platform that James is committed

The bottom line is what's best for James and it's users we
should do the following -

replace the following code

            return InetAddress.getByAddress(new byte[]
                (byte) (mask[0] & ip[0]),
                (byte) (mask[1] & ip[1]),
                (byte) (mask[2] & ip[2]),
                (byte) (mask[3] & ip[3])


            return InetAddress.getByName (
                Integer.toString((mask[0] & ip[0]) >>   0 &
0xFF, 10) + "." +
                Integer.toString((mask[1] & ip[1]) >>   8 &
0xFF, 10) + "." +
                Integer.toString((mask[2] & ip[2]) >>  16 &
0xFF, 10) + "." +
                Integer.toString((mask[3] & ip[3]) >>  24 &
0xFF, 10) );

to get InetNetwork compatible with our current environment.
Once we require 1.4, we can replace the code to use the 1.4 

InetAddress.getByAddress(byte[]) method. Benchmarking with
this change does not appear to slow down InetNetwork's
performance enough to be a concern.

in normalizeFromCIDR, validation of the CIDR notation needs
to be performed

Set up the GenericNetworkMatcher and it's associated
matchers to use InetNetworks and get a version for review 

Included this new InetNetwork class and associated matchers
in the next scheduled release of James; which I believe is
to be 

on a regular monthly schedule.

James now has the ability to receive network specifications
in the following formats -

explicit address -
address with a wildcard - 127.0.0*
explicit name - myHost.com
name with CIDR notation - myHost.com/24
name with IP/MASK notation - myHost.com/
CIDR notation -
IP/MASK notation -

Collaboration, not competition, is the bond that strengthens
our determination to go on.


To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org

View raw message