timmerk / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

ipaddr: Documentation bug and enhancement suggestion #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Peter,

I can't find a public bug tracker for ipaddr, so I thought I'd write to
you.

First off, a documentation bug in version 2.0.0: in the __doc__ for
IPv4Network.__init__, you state that the following are all equivalent:

'192.168.1.1/32'
'192.168.1.1/255.255.255.255'
'192.168.1.1/0.0.0.255'
'192.168.1.1'

but surely the second one should be '192.168.1.1/255.255.255.0'.

Second, a documentation enhancement proposal, also from
IPv4Network.__init__. Currently it says:

Instantiate a new IPv4 network object.
Args:
...
A netmask of '255.255.255.255' is assumed
to be /32 and '0.0.0.0' is assumed to be /0, even though
other netmasks can be expressed both as host- and
net-masks. (255.0.0.0 == 0.255.255.255)

which is (to me) unclear. It seems to be suggesting that 255.0.0.0 is a
hostmask, not a netmask, and 0.255.255.255 is a netmask. Isn't it the
other way around?

As I understand it, if the mask is of the form:

all-ones-followed-by-all-zeroes (e.g. 255.255.255.0)

it is a netmask, and if it is of the form:

all-zeroes-followed-by-all-ones (e.g. 0.255.255.255)

it is a hostmask. Correct? Assuming this is correct, and I'm not
confused, I would suggest being explicit about the decision algorithm
used:

"If the mask (portion after the / in the argument) is given in dotted
quad form, it is treated as a netmask if it starts with a non-zero
field (e.g. /255.0.0.0 == /8) and as a hostmask if it starts with a
zero field (e.g. 0.255.255.255 == /8), with the single exception of an
all-zero mask which is treated as a netmask == /0. If no mask is given,
a default of /32 is used."

Regards,

Original issue reported on code.google.com by pmo...@google.com on 27 Sep 2009 at 1:56

GoogleCodeExporter commented 9 years ago
r129

Original comment by pmo...@google.com on 17 Dec 2009 at 6:42

GoogleCodeExporter commented 9 years ago

Original comment by pmo...@google.com on 17 Dec 2009 at 6:43