Skip Menu |

This queue is for tickets about the NetAddr-IP CPAN distribution.

Report information
The Basics
Id: 66132
Status: resolved
Worked: 3.2 hours (190 min)
Priority: 0/
Queue: NetAddr-IP

People
Owner: michael [...] bizsystems.com
Requestors: jpl [...] plosquare.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 4.040
Fixed in: (no value)



Subject: ->num() incorrect for IPv6
The function ->num() seems to work incorrectly for IPv6 networks. For example, NetAddr::IP->new('f::', 92)->num() and NetAddr::IP->new('f::', 93)->num() both return 4294967294 on a 32-bit system.
On Thu Feb 24 13:24:07 2011, jploski wrote: Show quoted text
> The function ->num() seems to work incorrectly for IPv6 networks. For > example, NetAddr::IP->new('f::', 92)->num() and NetAddr::IP->new('f::', > 93)->num() both return 4294967294 on a 32-bit system.
NetAddr::IP returns 4294967293 as a maximum number # returns 1 for /32 /128, 0 for /31 /127 else n-2 up to 2**32 # number of usable IP's === number of ip's less broadcast & network addys The authors collectively are reviewing this to see if it is the correct response for all cases. Either way we will update the documentation accordingly. Best regards, Michael
On Thu Feb 24 14:55:06 2011, MIKER wrote: Show quoted text
> On Thu Feb 24 13:24:07 2011, jploski wrote:
> > The function ->num() seems to work incorrectly for IPv6 networks. > > For > > example, NetAddr::IP->new('f::', 92)->num() and > > NetAddr::IP->new('f::', > > 93)->num() both return 4294967294 on a 32-bit system.
> > NetAddr::IP returns 4294967293 as a maximum number > # returns 1 for /32 /128, 0 for /31 /127 else n-2 up to 2**32 > # number of usable IP's === number of ip's less broadcast > and network addys > > The authors collectively are reviewing this to see if it is > the correct > response for all cases. Either way we will update the documentation > accordingly. > > Best regards, > Michael >
v4.041 uploaded to CPAN NetAddr::IP response for ->num($IP) updated to return an integer numeric "string" for the number of usable addresses in a net. NOTE: to perform operations on integer numbers larger than 2**32 on 32 bit platforms or 2**64 on 64 bit platforms requires the user to load a module that will handle these numbers (i.e. Math::BigInt, etc...). NetAddr::IP DOES NOT REQUIRE THESE MODULES and will always return the appropriate numeric value as a text string. Perl is happy with that representation as either a number or text. It is up to the user to deal with it as they see fit for further numeric operations. On a 32 bit platform, numbers up to "about" 2**49 can be represented in perl without loss of resolution due to being handled internally as a float. User beware.