Markus Werner
1/4/2005 11:13:00 AM
Hi Again,
> I'd suggest a wrapper class: IPAddressWithContext or something. Let it
> have the net and host methods, and make use of IPAddr internally.
No a wrapper class is not the right solution in my opinion. It is a more
basic problem.
Yesterday night I was thinking about this problem. I came to the point, that
this implementation is brocken in any case. So it is not good to have as a
standard lib.
There are some reasons. But cause it is hard to argue if things are mixed up.
I try to split this case into 2 parts.
First Programming ( Since I'm a newbie, it is hard for me to argue in this
area).
Second Networking ( This is my core area, so I know something more about
it;-) )
####
Lets look at the Programming site.
Definition:
The address 192.168.2.243/24 is not a valid address. Valid addresses are just
Network addresses like 192.168.2.0/24 or 10.1.1.0/22.
The constructor method does accept an invalid value and then change the value
to a valid one. IMHO this shouldn't happen.
It should be reject at the first place.
The doc should mention what valid values are.
Even if you don't share my opinion. Then the doc should mention that invalid
values are turned to valid values automagically.
I was told or I read that constructors shouldn't behave the way that
IPAddress ones does. If I'm wrong, tell me please.
####
The Network view of things.
This is a matter of "terminology". So it is likely that there exist many
different opinions.
There are serval ways to express a Network ( Nowadays a IP Prefix)
Long form 10.93.192.0/255.255.224.0
Short form 10.93.192.0/19
Or even shorter 10.93.192/19
There are serval ways to write IP Addresses
-> IP = 10.93.192.14
Netmask = 255.255.255.128
-> 10.93.192.14/255.255.255.128
-> 10.93.192.14/25
Any 'real' netadmin will understand any notation.
In this notation the IP Address 10.93.192.0/25 has the special meaning. It is
the networkaddress or nothing else then the Prefix 10.93.192.0/25.
So technical if you talk about prefixes, the Prefix 10.93.192.14/25 is
unvalid, but if you talk about IP addresses, the Address 10.93.192.14/25 t is
a valid notation.
For instance the iproute2 suite for linux use the notation I mentioned above.
And even if there is just a great minority - I'm not saying it's a minority,
IMHO there are many people who share this opinion - but if there is just a
great minority that use this notation, it is necessary to rethink about the
recent implementation.
----------
Last but not least
In my last mail I wrote: 'But you right, technically there is no such Prefix
like "192.168.1.33/29" '
Thats true, but I don't know any more, why I was talking about prefixes.
Cause the Class is named "IPAddress" and not "IPPrefix".
And the doc tells the user also that it is about IPAddresses
----
# Creates a new ipaddr containing the given human readable form of
# an IP address.
----
If you don't share my opinions. I guess there is no argument against the fact
that it should be documented how the class behave.
regards
Markus