r35602 - in /branches/upstream/libnet-patricia-perl/current: Changes MANIFEST META.yml Patricia.pm Patricia.xs libpatricia/patricia.c test.pl

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Sun May 17 20:57:26 UTC 2009


Author: ryan52-guest
Date: Sun May 17 20:57:21 2009
New Revision: 35602

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35602
Log:
[svn-upgrade] Integrating new upstream version, libnet-patricia-perl (1.15)

Added:
    branches/upstream/libnet-patricia-perl/current/META.yml
Modified:
    branches/upstream/libnet-patricia-perl/current/Changes
    branches/upstream/libnet-patricia-perl/current/MANIFEST
    branches/upstream/libnet-patricia-perl/current/Patricia.pm
    branches/upstream/libnet-patricia-perl/current/Patricia.xs
    branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c
    branches/upstream/libnet-patricia-perl/current/test.pl

Modified: branches/upstream/libnet-patricia-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/Changes?rev=35602&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Changes (original)
+++ branches/upstream/libnet-patricia-perl/current/Changes Sun May 17 20:57:21 2009
@@ -3,6 +3,10 @@
 TODO
         - add AF_INET6 support
         - add POD describing Graham Barr's API improvements
+
+1.015 Sun Jan 25 19:07 2009 (alpha)
+	- fixed bugs #14244, #20219
+	- added _integer methods to add/remove entries
 
 1.014 Thu Dec  8 18:05 2005
         - fixed the "climb_inorder" item in the POD

Modified: branches/upstream/libnet-patricia-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/MANIFEST?rev=35602&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-patricia-perl/current/MANIFEST Sun May 17 20:57:21 2009
@@ -13,3 +13,4 @@
 demo/demo.c
 typemap
 COPYING
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libnet-patricia-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/META.yml?rev=35602&op=file
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/META.yml (added)
+++ branches/upstream/libnet-patricia-perl/current/META.yml Sun May 17 20:57:21 2009
@@ -1,0 +1,12 @@
+--- #YAML:1.0
+name:                Net-Patricia
+version:             1.15
+abstract:            ~
+license:             ~
+author:              ~
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: branches/upstream/libnet-patricia-perl/current/Patricia.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/Patricia.pm?rev=35602&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Patricia.pm (original)
+++ branches/upstream/libnet-patricia-perl/current/Patricia.pm Sun May 17 20:57:21 2009
@@ -1,5 +1,6 @@
 #  Net::Patricia - Patricia Trie perl module for fast IP address lookups
 #  Copyright (C) 2000-2005  Dave Plonka
+#  Copyright (C) 2009       Dave Plonka & Philip Prindeville
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -15,20 +16,22 @@
 #  along with this program; if not, write to the Free Software
 #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-# $Id: Patricia.pm,v 1.14 2005/12/09 00:03:56 dplonka Exp $
 # Dave Plonka <plonka at doit.wisc.edu>
+# Philip Prindeville <philipp at redfish-solutions.com>
 
 package Net::Patricia;
 
+use version;
 use strict;
 use Carp;
 use vars qw($VERSION @ISA);
-use Socket qw(AF_INET inet_aton);
+use Socket qw(AF_INET inet_aton inet_ntoa);
 
 require DynaLoader;
+require 5.6.0;
 
 @ISA = qw(DynaLoader);
-'$Revision: 1.14 $' =~ m/(\d+)\.(\d+)/ && (( $VERSION ) = sprintf("%d.%03d", $1, $2));
+'$Revision: 1.15 $' =~ m/(\d+)\.(\d+)(\.\d+)?/ && ( $VERSION = "$1.$2$3");
 
 bootstrap Net::Patricia $VERSION;
 
@@ -86,39 +89,51 @@
 
 sub Net::Patricia::AF_INET::add {
   my ($self, $ip, $bits, $data) = @_;
-  $data ||= $bits ? "$ip/$bits" : $ip;
+  $data ||= defined $bits ? "$ip/$bits" : $ip;
   my $packed = inet_aton($ip) || croak("invalid key");
-  _add($self,AF_INET,$packed,$bits || 32, $data);
+  _add($self,AF_INET,$packed,(defined $bits ? $bits : 32), $data);
+}
+
+sub Net::Patricia::AF_INET::add_integer {
+  my ($self, $num, $bits, $data) = @_;
+  my $packed = pack("N", $num);
+  my $ip = inet_ntoa($packed) || croak("invalid address");
+  $data ||= defined $bits ? "$ip/$bits" : $ip;
+  _add($self,AF_INET,$packed,(defined $bits ? $bits : 32), $data);
 }
 
 sub Net::Patricia::AF_INET::match_integer {
   my ($self, $num, $bits) = @_;
-  _match($self,AF_INET,pack("N",$num),$bits || 32);
+  _match($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
 }
 
 sub Net::Patricia::AF_INET::exact_integer {
   my ($self, $num, $bits) = @_;
-  _exact($self,AF_INET,pack("N",$num),$bits || 32);
+  _exact($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
 }
 
 sub Net::Patricia::AF_INET::match {
   my ($self, $ip, $bits) = @_;
   my $packed = inet_aton($ip) || croak("invalid key");
-  _match($self,AF_INET,$packed,$bits || 32);
+  _match($self,AF_INET,$packed,(defined $bits ? $bits : 32));
 }
 
 sub Net::Patricia::AF_INET::exact {
   my ($self, $ip, $bits) = @_;
   my $packed = inet_aton($ip) || croak("invalid key");
-  _exact($self,AF_INET,$packed,$bits || 32);
+  _exact($self,AF_INET,$packed,(defined $bits ? $bits : 32));
 }
 
 sub Net::Patricia::AF_INET::remove {
   my ($self, $ip, $bits) = @_;
   my $packed = inet_aton($ip) || return undef;
-  _remove($self,AF_INET,$packed,$bits || 32);
-}
-
+  _remove($self,AF_INET,$packed,(defined $bits ? $bits : 32));
+}
+
+sub Net::Patricia::AF_INET::remove_integer {
+  my ($self, $num, $bits) = @_;
+  _remove($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
+}
 
 1;
 __END__
@@ -328,34 +343,6 @@
 
 =head1 BUGS
 
-The match_string method ignores the mask bits/width, if specified, in
-its argument.  So, if you add two prefixes with the same base address
-but different mask widths, this module will match the most-specific
-prefix even if that prefix doesn't wholly cotain the prefix specified
-by the match argument.  For example:
-
-   use Net::Patricia;
-   my $pt = new Net::Patricia;
-   $pt->add_string('192.168.0.0/25');
-   $pt->add_string('192.168.0.0/16');
-   print $pt->match_string('192.168.0.0/24'), "\n";
-
-prints "192.168.0.0/25", just as if you had called:
-
-   print $pt->match_string('192.168.0.0'), "\n";
-
-This issue was reported to me by John Payne, who also provided a
-candidate patch, but I have not applied it since I hesitate to change
-this behavior which was inherited from MRT.  Consequently, this module
-might seem to violate the principle of least surprise if you specific
-the mask bits when trying to find the best match.
-
-Methods to add or remove nodes using integer arguments are yet to be
-implemented.  This was a lower priority since it is less necessary to
-avoid the overhead involved in translation from a string representation
-since add and remove operations are usually performed less frequently
-than matching operations.
-
 This modules does not yet support AF_INET6 (IP version 6) 128 bit
 addresses, although the underlying patricialib C code does.
 
@@ -370,8 +357,10 @@
 =head1 AUTHOR
 
 Dave Plonka <plonka at doit.wisc.edu>
-
-Copyright (C) 2000-2005  Dave Plonka.  This program is free software; you
+Philip Prindeville <philipp at redfish-solutions.com>
+
+Copyright (C) 2000-2005  Dave Plonka.  Copyright (C) 2009  Dave Plonka
+& Philip Prindeville.  This program is free software; you
 can redistribute it and/or modify it under the terms of the GNU General
 Public License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

Modified: branches/upstream/libnet-patricia-perl/current/Patricia.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/Patricia.xs?rev=35602&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Patricia.xs (original)
+++ branches/upstream/libnet-patricia-perl/current/Patricia.xs Sun May 17 20:57:21 2009
@@ -140,7 +140,7 @@
 
 #define Fill_Prefix(p,f,a,b,mb) \
 	do { \
-		if (b <= 0 || b > mb) \
+		if (b < 0 || b > mb) \
 		  croak("invalid key"); \
 		memcpy(&p.add.sin, a, (mb+7)/8); \
 		p.family = f; \

Modified: branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c?rev=35602&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c (original)
+++ branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c Sun May 17 20:57:21 2009
@@ -639,7 +639,7 @@
 #endif /* PATRICIA_DEBUG */
 	if (comp_with_mask (prefix_tochar (node->prefix), 
 			    prefix_tochar (prefix),
-			    node->prefix->bitlen)) {
+			    node->prefix->bitlen) && node->prefix->bitlen <= bitlen) {
 #ifdef PATRICIA_DEBUG
             fprintf (stderr, "patricia_search_best: found %s/%d\n", 
 	             prefix_toa (node->prefix), node->prefix->bitlen);

Modified: branches/upstream/libnet-patricia-perl/current/test.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/test.pl?rev=35602&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/test.pl (original)
+++ branches/upstream/libnet-patricia-perl/current/test.pl Sun May 17 20:57:21 2009
@@ -6,7 +6,7 @@
 # Change 1..1 below to 1..last_test_to_print .
 # (It may become useful if the test is moved to ./t subdirectory.)
 
-BEGIN { $| = 1; $debug = 1; print "1..18\n"; }
+BEGIN { $| = 1; $debug = 1; print "1..19\n"; }
 END {print "not ok 1\n" unless $loaded;}
 use Net::Patricia;
 $loaded = 1;
@@ -128,6 +128,10 @@
    print "not ok 18\n"
 }
 
+$t->add_string('0/0');
+
+print $t->match_string("10.0.0.1")?"ok 19\n":"not ok 19\n";
+
 undef $t;
 
 exit;




More information about the Pkg-perl-cvs-commits mailing list