The attached diff should exclude unroutable reserved ranges.
diff -ru Data-Validate-IP-0.14/lib/Data/Validate/IP.pm ../Data-Validate-IP-0.14/lib/Data/Validate/IP.pm
--- Data-Validate-IP-0.14/lib/Data/Validate/IP.pm 2011-01-06 06:29:26.000000000 -0800
+++ ../Data-Validate-IP-0.14/lib/Data/Validate/IP.pm 2013-01-31 20:36:15.418590406 -0800
@@ -13,6 +13,11 @@
use constant MULTICAST => [qw(224.0.0.0/4)];
use constant LINKLOCAL => [qw(169.254.0.0/16)];
+# Other unroutable reserved ranges
+use constant UNROUTABLE => [qw(0.0.0.0/8 100.64.0.0/10 192.0.0.0/29
+ 198.18.0.0/15 198.51.100.0/24 203.0.113.0/24
+ 240.0.0.0/4) ];
+
our @ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
@@ -765,8 +770,7 @@
=item I<Notes, Exceptions, & Bugs>
The function does not make any attempt to check whether an ip
-actually exists or could truly route. This is true for any
-non- private/testnet/loopback ip.
+actually exists or could truly route.
=back
@@ -797,7 +801,7 @@
return $MASK{$type} if (defined $MASK{$type});
my @masks;
if ($type eq 'public') {
- @masks = (LOOPBACK, TESTNET, PRIVATE,MULTICAST,LINKLOCAL);
+ @masks = (LOOPBACK, TESTNET, PRIVATE,MULTICAST,LINKLOCAL, UNROUTABLE);
} elsif ($type eq 'loopback') {
@masks = (LOOPBACK);
} elsif ($type eq 'private') {
diff -ru Data-Validate-IP-0.14/t/Data-Validate-IP.t ../Data-Validate-IP-0.14/t/Data-Validate-IP.t
--- Data-Validate-IP-0.14/t/Data-Validate-IP.t 2011-01-06 06:42:15.000000000 -0800
+++ ../Data-Validate-IP-0.14/t/Data-Validate-IP.t 2013-01-31 20:35:25.918591334 -0800
@@ -5,7 +5,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
-use Test::More tests => 50;
+use Test::More tests => 52;
BEGIN { use_ok('Data::Validate::IP', qw(is_ipv4 is_innet_ipv4 is_ipv6 is_private_ipv4 is_loopback_ipv4 is_testnet_ipv4 is_public_ipv4 is_multicast_ipv4 is_linklocal_ipv4 is_linklocal_ipv6) ) };
#########################
@@ -38,6 +38,10 @@
is (is_public_ipv4('216.17.184.1'), '216.17.184.1', 'is_public_ipv4 216.17.184.1');
is (is_public_ipv4('192.168.0.1'), undef, 'is_public_ipv4 192.168.0.1');
+is (is_public_ipv4('245.1.1.1'), undef, 'is_public_ipv4 245.1.1.1');
+is (is_public_ipv4('0.0.0.0'), undef, 'is_public_ipv4 0.0.0.0');
+
+
is (is_multicast_ipv4('224.0.0.1'), '224.0.0.1', 'is_multicast_ipv4 224.0.0.1');
is (is_multicast_ipv4('216.17.184.1'), undef, 'is_multicast_ipv4 216.17.184.1');