Hello community,
here is the log from the commit of package perl-Net-IP for openSUSE:Factory checked in at 2013-06-13 18:18:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Net-IP (Old)
and /work/SRC/openSUSE:Factory/.perl-Net-IP.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Net-IP"
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Net-IP/perl-Net-IP.changes 2011-11-18 16:39:58.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Net-IP.new/perl-Net-IP.changes 2013-06-13 18:18:34.000000000 +0200
@@ -1,0 +2,14 @@
+Sat Jun 8 07:11:10 UTC 2013 - coolo@suse.com
+
+- updated to 1.26
+ - 81138 ip types
+ - 80164 hexip does not change when ip changes (fix: hexformat needs to be cleared by set)
+ - 4898 double compression
+ - 73232 invalid ipv6 1:2:3:4:5:6:7
+ - 73105 invalid ip 1:2
+ - 73104 expand 1::2::3
+ - 71042 ip_reverse 2001:4f8:3:36:0:0:0:235
+ - 45165 ip_range_to_prefix updated documentation
+ - 32232 excepts 61-217-102-8.hinet-ip.hinet.net as range
+
+-------------------------------------------------------------------
Old:
----
Net-IP-1.25.tar.gz
New:
----
Net-IP-1.26.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Net-IP.spec ++++++
--- /var/tmp/diff_new_pack.V3y2PB/_old 2013-06-13 18:18:35.000000000 +0200
+++ /var/tmp/diff_new_pack.V3y2PB/_new 2013-06-13 18:18:35.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package perl-Net-IP
#
-# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -15,21 +15,18 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
-# norootforbuild
-
Name: perl-Net-IP
Url: http://cpan.org/modules/by-module/Net/
-License: Artistic-1.0
-Group: Development/Libraries/Perl
Provides: perl_Net-IP
Obsoletes: perl_Net-IP
-AutoReqProv: on
Summary: allow easy manipulation of IPv4 and IPv6 addresses
-Version: 1.25
-Release: 61
+License: Artistic-1.0
+Group: Development/Libraries/Perl
+Version: 1.26
+Release: 0
Source: Net-IP-%{version}.tar.gz
-Patch: %{name}-%{version}-zero_address.diff
+Patch: %{name}-1.25-zero_address.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{perl_requires}
BuildRequires: perl
++++++ Net-IP-1.25.tar.gz -> Net-IP-1.26.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-IP-1.25/Changes new/Net-IP-1.26/Changes
--- old/Net-IP-1.25/Changes 2006-05-24 18:34:39.000000000 +0200
+++ new/Net-IP-1.26/Changes 2012-11-28 16:20:32.000000000 +0100
@@ -1,5 +1,18 @@
Revision history for Perl extension Net::IP.
+1.26 Wed Nov 28 12:00:00 2012
+ - This version is authored by Ulrich Wisser
+ - 81138 ip types
+ - 80164 hexip does not change when ip changes (fix: hexformat needs to be cleared by set)
+ - 4898 double compression
+ - 73232 invalid ipv6 1:2:3:4:5:6:7
+ - 73105 invalid ip 1:2
+ - 73104 expand 1::2::3
+ - 71042 ip_reverse 2001:4f8:3:36:0:0:0:235
+ - 45165 ip_range_to_prefix updated documentation
+ - 32232 excepts 61-217-102-8.hinet-ip.hinet.net as range
+
+
1.25 Wed May 24 12:00:00 2006
- Math::BigInt is now mandatory
- Several bugfixes done
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Net-IP-1.25/IP.pm new/Net-IP-1.26/IP.pm
--- old/Net-IP-1.25/IP.pm 2006-05-22 18:46:40.000000000 +0200
+++ new/Net-IP-1.26/IP.pm 2012-11-28 16:23:38.000000000 +0100
@@ -47,7 +47,7 @@
%IPv4ranges %IPv6ranges $useBigInt
$IP_NO_OVERLAP $IP_PARTIAL_OVERLAP $IP_A_IN_B_OVERLAP $IP_B_IN_A_OVERLAP $IP_IDENTICAL);
-$VERSION = '1.25';
+$VERSION = '1.26';
require Exporter;
@@ -73,49 +73,55 @@
# Definition of the Ranges for IPv4 IPs
%IPv4ranges = (
- '00000000' => 'PRIVATE', # 0/8
- '00001010' => 'PRIVATE', # 10/8
- '01111111' => 'PRIVATE', # 127.0/8
- '101011000001' => 'PRIVATE', # 172.16/12
- '1100000010101000' => 'PRIVATE', # 192.168/16
- '1010100111111110' => 'RESERVED', # 169.254/16
- '110000000000000000000010' => 'RESERVED', # 192.0.2/24
- '1110' => 'RESERVED', # 224/4
- '11110' => 'RESERVED', # 240/5
- '11111' => 'RESERVED', # 248/5
+ '00000000' => 'PRIVATE', # 0/8
+ '00001010' => 'PRIVATE', # 10/8
+ '0110010001' => 'SHARED', # 100.64/10
+ '01111111' => 'LOOPBACK', # 127.0/8
+ '1010100111111110' => 'LINK-LOCAL', # 169.254/16
+ '101011000001' => 'PRIVATE', # 172.16/12
+ '110000000000000000000000' => 'RESERVED', # 192.0.0/24
+ '110000000000000000000010' => 'TEST-NET', # 192.0.2/24
+ '110000000101100001100011' => '6TO4-RELAY', # 192.88.99.0/24
+ '1100000010101000' => 'PRIVATE', # 192.168/16
+ '110001100001001' => 'RESERVED', # 198.18/15
+ '110001100011001101100100' => 'TEST-NET', # 198.51.100/24
+ '110010110000000001110001' => 'TEST-NET', # 203.0.113/24
+ '1110' => 'MULTICAST', # 224/4
+ '1111' => 'RESERVED', # 240/4
+ '11111111111111111111111111111111' => 'BROADCAST', # 255.255.255.255/32
);
# Definition of the Ranges for Ipv6 IPs
%IPv6ranges = (
- '00000000' => 'RESERVED', # ::/8
- '00000001' => 'RESERVED', # 0100::/8
- '0000001' => 'RESERVED', # 0200::/7
- '000001' => 'RESERVED', # 0400::/6
- '00001' => 'RESERVED', # 0800::/5
- '0001' => 'RESERVED', # 1000::/4
- '001' => 'GLOBAL-UNICAST', # 2000::/3
- '010' => 'RESERVED', # 4000::/3
- '011' => 'RESERVED', # 6000::/3
- '100' => 'RESERVED', # 8000::/3
- '101' => 'RESERVED', # A000::/3
- '110' => 'RESERVED', # C000::/3
- '1110' => 'RESERVED', # E000::/4
- '11110' => 'RESERVED', # F000::/5
- '111110' => 'RESERVED', # F800::/6
- '1111101' => 'RESERVED', # FA00::/7
- '1111110' => 'UNIQUE-LOCAL-UNICAST', # FC00::/7
- '111111100' => 'RESERVED', # FE00::/9
- '1111111010' => 'LINK-LOCAL-UNICAST', # FE80::/10
- '1111111011' => 'RESERVED', # FEC0::/10
- '11111111' => 'MULTICAST', # FF00::/8
- '00100000000000010000110110111000' => 'RESERVED', # 2001:DB8::/32
-
- '0' x 96 => 'IPV4COMP', # ::/96
- ('0' x 80) . ('1' x 16) => 'IPV4MAP', # ::FFFF:0:0/96
-
- '0' x 128 => 'UNSPECIFIED', # ::/128
- ('0' x 127) . '1' => 'LOOPBACK' # ::1/128
-
+ '00000000' => 'RESERVED', # ::/8
+ ('0' x 128) => 'UNSPECIFIED', # ::/128
+ ('0' x 127) . '1' => 'LOOPBACK', # ::1/128
+ ('0' x 80) . ('1' x 16) => 'IPV4MAP', # ::FFFF:0:0/96
+ '00000001' => 'RESERVED', # 0100::/8
+ '0000000100000000' . ('0' x 48) => 'DISCARD', # 0100::/64
+ '0000001' => 'RESERVED', # 0200::/7
+ '000001' => 'RESERVED', # 0400::/6
+ '00001' => 'RESERVED', # 0800::/5
+ '0001' => 'RESERVED', # 1000::/4
+ '001' => 'GLOBAL-UNICAST', # 2000::/3
+ '0010000000000001' . ('0' x 16) => 'TEREDO', # 2001::/32
+ '00100000000000010000000000000010' . ('0' x 16) => 'BMWG', # 2001:0002::/48
+ '00100000000000010000110110111000' => 'DOCUMENTATION', # 2001:DB8::/32
+ '0010000000000001000000000001' => 'ORCHID', # 2001:10::/28
+ '0010000000000010' => '6TO4', # 2002::/16
+ '010' => 'RESERVED', # 4000::/3
+ '011' => 'RESERVED', # 6000::/3
+ '100' => 'RESERVED', # 8000::/3
+ '101' => 'RESERVED', # A000::/3
+ '110' => 'RESERVED', # C000::/3
+ '1110' => 'RESERVED', # E000::/4
+ '11110' => 'RESERVED', # F000::/5
+ '111110' => 'RESERVED', # F800::/6
+ '1111110' => 'UNIQUE-LOCAL-UNICAST', # FC00::/7
+ '111111100' => 'RESERVED', # FE00::/9
+ '1111111010' => 'LINK-LOCAL-UNICAST', # FE80::/10
+ '1111111011' => 'RESERVED', # FEC0::/10
+ '11111111' => 'MULTICAST', # FF00::/8
);
# Overlap constants
@@ -211,7 +217,7 @@
# We need to reset everything
for (
qw(ipversion errno prefixlen binmask reverse_ip last_ip iptype
- binip error ip intformat mask last_bin last_int prefix is_prefix)
+ binip error ip intformat hexformat mask last_bin last_int prefix is_prefix)
)
{
delete($self->{$_});
@@ -1024,7 +1030,7 @@
# Count octets
my $n = ($ip =~ tr/:/:/);
- return (0) unless ($n > 0 and $n < 8);
+ return 0 unless ($n > 0 and $n < 8);
# $k is a counter
my $k;
@@ -1039,8 +1045,9 @@
next if (/^[a-f\d]{1,4}$/i);
# Last octet - is it IPv4 ?
- if ($k == $n + 1) {
- next if (ip_is_ipv4($_));
+ if ( ($k == $n + 1) && ip_is_ipv4($_) ) {
+ $n++; # ipv4 is two octets
+ next;
}
$ERROR = "Invalid IP address $ip";
@@ -1063,12 +1070,20 @@
}
# Does the IP address have more than one '::' pattern ?
- if ($ip =~ s/:(?=:)//g > 1) {
+ if ($ip =~ s/:(?=:)/:/g > 1) {
$ERROR = "Invalid address $ip (More than one :: pattern)";
$ERRNO = 111;
return 0;
}
+ # number of octets
+ if ($n != 7 && $ip !~ /::/) {
+ $ERROR = "Invalid number of octets $ip";
+ $ERRNO = 112;
+ return 0;
+ }
+
+ # valid IPv6 address
return 1;
}
@@ -1090,9 +1105,24 @@
if ($ip_version == 4) {
my @quads = split /\./, $ip;
+ # check number of quads
+ if (scalar(@quads) > 4) {
+ $ERROR = "Not a valid IPv address $ip";
+ $ERRNO = 102;
+ return;
+ }
my @clean_quads = (0, 0, 0, 0);
foreach my $q (reverse @quads) {
+
+ #check quad data
+ if ($q !~ m/^\d{1,3}$/) {
+ $ERROR = "Not a valid IPv4 address $ip";
+ $ERRNO = 102;
+ return;
+ }
+
+ # build clean ipv4
unshift(@clean_quads, $q + 1 - 1);
}
@@ -1100,7 +1130,12 @@
}
# Keep track of ::
- $ip =~ s/::/:!:/;
+ my $num_of_double_colon = ($ip =~ s/::/:!:/g);
+ if ($num_of_double_colon > 1) {
+ $ERROR = "Too many :: in ip";
+ $ERRNO = 102;
+ return;
+ }
# IP as an array
my @ip = split /:/, $ip;
@@ -1118,10 +1153,7 @@
# Convert into hex
# Keep the last two octets
- $ip[$_] =
- substr(
- ip_bintoip(ip_iptobin(ip_expand_address($ip[$_], 4), 4), 6),
- -9);
+ $ip[$_] = substr( ip_bintoip( ip_iptobin( ip_expand_address($ip[$_], 4), 4), 6), -9);
# Has an error occured here ?
return unless (defined($ip[$_]));
@@ -1506,6 +1538,9 @@
# Just return if IP is IPv4
return ($ip) if ($ip_version == 4);
+ # already compressed addresses must be expanded first
+ $ip = ip_expand_address( $ip, $ip_version);
+
# Remove leading 0s: 0034 -> 34; 0000 -> 0
$ip =~ s/
(^|:) # Find beginning or ':' -> $1
@@ -1695,21 +1730,60 @@
sub ip_iptype {
my ($ip, $ip_version) = @_;
- # Find IP version
+ # handle known ip versions
+ return ip_iptypev4($ip) if $ip_version == 4;
+ return ip_iptypev6($ip) if $ip_version == 6;
- if ($ip_version == 4) {
- foreach (sort { length($b) <=> length($a) } keys %IPv4ranges) {
- return ($IPv4ranges{$_}) if ($ip =~ m/^$_/);
- }
+ # unsupported ip version
+ $ERROR = "IP version $ip not supported";
+ $ERRNO = 180;
+ return;
+}
- # IP is public
- return 'PUBLIC';
+#------------------------------------------------------------------------------
+# Subroutine ip_iptypev4
+# Purpose : Return the type of an IP (Public, Private, Reserved)
+# Params : IP to test, IP version
+# Returns : type or undef (invalid)
+sub ip_iptypev4 {
+ my ($ip) = @_;
+
+ # check ip
+ if ($ip !~ m/^[01]{1,32}$/) {
+ $ERROR = "$ip is not a binary IPv4 address $ip";
+ $ERRNO = 180;
+ return;
}
+
+ # see if IP is listed
+ foreach (sort { length($b) <=> length($a) } keys %IPv4ranges) {
+ return ($IPv4ranges{$_}) if ($ip =~ m/^$_/);
+ }
+
+ # not listed means IP is public
+ return 'PUBLIC';
+}
+
+#------------------------------------------------------------------------------
+# Subroutine ip_iptypev6
+# Purpose : Return the type of an IP (Public, Private, Reserved)
+# Params : IP to test, IP version
+# Returns : type or undef (invalid)
+sub ip_iptypev6 {
+ my ($ip) = @_;
+ # check ip
+ if ($ip !~ m/^[01]{1,128}$/) {
+ $ERROR = "$ip is not a binary IPv6 address";
+ $ERRNO = 180;
+ return;
+ }
+
foreach (sort { length($b) <=> length($a) } keys %IPv6ranges) {
return ($IPv6ranges{$_}) if ($ip =~ m/^$_/);
}
+ # How did we get here? All IPv6 addresses should match
$ERROR = "Cannot determine type for $ip";
$ERRNO = 180;
return;
@@ -1780,7 +1854,7 @@
return join '.', @reverse_quads, 'in-addr', 'arpa.';
}
elsif ($ip_version == 6) {
- my @rev_groups = reverse split /:/, $ip;
+ my @rev_groups = reverse split /:/, ip_expand_address($ip, 6);
my @result;
foreach (@rev_groups) {
@@ -1930,7 +2004,7 @@
1;
__END__
-
+=encoding utf8
=head1 NAME
Net::IP - Perl extension for manipulating IPv4/IPv6 addresses
@@ -2110,7 +2184,7 @@
=head2 iptype
Return the IP Type - this describes the type of an IP (Public, Private,
-Reserved, etc.)
+Reserved, etc.) See procedural interface ip_iptype for more details.
C