[Python-modules-team] Bug#460234: Bug#460234: check_addr_prefixlen exposes bug in net()/broadcast()/overlaps() methods

Bernd Zeimetz bernd at bzed.de
Sun Jan 27 01:02:41 UTC 2008


severity 460234 wishlist
retitle 460234 Support IP+prefixlen combinations like 172.30.1.14/22
thanks

> I didn't see http://pypi.python.org/pypi/IPy/0.55 but was looking at
> old documentation. IPy has a global option,
> IPy.check_addr_prefixlen, which, if False, allows for "uncommon"
> prefixes. Now, IP('172.30.1.14/22') seems to work.

Don't use this option if you want to work with real-life address ranges.
It works, but not as you expect.

> However, now the net() and broadcast() methods return garbage:
> 
> In [50]: IP('172.30.1.14/22').net()
> Out[50]: IP('172.30.1.14')

no, that's right, with IPy.check_addr_prefixlen == False you're creating
a /22 network which starts at 172.30.1.14. Please don't use this option
if you want to handle real-life address ranges (or if you don't
understand which weirdness the option introduces....)


> In [51]: IP('172.30.1.14/22').broadcast()
> Out[51]: IP('172.30.5.13')

Still right. If we assume that the /22 network starts at 172.30.1.14,
the broadcast address is 172.30.5.13



> Also,
> 
> IP('172.30.1.14/22').overlaps('127.30.0.50/24') == 0
---------------------------------^^^
I guess you mean 172.... there.

In [3]: IPy.IP('172.30.1.14/22').overlaps('172.30.0.50/24')
Out[3]: -1


Which is right for IPy.check_addr_prefixlen == False.


The function you're looking for - storing an IP with the network's
prefix length - is just not supported by IPy yet. Patches are welcome :)


Cheers,

Bernd

-- 
Bernd Zeimetz
<bernd at bzed.de>                         <http://bzed.de/>





More information about the Python-modules-team mailing list