Commit 38e03228 authored by Nick Morrott's avatar Nick Morrott

Import Upstream version 0.13

parent 8633790d
# Net::CIDR
#
# Copyright 2001-2003 Sam Varshavchik.
# Copyright 2001-2009 Sam Varshavchik.
#
# with contributions from David Cantrell.
#
# This program is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
#
# $Revision: 1.17 $
# $Revision: 1.19 $
package Net::CIDR;
......@@ -54,7 +54,7 @@ use Math::BigInt;
);
$VERSION = "0.11";
$VERSION = "0.13";
1;
......@@ -235,7 +235,7 @@ cidr2range() does not merge adjacent or overlapping netblocks in
The addr2cidr function takes an IP address and returns a list of all
the CIDR netblocks it might belong to:
@a=Net::CIDR::addr2range('192.68.0.31');
@a=Net::CIDR::addr2cidr('192.68.0.31');
The result is a thirtythree-element array:
('192.68.0.31/32', '192.68.0.30/31', '192.68.0.28/30', '192.68.0.24/29',
......@@ -243,7 +243,7 @@ The result is a thirtythree-element array:
consisting of all the possible subnets containing this address from
0.0.0.0/0 to address/32.
Any addresses supplied to addr2range after the first will be ignored.
Any addresses supplied to addr2cidr after the first will be ignored.
It works similarly for IPv6 addresses, returning a list of one hundred
and twenty nine elements.
......@@ -290,10 +290,11 @@ sub cidr2range {
my @ips= split (/\.+/, $ip);
grep {
croak unless $_ >= 0 && $_ <= 255 && $_ =~ /^[0-9]+$/;
croak "$_, as in '$cidr', is not a byte" unless $_ >= 0 && $_ <= 255 && $_ =~ /^[0-9]+$/;
} @ips;
croak unless $pfix >= 0 && $pfix <= ($#ips+1) * 8 && $pfix =~ /^[0-9]+$/;
croak "$pfix, as in '$cidr', does not make sense"
unless $pfix >= 0 && $pfix <= ($#ips+1) * 8 && $pfix =~ /^[0-9]+$/;
my @rr=_cidr2iprange($pfix, @ips);
......@@ -848,10 +849,11 @@ sub cidr2octets {
my @ips= split (/\.+/, $ip);
grep {
croak unless $_ >= 0 && $_ <= 255 && $_ =~ /^[0-9]+$/;
croak "$_, as in '$cidr', is not a byte" unless $_ >= 0 && $_ <= 255 && $_ =~ /^[0-9]+$/;
} @ips;
croak unless $pfix >= 0 && $pfix <= ($#ips+1) * 8 && $pfix =~ /^[0-9]+$/;
croak "$pfix, as in '$cidr', does not make sense"
unless $pfix >= 0 && $pfix <= ($#ips+1) * 8 && $pfix =~ /^[0-9]+$/;
my $i;
......@@ -866,7 +868,23 @@ sub cidr2octets {
if ($#ips < 0 || $bitsleft == 0)
{
if ($isipv6)
if ($pfix == 0 && $bitsleft == 0)
{
foreach (0..255)
{
my @n=($_);
if ($isipv6)
{
_push_ipv6_octets(\@r, \@n);
}
else
{
push @r, $n[0];
}
}
}
elsif ($isipv6)
{
_push_ipv6_octets(\@r, \@msb);
}
......
......@@ -18,3 +18,11 @@ Revision history for Perl extension Net::CIDR.
0.11 Tue Aug 9 21:17:55 EDT 2005
- Fix croak in cidradd if adding after 255.255.255.255
0.12 Thu Nov 30 23:40:18 EST 2006
- cidr2octets: 0.0.0.0/0 will expand out to the entire IPv4 address
space
- be more informative when we croak.
0.13 Sun Jan 18 19:51:43 EST 2009
- Fix some documentation typos.
--- #YAML:1.0
name: Net-CIDR
version: 0.13
abstract: Manipulate IPv4/IPv6 netblocks in CIDR notation
license: ~
author:
- Sam Varshavchik <sam@email-scan.com>
generated_by: ExtUtils::MakeMaker version 6.42
distribution_type: module
requires:
Carp: 0
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
Summary: Net::CIDR Perl module
Name: perl-Net-CIDR
Version: 0.10
Version: 0.13
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