diff --git a/Changes b/Changes index 78cc64a..1ecdcb6 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,25 @@ Revision history for Perl extension NetAddr::IP +4.003 Sun Aug 6 10:48:25 PDT 2006 + correct SYNOPSIS documentation + add :old_nth + + update Lite.pm documentation + update Util.pm documentation + Imported into distribution CVS tree - Some revision number + mismatches are to be expected + Latin-1 is back + Fixed some angle brackets so that they show up in the docs + +4.002 Fri Aug 4 14:14:16 PDT 2006 + remove unused global variable $isV6 + + update Lite.pm to v1.02 + $isV6 global converted to a lexical variable within sub "_xnew" + $Class global removed and replaced by calls to UNIVERSAL::isa + Thanks to julian@mehnle.net for spotting problems related to + using the Lite.pm with mod_perl + 4.001 Thu Jul 6 14:09:01 PDT 2006 various bug fixes courtesy of Luis Munoz: changes to Lite.pm v1.01, Util.pm v0.17 see Changes in those distros. diff --git a/IP.pm b/IP.pm index 479c7d7..28a3796 100644 --- a/IP.pm +++ b/IP.pm @@ -4,7 +4,7 @@ use strict; #use diagnostics; -use NetAddr::IP::Lite 1.01 qw(Zero Ones V4mask V4net); +use NetAddr::IP::Lite 1.02 qw(Zero Ones V4mask V4net); use NetAddr::IP::Util qw( sub128 inet_aton @@ -24,7 +24,6 @@ @EXPORT_OK @ISA $VERSION - $isV6 ); require Exporter; @@ -32,7 +31,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.001 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.3 $ =~ /\d+/g) }; =pod @@ -51,6 +50,7 @@ V4net :aton :old_storable + :old_nth ); my $ip = new NetAddr::IP 'loopback'; @@ -1059,7 +1059,7 @@ =head1 HISTORY -$Id: IP.pm,v 3.28 2005/09/28 23:56:52 lem Exp $ +$Id: IP.pm,v 4.3 2006/08/14 16:24:03 lem Exp $ =over @@ -1695,8 +1695,8 @@ =head1 AUTHORS -Luis E. Muñoz , -Michael Robinton +Luis E. Mu�oz Eluismunoz@cpan.orgE, +Michael Robinton Emichael@bizsystems.comE =head1 WARRANTY @@ -1705,7 +1705,7 @@ =head1 LICENSE -This software is (c) Luis E. Muñoz, 1999 - 2005, and (c) Michael Robinton, 2006. +This software is (c) Luis E. Mu�oz, 1999 - 2005, and (c) Michael Robinton, 2006. It can be used under the terms of the perl artistic license provided that proper credit for the work of the author is preserved in the form of this copyright notice and license for this module. diff --git a/Lite/Changes b/Lite/Changes index e20e832..23e835e 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,14 @@ Revision history for Perl extension NetAddr::IP::Lite +1.03 Sun Aug 6 10:48:25 PDT 2006 + update Util.pm v0.18 documentation + +1.02 Fri Aug 4 14:14:16 PDT 2006 + $isV6 global converted to a lexical variable within sub "_xnew" + $Class global removed and replaced by calls to UNIVERSAL::isa + Thanks to julian@mehnle.net for spotting problems related to + using the Lite.pm with mod_perl + 1.01 Thu Jul 6 10:46:48 PDT 2006 update v4-wnew.t to warn user of possible long wait update Util.pm v0.17 -- see Changes in that distro diff --git a/Lite/Lite.pm b/Lite/Lite.pm index d21ea5b..417887d 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -25,9 +25,9 @@ mask4to6 ipv4to6 ); -use vars qw(@ISA @EXPORT_OK $Class $VERSION $isV6 $Accept_Binary_IP $Old_nth); +use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth); -$VERSION = do { my @r = (q$Revision: 1.01 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -148,14 +148,13 @@ '""' => sub { $_[0]->cidr(); }, 'eq' => sub { - my $a = ref $_[0] eq $Class ? $_[0]->cidr : $_[0]; - my $b = ref $_[1] eq $Class ? $_[1]->cidr : $_[1]; + my $a = (UNIVERSAL::isa($_[0],__PACKAGE__)) ? $_[0]->cidr : $_[0]; + my $b = (UNIVERSAL::isa($_[1],__PACKAGE__)) ? $_[1]->cidr : $_[1]; $a eq $b; }, '==' => sub { - return 0 unless ref $_[0] eq $Class; - return 0 unless ref $_[1] eq $Class; + return 0 unless UNIVERSAL::isa($_[0],__PACKAGE__) && UNIVERSAL::isa($_[1],__PACKAGE__); $_[0]->cidr eq $_[1]->cidr; }, @@ -497,18 +496,19 @@ } sub new($;$$) { - $isV6 = 0; + unshift @_, 0; goto &_xnew; } sub new6($;$$) { - $isV6 = 1; + unshift @_, 1; goto &_xnew; } -sub _xnew($;$$) { +sub _xnew($$;$$) { + my $isV6 = shift; my $proto = shift; - $Class = ref $proto || $proto || __PACKAGE__; + my $class = ref $proto || $proto || __PACKAGE__; my $ip = lc shift; $ip = 'default' unless defined $ip; my $hasmask = 1; @@ -708,7 +708,7 @@ mask => $mask, isv6 => $isV6, }; - return bless $self, $Class; + return bless $self, $class; } =item C<-Ebroadcast()> @@ -896,7 +896,6 @@ =cut sub within ($$) { - return undef unless ref($_[0]) eq $Class && ref($_[1]) eq $Class; return 1 unless hasbits($_[1]->{mask}); # 0x0 contains everything my $netme = $_[0]->{addr} & $_[0]->{mask}; my $brdme = $_[0]->{addr} | ~ $_[0]->{mask}; @@ -1038,8 +1037,8 @@ =head1 AUTHOR -Luis E. Muñoz , -Michael Robinton +Luis E. Mu�oz Eluismunoz@cpan.orgE, +Michael Robinton Emichael@bizsystems.comE =head1 WARRANTY @@ -1048,7 +1047,7 @@ =head1 LICENSE -This software is (c) Luis E. Muñoz, 1999 - 2005, and (c) Michael Robinton, 2006. +This software is (c) Luis E. Mu�oz, 1999 - 2005, and (c) Michael Robinton, 2006. It can be used under the terms of the perl artistic license provided that proper credit for the work of the author is preserved in the form of this copyright notice and license for this module. diff --git a/Lite/MANIFEST b/Lite/MANIFEST deleted file mode 100644 index 0f69293..0000000 --- a/Lite/MANIFEST +++ /dev/null @@ -1,96 +0,0 @@ -README -MANIFEST -MANIFEST.SKIP -Makefile.PL -Lite.pm -Changes -t/addr.t -t/aton.t -t/bits.t -t/broadcast.t -t/cidr.t -t/contains.t -t/copy.t -t/firstlast.t -t/lemasklen.t -t/loops.t -t/mask.t -t/masklen.t -t/netaddr.t -t/network.t -t/new-nth.t -t/old-nth.t -t/new-num.t -t/old-num.t -t/numeric.t -t/over-qq.t -t/over_comp.t -t/over_copy.t -t/over_equal.t -t/over_math.t -t/pathological.t -t/range.t -t/relops.t -t/v4-aton.t -t/v4-badnm.t -t/v4-base.t -t/v4-basem.t -t/v4-cidr.t -t/v4-cnew.t -t/v4-contains.t -t/v4-new-first.t -t/v4-old-first.t -t/v4-last.t -t/v4-new.t -t/v4-num.t -t/v4-numeric.t -t/v4-range.t -t/v4-snew.t -t/v4-wnew.t -t/v6-new-base.t -t/v6-old-base.t -t/v6-contains.t -t/v6-inc.t -t/v6-numeric.t -t/version.t -t/within.t -Util/Changes -Util/docs/rfc1884.txt -Util/GPL -Util/lib/NetAddr/IP/UtilPP.pm -Util/Makefile.PL -Util/MANIFEST -Util/MANIFEST.SKIP -Util/README -Util/t/4to6.t -Util/t/add128.t -Util/t/addconst.t -Util/t/anyto6.t -Util/t/badd.t -Util/t/bcd2bin.t -Util/t/bcdn2bin.t -Util/t/bin.t -Util/t/comp128.t -Util/t/croak.t -Util/t/hasbits.t -Util/t/inet_n2ad.t -Util/t/inet_n2dx.t -Util/t/ipv4_inet.t -Util/t/ipv6_any2n.t -Util/t/ipv6func.t -Util/t/ipv6to4.t -Util/t/isIPv4.t -Util/t/leftshift.t -Util/t/mode.t -Util/t/notcontiguous.t -Util/t/simple_pack.t -Util/t/sub128.t -Util/Util.pm -Util/Util.xs -Util/typemap -Util/siteconf -Util/u_intxx.h -Util/xs_include/miniSocket.inc -Util/xs_include/inet_aton.c - -META.yml Module meta-data (added by MakeMaker) diff --git a/Lite/README b/Lite/README index 45aafaa..f03dea1 100644 --- a/Lite/README +++ b/Lite/README @@ -344,7 +344,7 @@ :old_nth AUTHOR - Luis E. Muñoz , Michael Robinton + Luis E. Mu�oz , Michael Robinton WARRANTY @@ -352,7 +352,7 @@ by using it you accept any and all the liability. LICENSE - This software is (c) Luis E. Muñoz, 1999 - 2005, and (c) Michael + This software is (c) Luis E. Mu�oz, 1999 - 2005, and (c) Michael Robinton, 2006. It can be used under the terms of the perl artistic license provided that proper credit for the work of the author is preserved in the form of this copyright notice and license for this diff --git a/Lite/Util/Changes b/Lite/Util/Changes index cc5405f..abee5d2 100644 --- a/Lite/Util/Changes +++ b/Lite/Util/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension NetAddr::IP::Util +0.18 Sun Aug 6 10:48:25 PDT 2006 + correct shiftleft documentation + correct mask4to6 documentation + 0.17 Thu Jul 6 10:46:48 PDT 2006 update 'siteconf line 1608' to fix empty variable in inet_aton test update 'siteconf line 1636' to fix empty variable in inet_pton test diff --git a/Lite/Util/MANIFEST b/Lite/Util/MANIFEST deleted file mode 100644 index f5b5ced..0000000 --- a/Lite/Util/MANIFEST +++ /dev/null @@ -1,38 +0,0 @@ -README -MANIFEST -MANIFEST.SKIP -Makefile.PL -Util.pm -Util.xs -Changes -GPL -siteconf -typemap -u_intxx.h -docs/rfc1884.txt -lib/NetAddr/IP/UtilPP.pm -xs_include/inet_aton.c -xs_include/miniSocket.inc -t/4to6.t -t/add128.t -t/addconst.t -t/anyto6.t -t/badd.t -t/bcd2bin.t -t/bcdn2bin.t -t/bin.t -t/notcontiguous.t -t/comp128.t -t/croak.t -t/hasbits.t -t/inet_n2ad.t -t/inet_n2dx.t -t/ipv4_inet.t -t/ipv6_any2n.t -t/ipv6func.t -t/ipv6to4.t -t/isIPv4.t -t/leftshift.t -t/mode.t -t/simple_pack.t -t/sub128.t diff --git a/Lite/Util/Makefile.old b/Lite/Util/Makefile.old deleted file mode 100644 index 772cb5d..0000000 --- a/Lite/Util/Makefile.old +++ /dev/null @@ -1,765 +0,0 @@ -# This Makefile is for the NetAddr::IP::Util extension to perl. -# -# It was generated automatically by MakeMaker version -# 6.30 (Revision: Revision: 4535 ) from the contents of -# Makefile.PL. Don't edit this file, edit Makefile.PL instead. -# -# ANY CHANGES MADE HERE WILL BE LOST! -# -# MakeMaker ARGV: () -# -# MakeMaker Parameters: - -# LIBS => [q[-lnsl]] -# NAME => q[NetAddr::IP::Util] -# VERSION_FROM => q[Util.pm] -# clean => { FILES=>q[*.bs *.o *.c *~ tmp* Util_IS.pm localStuff.h config.log] } -# depend => { Util.c=>q[xs_include/miniSocket.inc localStuff.h] } -# dist => { COMPRESS=>q[gzip], SUFFIX=>q[gz] } - -# --- MakeMaker post_initialize section: - - -# --- MakeMaker const_config section: - -# These definitions are from config.sh (via /usr/lib/perl5/i386-linux/Config.pm) - -# They may have been overridden via Makefile.PL or on the command line -AR = ar -CC = cc -CCCDLFLAGS = -fpic -CCDLFLAGS = -rdynamic -DLEXT = so -DLSRC = dl_dlopen.xs -LD = cc -LDDLFLAGS = -shared -L/usr/local/lib -LDFLAGS = -L/usr/local/lib -LIBC = /lib/libc-2.2.2.so -LIB_EXT = .a -OBJ_EXT = .o -OSNAME = linux -OSVERS = 2.4.2 -RANLIB = : -SITELIBEXP = /usr/lib/perl5/site_perl -SITEARCHEXP = /usr/lib/perl5/site_perl/i386-linux -SO = so -EXE_EXT = -FULL_AR = /usr/bin/ar -VENDORARCHEXP = -VENDORLIBEXP = - - -# --- MakeMaker constants section: -AR_STATIC_ARGS = cr -DIRFILESEP = / -DFSEP = $(DIRFILESEP) -NAME = NetAddr::IP::Util -NAME_SYM = NetAddr_IP_Util -VERSION = 0.17 -VERSION_MACRO = VERSION -VERSION_SYM = 0_17 -DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" -XS_VERSION = 0.17 -XS_VERSION_MACRO = XS_VERSION -XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" -INST_ARCHLIB = ../../blib/arch -INST_SCRIPT = ../../blib/script -INST_BIN = ../../blib/bin -INST_LIB = ../../blib/lib -INST_MAN1DIR = ../../blib/man1 -INST_MAN3DIR = ../../blib/man3 -MAN1EXT = 1 -MAN3EXT = 3 -INSTALLDIRS = site -DESTDIR = -PREFIX = $(SITEPREFIX) -PERLPREFIX = /usr -SITEPREFIX = /usr -VENDORPREFIX = -INSTALLPRIVLIB = /usr/lib/perl5 -DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) -INSTALLSITELIB = /usr/lib/perl5/site_perl -DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) -INSTALLVENDORLIB = -DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) -INSTALLARCHLIB = /usr/lib/perl5/i386-linux -DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) -INSTALLSITEARCH = /usr/lib/perl5/site_perl/i386-linux -DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) -INSTALLVENDORARCH = -DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) -INSTALLBIN = /usr/bin -DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) -INSTALLSITEBIN = /usr/bin -DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) -INSTALLVENDORBIN = -DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) -INSTALLSCRIPT = /usr/bin -DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) -INSTALLMAN1DIR = /usr/man/man1 -DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) -INSTALLSITEMAN1DIR = $(INSTALLMAN1DIR) -DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) -INSTALLVENDORMAN1DIR = -DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) -INSTALLMAN3DIR = /usr/man/man3 -DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) -INSTALLSITEMAN3DIR = $(INSTALLMAN3DIR) -DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) -INSTALLVENDORMAN3DIR = -DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) -PERL_LIB = /usr/lib/perl5 -PERL_ARCHLIB = /usr/lib/perl5/i386-linux -LIBPERL_A = libperl.a -FIRST_MAKEFILE = Makefile -MAKEFILE_OLD = Makefile.old -MAKE_APERL_FILE = Makefile.aperl -PERLMAINCC = $(CC) -PERL_INC = /usr/lib/perl5/i386-linux/CORE -PERL = /usr/local/bin/perl -FULLPERL = /usr/local/bin/perl -ABSPERL = $(PERL) -PERLRUN = $(PERL) -FULLPERLRUN = $(FULLPERL) -ABSPERLRUN = $(ABSPERL) -PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" -FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" -ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" -PERL_CORE = 0 -PERM_RW = 644 -PERM_RWX = 755 - -MAKEMAKER = /usr/lib/perl5/ExtUtils/MakeMaker.pm -MM_VERSION = 6.30 -MM_REVISION = Revision: 4535 - -# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). -# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) -# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) -# DLBASE = Basename part of dynamic library. May be just equal BASEEXT. -FULLEXT = NetAddr/IP/Util -BASEEXT = Util -PARENT_NAME = NetAddr::IP -DLBASE = $(BASEEXT) -VERSION_FROM = Util.pm -OBJECT = $(BASEEXT)$(OBJ_EXT) -LDFROM = $(OBJECT) -LINKTYPE = dynamic -BOOTDEP = - -# Handy lists of source code files: -XS_FILES = Util.xs -C_FILES = Util.c -O_FILES = Util.o -H_FILES = u_intxx.h -MAN1PODS = -MAN3PODS = Util.pm \ - Util_IS.pm \ - lib/NetAddr/IP/UtilPP.pm - -# Where is the Config information that we are using/depend on -CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h - -# Where to build things -INST_LIBDIR = $(INST_LIB)/NetAddr/IP -INST_ARCHLIBDIR = $(INST_ARCHLIB)/NetAddr/IP - -INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) -INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) - -INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT) -INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT) -INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs - -# Extra linker info -EXPORT_LIST = -PERL_ARCHIVE = -PERL_ARCHIVE_AFTER = - - -TO_INST_PM = Util.pm \ - Util_IS.pm \ - lib/NetAddr/IP/UtilPP.pm - -PM_TO_BLIB = lib/NetAddr/IP/UtilPP.pm \ - ../../blib/lib/NetAddr/IP/UtilPP.pm \ - Util_IS.pm \ - $(INST_LIB)/NetAddr/IP/Util_IS.pm \ - Util.pm \ - $(INST_LIB)/NetAddr/IP/Util.pm - - -# --- MakeMaker platform_constants section: -MM_Unix_VERSION = 1.50 -PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc - - -# --- MakeMaker tool_autosplit section: -# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' - - - -# --- MakeMaker tool_xsubpp section: - -XSUBPPDIR = /usr/lib/perl5/ExtUtils -XSUBPP = $(XSUBPPDIR)$(DFSEP)xsubpp -XSUBPPRUN = $(PERLRUN) $(XSUBPP) -XSPROTOARG = -XSUBPPDEPS = /usr/lib/perl5/ExtUtils/typemap typemap $(XSUBPP) -XSUBPPARGS = -typemap /usr/lib/perl5/ExtUtils/typemap -typemap typemap -XSUBPP_EXTRA_ARGS = - - -# --- MakeMaker tools_other section: -SHELL = /bin/sh -CHMOD = chmod -CP = cp -MV = mv -NOOP = $(SHELL) -c true -NOECHO = @ -RM_F = rm -f -RM_RF = rm -rf -TEST_F = test -f -TOUCH = touch -UMASK_NULL = umask 0 -DEV_NULL = > /dev/null 2>&1 -MKPATH = $(ABSPERLRUN) "-MExtUtils::Command" -e mkpath -EQUALIZE_TIMESTAMP = $(ABSPERLRUN) "-MExtUtils::Command" -e eqtime -ECHO = echo -ECHO_N = echo -n -UNINST = 0 -VERBINST = 0 -MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -DOC_INSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install -UNINSTALL = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall -WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist -MACROSTART = -MACROEND = -USEMAKEFILE = -f -FIXIN = $(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)" - - -# --- MakeMaker makemakerdflt section: -makemakerdflt: all - $(NOECHO) $(NOOP) - - -# --- MakeMaker dist section skipped. - -# --- MakeMaker macro section: - - -# --- MakeMaker depend section: -Util.c : xs_include/miniSocket.inc localStuff.h - - -# --- MakeMaker cflags section: - -CCFLAGS = -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -OPTIMIZE = -O2 -PERLTYPE = -MPOLLUTE = - - -# --- MakeMaker const_loadlibs section: - -# NetAddr::IP::Util might depend on some other libraries: -# See ExtUtils::Liblist for details -# -EXTRALIBS = -LDLOADLIBS = -lnsl -BSLOADLIBS = - - -# --- MakeMaker const_cccmd section: -CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \ - $(CCFLAGS) $(OPTIMIZE) \ - $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \ - $(XS_DEFINE_VERSION) - -# --- MakeMaker post_constants section: - -MY_POD2TEXT = /usr/bin/pod2text - - -# --- MakeMaker pasthru section: - -PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ - LINKTYPE="$(LINKTYPE)"\ - OPTIMIZE="$(OPTIMIZE)"\ - PREFIX="$(PREFIX)" - - -# --- MakeMaker special_targets section: -.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) - -.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir - - - -# --- MakeMaker c_o section: - -.c.i: - cc -E -c $(PASTHRU_INC) $(INC) \ - $(CCFLAGS) $(OPTIMIZE) \ - $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \ - $(XS_DEFINE_VERSION) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c > $*.i - -.c.s: - $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c - -.c$(OBJ_EXT): - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c - -.C$(OBJ_EXT): - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.C - -.cpp$(OBJ_EXT): - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cpp - -.cxx$(OBJ_EXT): - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cxx - -.cc$(OBJ_EXT): - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.cc - - -# --- MakeMaker xs_c section: - -.xs.c: - $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c - - -# --- MakeMaker xs_o section: - -.xs$(OBJ_EXT): - $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c - $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c - - -# --- MakeMaker top_targets section: - -config :: localStuff.h - @$(NOOP) - -# siteconf CCname Cfile_ext OBJext EXEext "Cflags" "LDflags" "LDLOADLIBS" -# -localStuff.h : - ./siteconf "$(CC)" ".c" "$(OBJ_EXT)" "$(EXE_EXT)" "$(CCFLAGS)" "$(LDflags)" "$(LDLOADLIBS)" -all :: pure_all manifypods - $(NOECHO) $(NOOP) - - -pure_all :: config pm_to_blib subdirs linkext README - $(NOECHO) $(NOOP) - -subdirs :: $(MYEXTLIB) - $(NOECHO) $(NOOP) - -config :: $(FIRST_MAKEFILE) blibdirs - $(NOECHO) $(NOOP) - -$(O_FILES): $(H_FILES) - -help : - perldoc ExtUtils::MakeMaker - - -# --- MakeMaker blibdirs section: -blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists - $(NOECHO) $(NOOP) - -# Backwards compat with 6.18 through 6.25 -blibdirs.ts : blibdirs - $(NOECHO) $(NOOP) - -$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_LIBDIR) - $(NOECHO) $(CHMOD) 755 $(INST_LIBDIR) - $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists - -$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_ARCHLIB) - $(NOECHO) $(CHMOD) 755 $(INST_ARCHLIB) - $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists - -$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_AUTODIR) - $(NOECHO) $(CHMOD) 755 $(INST_AUTODIR) - $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists - -$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) - $(NOECHO) $(CHMOD) 755 $(INST_ARCHAUTODIR) - $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists - -$(INST_BIN)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_BIN) - $(NOECHO) $(CHMOD) 755 $(INST_BIN) - $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists - -$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_SCRIPT) - $(NOECHO) $(CHMOD) 755 $(INST_SCRIPT) - $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists - -$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_MAN1DIR) - $(NOECHO) $(CHMOD) 755 $(INST_MAN1DIR) - $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists - -$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL - $(NOECHO) $(MKPATH) $(INST_MAN3DIR) - $(NOECHO) $(CHMOD) 755 $(INST_MAN3DIR) - $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists - - - -# --- MakeMaker linkext section: - -linkext :: $(LINKTYPE) - $(NOECHO) $(NOOP) - - -# --- MakeMaker dlsyms section: - - -# --- MakeMaker dynamic section: - -dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) - $(NOECHO) $(NOOP) - - -# --- MakeMaker dynamic_bs section: -BOOTSTRAP = $(BASEEXT).bs - -# As Mkbootstrap might not write a file (if none is required) -# we use touch to prevent make continually trying to remake it. -# The DynaLoader only reads a non-empty file. -$(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists - $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))" - $(NOECHO) $(PERLRUN) \ - "-MExtUtils::Mkbootstrap" \ - -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');" - $(NOECHO) $(TOUCH) $@ - $(CHMOD) $(PERM_RW) $@ - -$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists - $(NOECHO) $(RM_RF) $@ - - $(CP) $(BOOTSTRAP) $@ - $(CHMOD) $(PERM_RW) $@ - - -# --- MakeMaker dynamic_lib section: - -# This section creates the dynamically loadable $(INST_DYNAMIC) -# from $(OBJECT) and possibly $(MYEXTLIB). -ARMAYBE = : -OTHERLDFLAGS = -INST_DYNAMIC_DEP = -INST_DYNAMIC_FIX = - -$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP) - $(RM_F) $@ - $(LD) $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \ - $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \ - $(INST_DYNAMIC_FIX) - $(CHMOD) $(PERM_RWX) $@ - - -# --- MakeMaker static section: - -## $(INST_PM) has been moved to the all: target. -## It remains here for awhile to allow for old usage: "make static" -static :: $(FIRST_MAKEFILE) $(INST_STATIC) - $(NOECHO) $(NOOP) - - -# --- MakeMaker static_lib section: - -$(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists - $(RM_RF) $@ - $(FULL_AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@ - $(CHMOD) $(PERM_RWX) $@ - $(NOECHO) $(ECHO) "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld - - -# --- MakeMaker manifypods section: - -POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" -POD2MAN = $(POD2MAN_EXE) - - -manifypods : pure_all \ - lib/NetAddr/IP/UtilPP.pm \ - Util_IS.pm \ - Util.pm \ - lib/NetAddr/IP/UtilPP.pm \ - Util_IS.pm \ - Util.pm - $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) \ - lib/NetAddr/IP/UtilPP.pm $(INST_MAN3DIR)/NetAddr::IP::UtilPP.$(MAN3EXT) \ - Util_IS.pm $(INST_MAN3DIR)/NetAddr::IP::Util_IS.$(MAN3EXT) \ - Util.pm $(INST_MAN3DIR)/NetAddr::IP::Util.$(MAN3EXT) - - - - -# --- MakeMaker processPL section: - - -# --- MakeMaker installbin section: - - -# --- MakeMaker subdirs section: - -# none - -# --- MakeMaker clean_subdirs section: -clean_subdirs : - $(NOECHO) $(NOOP) - - -# --- MakeMaker clean section: - -# Delete temporary files but do not touch installed files. We don't delete -# the Makefile here so a later make realclean still has a makefile to use. - -clean :: clean_subdirs - - $(RM_F) \ - perl.exe core.*perl.*.? \ - pm_to_blib.ts core.[0-9][0-9] \ - core.[0-9] $(INST_ARCHAUTODIR)/extralibs.ld \ - $(INST_ARCHAUTODIR)/extralibs.all perl$(EXE_EXT) \ - core.[0-9][0-9][0-9][0-9][0-9] *perl.core \ - *$(LIB_EXT) core.[0-9][0-9][0-9] \ - $(BASEEXT).exp $(BOOTSTRAP) \ - so_locations perl \ - $(BASEEXT).x pm_to_blib \ - core blibdirs.ts \ - perlmain.c $(MAKE_APERL_FILE) \ - mon.out core.[0-9][0-9][0-9][0-9] \ - $(BASEEXT).bso $(BASEEXT).def \ - tmon.out lib$(BASEEXT).def \ - Util.c *$(OBJ_EXT) - - $(RM_RF) \ - *.c *.bs \ - localStuff.h *~ \ - config.log Util_IS.pm \ - blib tmp* \ - *.o - - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) - - -# --- MakeMaker realclean_subdirs section: -realclean_subdirs : - $(NOECHO) $(NOOP) - - -# --- MakeMaker realclean section: -# Delete temporary files (via clean) and also delete dist files -realclean purge :: clean realclean_subdirs - - $(RM_F) \ - $(FIRST_MAKEFILE) $(OBJECT) \ - $(MAKEFILE_OLD) - - $(RM_RF) \ - $(DISTVNAME) - - -# --- MakeMaker metafile section: -metafile : create_distdir - $(NOECHO) $(ECHO) Generating META.yml - $(NOECHO) $(ECHO) '# http://module-build.sourceforge.net/META-spec.html' > META_new.yml - $(NOECHO) $(ECHO) '#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#' >> META_new.yml - $(NOECHO) $(ECHO) 'name: NetAddr-IP-Util' >> META_new.yml - $(NOECHO) $(ECHO) 'version: 0.17' >> META_new.yml - $(NOECHO) $(ECHO) 'version_from: Util.pm' >> META_new.yml - $(NOECHO) $(ECHO) 'installdirs: site' >> META_new.yml - $(NOECHO) $(ECHO) 'requires:' >> META_new.yml - $(NOECHO) $(ECHO) '' >> META_new.yml - $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml - $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.30' >> META_new.yml - -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml - - -# --- MakeMaker signature section: -signature : - cpansign -s - - -# --- MakeMaker dist_basics section skipped. - -# --- MakeMaker dist_core section skipped. - -# --- MakeMaker distdir section skipped. - -# --- MakeMaker dist_test section skipped. - -# --- MakeMaker dist_ci section skipped. - -# --- MakeMaker distmeta section: -distmeta : create_distdir metafile - $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ - -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' - - - -# --- MakeMaker distsignature section: -distsignature : create_distdir - $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \ - -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' - $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE - cd $(DISTVNAME) && cpansign -s - - - -# --- MakeMaker install section skipped. - -# --- MakeMaker force section: -# Phony target to force checking subdirectories. -FORCE: - $(NOECHO) $(NOOP) - - -# --- MakeMaker perldepend section: - -PERL_HDRS = \ - $(PERL_INC)/EXTERN.h \ - $(PERL_INC)/INTERN.h \ - $(PERL_INC)/XSUB.h \ - $(PERL_INC)/av.h \ - $(PERL_INC)/cc_runtime.h \ - $(PERL_INC)/config.h \ - $(PERL_INC)/cop.h \ - $(PERL_INC)/cv.h \ - $(PERL_INC)/dosish.h \ - $(PERL_INC)/embed.h \ - $(PERL_INC)/embedvar.h \ - $(PERL_INC)/fakethr.h \ - $(PERL_INC)/form.h \ - $(PERL_INC)/gv.h \ - $(PERL_INC)/handy.h \ - $(PERL_INC)/hv.h \ - $(PERL_INC)/intrpvar.h \ - $(PERL_INC)/iperlsys.h \ - $(PERL_INC)/keywords.h \ - $(PERL_INC)/mg.h \ - $(PERL_INC)/nostdio.h \ - $(PERL_INC)/op.h \ - $(PERL_INC)/opcode.h \ - $(PERL_INC)/patchlevel.h \ - $(PERL_INC)/perl.h \ - $(PERL_INC)/perlio.h \ - $(PERL_INC)/perlsdio.h \ - $(PERL_INC)/perlsfio.h \ - $(PERL_INC)/perlvars.h \ - $(PERL_INC)/perly.h \ - $(PERL_INC)/pp.h \ - $(PERL_INC)/pp_proto.h \ - $(PERL_INC)/proto.h \ - $(PERL_INC)/regcomp.h \ - $(PERL_INC)/regexp.h \ - $(PERL_INC)/regnodes.h \ - $(PERL_INC)/scope.h \ - $(PERL_INC)/sv.h \ - $(PERL_INC)/thrdvar.h \ - $(PERL_INC)/thread.h \ - $(PERL_INC)/unixish.h \ - $(PERL_INC)/util.h - -$(OBJECT) : $(PERL_HDRS) - -Util.c : $(XSUBPPDEPS) - - -# --- MakeMaker makefile section: - -$(OBJECT) : $(FIRST_MAKEFILE) - -# We take a very conservative approach here, but it's worth it. -# We move Makefile to Makefile.old here to avoid gnu make looping. -$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) - $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" - $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." - -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) - -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) - $(PERLRUN) Makefile.PL - $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" - $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" - false - - - -# --- MakeMaker staticmake section: - -# --- MakeMaker makeaperl section --- -MAP_TARGET = ../../perl -FULLPERL = /usr/local/bin/perl - - -# --- MakeMaker test section: - -TEST_VERBOSE=0 -TEST_TYPE=test_$(LINKTYPE) -TEST_FILE = test.pl -TEST_FILES = t/*.t -TESTDB_SW = -d - -testdb :: testdb_$(LINKTYPE) - -test :: $(TEST_TYPE) - -test_dynamic :: pure_all - PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) - -testdb_dynamic :: pure_all - PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) - -test_ : test_dynamic - -test_static :: pure_all $(MAP_TARGET) - PERL_DL_NONLAZY=1 ./$(MAP_TARGET) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) - -testdb_static :: pure_all $(MAP_TARGET) - PERL_DL_NONLAZY=1 ./$(MAP_TARGET) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) - - - -# --- MakeMaker ppd section: -# Creates a PPD (Perl Package Description) for a binary distribution. -ppd: - $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' $(DISTNAME)' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd - - -# --- MakeMaker pm_to_blib section: - -pm_to_blib : $(TO_INST_PM) - $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')' \ - lib/NetAddr/IP/UtilPP.pm ../../blib/lib/NetAddr/IP/UtilPP.pm \ - Util_IS.pm $(INST_LIB)/NetAddr/IP/Util_IS.pm \ - Util.pm $(INST_LIB)/NetAddr/IP/Util.pm - $(NOECHO) $(TOUCH) pm_to_blib - - -# --- MakeMaker selfdocument section: - - -# --- MakeMaker postamble section: - -README : Util.pm - @$(MY_POD2TEXT) Util.pm > README - - - -# End. diff --git a/Lite/Util/README b/Lite/Util/README index 024aa3d..b58afe3 100644 --- a/Lite/Util/README +++ b/Lite/Util/README @@ -200,7 +200,7 @@ returns: 128 bit network address * $ipv6naddr = mask4to6($netaddr); - Convert an ipv4 netowrk address into an ipv6 network mask. + Convert an ipv4 network address/mask into an ipv6 network mask. input: 32 bit network/mask address returns: 128 bit network/mask address diff --git a/Lite/Util/Util.bs b/Lite/Util/Util.bs new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Lite/Util/Util.bs diff --git a/Lite/Util/Util.c b/Lite/Util/Util.c new file mode 100644 index 0000000..b1862eb --- /dev/null +++ b/Lite/Util/Util.c @@ -0,0 +1,996 @@ +/* + * This file was generated automatically by xsubpp version 1.9508 from the + * contents of Util.xs. Do not edit this file, edit Util.xs instead. + * + * ANY CHANGES MADE HERE WILL BE LOST! + * + */ + +#line 1 "Util.xs" + +/* + * Copyright 2006, Michael Robinton + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _CYGWIN +#include +#endif + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#ifdef _CYGWIN +#include +#endif + +/* take care of missing u_int32_t definitions windoze/sun */ +#include "u_intxx.h" + +/* needed for testing with 'printf' +#include + */ + +#ifdef __cplusplus +} +#endif + +/* workaround for OS's without inet_aton */ +#include "xs_include/inet_aton.c" + +typedef union +{ + u_int32_t u[4]; + unsigned char c[16]; +} n128; + +n128 c128, a128; + +u_int32_t wa[4], wb[4]; /* working registers */ + +struct +{ /* character array of 40 bytes */ + char txt[20]; /* 20 bytes */ + u_int32_t bcd[5]; /* 20 bytes, 40 digits */ +} n; + +#define zero ('0' & 0x7f) + +void +extendipv4(void * aa) +{ + register u_int32_t * a = wa; + *a++ = 0; + *a++ = 0; + *a++ = 0; + *a = *((u_int32_t *)aa); +} + +void +extendmask4(void *aa) +{ + register u_int32_t * a = wa; + *a++ = 0xffffffff; + *a++ = 0xffffffff; + *a++ = 0xffffffff; + *a = *((u_int32_t *)aa); +} + +void +fastcomp128(void * aa) +{ + register u_int32_t * a; + a = aa; + + *a++ ^= 0xffffffff; + *a++ ^= 0xffffffff; + *a++ ^= 0xffffffff; + *a++ ^= 0xffffffff; +} + +/* add two 128 bit numbers + return the carry + */ + +int +adder128(void * aa, void * bb, int carry) +{ + int i; + register u_int32_t a, b, r; + + for (i=3; i >= 0; i--) { + a = *((u_int32_t *)aa + i); + b = *((u_int32_t *)bb + i); + r = a + b; + a = 0; /* ripple carry forward */ + if ( r < a || r < b) /* if overflow */ + a = 1; + + b = r + carry; /* carry propagate in */ + if (b < r) /* ripple carry forward */ + carry = 1; /* if overflow */ + else + carry = a; + + *((u_int32_t *)a128.u + i) = b; + } + return carry; +} + +int +addercon(void * aa, int32_t con) +{ + register u_int32_t tmp = 0x80000000; + + if (con & tmp) + tmp = 0xffffffff; + else + tmp = 0; + + wb[0] = tmp; + wb[1] = tmp; + wb[2] = tmp; + wb[3] = (u_int32_t)con; + return adder128(aa,wb,0); +} + +int +have128(void * bp) +{ + register u_int32_t * p = bp; + + if (*p++ || *p++ || *p++ || *p++) + return 1; + return 0; +} + +int +_isipv4(void * bp) +{ + register u_int32_t * p = bp; + + if (*p++ || *p++ || *p++) + return 0; + return 1; +} + +/* network byte swap and copy */ +void +netswap_copy(void * dest, void * src, int len) +{ + register u_int32_t * d = dest, * s = src; + + for (/* -- */;len>0;len--) { +#ifdef host_is_LITTLE_ENDIAN + *d++ = (((*s & 0xff000000) >> 24) | ((*s & 0x00ff0000) >> 8) | \ + ((*s & 0x0000ff00) << 8) | ((*s & 0x000000ff) << 24)); +#else +# ifdef host_is_BIG_ENDIAN + *d++ = *s; +# else +# error ENDIANness not defined +# endif +#endif + s++; + } +} + +/* do ntohl / htonl changes as necessary for this OS + */ +void +netswap(void * ap, int len) +{ +#ifdef host_is_LITTLE_ENDIAN + register u_int32_t * a = ap; + for (/* -- */;len >0;len--) { + *a++ = (((*a & 0xff000000) >> 24) | ((*a & 0x00ff0000) >> 8) | \ + ((*a & 0x0000ff00) << 8) | ((*a & 0x000000ff) << 24)); + } +#endif +} + +/* shift right to purge '0's, + return mask bit count and remainder value, + left fill with ones + */ +unsigned char +_countbits(void *ap) +{ + register u_int32_t * p0 = (u_int32_t *)ap, * p1 = p0 +1, * p2 = p1 +1, * p3 = p2 +1; + unsigned char count = 128; + + fastcomp128(ap); + + do { + if (!(*p3 & 1)) + break; + count--; + *p3 >>= 1; + if (*p2 & 1) + *p3 |= 0x80000000; + *p2 >>= 1; + if (*p1 & 1) + *p2 |= 0x80000000; + *p1 >>= 1; + if (*p0 & 1) + *p1 |= 0x80000000; + *p0 >>= 1; + } while (count > 0); + return count; +} + +/* multiply 128 bit number x 2 + */ +void +_128x2(void * ap) +{ + register u_int32_t * p = (u_int32_t *)ap +3, tmpc, carry = 0; + + do { + tmpc = *p & 0x80000000; /* propagate hi bit to next word */ + *p <<= 1; + if (carry) + *p += 1; + carry = tmpc; + } while (p-- > (u_int32_t *)ap); +/* printf("2o %04X:%04X:%04X:%04X\n",*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ +} + +/* multiply 128 bit number X10 + */ +int +_128x10(void * ap, void * tp) +{ + _128x2(ap); /* multiply by two */ + *(u_int32_t *)tp = *(u_int32_t *)ap; /* temp save */ + *((u_int32_t *)tp +1) = *((u_int32_t *)ap +1); + *((u_int32_t *)tp +2) = *((u_int32_t *)ap +2); + *((u_int32_t *)tp +3) = *((u_int32_t *)ap +3); + _128x2(ap); + _128x2(ap); /* times 8 */ + (void) adder128(ap,tp,0); +/* printf("x %04X:%04X:%04X:%04X\n",*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ +} + +/* multiply 128 bit number by 10, add bcd digit to result + */ +void +_128x10plusbcd(void * ap, void * tp, char digit) +{ +/* printf("digit %X + %X = ",digit,*((u_int32_t *)ap +3)); */ + _128x10(ap,tp); + *(u_int32_t *)tp = 0; + *((u_int32_t *)tp + 1) = 0; + *((u_int32_t *)tp + 2) = 0; + *((u_int32_t *)tp + 3) = digit; + (void) adder128(ap,tp,0); +/* printf("%d %04X:%04X:%04X:%04X\n",digit,*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ +} + +char +_simple_pack(void * str,int len) +{ + int i = len -1, j=19, lo=1; + register unsigned char c, * bcdn = (unsigned char *)n.bcd, * sp = (unsigned char *) str; + + if (len > 40) + return '*'; /* error, input string too long */ + + memset (n.bcd, 0, 20); + + do { + c = *(sp + i) & 0x7f; + if (c < zero || c > (zero + 9)) + return c; /* error, out of range */ + + if (lo) { /* lo byte ? */ + *(bcdn + j) = c & 0xF; + lo = 0; + } + else { + c <<= 4; + *(bcdn + j) |= c; + lo = 1; /* lo byte next */ + j--; + } + } while (i-- > 0); + return 0; +} + +/* convert a packed bcd string to 128 bit binary string + */ +void +_bcdn2bin(void * bp, int len) +{ + int i = 0, hasdigits = 0, lo; + register unsigned char c, * cp = (unsigned char *)bp; + + memset(a128.c, 0, 16); + memset(c128.c, 0, 16); + + while (i < len ) { + c = *cp++; + for (lo=0;lo<2;lo+=1) { + if (lo) { + if (hasdigits) /* suppress leading zero multiplications */ + _128x10plusbcd(a128.u,c128.u, c & 0xF); + else { + if (c & 0xF) { + hasdigits = 1; + a128.u[3] = c & 0xF; + } + } + } + else { + if (hasdigits) /* suppress leading zero multiplications */ + _128x10plusbcd(a128.u,c128.u, c >> 4); + else { + if (c & 0XF0) { + hasdigits = 1; + a128.u[3] = c >> 4; + } + } + } + i++; + if (i >= len) + break; + } + } +} + +/* convert a 128 bit number string to a bcd number string + returns the length of the bcd string === 20 + */ +int +_bin2bcd (unsigned char * binary) +{ + register u_int32_t tmp, add3, msk8, bcd8, carry; + u_int32_t word; + unsigned char binmsk = 0; + int c = 0,i, j, p; + + memset (n.bcd, 0, 20); + + for (p=0;p<128;p++) { /* bit pointer */ + if (! binmsk) { + word = *((unsigned char *)binary + c); + binmsk = 0x80; + c++; + } + carry = word & binmsk; /* bit to convert */ + binmsk >>= 1; + for (i=4;i>=0;i--) { + bcd8 = n.bcd[i]; + if (carry | bcd8) { /* if something to do */ + add3 = 3; + msk8 = 8; + + for (j=0;j<8;j++) { /* prep bcd digits for X2 */ + tmp = bcd8 + add3; + if (tmp & msk8) + bcd8 = tmp; + add3 <<= 4; + msk8 <<= 4; + } + tmp = bcd8 & 0x80000000; /* propagated carry */ + bcd8 <<= 1; /* x 2 */ + if (carry) + bcd8 += 1; + n.bcd[i] = bcd8; + carry = tmp; + } + } + } + netswap(n.bcd,5); + return 20; +} + +/* convert a bcd number string to a bcd text string + returns the number of digits + */ +int +_bcd2txt(unsigned char * bcd2p) +{ + register unsigned char bcd, dchar; + int i, j = 0; + + for (i=0;i<20;i++) { + dchar = *(bcd2p + i); + bcd = dchar >> 4; + if (j || bcd) { + n.txt[j] = bcd + zero; + j++; + } + bcd = dchar & 0xF; + if (j || bcd || i == 19) { /* must be at least one digit */ + n.txt[j] = bcd + zero; + j++; + } + } + n.txt[j] = 0; /* string terminator */ + return j; +} + +#line 433 "Util.c" + +/* INCLUDE: Including 'xs_include/miniSocket.inc' from 'Util.xs' */ + +#ifndef Newx +#define Newx(v,n,t) New(1138,v,n,t) +#endif +#include +XS(XS_NetAddr__IP__Util_inet_aton); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_inet_aton) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NetAddr::IP::Util::inet_aton(host)"); + { + char * host = (char *)SvPV_nolen(ST(0)); +#line 76 "xs_include/miniSocket.inc" + { + struct in_addr ip_address; + struct hostent * phe; + int ok = + (host != NULL) && + (*host != '\0') && + inet_aton(host, &ip_address); + + if (!ok && (phe = gethostbyname(host))) { + Copy( phe->h_addr, &ip_address, phe->h_length, char ); + ok = 1; + } + + ST(0) = sv_newmortal(); + if (ok) + sv_setpvn( ST(0), (char *)&ip_address, sizeof ip_address ); + } +#line 467 "Util.c" + } + XSRETURN(1); +} + +XS(XS_NetAddr__IP__Util_inet_ntoa); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_inet_ntoa) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NetAddr::IP::Util::inet_ntoa(ip_address_sv)"); + { + SV * ip_address_sv = ST(0); +#line 98 "xs_include/miniSocket.inc" + { + STRLEN addrlen; + struct in_addr addr; + char * addr_str; + char * ip_address; + ip_address = SvPV(ip_address_sv,addrlen); + if (addrlen == sizeof(addr) || addrlen == 4) + addr.s_addr = + (ip_address[0] & 0xFF) << 24 | + (ip_address[1] & 0xFF) << 16 | + (ip_address[2] & 0xFF) << 8 | + (ip_address[3] & 0xFF); + else + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::inet_ntoa", + addrlen, sizeof(addr)); + /* We could use inet_ntoa() but that is broken + * in HP-UX + GCC + 64bitint (returns "0.0.0.0"), + * so let's use this sprintf() workaround everywhere. + * This is also more threadsafe than using inet_ntoa(). */ + Newx(addr_str, 4 * 3 + 3 + 1, char); /* IPv6? */ + sprintf(addr_str, "%d.%d.%d.%d", + ((addr.s_addr >> 24) & 0xFF), + ((addr.s_addr >> 16) & 0xFF), + ((addr.s_addr >> 8) & 0xFF), + ( addr.s_addr & 0xFF)); + ST(0) = sv_2mortal(newSVpvn(addr_str, strlen(addr_str))); + Safefree(addr_str); + } +#line 510 "Util.c" + } + XSRETURN(1); +} + + +/* INCLUDE: Returning to 'Util.xs' from 'xs_include/miniSocket.inc' */ + +XS(XS_NetAddr__IP__Util_comp128); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_comp128) +{ + dXSARGS; + dXSI32; + if (items < 1) + Perl_croak(aTHX_ "Usage: %s(s, ...)", GvNAME(CvGV(cv))); + SP -= items; + { + SV * s = ST(0); +#line 436 "Util.xs" + unsigned char * ap; + STRLEN len; + int i; +#line 532 "Util.c" +#line 440 "Util.xs" + ap = SvPV(s,len); + if (len != 16) { + if (ix == 2) + strcpy((char *)wa,"ipv6to4"); + else if (ix == 1) + strcpy((char *)wa,"shiftleft"); + else + strcpy((char *)wa,"comp128"); + croak("Bad arg length for %s%s, length is %d, should be %d", + "NetAddr::IP::Util::",(char *)wa,len *8,128); + } + if (ix == 2) { + XPUSHs(sv_2mortal(newSVpvn((unsigned char *)(ap +12),4))); + XSRETURN(1); + } + else if (ix == 1) { + if (items < 2) { + memcpy(wa,ap,16); + } + else if ((i = SvIV(ST(1))) == 0) { + memcpy(wa,ap,16); + } + else if (i < 0 || i > 128) { + croak("Bad arg value for %s, is %d, should be 0 thru 128", + "NetAddr::IP::Util::shiftleft",i); + } + else { + netswap_copy(wa,ap,4); + do { + _128x2(wa); + i--; + } while (i > 0); + netswap(wa,4); + } + } + else { + memcpy(wa,ap,16); + fastcomp128(wa); + } + XPUSHs(sv_2mortal(newSVpvn((unsigned char *)wa,16))); + XSRETURN(1); +#line 575 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_add128); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_add128) +{ + dXSARGS; + dXSI32; + if (items != 2) + Perl_croak(aTHX_ "Usage: %s(as, bs)", GvNAME(CvGV(cv))); + SP -= items; + { + SV * as = ST(0); + SV * bs = ST(1); +#line 489 "Util.xs" + unsigned char * ap, *bp; + STRLEN len; +#line 595 "Util.c" +#line 492 "Util.xs" + ap = SvPV(as,len); + if (len != 16) { + Bail: + if (ix == 1) + strcpy((char *)wa,"sub128"); + else + strcpy((char *)wa,"add128"); + croak("Bad arg length for %s%s, length is %d, should be %d", + "NetAddr::IP::Util::",(char *)wa,len *8,128); + } + + bp = SvPV(bs,len); + if (len != 16) { + goto Bail; + } + + netswap_copy(wa,ap,4); + netswap_copy(wb,bp,4); + if (ix == 1) { + fastcomp128(wb); + XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,1)))); + } + else { + XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,0)))); + } + if (GIMME_V == G_ARRAY) { + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn(a128.c,16))); + XSRETURN(2); + } + XSRETURN(1); +#line 628 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_addconst); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_addconst) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: NetAddr::IP::Util::addconst(s, cnst)"); + SP -= items; + { + SV * s = ST(0); + I32 cnst = (I32)SvIV(ST(1)); +#line 529 "Util.xs" + unsigned char * ap; + STRLEN len; +#line 647 "Util.c" +#line 532 "Util.xs" + ap = SvPV(s,len); + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::addconst",len *8,128); + } + netswap_copy(wa,ap,4); + XPUSHs(sv_2mortal(newSViv((I32)addercon(wa,cnst)))); + if (GIMME_V == G_ARRAY) { + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn(a128.c,16))); + XSRETURN(2); + } + XSRETURN(1); +#line 662 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_hasbits); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_hasbits) +{ + dXSARGS; + dXSI32; + if (items != 1) + Perl_croak(aTHX_ "Usage: %s(s)", GvNAME(CvGV(cv))); + { + SV * s = ST(0); +#line 552 "Util.xs" + unsigned char * bp; + STRLEN len; +#line 680 "Util.c" + int RETVAL; + dXSTARG; +#line 555 "Util.xs" + bp = SvPV(s,len); + if (len != 16) { + if (ix == 1) + strcpy((char *)wa,"isIPv4"); + else + strcpy((char *)wa,"hasbits"); + croak("Bad arg length for %s%s, length is %d, should be %d", + "NetAddr::IP::Util::",(char *)wa,len *8,128); + } + if (ix == 1) { + RETVAL = _isipv4(bp); + } + else { + RETVAL = have128(bp); + } +#line 699 "Util.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_NetAddr__IP__Util_bin2bcd); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_bin2bcd) +{ + dXSARGS; + dXSI32; + if (items != 1) + Perl_croak(aTHX_ "Usage: %s(s)", GvNAME(CvGV(cv))); + SP -= items; + { + SV * s = ST(0); +#line 580 "Util.xs" + unsigned char * cp; + STRLEN len; +#line 718 "Util.c" +#line 583 "Util.xs" + cp = SvPV(s,len); + if (ix == 0) { + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::bin2bcd",len *8,128); + } + (void) _bin2bcd(cp); + XPUSHs(sv_2mortal(newSVpvn(n.txt,_bcd2txt((unsigned char *)n.bcd)))); + } + else if (ix == 1) { + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::bin2bcdn",len *8,128); + } + XPUSHs(sv_2mortal(newSVpvn((unsigned char *)n.bcd,_bin2bcd(cp)))); + } + else { + if (len > 20) { + croak("Bad arg length for %s, length is %d, should %d digits or less", + "NetAddr::IP::Util::bcdn2txt",len *2,40); + } + XPUSHs(sv_2mortal(newSVpvn(n.txt,_bcd2txt(cp)))); + } + XSRETURN(1); +#line 744 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_bcd2bin); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_bcd2bin) +{ + dXSARGS; + dXSI32; + if (items < 1) + Perl_croak(aTHX_ "Usage: %s(s, ...)", GvNAME(CvGV(cv))); + SP -= items; + { + SV * s = ST(0); +#line 621 "Util.xs" + unsigned char * cp, badc; + STRLEN len; +#line 763 "Util.c" +#line 624 "Util.xs" + cp = SvPV(s,len); + if (len > 40) { + if (ix == 0) + strcpy((char *)wa,"bcd2bin"); + else if (ix ==1) + strcpy((char *)wa,"simple_pack"); + Badigits: + croak("Bad arg length for %s%s, length is %d, should be %d digits or less", + "NetAddr::IP::Util::",(char *)wa,len,40); + } + if (ix == 2) { + if (len > 20) { + len <<= 1; /* times 2 */ + strcpy((char *)wa,"bcdn2bin"); + goto Badigits; + } + if (items < 2) { + croak("Bad usage, should have %s('packedbcd,length)", + "NetAddr::IP::Util::bcdn2bin"); + } + len = SvIV(ST(1)); + _bcdn2bin(cp,(int)len); + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn(a128.c,16))); + XSRETURN(1); + } + + badc = _simple_pack(cp,(int)len); + if (badc) { + if (ix == 1) + strcpy((char *)wa,"simple_pack"); + else + strcpy((char *)wa,"bcd2bin"); + croak("Bad char in string for %s%s, character is '%c', allowed are 0-9", + "NetAddr::IP::Util::",(char *)wa,badc); + } + if (ix == 0) { + _bcdn2bin(n.bcd,40); + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn(a128.c,16))); + } + else { /* ix == 1 */ + XPUSHs(sv_2mortal(newSVpvn((unsigned char *)n.bcd,20))); + } + XSRETURN(1); +#line 810 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_notcontiguous); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_notcontiguous) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NetAddr::IP::Util::notcontiguous(s)"); + SP -= items; + { + SV * s = ST(0); +#line 674 "Util.xs" + unsigned char * ap, count; + STRLEN len; +#line 828 "Util.c" +#line 677 "Util.xs" + ap = SvPV(s,len); + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::countbits",len *8,128); + } + netswap_copy(wa,ap,4); + count = _countbits(wa); + XPUSHs(sv_2mortal(newSViv((I32)have128(wa)))); + if (GIMME_V == G_ARRAY) { + XPUSHs(sv_2mortal(newSViv((I32)count))); + XSRETURN(2); + } + XSRETURN(1); +#line 843 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_ipv4to6); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_ipv4to6) +{ + dXSARGS; + dXSI32; + if (items != 1) + Perl_croak(aTHX_ "Usage: %s(s)", GvNAME(CvGV(cv))); + SP -= items; + { + SV * s = ST(0); +#line 697 "Util.xs" + unsigned char * ip; + STRLEN len; +#line 862 "Util.c" +#line 700 "Util.xs" + ip = SvPV(s,len); + if (len != 4) { + if (ix == 1) + strcpy((char *)wa,"mask4to6"); + else + strcpy((char *)wa,"ipv4to6"); + croak("Bad arg length for %s%s, length is %d, should be 32", + "NetAddr::IP::Util::",(char *)wa,len *8); + } + if (ix == 0) + extendipv4(ip); + else + extendmask4(ip); + XPUSHs(sv_2mortal(newSVpvn((unsigned char *)wa,16))); + XSRETURN(1); +#line 879 "Util.c" + PUTBACK; + return; + } +} + +XS(XS_NetAddr__IP__Util_ipanyto6); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NetAddr__IP__Util_ipanyto6) +{ + dXSARGS; + dXSI32; + if (items != 1) + Perl_croak(aTHX_ "Usage: %s(s)", GvNAME(CvGV(cv))); + SP -= items; + { + SV * s = ST(0); +#line 722 "Util.xs" + unsigned char * ip; + STRLEN len; +#line 898 "Util.c" +#line 725 "Util.xs" + ip = SvPV(s,len); + if (len == 16) /* if already 128 bits, return input */ + XPUSHs(sv_2mortal(newSVpvn(ip,16))); + else if (len == 4) { + if (ix == 0) + extendipv4(ip); + else + extendmask4(ip); + XPUSHs(sv_2mortal(newSVpvn((unsigned char *)wa,16))); + } + else { + if (ix == 1) + strcpy((char *)wa,"maskanyto6"); + else + strcpy((char *)wa,"ipanyto6"); + croak("Bad arg length for %s%s, length is %d, should be 32 or 128", + "NetAddr::IP::Util::",(char *)wa,len *8); + } + XSRETURN(1); +#line 919 "Util.c" + PUTBACK; + return; + } +} + +#ifdef __cplusplus +extern "C" +#endif +XS(boot_NetAddr__IP__Util); /* prototype to pass -Wmissing-prototypes */ +XS(boot_NetAddr__IP__Util) +{ + dXSARGS; + char* file = __FILE__; + + XS_VERSION_BOOTCHECK ; + + { + CV * cv ; + + newXSproto("NetAddr::IP::Util::inet_aton", XS_NetAddr__IP__Util_inet_aton, file, "$"); + newXSproto("NetAddr::IP::Util::inet_ntoa", XS_NetAddr__IP__Util_inet_ntoa, file, "$"); + cv = newXS("NetAddr::IP::Util::ipv6to4", XS_NetAddr__IP__Util_comp128, file); + XSANY.any_i32 = 2 ; + sv_setpv((SV*)cv, "$;@") ; + cv = newXS("NetAddr::IP::Util::comp128", XS_NetAddr__IP__Util_comp128, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$;@") ; + cv = newXS("NetAddr::IP::Util::shiftleft", XS_NetAddr__IP__Util_comp128, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$;@") ; + cv = newXS("NetAddr::IP::Util::add128", XS_NetAddr__IP__Util_add128, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$$") ; + cv = newXS("NetAddr::IP::Util::sub128", XS_NetAddr__IP__Util_add128, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$$") ; + newXSproto("NetAddr::IP::Util::addconst", XS_NetAddr__IP__Util_addconst, file, "$$"); + cv = newXS("NetAddr::IP::Util::hasbits", XS_NetAddr__IP__Util_hasbits, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::isIPv4", XS_NetAddr__IP__Util_hasbits, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::bin2bcdn", XS_NetAddr__IP__Util_bin2bcd, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::bcdn2txt", XS_NetAddr__IP__Util_bin2bcd, file); + XSANY.any_i32 = 2 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::bin2bcd", XS_NetAddr__IP__Util_bin2bcd, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::bcd2bin", XS_NetAddr__IP__Util_bcd2bin, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$;@") ; + cv = newXS("NetAddr::IP::Util::simple_pack", XS_NetAddr__IP__Util_bcd2bin, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$;@") ; + cv = newXS("NetAddr::IP::Util::bcdn2bin", XS_NetAddr__IP__Util_bcd2bin, file); + XSANY.any_i32 = 2 ; + sv_setpv((SV*)cv, "$;@") ; + newXSproto("NetAddr::IP::Util::notcontiguous", XS_NetAddr__IP__Util_notcontiguous, file, "$"); + cv = newXS("NetAddr::IP::Util::ipv4to6", XS_NetAddr__IP__Util_ipv4to6, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::mask4to6", XS_NetAddr__IP__Util_ipv4to6, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::maskanyto6", XS_NetAddr__IP__Util_ipanyto6, file); + XSANY.any_i32 = 1 ; + sv_setpv((SV*)cv, "$") ; + cv = newXS("NetAddr::IP::Util::ipanyto6", XS_NetAddr__IP__Util_ipanyto6, file); + XSANY.any_i32 = 0 ; + sv_setpv((SV*)cv, "$") ; + } + XSRETURN_YES; +} + diff --git a/Lite/Util/Util.o b/Lite/Util/Util.o new file mode 100644 index 0000000..20d535c --- /dev/null +++ b/Lite/Util/Util.o Binary files differ diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm index 3871d83..f449183 100644 --- a/Lite/Util/Util.pm +++ b/Lite/Util/Util.pm @@ -13,7 +13,7 @@ @ISA = qw(Exporter DynaLoader); -$VERSION = do { my @r = (q$Revision: 0.17 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; my @export_ok = qw( inet_aton @@ -421,7 +421,7 @@ =item * $ipv6naddr = mask4to6($netaddr); -Convert an ipv4 netowrk address into an ipv6 network mask. +Convert an ipv4 network address/mask into an ipv6 network mask. input: 32 bit network/mask address returns: 128 bit network/mask address @@ -710,7 +710,7 @@ =head1 COPYRIGHT -Copyright 2003 - 2006, Michael Robinton +Copyright 2003 - 2006, Michael Robinton Emichael@bizsystems.comE LICENSE AND WARRANTY diff --git a/Lite/Util/config.log b/Lite/Util/config.log new file mode 100644 index 0000000..245230f --- /dev/null +++ b/Lite/Util/config.log @@ -0,0 +1,75 @@ +This file contains any messages produced by compilers while +running siteconf, to aid debugging if siteconf makes a mistake. + +It was created by siteconf, which was +generated by GNU Autoconf 2.53. Invocation command line was + + $ ./siteconf gcc-3.3 .c .o -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include + + +siteconf:285: checking for char +siteconf:312: gcc-3.3 -c -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:315: $? = 0 +siteconf:318: test -s conftest.o +siteconf:321: $? = 0 +siteconf:331: result: yes +siteconf:334: checking size of char +siteconf:612: gcc-3.3 -o conftest -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:615: $? = 0 +siteconf:617: ./conftest +siteconf:620: $? = 0 +siteconf:640: result: 1 +siteconf:647: checking for short int +siteconf:674: gcc-3.3 -c -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:677: $? = 0 +siteconf:680: test -s conftest.o +siteconf:683: $? = 0 +siteconf:693: result: yes +siteconf:696: checking size of short int +siteconf:974: gcc-3.3 -o conftest -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:977: $? = 0 +siteconf:979: ./conftest +siteconf:982: $? = 0 +siteconf:1002: result: 2 +siteconf:1009: checking for int +siteconf:1036: gcc-3.3 -c -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1039: $? = 0 +siteconf:1042: test -s conftest.o +siteconf:1045: $? = 0 +siteconf:1055: result: yes +siteconf:1058: checking size of int +siteconf:1336: gcc-3.3 -o conftest -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1339: $? = 0 +siteconf:1341: ./conftest +siteconf:1344: $? = 0 +siteconf:1364: result: 4 +siteconf:1372: checking for u_intXX_t types +siteconf:1397: gcc-3.3 -c -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1400: $? = 0 +siteconf:1403: test -s conftest.o +siteconf:1406: $? = 0 +siteconf:1418: result: yes +siteconf:1539: checking for uintXX_t types in stdint.h +siteconf:1560: gcc-3.3 -c -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1563: $? = 0 +siteconf:1566: test -s conftest.o +siteconf:1569: $? = 0 +siteconf:1576: result: yes +siteconf:1591: checking for inet_aton +siteconf:1619: gcc-3.3 -o conftest -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1622: $? = 0 +siteconf:1624: ./conftest +siteconf:1627: $? = 0 +siteconf:1633: result: yes +siteconf:1648: checking for inet_pton +siteconf:1676: gcc-3.3 -o conftest -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1679: $? = 0 +siteconf:1681: ./conftest +siteconf:1684: $? = 0 +siteconf:1690: result: yes +siteconf:1706: checking ENDIANness +siteconf:1737: gcc-3.3 -o conftest -I/sw/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -I/opt/local/include conftest.c >&5 +siteconf:1740: $? = 0 +siteconf:1742: ./conftest +siteconf:1745: $? = 0 +siteconf:1751: result: BIG_ENDIAN diff --git a/Lite/Util/lib/NetAddr/IP/UtilPP.pm b/Lite/Util/lib/NetAddr/IP/UtilPP.pm index ea8628e..388b7de 100644 --- a/Lite/Util/lib/NetAddr/IP/UtilPP.pm +++ b/Lite/Util/lib/NetAddr/IP/UtilPP.pm @@ -12,7 +12,7 @@ @ISA = qw(Exporter); -$VERSION = do { my @r = (q$Revision: 0.07 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( hasbits @@ -154,7 +154,7 @@ number of shifts [optional] returns: bits X n shifts - NOTE: a single shift is performed + NOTE: input bits are returned if $n is not specified =cut @@ -664,7 +664,7 @@ =head1 AUTHOR -Michael Robinton +Michael Robinton Emichael@bizsystems.comE =head1 COPYRIGHT diff --git a/Lite/Util/localStuff.h b/Lite/Util/localStuff.h new file mode 100644 index 0000000..0db9456 --- /dev/null +++ b/Lite/Util/localStuff.h @@ -0,0 +1,22 @@ +/* **************************************************** * + * ## localStuff.h ## * + * ## ----------- ## * + * * + * This file was generated automatically by 'siteconf'. * + * Don't edit this file, edit 'siteconf' instead. * + * * + * **************************************************** */ +#ifdef host_is_BIG_ENDIAN +#undef host_is_BIG_ENDIAN +#endif +#ifdef host_is_LITTLE_ENDIAN +#undef host_is_LITTLE_ENDIAN +#endif +#define SIZEOF_CHAR 1 +#define SIZEOF_SHORT_INT 2 +#define SIZEOF_INT 4 +#define HAVE_U_INTXX_T 1 +#define HAVE_UINTXX_T 2 +#define LOCAL_HAVE_inet_aton +#define LOCAL_HAVE_inet_pton +#define host_is_BIG_ENDIAN diff --git a/Lite/Util/pm_to_blib b/Lite/Util/pm_to_blib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Lite/Util/pm_to_blib diff --git a/Lite/pm_to_blib b/Lite/pm_to_blib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Lite/pm_to_blib diff --git a/MANIFEST b/MANIFEST index f7239d4..46cdb2b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,54 +1,11 @@ Changes IP.pm -MANIFEST -MANIFEST.SKIP -META.yml -Makefile.PL -README -TODO -t/imhoff.t -t/loops.t -t/masklen.t -t/new-store.t -t/old-store.t -t/over-arr.t -t/over-qq.t -t/relops.t -t/short.t -t/v4-aton.t -t/v4-badnm.t -t/v4-base.t -t/v4-basem.t -t/v4-cidr.t -t/v4-cnew.t -t/v4-coalesce.t -t/v4-compact.t -t/v4-compplus.t -t/v4-contains.t -t/v4-hostenum.t -t/v4-last.t -t/v4-new.t -t/v4-numeric.t -t/v4-range.t -t/v4-re.t -t/v4-snew.t -t/v4-split-bulk.t -t/v4-split-list.t -t/v4-sprefix.t -t/v4-wnew.t -t/v4-xprefix.t -t/v6-contains.t -t/v6-inc.t -t/v6-numeric.t -t/v6-re.t -t/v6-split-bulk.t -t/wildcard.t Lite/Changes Lite/Lite.pm -Lite/MANIFEST +Lite/Makefile.PL Lite/MANIFEST.SKIP Lite/META.yml -Lite/Makefile.PL +Lite/pm_to_blib Lite/README Lite/t/addr.t Lite/t/aton.t @@ -64,7 +21,11 @@ Lite/t/masklen.t Lite/t/netaddr.t Lite/t/network.t +Lite/t/new-nth.t +Lite/t/new-num.t Lite/t/numeric.t +Lite/t/old-nth.t +Lite/t/old-num.t Lite/t/over-qq.t Lite/t/over_comp.t Lite/t/over_copy.t @@ -81,36 +42,31 @@ Lite/t/v4-cnew.t Lite/t/v4-contains.t Lite/t/v4-last.t +Lite/t/v4-new-first.t Lite/t/v4-new.t Lite/t/v4-num.t Lite/t/v4-numeric.t +Lite/t/v4-old-first.t Lite/t/v4-range.t Lite/t/v4-snew.t Lite/t/v4-wnew.t Lite/t/v6-contains.t Lite/t/v6-inc.t +Lite/t/v6-new-base.t Lite/t/v6-numeric.t +Lite/t/v6-old-base.t Lite/t/version.t Lite/t/within.t -Lite/t/new-nth.t -Lite/t/new-num.t -Lite/t/old-nth.t -Lite/t/old-num.t -Lite/t/v4-new-first.t -Lite/t/v4-old-first.t -Lite/t/v6-new-base.t -Lite/t/v6-old-base.t Lite/Util/Changes -Lite/Util/GPL -Lite/Util/MANIFEST -Lite/Util/MANIFEST.SKIP -Lite/Util/Makefile.PL -Lite/Util/Makefile.old -Lite/Util/README -Lite/Util/Util.pm -Lite/Util/Util.xs +Lite/Util/config.log Lite/Util/docs/rfc1884.txt +Lite/Util/GPL Lite/Util/lib/NetAddr/IP/UtilPP.pm +Lite/Util/localStuff.h +Lite/Util/Makefile.PL +Lite/Util/MANIFEST.SKIP +Lite/Util/pm_to_blib +Lite/Util/README Lite/Util/siteconf Lite/Util/t/4to6.t Lite/Util/t/add128.t @@ -137,5 +93,37 @@ Lite/Util/t/sub128.t Lite/Util/typemap Lite/Util/u_intxx.h +Lite/Util/Util.bs +Lite/Util/Util.c +Lite/Util/Util.o +Lite/Util/Util.pm +Lite/Util/Util.xs Lite/Util/xs_include/inet_aton.c Lite/Util/xs_include/miniSocket.inc +Makefile.PL +MANIFEST This list of files +MANIFEST.SKIP +META.yml +README +t/imhoff.t +t/loops.t +t/masklen.t +t/new-store.t +t/old-store.t +t/over-arr.t +t/over-qq.t +t/relops.t +t/short.t +t/v4-coalesce.t +t/v4-compact.t +t/v4-compplus.t +t/v4-hostenum.t +t/v4-re.t +t/v4-split-bulk.t +t/v4-split-list.t +t/v4-sprefix.t +t/v4-xprefix.t +t/v6-re.t +t/v6-split-bulk.t +t/wildcard.t +TODO diff --git a/META.yml b/META.yml index 5011e11..0a56dfc 100644 --- a/META.yml +++ b/META.yml @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: NetAddr-IP -version: 4.001 +version: 4.003 version_from: IP.pm installdirs: site requires: diff --git a/README b/README index 28c5791..99cb0de 100644 --- a/README +++ b/README @@ -3,6 +3,8 @@ + + NetAddr::IP - Manage IP addresses and subnets This distribution is designed as a help for managing (ranges of) IP @@ -185,7 +187,7 @@ LICENSE AND WARRANTY -This software is (c) Luis E. Muñoz and Michael A. Robinton. It can be +This software is (c) Luis E. Mu�oz and Michael A. Robinton. It can be used under the terms of the perl artistic license provided that proper credit for the work of the authors is preserved in the form of this copyright notice and license for this module. @@ -196,7 +198,7 @@ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (Darwin) -iD8DBQFEzo9TQyDWGRI/hhARAiDiAJ9QW3va/3+Fjk3IbxXaISUFO9djtwCfamKl -oml7Sgrp5lEEQEdppKIyI2A= -=4GL1 +iD8DBQFE4KXRQyDWGRI/hhARAqjSAJ4/MnV9e01zLfrIJ1CtfwfaJiKUDwCePdhb +djsPkRD3CRKuxz5d+9oX9zc= +=srrF -----END PGP SIGNATURE----- diff --git a/t/loops.t b/t/loops.t index 5cbef31..20c26a5 100644 --- a/t/loops.t +++ b/t/loops.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: loops.t,v 1.2 2002/10/31 04:30:35 lem Exp $ +# $Id: loops.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ $| = 1; diff --git a/t/masklen.t b/t/masklen.t index bd28ee2..0791021 100644 --- a/t/masklen.t +++ b/t/masklen.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: masklen.t,v 1.2 2002/10/31 04:30:35 lem Exp $ +# $Id: masklen.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @masks = 0 .. 32; diff --git a/t/over-qq.t b/t/over-qq.t index 1fca4b3..b427f22 100644 --- a/t/over-qq.t +++ b/t/over-qq.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: over-qq.t,v 1.2 2002/10/31 04:30:35 lem Exp $ +# $Id: over-qq.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @addr = ('10.0.0.0/8', '192.168.0.0/16', '127.0.0.1/32'); diff --git a/t/relops.t b/t/relops.t index 53db1f8..a2761c5 100644 --- a/t/relops.t +++ b/t/relops.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: relops.t,v 1.5 2004/02/23 22:20:17 lem Exp $ +# $Id: relops.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ BEGIN { @gt = ( diff --git a/t/short.t b/t/short.t index 8b95561..40d2692 100644 --- a/t/short.t +++ b/t/short.t @@ -1,6 +1,6 @@ use Test::More; -# $Id: short.t,v 1.1 2004/02/22 05:07:51 lem Exp $ +# $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my %cases = ( diff --git a/t/v4-aton.t b/t/v4-aton.t deleted file mode 100644 index 7766aab..0000000 --- a/t/v4-aton.t +++ /dev/null @@ -1,40 +0,0 @@ -use Test::More tests => 18; -use Socket; - -# $Id: v4-aton.t,v 1.3 2005/08/25 15:38:03 lem Exp $ - -my @addr = ( - [ 'localhost', '127.0.0.1' ], - [ 'broadcast', '255.255.255.255' ], - [ '254.254.0.1', '254.254.0.1' ], - [ 'default', '0.0.0.0' ], - [ '10.0.0.1', '10.0.0.1' ], - -); - -# Verify that Accept_Binary_IP works... - -SKIP: -{ - skip "Failed to load NetAddr::IP", 17 - unless use_ok('NetAddr::IP'); - - ok(! defined NetAddr::IP->new("\1\1\1\1"), - "binary unrecognized by default..."); - - # This mimicks the actual use with :aton - NetAddr::IP::import(':aton'); - - ok(defined NetAddr::IP->new("\1\1\1\1"), - "...but can be recognized"); - - is(NetAddr::IP->new($_->[0])->aton, inet_aton($_->[1]), "->aton($_->[0])") - for @addr; - - ok(defined NetAddr::IP->new(inet_aton($_->[1])), "->new aton($_->[1])") - for @addr; - - is(NetAddr::IP->new(inet_aton($_->[1]))->addr, $_->[1], - "->new aton($_->[1])") - for @addr; -} diff --git a/t/v4-badnm.t b/t/v4-badnm.t deleted file mode 100644 index 43520de..0000000 --- a/t/v4-badnm.t +++ /dev/null @@ -1,44 +0,0 @@ -# I know this does not look like -*- perl -*-, but I swear it is... - -# $Id: v4-badnm.t,v 1.3 2005/08/08 02:42:05 lem Exp $ - -use strict; -use Test::More; - -$| = 1; - -my @badnets = ( - '10.10.10.10/255.255.0.255', - '10.10.10.10/255.0.255.255', - '10.10.10.10/0.255.255.255', - '10.10.10.10/128.255.0.255', - '10.10.10.10/255.128.0.255', - '10.10.10.10/255.255.255.129', - '10.10.10.10/255.255.129.0', - '10.10.10.10/255.255.255.130', - '10.10.10.10/255.255.130.0', - '10.10.10.10/255.0.0.1', - '10.10.10.10/255.129.0.1', - '10.10.10.10/0.255.0.255', - '58.26.0.0-58.27.127.255', # Taken from APNIC's WHOIS case -); - -my @goodnets = (); - -push @goodnets, "10.0.0.1/$_" for (0 .. 32); -push @goodnets, "10.0.0.1/255.255.255.255"; - -plan tests => 1 + @badnets + @goodnets; - -die "# Cannot continue without NetAddr::IP\n" - unless use_ok('NetAddr::IP'); - -my $count = 1; - -ok(! defined NetAddr::IP->new($_), "new $_ should fail") - for @badnets; - -ok(defined NetAddr::IP->new($_), "new $_ should work") - for @goodnets; - - diff --git a/t/v4-base.t b/t/v4-base.t deleted file mode 100644 index 5358c1e..0000000 --- a/t/v4-base.t +++ /dev/null @@ -1,21 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-base.t,v 1.2 2002/10/31 04:30:35 lem Exp $ - -my @addr = (qw( 127.0.0.1 10.0.0.1 )); -my @mask = (qw( 255.0.0.0 255.255.0.0 255.255.255.0 255.255.255.255 )); - -$| = 1; -print "1..", (2 * scalar @addr * scalar @mask), "\n"; - -my $count = 1; - -for my $a (@addr) { - for my $m (@mask) { - my $ip = new NetAddr::IP $a, $m; - print (($ip->addr ne $a ? 'not ' : ''), "ok ", $count++, "\n"); - print (($ip->mask ne $m ? 'not ' : ''), "ok ", $count++, "\n"); - } -} - - diff --git a/t/v4-basem.t b/t/v4-basem.t deleted file mode 100644 index 7f4b36a..0000000 --- a/t/v4-basem.t +++ /dev/null @@ -1,26 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-basem.t,v 1.2 2002/10/31 04:30:35 lem Exp $ - -my $nets = { - '10.0.0.16' => [ 24, '10.0.0.255', '10.0.0.0' ], - '127.0.0.1' => [ 8, '127.255.255.255', '127.0.0.0' ], - '192.168.0.10' => [ 17, '192.168.127.255', '192.168.0.0' ], -}; - -$| = 1; -print "1..", (2 * scalar keys %$nets), "\n"; - -my $count = 1; - -for my $a (keys %$nets) { - my $ip = new NetAddr::IP $a, $nets->{$a}->[0]; - print '', (($ip->broadcast->addr ne $nets->{$a}->[1] ? - 'not ' : ''), - "ok ", $count++, "\n"); - print '', (($ip->network->addr ne $nets->{$a}->[2] ? - 'not ' : ''), - "ok ", $count++, "\n"); -} - - diff --git a/t/v4-cidr.t b/t/v4-cidr.t deleted file mode 100644 index efa4316..0000000 --- a/t/v4-cidr.t +++ /dev/null @@ -1,30 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-cidr.t,v 1.2 2002/10/31 04:30:35 lem Exp $ - -$| = 1; - -my @addr = (qw( - 0.0.0.0/0 - 1.0.0.0/1 - 2.0.0.0/2 - 10.0.0.0/8 - 10.0.120.0/24 - 161.196.66.0/25 - 255.255.255.255/32 - )); - -print '1..', scalar @addr, "\n"; - -my $count = 1; - -for my $a (@addr) { - my $ip = new NetAddr::IP $a; - if ($ip->cidr eq $a) { - print "ok ", $count ++, "\n"; - } - else { - print "not ok ", $count ++, "\n"; - print "$a -> ", $ip->cidr, " [", $ip->mask, "]\n"; - } -} diff --git a/t/v4-cnew.t b/t/v4-cnew.t deleted file mode 100644 index 0407182..0000000 --- a/t/v4-cnew.t +++ /dev/null @@ -1,28 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-cnew.t,v 1.2 2002/10/31 04:30:35 lem Exp $ - -my @subnets = ( - [ '127.1', '127.0.0.1/32' ], - [ '127.1/16', '127.1.0.0/16' ], - [ '10.10.10', '10.10.0.10/32' ], - [ '10.10.10/24', '10.10.10.0/24' ], - ); - -$| = 1; - -print '1..', (scalar @subnets) , "\n"; - -my $count = 1; - -for my $n (@subnets) { - my $ip = new NetAddr::IP $n->[0]; - if ($ip eq $n->[1]) { - print "ok $count\n"; - } - else { - print "not ok $count\n"; - } - - ++ $count; -} diff --git a/t/v4-compact.t b/t/v4-compact.t index 7aac06d..0e630c2 100644 --- a/t/v4-compact.t +++ b/t/v4-compact.t @@ -1,6 +1,6 @@ use NetAddr::IP qw(Compact); -# $Id: v4-compact.t,v 1.3 2002/12/27 20:37:55 lem Exp $ +# $Id: v4-compact.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @r = ( [ '10.0.0.0', '255.255.255.0'], diff --git a/t/v4-compplus.t b/t/v4-compplus.t index 6293079..0902afe 100644 --- a/t/v4-compplus.t +++ b/t/v4-compplus.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: v4-compplus.t,v 1.2 2002/10/31 04:30:36 lem Exp $ +# $Id: v4-compplus.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ $| = 1; diff --git a/t/v4-contains.t b/t/v4-contains.t deleted file mode 100644 index f0d27f5..0000000 --- a/t/v4-contains.t +++ /dev/null @@ -1,64 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-contains.t,v 1.2 2002/10/31 04:30:36 lem Exp $ - -#require "IP.pm"; - -my @yes_pairs = ( - [ [ '127.0.0.0', '255.0.0.0' ], - [ '127.0.0.1', '255.255.255.255'] ], - [ [ '10.0.0.0', '255.255.255.0' ], - [ '10.0.0.128', '255.255.255.128' ] ], - [ [ '10.0.0.0', '255.0.0.0' ], - [ '10.0.0.0', '255.0.0.0' ]], - [ [ '10.0.0.0', '255.0.0.0' ], - [ '10.0.0.1', '255.0.0.0' ]], - [ [ '10.0.0.0', '255.255.255.254' ], - [ '10.0.0.1', '255.255.255.254' ]], - [ [ '10.0.0.0', '255.255.255.254' ], - [ '10.0.0.1', '255.255.255.255' ]], - [ [ '10.0.0.1', '255.0.0.0' ], - [ '10.0.0.1', '255.255.255.255' ]], - [ [ 'default', 'default' ], - [ '10.0.0.1', '255.255.255.254' ]], - [ [ 'default', 'default' ], - [ 'broadcast', undef ]], - [ [ 'loopback', '255.0.0.0' ], - [ '127.0.0.0', '255.0.0.0' ] ], - ); - -my @no_pairs = ( - [ [ '127.0.0.1', '255.255.255.255' ], - [ '127.0.0.0', '255.0.0.0' ] ], - [ [ '10.0.0.0', '255.0.0.0' ], - [ '11.0.0.0', '255.0.0.0' ] ], - [ [ '10.0.1.0', '255.255.255.0' ], - [ '10.0.2.0', '255.255.255.0' ] ], - [ [ '10.0.0.1', '255.255.255.254' ], - [ 'default', '0' ] ], - ); - -$| = 1; -print "1..", 2 * (scalar @yes_pairs + scalar @no_pairs), "\n"; - -my $count = 1; - -for my $p (@yes_pairs) { - my $ip_a = new NetAddr::IP $p->[0]->[0], $p->[0]->[1]; - my $ip_b = new NetAddr::IP $p->[1]->[0], $p->[1]->[1]; - print (($ip_a->contains($ip_b) ? '' : 'not '), 'ok ', $count++, "\n"); - print (($ip_b->within($ip_a) ? '' : 'not '), 'ok ', $count++, "\n"); - -# print "a = ", $ip_a->addr, "/", $ip_a->mask, "\n"; -# print "b = ", $ip_b->addr, "/", $ip_b->mask, "\n"; - -} - -for my $p (@no_pairs) { - my $ip_a = new NetAddr::IP $p->[0]->[0], $p->[0]->[1]; - my $ip_b = new NetAddr::IP $p->[1]->[0], $p->[1]->[1]; - print (($ip_a->contains($ip_b) ? 'not ' : ''), 'ok ', $count++, "\n"); - print (($ip_b->within($ip_a) ? 'not ' : ''), 'ok ', $count++, "\n"); -} - - diff --git a/t/v4-hostenum.t b/t/v4-hostenum.t index 5fb432b..5033156 100644 --- a/t/v4-hostenum.t +++ b/t/v4-hostenum.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: v4-hostenum.t,v 1.2 2002/10/31 04:30:36 lem Exp $ +# $Id: v4-hostenum.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my %addr = ( '10.0.0.0' => [ '255.255.255.252', diff --git a/t/v4-last.t b/t/v4-last.t deleted file mode 100644 index 76ee806..0000000 --- a/t/v4-last.t +++ /dev/null @@ -1,34 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-last.t,v 1.2 2002/10/31 04:30:36 lem Exp $ - -my %w = ('default' => [ '255.255.255.254', '0.0.0.0' ], - 'loopback' => [ '127.255.255.254', '255.0.0.0' ], - '127.0.0.1/8' => [ '127.255.255.254', '255.0.0.0' ], - '10.' => [ '10.255.255.254', '255.0.0.0' ], - '10.10.10/24' => [ '10.10.10.254', '255.255.255.0' ], - ); - -$| = 1; - -print '1..', (2 * scalar keys %w), "\n"; - -my $count = 1; - -for my $a (keys %w) { - my $ip = NetAddr::IP->new($a)->last; - - if ($ip->addr eq $w{$a}->[0]) { - print "ok ", $count++, "\n"; - } - else { - print "not ok ", $count++, "\n"; - } - - if ($ip->mask eq $w{$a}->[1]) { - print "ok ", $count++, "\n"; - } - else { - print "not ok ", $count++, "\n"; - } -} diff --git a/t/v4-new.t b/t/v4-new.t deleted file mode 100644 index fb4cbc4..0000000 --- a/t/v4-new.t +++ /dev/null @@ -1,64 +0,0 @@ -use NetAddr::IP; - -use Test::More; - -my $binword; -{ - local $SIG{__WARN__} = sub {}; - $binword = eval "0b11111111111111110000000000000000"; -} -if ($@) { - $binword = 0xffff0000; - print STDERR "\t\tskipped! 0b11111111111111110000000000000000\n\t\tbinary bit strings unsupported in Perl version $]\n"; -} - -@a = ( - [ 'localhost', '127.0.0.1' ], - [ 0x01010101, '1.1.1.1' ], - [ 1, '1.0.0.0' ], # Because it will have a mask. 0.0.0.1 ow - [ 'default', '0.0.0.0' ], - [ 'any', '0.0.0.0' ], - [-809041407, '207.199.2.1'], - [3485925889, '207.199.2.1'], -); - -@m = ( - [ 0, '0.0.0.0' ], - [ 1, '128.0.0.0' ], - [ 2, '192.0.0.0' ], - [ 4, '240.0.0.0' ], - [ 8, '255.0.0.0' ], - [ 16, '255.255.0.0' ], - [ 17, '255.255.128.0' ], - [ 24, '255.255.255.0' ], - [ 'default', '0.0.0.0' ], - [ 32, '255.255.255.255' ], - [ 'host', '255.255.255.255' ], - [ 0xffffff00, '255.255.255.0' ], - [ '255.255.255.240', '255.255.255.240' ], - [ '255.255.128.0', '255.255.128.0' ], - [ $binword, '255.255.0.0' ], -); - -plan tests => (4 * scalar @a * scalar @m) + 4; - -ok(! defined NetAddr::IP->new('256.1.1.1'), "Invalid IP returns undef"); -ok(! defined NetAddr::IP->new('256.256.1.1'), "Invalid IP returns undef"); -ok(! defined NetAddr::IP->new('256.256.256.1'), "Invalid IP returns undef"); -ok(! defined NetAddr::IP->new('256.256.256.256'), "Invalid IP returns undef"); - -for my $a (@a) { - for my $m (@m) { - my $ip = new NetAddr::IP $a->[0], $m->[0]; - SKIP: - { - skip "Failed to make an object for $a->[0]/$m->[0]", 4 - unless defined $ip; - is($ip->addr, $a->[1], "$a->[0] / $m->[0] is $a->[1]"); - is($ip->mask, $m->[1], "$a->[0] / $m->[0] is $m->[1]"); - is($ip->bits, 32, "$a->[0] / $m->[0] is 32 bits wide"); - is($ip->version, 4, "$a->[0] / $m->[0] is version 4"); - }; - } -} - diff --git a/t/v4-numeric.t b/t/v4-numeric.t deleted file mode 100644 index d7e8a6f..0000000 --- a/t/v4-numeric.t +++ /dev/null @@ -1,38 +0,0 @@ -use NetAddr::IP; - -# $Id: v4-numeric.t,v 1.2 2002/10/31 04:30:36 lem Exp $ - -my $nets = { - '10.0.0.0/20' => [ 167772160, 4294963200 ], - '10.0.15.0/24' => [ 167776000, 4294967040 ], - '192.168.0.0/24' => [ 3232235520, 4294967040], - 'broadcast' => [ 4294967295, 4294967295], - 'default' => [ 0, 0 ], -}; - -$| = 1; -print "1..", 4 * (scalar keys %$nets), "\n"; - -my $count = 1; - -for my $a (keys %$nets) { - my $ip = new NetAddr::IP $a; - my ($addr, $mask) = $ip->numeric; - - my $nip = new NetAddr::IP $addr, $mask; - - print '', ($nip ? '' : 'not '), 'ok ', $count++, "\n"; - - print '', ($nip and $nip->cidr eq $ip->cidr) ? '' : 'not ', - 'ok ', $count ++, "\n"; - - print '', (($addr != $nets->{$a}->[0] ? 'not ' : ''), - "ok ", $count++, "\n"); - - print '', (($mask != $nets->{$a}->[1] ? 'not ' : ''), - "ok ", $count++, "\n"); - - -} - - diff --git a/t/v4-range.t b/t/v4-range.t deleted file mode 100644 index 14af22f..0000000 --- a/t/v4-range.t +++ /dev/null @@ -1,50 +0,0 @@ -use NetAddr::IP; - -use Test::More; - -# $Id: v4-range.t,v 1.3 2003/11/27 20:04:02 lem Exp $ - -my @ranges = ( - [ '10.0.0.0/8', '10.0.0.0', '10.255.255.255' ], - [ '192.168.0.0/16', '192.168.0.0', '192.168.255.255' ], - ); - -my @weird = ( - [ '128.111.12.0', '128.111.12.129' ], - ); - -plan tests => 6 * @ranges + 2 * @weird + 28; - -for my $r (@ranges) { - my $r1 = new NetAddr::IP $r->[1] . '-' . $r->[2]; - isa_ok($r1, 'NetAddr::IP'); - is($r1, $r->[0], "Correct interpretation (with space)"); - - $r1 = new NetAddr::IP $r->[1] . ' - ' . $r->[2]; - isa_ok($r1, 'NetAddr::IP'); - is($r1, $r->[0], "Correct interpretation (w/o space)"); - - $r1 = new NetAddr::IP $r->[0]; - isa_ok($r1, 'NetAddr::IP'); - is($r1->range, $r->[1] . ' - ' . $r->[2], "Correct reverse"); -} - -for my $r (@weird) -{ - my $r1 = new NetAddr::IP $r->[0] . '-' . $r->[1]; - ok(! defined $r1, "Weird range w/o space produces undef"); - $r1 = new NetAddr::IP $r->[0] . ' - ' . $r->[1]; - ok(! defined $r1, "Weird range with space produces undef"); -} - -for my $o (254, 252, 248, 240, 224, 192, 128) -{ - my $r1 = new NetAddr::IP '0.0.0.0 - ' . $o . '.0.0.0'; - ok(! defined $r1, "Weird $o range, first octet"); - $r1 = new NetAddr::IP '0.0.0.0 - 0.' . $o . '.0.0'; - ok(! defined $r1, "Weird $o range, second octet"); - $r1 = new NetAddr::IP '0.0.0.0 - 0.0.' . $o . '.0'; - ok(! defined $r1, "Weird $o range, third octet"); - $r1 = new NetAddr::IP '0.0.0.0 - 0.0.0.' . $o; - ok(! defined $r1, "Weird $o range, fourth octet"); -} diff --git a/t/v4-re.t b/t/v4-re.t index 6c4f90d..1ee1862 100644 --- a/t/v4-re.t +++ b/t/v4-re.t @@ -1,6 +1,6 @@ use Test::More; -# $Id: v4-re.t,v 1.1 2005/03/24 20:41:51 lem Exp $ +# $Id: v4-re.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @ips = qw! 10.11.12.13 diff --git a/t/v4-snew.t b/t/v4-snew.t deleted file mode 100644 index 36e46f8..0000000 --- a/t/v4-snew.t +++ /dev/null @@ -1,31 +0,0 @@ -use Test::More; -use NetAddr::IP; - -# $Id: v4-snew.t,v 1.3 2003/05/29 17:45:00 lem Exp $ - -my %w = ('broadcast' => [ '255.255.255.255', '255.255.255.255' ], - 'default' => [ '0.0.0.0', '0.0.0.0' ], - 'loopback' => [ '127.0.0.1', '255.0.0.0' ], - '10.' => [ '10.0.0.0', '255.0.0.0' ], - '10/8' => [ '10.0.0.0', '255.0.0.0' ], - '127/8' => [ '127.0.0.0', '255.0.0.0' ], - '11.11.' => [ '11.11.0.0', '255.255.0.0' ], - '12.12.12.' => [ '12.12.12.0', '255.255.255.0' ], - '13.13.13.13' => [ '13.13.13.13', '255.255.255.255' ], - '0-127' => [ '0.0.0.0', '128.0.0.0' ], - '128-255' => [ '128.0.0.0', '128.0.0.0' ], - '0-63' => [ '0.0.0.0', '192.0.0.0' ], - '128-191' => [ '128.0.0.0', '192.0.0.0' ], - '10.128.0-127' => [ '10.128.0.0', '255.255.128.0' ], - '10.10.10/24' => [ '10.10.10.0', '255.255.255.0' ], - '10.10/16' => [ '10.10.0.0', '255.255.0.0' ], - '10.10.10' => [ '10.10.0.10', '255.255.255.255' ], - ); - -plan tests => 2 * scalar keys %w; - -for my $a (keys %w) { - my $ip = new NetAddr::IP $a; - is($ip->addr, $w{$a}->[0], "Matching ->addr()"); - is($ip->mask, $w{$a}->[1], "Matching ->mask()"); -} diff --git a/t/v4-split-bulk.t b/t/v4-split-bulk.t index f4554be..c0bb650 100644 --- a/t/v4-split-bulk.t +++ b/t/v4-split-bulk.t @@ -1,7 +1,7 @@ use Test::More; use NetAddr::IP; -# $Id: v4-split-bulk.t,v 1.3 2003/10/08 06:46:02 lem Exp $ +# $Id: v4-split-bulk.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @addr = ( [ '10.0.0.0', 20, 32, 4096 ], [ '10.0.0.0', 22, 32, 1024 ], diff --git a/t/v4-split-list.t b/t/v4-split-list.t index 64817a2..75d865c 100644 --- a/t/v4-split-list.t +++ b/t/v4-split-list.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: v4-split-list.t,v 1.2 2002/10/31 04:30:37 lem Exp $ +# $Id: v4-split-list.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my %addr = ( '10.0.0.10' => [ '255.255.252.0', 24, diff --git a/t/v4-sprefix.t b/t/v4-sprefix.t index eabdf6a..b130aeb 100644 --- a/t/v4-sprefix.t +++ b/t/v4-sprefix.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: v4-sprefix.t,v 1.2 2002/10/31 04:30:37 lem Exp $ +# $Id: v4-sprefix.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @addr = ( [ '10.', '10.0.0.0/8' ], diff --git a/t/v4-wnew.t b/t/v4-wnew.t deleted file mode 100644 index 710ca0a..0000000 --- a/t/v4-wnew.t +++ /dev/null @@ -1,21 +0,0 @@ -use Test::More tests => 12; -use NetAddr::IP; - -my @good = (qw(default any broadcast loopback)); -my @bad = map { ("$_.neveranydomainlikethis", - "nohostlikethis.$_") } @good; - -ok(defined NetAddr::IP->new($_), "defined ->new($_)") - for @good; - -my $bad = scalar @bad; - -diag <new($_), "not defined ->new($_)") - for @bad; - diff --git a/t/v4-xprefix.t b/t/v4-xprefix.t index f1ac9ed..6978ace 100644 --- a/t/v4-xprefix.t +++ b/t/v4-xprefix.t @@ -1,6 +1,6 @@ use NetAddr::IP; -# $Id: v4-xprefix.t,v 1.2 2002/10/31 04:30:37 lem Exp $ +# $Id: v4-xprefix.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @addr = ( [ '0.0.0.0/1', '0-127' ], diff --git a/t/v6-contains.t b/t/v6-contains.t deleted file mode 100644 index c1e1573..0000000 --- a/t/v6-contains.t +++ /dev/null @@ -1,53 +0,0 @@ -use NetAddr::IP; -use Test::More; - -# $Id: v6-contains.t,v 1.2 2004/02/23 22:38:28 lem Exp $ - -my @yes_pairs = - ( - [ '::/0', '2001:620:0:4:a00:20ff:fe9c:7e4a' ], - [ '3ffe:2000:0:4::/64', '3ffe:2000:0:4:a00:20ff:fe9c:7e4a' ], - [ '3ffe:2000:0:4::/64', '3ffe:2000:0:4:a00:20ff:fe9c:7e4a/65' ], - [ '2001:620:0:4::/64', '2001:620:0:4:a00:20ff:fe9c:7e4a' ], - [ '2001:620:0:4::/64', '2001:620:0:4:a00:20ff:fe9c:7e4a/65' ], - [ '2001:620:0:4::/64', '2001:620:0:4::1' ], - [ '2001:620:0:4::/64', '2001:620:0:4:0:0:0:1' ], - [ 'deaf:beef::/32', 'deaf:beef::1' ], - [ 'deaf:beef::/32', 'deaf:beef::1:1' ], - [ 'deaf:beef::/32', 'deaf:beef::1:0:1' ], - [ 'deaf:beef::/32', 'deaf:beef::1:0:0:1' ], - [ 'deaf:beef::/32', 'deaf:beef::1:0:0:0:1' ], - ); - -my @no_pairs = - ( - [ '3ffe:2000:0:4::/64', '3ffe:2000:0:4:a00:20ff:fe9c:7e4a/63' ], - [ '2001:620:0:4::/64', '2001:620:0:4:a00:20ff:fe9c:7e4a/63' ], - [ 'deaf:beef::/32', 'dead:cafe::1' ], - [ 'deaf:beef::/32', 'dead:cafe::1:1' ], - [ 'deaf:beef::/32', 'dead:cafe::1:0:1' ], - [ 'deaf:beef::/32', 'dead:cafe::1:0:0:1' ], - [ 'deaf:beef::/32', 'dead:cafe::1:0:0:0:1' ], - ); - -my $tests = 6 * @yes_pairs + 1; -plan tests => $tests; - -ok(NetAddr::IP->new('::')->contains(NetAddr::IP->new('::')), - ":: contains itself"); - -for my $p (@yes_pairs) -{ - my $a = new NetAddr::IP $p->[0]; - my $b = new NetAddr::IP $p->[1]; - - isa_ok($a, 'NetAddr::IP', "$p->[0]"); - isa_ok($b, 'NetAddr::IP', "$p->[1]"); - - SKIP: { - ok($a->contains($b), "->contains $p->[0], $p->[1] is true"); - ok($b->within($a), "->within $p->[1], $p->[0] is true"); - ok(!$b->contains($a), "->contains $p->[1], $p->[0] is false"); - ok(!$a->within($b), "->within $p->[0], $p->[1] is false"); - } -} diff --git a/t/v6-inc.t b/t/v6-inc.t deleted file mode 100644 index a716b23..0000000 --- a/t/v6-inc.t +++ /dev/null @@ -1,38 +0,0 @@ -use Test::More; -use NetAddr::IP; - -# Test ++ in IPv6 addresses (Bug rt.cpan.org #7070 by a guest) - -@ip = (NetAddr::IP->new('2001:468:ff:fffe::2/64'), - NetAddr::IP->new('2001:468:ff:fffe::2/64'), - NetAddr::IP->new('2001:468:ff:fffe::2/64')); - -$ip[1] ++; -$ip[2] ++; $ip[2] ++; - -plan tests => 11; - -# Test correct v6 creation -isa_ok($_, 'NetAddr::IP') for @ip; - -# Test that we did actually do something -diag "$ip[0] -- $ip[1]" - unless ok($ip[0] != $ip[1], "Auto incremented once differ"); -diag "$ip[0] -- $ip[2]" - unless ok($ip[0] != $ip[2], "Auto incremented twice differ"); -diag "$ip[1] -- $ip[2]" - unless ok($ip[1] != $ip[2], "Auto incremented two times differ"); - -# Test that what we did is correct -is($ip[1], $ip[0] + 1, "Test of first auto-increment"); -is($ip[2], $ip[0] + 2, "Test of second auto-increment"); - -# Now test auto-decrement - -$ip[1] --; -$ip[2] --; $ip[2] --; - -is($ip[0], $ip[1], "Decrement of decrement once is ok"); -is($ip[0], $ip[2], "Decrement of decrement twice is ok"); -is($ip[1], $ip[2], "Third case"); - diff --git a/t/v6-numeric.t b/t/v6-numeric.t deleted file mode 100644 index e7d90f3..0000000 --- a/t/v6-numeric.t +++ /dev/null @@ -1,93 +0,0 @@ -use NetAddr::IP; -use Test::More; - -# $Id: v6-numeric.t,v 1.2 2004/03/02 20:33:37 lem Exp $ - -my @pairs = - ( - [ '::/0', '0', '0' ], - [ '::/128', '0', '340282366920938463463374607431768211455' ], - [ 'cafe:cafe::/64', - '269827015721314068804783158349174669312', - '340282366920938463444927863358058659840' ], - [ 'cafe:cafe::1/64', - '269827015721314068804783158349174669313', - '340282366920938463444927863358058659840' ], - [ 'dead:beef::/100', - '295990755014133383690938178081940045824', - '340282366920938463463374607431499776000' ], - [ 'dead:beef::1/100', - '295990755014133383690938178081940045825', - '340282366920938463463374607431499776000' ], - ); - -my @scale = -qw( - 0000:0000:0000:0000:0000:0000:0000:0000 - 0000:0000:0000:0000:0000:0000:0000:0001 - 0000:0000:0000:0000:0000:0000:0000:0010 - 0000:0000:0000:0000:0000:0000:0000:0100 - 0000:0000:0000:0000:0000:0000:0000:1000 - 0000:0000:0000:0000:0000:0000:0001:0000 - 0000:0000:0000:0000:0000:0001:0000:0000 - 0000:0000:0000:0000:0000:0010:0000:0000 - 0000:0000:0000:0000:0000:0100:0000:0000 - 0000:0000:0000:0000:0000:1000:0000:0000 - 0000:0000:0000:0000:0001:0000:0000:0000 - 0000:0000:0000:0001:0000:0000:0000:0000 - 0000:0000:0000:0010:0000:0000:0000:0000 - 0000:0000:0000:0100:0000:0000:0000:0000 - 0000:0000:0000:1000:0000:0000:0000:0000 - 0000:0000:0001:0000:0000:0000:0000:0000 - 0000:0001:0000:0000:0000:0000:0000:0000 - 0000:0010:0000:0000:0000:0000:0000:0000 - 0000:0100:0000:0000:0000:0000:0000:0000 - 0000:1000:0000:0000:0000:0000:0000:0000 - 0001:0000:0000:0000:0000:0000:0000:0000 - 0010:0000:0000:0000:0000:0000:0000:0000 - 0100:0000:0000:0000:0000:0000:0000:0000 - 1000:0000:0000:0000:0000:0000:0000:0000 - ); - -my $tests = 4 * @pairs + @scale ** 2; -plan tests => $tests; - -for my $p (@pairs) -{ - my $a = new NetAddr::IP $p->[0]; - isa_ok($a, 'NetAddr::IP', "$p->[0]"); - is($a->numeric, $p->[1], "$p->[0] Scalar numeric ok"); - is(($a->numeric)[0], $p->[1], "$p->[0] Array numeric ok for network"); - is(($a->numeric)[1], $p->[2], "$p->[0] Array numeric ok for mask"); -} - -@ip_scale = map { new NetAddr::IP $_ } @scale; - -isa_ok($_, 'NetAddr::IP', $_->addr) for @ip_scale; - -for my $i (0 .. $#ip_scale) -{ - for my $l (0 .. $i - 1) - { - next if $l >= $i; - unless (ok($ip_scale[$i]->numeric > $ip_scale[$l]->numeric, - "[$i, $l] $scale[$i] > $scale[$l]")) - { - diag "assertion [$i]: " . $ip_scale[$i]->numeric . - " > " . $ip_scale[$l]->numeric; - } - } - - next if $i == $#ip_scale; - - for my $l ($i + 1 .. $#ip_scale) - { - next if $l <= $i; - unless (ok($ip_scale[$i]->numeric < $ip_scale[$l]->numeric, - "[$i, $l] $scale[$i] < $scale[$l]")) - { - diag "assertion [$i]: " . $ip_scale[$i]->numeric . - " < " . $ip_scale[$l]->numeric; - } - } -} diff --git a/t/v6-split-bulk.t b/t/v6-split-bulk.t index 72e298b..49dad4f 100644 --- a/t/v6-split-bulk.t +++ b/t/v6-split-bulk.t @@ -1,7 +1,7 @@ use Test::More; use NetAddr::IP; -# $Id: v6-split-bulk.t,v 1.3 2003/10/10 17:51:32 lem Exp $ +# $Id: v6-split-bulk.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ my @addr = ( [ 'dead:beef::1', 126, 127, 2 ],