Open frithnanth opened 11 months ago
I looked at your code and I see it doesn't work for any CIDR with mask between /120 and /128 (the 16th byte).
I think it's easy to avoid the issue: change line 261 in lib/Net/IP/Parse.rakumod
from
@b[$div] = 255 +^ (2**((($div + 1) * 8) - $prefix)-1);
to
@b[$div] = 255 +^ (2**((($div + 1) * 8) - $prefix)-1) if $div < 16;
This way if the prefix length is /128 the mask is not modified from its initial value (255 xx 16).
This small change passes all the present tests and lets the loopback CIDR work fine. It seems to me that the prefix_addr
, network_addr
, broadcast_addr
, and wildcard_addr
are all reasonable; I hope I'm not overlooking anything.
Do you like me to open a PR?
hi! yes if you don't mind opening a PR, I will accept it immediately...I haven't played with Raku much lately and I don't have the toolchain installed on my laptop anymore.
This code:
fails with this error:
hinting that the problem might be with the Subsets::Common module. 0:0:0:0:0:0:0:0/128 and 0:0:0:0:0:0:0:1/128 fail as well with the same error.
The IP class seems safe from this kind of error, so this program:
executes without problems, hinting that the bug might be in the netmask handling.