r64519 - in /branches/upstream/libnet-patricia-perl/current: Changes MANIFEST META.yml Makefile.PL Patricia.pm Patricia.xs libpatricia/patricia.c libpatricia/patricia.h t/ t/01everything.t test.pl
jotamjr-guest at users.alioth.debian.org
jotamjr-guest at users.alioth.debian.org
Thu Nov 4 06:46:17 UTC 2010
Author: jotamjr-guest
Date: Thu Nov 4 06:45:08 2010
New Revision: 64519
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64519
Log:
[svn-upgrade] new version libnet-patricia-perl (1.18)
Added:
branches/upstream/libnet-patricia-perl/current/t/
branches/upstream/libnet-patricia-perl/current/t/01everything.t
Removed:
branches/upstream/libnet-patricia-perl/current/test.pl
Modified:
branches/upstream/libnet-patricia-perl/current/Changes
branches/upstream/libnet-patricia-perl/current/MANIFEST
branches/upstream/libnet-patricia-perl/current/META.yml
branches/upstream/libnet-patricia-perl/current/Makefile.PL
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/libpatricia/patricia.h
Modified: branches/upstream/libnet-patricia-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/Changes?rev=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Changes (original)
+++ branches/upstream/libnet-patricia-perl/current/Changes Thu Nov 4 06:45:08 2010
@@ -1,12 +1,21 @@
Revision history for Perl extension Net::Patricia.
TODO
- - add AF_INET6 support
- add POD describing Graham Barr's API improvements
+
+1.017 Sun May 23 17:30 2010
+ - miscellaneous bug fixes
+ - add additional hybrid methods if Net::CIDR::Lite is present
+ - corrections to PM_PREREQ
+
+1.016 Sun Feb 14 11:16 2010
+ - miscellaneous bug fixes
+ - rewrote Makefile to simplify it
1.015 Sun Jan 25 19:07 2009 (alpha)
- fixed bugs #14244, #20219
- added _integer methods to add/remove entries
+ - add AF_INET6 support
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=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-patricia-perl/current/MANIFEST Thu Nov 4 06:45:08 2010
@@ -1,16 +1,16 @@
-README
Changes
+COPYING
+demo/demo.c
+libpatricia/copyright
+libpatricia/credits.txt
+libpatricia/Makefile.PL
+libpatricia/patricia.c
+libpatricia/patricia.h
+Makefile.PL
+MANIFEST This list of files
+META.yml
Patricia.pm
Patricia.xs
-MANIFEST
-Makefile.PL
-test.pl
-libpatricia/Makefile.PL
-libpatricia/copyright
-libpatricia/credits.txt
-libpatricia/patricia.c
-libpatricia/patricia.h
-demo/demo.c
+README
+t/01everything.t
typemap
-COPYING
-META.yml Module meta-data (added by MakeMaker)
Modified: 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=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/META.yml (original)
+++ branches/upstream/libnet-patricia-perl/current/META.yml Thu Nov 4 06:45:08 2010
@@ -1,13 +1,24 @@
--- #YAML:1.0
-name: Net-Patricia
-version: 1.16
-abstract: ~
-license: ~
-author: ~
-generated_by: ExtUtils::MakeMaker version 6.42
-distribution_type: module
-requires:
- Socket6: 0
+name: Net-Patricia
+version: 1.18
+abstract: ~
+author: []
+license: unknown
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ Net::CIDR::Lite: 0.20
+ Socket6: 0
+ Test::More: 0.88
+ version: 0
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.55_02
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: branches/upstream/libnet-patricia-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/Makefile.PL?rev=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Makefile.PL (original)
+++ branches/upstream/libnet-patricia-perl/current/Makefile.PL Thu Nov 4 06:45:08 2010
@@ -1,3 +1,4 @@
+use 5.008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
@@ -9,7 +10,11 @@
'INC' => '', # e.g., '-I/usr/include/other'
'MYEXTLIB' => 'libpatricia/libpatricia$(LIB_EXT)', # e.g., '-I/usr/include/other'
'dist' => {'COMPRESS'=>'gzip -9f', 'SUFFIX' => 'gz'},
- 'PREREQ_PM' => {'Socket6' => 0},
+ 'PREREQ_PM' => {'Socket6' => 0,
+ 'version' => 0,
+ 'Test::More' => '0.88',
+ 'Net::CIDR::Lite' => '0.20',
+ },
);
sub MY::postamble {
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=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Patricia.pm (original)
+++ branches/upstream/libnet-patricia-perl/current/Patricia.pm Thu Nov 4 06:45:08 2010
@@ -24,13 +24,12 @@
use strict;
use warnings;
-require 5.006_000;
+require 5.008;
use version;
use Carp;
use vars qw($VERSION @ISA @EXPORT);
-use Socket qw(AF_INET AF_INET6 inet_aton inet_ntoa);
-use Socket6 qw(inet_pton inet_ntop);
+use Socket qw(AF_INET AF_INET6);
BEGIN {
require Exporter;
@@ -39,7 +38,7 @@
@EXPORT = qw(AF_INET AF_INET6);
}
-'$Revision: 1.16 $' =~ m/(\d+)\.(\d+)(_\d+|)/ && ( $VERSION = "$1.$2$3");
+'$Revision: 1.18 $' =~ m/(\d+)\.(\d+)((_\d+)|)/ && ( $VERSION = "$1.$2$3");
bootstrap Net::Patricia $VERSION;
@@ -56,7 +55,7 @@
return bless _new(128), 'Net::Patricia::AF_INET6';
}
- undef;
+ croak "new: unimplemented type";
}
##
@@ -68,9 +67,9 @@
my $bits;
if (ref ($self) eq 'Net::Patricia::AF_INET6') {
- $bits = ($str =~ s,/(\d+)$,,) ? $1 : 128;
+ $bits = ($str =~ s|/(\d+)$||) ? $1 : 128;
} else {
- $bits = ($str =~ s,/(\d+)$,,) ? $1 : 32;
+ $bits = ($str =~ s|/(\d+)$||) ? $1 : 32;
}
($str,$bits);
}
@@ -100,112 +99,167 @@
$self->remove($self->_ip_bits($str))
}
+BEGIN {
+ eval {
+ my $class = 'Net::CIDR::Lite';
+ eval "require $class";
+ };
+ last if (@_);
+
+ sub add_cidr {
+ my ($self, $range, $data) = @_;
+ my $cidr = Net::CIDR::Lite->new();
+ $cidr->add_range($range);
+
+ my @list = ();
+ for ($cidr->list()) {
+ push(@list, $_) if ($self->add_string($_, $data));
+ }
+ @list;
+ }
+
+ sub remove_cidr {
+ my ($self, $range) = @_;
+ my $cidr = Net::CIDR::Lite->new();
+ $cidr->add_range($range);
+
+ my @list = ();
+ for ($cidr->list()) {
+ push(@list, $_) if ($self->remove_string($_));
+ }
+ @list;
+ }
+}
+
##
## AF_INET
##
- at Net::Patricia::AF_INET::ISA = qw(Net::Patricia);
-
-sub Net::Patricia::AF_INET::add {
+package Net::Patricia::AF_INET;
+
+use Carp;
+use Socket qw(AF_INET inet_aton inet_ntoa);
+use vars qw(@ISA @EXPORT);
+
+BEGIN {
+ require Exporter;
+ require DynaLoader;
+ @ISA = qw(Exporter DynaLoader Net::Patricia);
+ @EXPORT = qw(AF_INET);
+}
+
+sub add {
my ($self, $ip, $bits, $data) = @_;
$data ||= defined $bits ? "$ip/$bits" : $ip;
my $packed = inet_aton($ip) || croak("invalid key");
- _add($self,AF_INET,$packed,(defined $bits ? $bits : 32), $data);
-}
-
-sub Net::Patricia::AF_INET::add_integer {
+ $self->SUPER::_add(AF_INET,$packed,(defined $bits ? $bits : 32), $data);
+}
+
+sub 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 {
+ $self->SUPER::_add(AF_INET,$packed,(defined $bits ? $bits : 32), $data);
+}
+
+sub match_integer {
my ($self, $num, $bits) = @_;
- _match($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
-}
-
-sub Net::Patricia::AF_INET::exact_integer {
+ $self->SUPER::_match(AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
+}
+
+sub exact_integer {
my ($self, $num, $bits) = @_;
- _exact($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
-}
-
-sub Net::Patricia::AF_INET::match {
+ $self->SUPER::_exact(AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
+}
+
+sub match {
my ($self, $ip, $bits) = @_;
my $packed = inet_aton($ip) || croak("invalid key");
- _match($self,AF_INET,$packed,(defined $bits ? $bits : 32));
-}
-
-sub Net::Patricia::AF_INET::exact {
+ $self->SUPER::_match(AF_INET,$packed,(defined $bits ? $bits : 32));
+}
+
+sub exact {
my ($self, $ip, $bits) = @_;
my $packed = inet_aton($ip) || croak("invalid key");
- _exact($self,AF_INET,$packed,(defined $bits ? $bits : 32));
-}
-
-sub Net::Patricia::AF_INET::remove {
+ $self->SUPER::_exact(AF_INET,$packed,(defined $bits ? $bits : 32));
+}
+
+sub remove {
my ($self, $ip, $bits) = @_;
my $packed = inet_aton($ip) || return undef;
- _remove($self,AF_INET,$packed,(defined $bits ? $bits : 32));
-}
-
-sub Net::Patricia::AF_INET::remove_integer {
+ $self->SUPER::_remove(AF_INET,$packed,(defined $bits ? $bits : 32));
+}
+
+sub remove_integer {
my ($self, $num, $bits) = @_;
- _remove($self,AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
+ $self->SUPER::_remove(AF_INET,pack("N",$num),(defined $bits ? $bits : 32));
}
##
## AF_INET6
##
- at Net::Patricia::AF_INET6::ISA = qw(Net::Patricia);
-
-sub Net::Patricia::AF_INET6::add {
+package Net::Patricia::AF_INET6;
+
+use Carp;
+use Socket qw(AF_INET6);
+use Socket6 qw(inet_pton inet_ntop);
+use vars qw(@ISA @EXPORT);
+
+BEGIN {
+ require Exporter;
+ require DynaLoader;
+ @ISA = qw(Exporter DynaLoader Net::Patricia);
+ @EXPORT = qw(AF_INET6);
+}
+
+sub add {
my ($self, $ip, $bits, $data) = @_;
$data ||= $bits ? "$ip/$bits" : $ip;
my $packed = inet_pton(AF_INET6, $ip) || croak("invalid key");
- _add($self,AF_INET6,$packed,(defined $bits ? $bits : 128), $data);
-}
-
-sub Net::Patricia::AF_INET6::add_integer {
+ $self->SUPER::_add(AF_INET6,$packed,(defined $bits ? $bits : 128), $data);
+}
+
+sub add_integer {
my ($self, $num, $bits, $data) = @_;
my $packed = pack("N", $num);
my $ip = inet_ntop(AF_INET6, $packed) || croak("invalid address");
$data ||= defined $bits ? "$ip/$bits" : $ip;
- _add($self,AF_INET6,$packed,(defined $bits ? $bits : 128), $data);
-}
-
-sub Net::Patricia::AF_INET6::match_integer {
+ $self->SUPER::_add(AF_INET6,$packed,(defined $bits ? $bits : 128), $data);
+}
+
+sub match_integer {
my ($self, $num, $bits) = @_;
- _match($self,AF_INET6,pack("N",$num),(defined $bits ? $bits : 128));
-}
-
-sub Net::Patricia::AF_INET6::exact_integer {
+ $self->SUPER::_match(AF_INET6,pack("N",$num),(defined $bits ? $bits : 128));
+}
+
+sub exact_integer {
my ($self, $num, $bits) = @_;
- _exact($self,AF_INET6,pack("N",$num),(defined $bits ? $bits : 128));
-}
-
-sub Net::Patricia::AF_INET6::match {
+ $self->SUPER::_exact(AF_INET6,pack("N",$num),(defined $bits ? $bits : 128));
+}
+
+sub match {
my ($self, $ip, $bits) = @_;
my $packed = inet_pton(AF_INET6, $ip) || croak("invalid key");
- _match($self,AF_INET6,$packed,(defined $bits ? $bits : 128));
-}
-
-sub Net::Patricia::AF_INET6::exact {
+ $self->SUPER::_match(AF_INET6,$packed,(defined $bits ? $bits : 128));
+}
+
+sub exact {
my ($self, $ip, $bits) = @_;
my $packed = inet_pton(AF_INET6, $ip) || croak("invalid key");
- _exact($self,AF_INET6,$packed,(defined $bits ? $bits : 128));
-}
-
-sub Net::Patricia::AF_INET6::remove {
+ $self->SUPER::_exact(AF_INET6,$packed,(defined $bits ? $bits : 128));
+}
+
+sub remove {
my ($self, $ip, $bits) = @_;
my $packed = inet_pton(AF_INET6, $ip) || return undef;
- _remove($self,AF_INET6,$packed,(defined $bits ? $bits : 128));
-}
-
-sub Net::Patricia::AF_INET6::remove_integer {
+ $self->SUPER::_remove(AF_INET6,$packed,(defined $bits ? $bits : 128));
+}
+
+sub remove_integer {
my ($self, $num, $bits) = @_;
- _remove($self,AF_INET6,pack("N",$num),(defined $bits ? $bits : 128));
+ $self->SUPER::_remove(AF_INET6,pack("N",$num),(defined $bits ? $bits : 128));
}
1;
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=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/Patricia.xs (original)
+++ branches/upstream/libnet-patricia-perl/current/Patricia.xs Thu Nov 4 06:45:08 2010
@@ -150,7 +150,7 @@
static void deref_data(SV *data) {
SvREFCNT_dec(data);
- data = (void *)0;
+ data = NULL;
}
static size_t
@@ -163,7 +163,7 @@
}
if (node->prefix) {
- if ((SV *)0 != coderef) {
+ if (NULL != coderef) {
PUSHMARK(SP);
XPUSHs(sv_mortalcopy((SV *)node->data));
PUTBACK;
@@ -214,7 +214,7 @@
PPCODE:
Fill_Prefix(prefix, family, addr, bits, tree->maxbits);
node = patricia_lookup(tree, &prefix);
- if ((patricia_node_t *)0 != node) {
+ if (NULL != node) {
/* { */
if (node->data) {
deref_data(node->data);
@@ -239,7 +239,7 @@
PPCODE:
Fill_Prefix(prefix, family, addr, bits, tree->maxbits);
node = patricia_search_best(tree, &prefix);
- if ((patricia_node_t *)0 != node) {
+ if (NULL != node) {
XPUSHs((SV *)node->data);
} else {
XSRETURN_UNDEF;
@@ -258,7 +258,7 @@
PPCODE:
Fill_Prefix(prefix, family, addr, bits, tree->maxbits);
node = patricia_search_exact(tree, &prefix);
- if ((patricia_node_t *)0 != node) {
+ if (NULL != node) {
XPUSHs((SV *)node->data);
} else {
XSRETURN_UNDEF;
@@ -278,7 +278,7 @@
PPCODE:
Fill_Prefix(prefix, family, addr, bits, tree->maxbits);
node = patricia_search_exact(tree, &prefix);
- if ((Net__PatriciaNode)0 != node) {
+ if (NULL != node) {
XPUSHs(sv_mortalcopy((SV *)node->data));
deref_data(node->data);
patricia_remove(tree, node);
@@ -290,9 +290,9 @@
climb(tree, ...)
Net::Patricia tree
PREINIT:
- patricia_node_t *node = (patricia_node_t *)0;
+ patricia_node_t *node = NULL;
size_t n = 0;
- SV *func = (SV *)0;
+ SV *func = NULL;
CODE:
if (2 == items) {
func = ST(1);
@@ -300,7 +300,7 @@
croak("Usage: Net::Patricia::climb(tree[,CODEREF])");
}
PATRICIA_WALK (tree->head, node) {
- if ((SV *)0 != func) {
+ if (NULL != func) {
PUSHMARK(SP);
XPUSHs(sv_mortalcopy((SV *)node->data));
PUTBACK;
@@ -318,9 +318,9 @@
Net::Patricia tree
PREINIT:
size_t n = 0;
- SV *func = (SV *)0;
+ SV *func = NULL;
CODE:
- func = (SV *)0;
+ func = NULL;
if (2 == items) {
func = ST(1);
} else if (2 < items) {
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=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c (original)
+++ branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.c Thu Nov 4 06:45:08 2010
@@ -59,43 +59,6 @@
return (1);
}
return (0);
-}
-
-/* inet_pton substitute implementation
- * Uses inet_addr to convert an IP address in dotted decimal notation into
- * unsigned long and copies the result to dst.
- * Only supports AF_INET. Follows standard error return conventions of
- * inet_pton.
- */
-int
-inet_pton (int af, const char *src, void *dst)
-{
- u_long result;
-
- if (af == AF_INET) {
- result = inet_addr(src);
- if (result == -1)
- return 0;
- else {
- memcpy (dst, &result, sizeof(struct in_addr));
- return 1;
- }
- }
-#ifdef NT
-#ifdef HAVE_IPV6
- else if (af == AF_INET6) {
- struct in6_addr Address;
- return (inet6_addr(src, &Address));
- }
-#endif /* HAVE_IPV6 */
-#endif /* NT */
-#ifndef NT
- else {
-
- errno = EAFNOSUPPORT;
- return -1;
- }
-#endif /* NT */
}
/* this allows imcomplete prefix */
@@ -1017,7 +980,7 @@
{
patricia_node_t *node;
- if (node = try_search_exact (tree, string))
+ if ((node = try_search_exact (tree, string)))
patricia_remove (tree, node);
}
@@ -1035,7 +998,7 @@
printf ("try_search_best: %s/%d found\n",
prefix_toa (node->prefix), node->prefix->bitlen);
Deref_Prefix (prefix);
- return (prefix);
+ return (node);
}
/* } */
Modified: branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.h?rev=64519&op=diff
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.h (original)
+++ branches/upstream/libnet-patricia-perl/current/libpatricia/patricia.h Thu Nov 4 06:45:08 2010
@@ -87,7 +87,10 @@
patricia_tree_t *New_Patricia (int maxbits);
void Clear_Patricia (patricia_tree_t *patricia, void_fn_t func);
void Destroy_Patricia (patricia_tree_t *patricia, void_fn_t func);
+
void patricia_process (patricia_tree_t *patricia, void_fn_t func);
+
+char *prefix_toa (prefix_t * prefix);
/* { from demo.c */
Added: branches/upstream/libnet-patricia-perl/current/t/01everything.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-patricia-perl/current/t/01everything.t?rev=64519&op=file
==============================================================================
--- branches/upstream/libnet-patricia-perl/current/t/01everything.t (added)
+++ branches/upstream/libnet-patricia-perl/current/t/01everything.t Thu Nov 4 06:45:08 2010
@@ -1,0 +1,118 @@
+#!/usr/bin/perl -w
+
+use Test::More;
+
+use strict qw(vars);
+use diagnostics;
+
+plan tests => 32;
+
+use Net::Patricia;
+
+our $debug = 1;
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $t = new Net::Patricia;
+
+isa_ok($t, 'Net::Patricia', 'creating base object');
+
+ok($t->add_string('127.0.0.0/8'), 'adding 127.0.0.0/8');
+
+is($t->match_string("127.0.0.1"), '127.0.0.0/8', 'looking for 127.0.0.1');
+
+is($t->match_integer(2130706433), '127.0.0.0/8', 'looking for 2130706433');
+
+ok(!$t->match_string("10.0.0.1"), 'looking for 10.0.0.1');
+
+ok(!$t->match_integer(42), 'looking for 42');
+
+{
+ my $ten = new Thingy 10;
+ my $twenty = new Thingy 20;
+ok($t->add_string('10.0.0.0/8', $ten), 'adding 10.0.0.0/8');
+}
+
+diag "Destructor 10 should *not* have run yet.\n" if $debug;
+
+foreach my $subnet (qw(10.42.42.0/31 10.42.42.0/26 10.42.42.0/24 10.42.42.0/32 10.42.69.0/24)) {
+ ok($t->add_string($subnet), "adding $subnet");
+}
+
+my $str1 = $t->match_string('10.42.42.0/24');
+my $str2 = $t->match_string('10.42.69.0/24');
+
+isnt($str1, $str2, 'compare matches from 10.42.42.0/24 and 10.42.69.0/24');
+
+is(${$t->match_integer(168430090)}, 10, 'looking for 168430090');
+
+ok($t->match_string("10.0.0.1"), 'looking for 10.0.0.1');
+
+ok(!$t->match_exact_integer(167772160), 'looking for 167772160');
+
+ok($t->match_exact_integer(167772160, 8), 'looking for 167772160, 8');
+
+is(${$t->match_exact_string("10.0.0.0/8")}, 10, 'looking for 10.0.0.0/8');
+
+ok(!$t->remove_string("42.0.0.0/8"), 'removing 42.0.0.0/8');
+
+is(${$t->remove_string("10.0.0.0/8")}, 10, 'removing 10.0.0.0/8');
+
+diag "Destructor 10 should have just run.\n" if $debug;
+
+ok(!$t->match_exact_integer(167772160, 8), 'looking for exact 167772160, 8');
+
+# print "YOU SHOULD SEE A USAGE ERROR HERE:\n";
+# $t->match_exact_integer(167772160, 8, 10);
+
+is($t->climb_inorder(sub { diag "climbing at $_[0]\n" }), 6, 'climb inorder');
+
+ok($t->climb, 'climb');
+
+eval '$t->add_string("_")'; # invalid key
+like($@, qr/invalid/, 'adding "_"');
+
+ok($t->add_string('0/0'), 'add 0/0');
+
+ok($t->match_string("10.0.0.1"), 'lookup 10.0.0.1');
+
+my @a = $t->add_cidr('211.200.0.0-211.205.255.255', 'cidr block!');
+
+is(@a, 2, 'adding cidr block');
+
+is($t->match_string('211.202.0.1'), 'cidr block!', 'looking for 211.202.0.1');
+
+ at a = $t->remove_cidr('211.200.0.0-211.205.255.255');
+
+is(@a, 2, 'removing cidr block');
+
+undef $t;
+
+$t = new Net::Patricia(AF_INET6);
+
+isa_ok($t, 'Net::Patricia::AF_INET6', 'constructing a Net::Patrica::AF_INET6');
+
+ok($t->add_string('2001:220::/35', 'hello, world'), 'adding 2001:220::/35');
+
+is($t->match_string('2001:220::/128'), 'hello, world', 'looking for 2001:220::/128');
+
+undef $t;
+
+done_testing();
+
+package Thingy;
+
+use diagnostics;
+
+sub new {
+ my $class = shift(@_);
+ my $self = shift(@_);
+ return bless \$self, $class;
+}
+
+sub DESTROY {
+ my $self = shift(@_);
+ print STDERR "$$self What a world, what a world...\n";
+}
More information about the Pkg-perl-cvs-commits
mailing list