Skip Menu |
 

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

Report information
The Basics
Id: 25169
Status: resolved
Priority: 0/
Queue: Net-IP

People
Owner: cpan [...] bat.ru
Requestors: mb [...] imp.ch
Cc:
AdminCc:

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



Subject: Net-IP reverse ip translation doesn't honor prefixes
Date: Tue, 27 Feb 2007 09:36:19 +0100 (CET)
To: 5Abug-Net-IP [...] rt.cpan.org
From: Martin Blapp <mb [...] imp.ch>
Hi, If you try to get a reverse network adresse like the one it seems to work: Here are examples: 192.168.1.1/32 -> 1.1.168.192.in-addr.arpa correct 192.168.1.0/24 -> 1.168.192.in-addr.arpa correct 192.168.0.0/16 -> 168.192.in-addr.arpa correct but ... here are some examples which give wrong results ! 192.168.0.0/24 -> 168.192.in-addr.arpa wrong ! 192.0.0.0/24 -> 192.in-addr.arpa wrong ! 192.0.0.0/32 -> 192.in-addr.arpa wrong ! The patch below works only for the prefixes/netclasses (/32 /24 /16), the other ones don't make any sense IMHO. We need this functionality for a Net::DNS::Resolver driven blacklist via dynamic dns updates. -- Martin --- IP.pm Mon May 22 18:46:40 2006 +++ IP.pm Mon Feb 26 12:14:39 2007 @@ -1772,12 +1772,39 @@ my $no_quads = ($len / 8); my @reverse_quads = reverse @quads; + my $octcount = 0; + my $zeros = ""; while (@reverse_quads and $reverse_quads[0] == 0) { - shift(@reverse_quads); + # + # Keep zeros if the prefix doesn't match the + # number of zeros. + # + $octcount++; + if ($len == 32) { + if ($octcount == 1) { + $zeros = "0\."; + } elsif ($octcount == 2) { + $zeros = "0\.0\."; + } elsif ($octcount == 3) { + $zeros = "0\.0\.0\."; + } + } elsif ($len == 24) { + if ($octcount == 2) { + $zeros = "0\."; + } elsif ($octcount == 3) { + $zeros = "0\.0\."; + } + } elsif ($len == 16) { + if ($octcount == 3) { + $zeros = "0\."; + } + } + shift(@reverse_quads); } - - return join '.', @reverse_quads, 'in-addr', 'arpa.'; + my $ret = join '.', @reverse_quads, 'in-addr', 'arpa.'; + $ret = $zeros . "$ret"; + return $ret; } elsif ($ip_version == 6) { my @rev_groups = reverse split /:/, $ip;
Also see bug #42793.
Fixed in the #42793, going to be in 1.27. Thanks for the report!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.