Commit 98b9d0b9 authored by Nick Morrott's avatar Nick Morrott

Import Upstream version 0.17

parent dd307a74
# Net::CIDR
#
# Copyright 2001-2010 Sam Varshavchik.
# Copyright 2001-2012 Sam Varshavchik.
#
# with contributions from David Cantrell.
#
......@@ -50,7 +50,7 @@ use Carp;
);
$VERSION = "0.15";
$VERSION = "0.17";
1;
......@@ -630,8 +630,8 @@ sub _range2cidr {
return _range2cidr8($a, $b) if $#a < 0; # Least significant octet pair.
croak unless $a >= 0 && $a <= 255 && $a =~ /^[0-9]+$/;
croak unless $b >= 0 && $b <= 255 && $b =~ /^[0-9]+$/ && $b >= $a;
croak "Bad starting address\n" unless $a >= 0 && $a <= 255 && $a =~ /^[0-9]+$/;
croak "Bad ending address\n" unless $b >= 0 && $b <= 255 && $b =~ /^[0-9]+$/ && $b >= $a;
my @c;
......@@ -731,8 +731,8 @@ sub _range2cidr8 {
my $a=shift @r;
my $b=shift @r;
croak unless $a >= 0 && $a <= 255 && $a =~ /^[0-9]+$/;
croak unless $b >= 0 && $b <= 255 && $b =~ /^[0-9]+$/ && $b >= $a;
croak "Bad starting address\n" unless $a >= 0 && $a <= 255 && $a =~ /^[0-9]+$/;
croak "Bad ending address\n" unless $b >= 0 && $b <= 255 && $b =~ /^[0-9]+$/ && $b >= $a;
++$b;
......@@ -775,8 +775,8 @@ sub _cidr2range8 {
my $a=shift @c;
my $b=shift @c;
croak unless $a >= 0 && $a <= 255 && $a =~ /^[0-9]+$/;
croak unless $b >= 0 && $b <= 8 && $b =~ /^[0-9]+$/;
croak "Bad starting address" unless $a >= 0 && $a <= 255 && $a =~ /^[0-9]+$/;
croak "Bad ending address" unless $b >= 0 && $b <= 8 && $b =~ /^[0-9]+$/;
my $n= 1 << (8-$b);
......@@ -807,7 +807,7 @@ sub _ipcmp {
my @a=split (/\./, $aa);
my @b=split (/\./, $bb);
croak unless $#a == $#b;
croak "Different number of octets in IP addresses" unless $#a == $#b;
while ($#a >= 0 && $a[0] == $b[0])
{
......@@ -859,7 +859,7 @@ sub cidr2octets {
$cidr =~ s/\s//g;
croak unless ($cidr =~ /(.*)\/(.*)/);
croak "CIDR doesn't look like a CIDR\n" unless ($cidr =~ /(.*)\/(.*)/);
my ($ip, $pfix)=($1, $2);
......@@ -997,7 +997,7 @@ sub cidradd {
my @b;
grep {
croak unless /(.*)-(.*)/;
croak "This doesn't look like start-end\n" unless /(.*)-(.*)/;
push @a, $1;
push @b, $2;
} @cidr;
......@@ -1165,7 +1165,7 @@ sub cidrlookup {
my @b;
grep {
croak unless /(.*)-(.*)/;
croak "This doesn't look like start-end\n" unless /(.*)-(.*)/;
push @a, $1;
push @b, $2;
} @cidr;
......@@ -1193,6 +1193,10 @@ Validate whether $ip is a valid IPv4 or IPv6 address, or a CIDR.
Returns its argument or undef.
Spaces are removed, and IPv6 hexadecimal address are converted to lowercase.
$ip with less than four octets gets filled out with additional octets, and
the modified value gets returned. This turns "192.168/16" into a proper
"192.168.0.0/16".
If $ip contains a "/", it must be a valid CIDR, otherwise it must be a valid
IPv4 or an IPv6 address.
......@@ -1227,6 +1231,13 @@ sub cidrvalidate {
my @o= split(/\./, $n);
while ($#o < 3)
{
push @o, "0";
}
$n=join(".", @o);
return undef if $#o != 3;
foreach (@o)
......
......@@ -36,3 +36,10 @@ Revision history for Perl extension Net::CIDR.
0.15 Thu Feb 16 08:09:45 EST 2012
- corrected cidrvalidate() to return values according to its
documentation, in some corner cases.
0.16 Sat Sep 29 09:29:43 EDT 2012
- cidrvalidate() corrects octet-shortchanged IPv4 addresses to their
proper size.
0.17 Sat Oct 20 23:21:18 EDT 2012
- version bump, put META back into the tarball.
......@@ -7,4 +7,5 @@ COPYING
README
Net-CIDR.spec
Net-CIDR.spec.PL
META.yml Module meta-data (added by MakeMaker)
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
{
"abstract" : "Manipulate IPv4/IPv6 netblocks in CIDR notation",
"author" : [
"Sam Varshavchik <sam@email-scan.com>"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "Net-CIDR",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Carp" : "0"
}
}
},
"release_status" : "stable",
"version" : "0.17"
}
--- #YAML:1.0
name: Net-CIDR
version: 0.15
abstract: Manipulate IPv4/IPv6 netblocks in CIDR notation
---
abstract: 'Manipulate IPv4/IPv6 netblocks in CIDR notation'
author:
- Sam Varshavchik <sam@email-scan.com>
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
- 'Sam Varshavchik <sam@email-scan.com>'
build_requires:
ExtUtils::MakeMaker: 0
requires:
Carp: 0
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version 6.57_05
ExtUtils::MakeMaker: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Net-CIDR
no_index:
directory:
- t
- inc
requires:
Carp: 0
version: 0.17
......@@ -3,10 +3,11 @@ use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'AUTHOR' => 'Sam Varshavchik <sam@email-scan.com>',
'ABSTRACT_FROM' => 'CIDR.pm',
'NAME' => 'Net::CIDR',
'VERSION_FROM' => 'CIDR.pm', # finds $VERSION
'PREREQ_PM' => { 'Carp' => 0 }, # e.g., Module::Name => 1.1
'PL_FILES' => { 'Net-CIDR.spec.PL' => 'Net-CIDR.spec' }
'AUTHOR' => 'Sam Varshavchik <sam@email-scan.com>',
'ABSTRACT_FROM' => 'CIDR.pm',
'NAME' => 'Net::CIDR',
'VERSION_FROM' => 'CIDR.pm', # finds $VERSION
'PREREQ_PM' => { 'Carp' => 0 }, # e.g., Module::Name => 1.1
'LICENSE' => 'perl',
'PL_FILES' => { 'Net-CIDR.spec.PL' => 'Net-CIDR.spec' }
);
Summary: Net::CIDR Perl module
Name: perl-Net-CIDR
Version: 0.15
Version: 0.17
Release: 1%(%{__perl} -e 'my $v=$^V; $v =~ s/(.)/".".ord($1)/ge;print "$v\n";')
Source0: Net-CIDR-%{version}.tar.gz
License: Perl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment