Import of MIKER/NetAddr-IP-4.059 from CPAN.
gitpan-cpan-distribution: NetAddr-IP
gitpan-cpan-version:      4.059
gitpan-cpan-path:         MIKER/NetAddr-IP-4.059.tar.gz
gitpan-cpan-author:       MIKER
gitpan-cpan-maturity:     released
1 parent 3605ada commit 50fcc01e06f001bf734423b0fc378a5612420d11
@Michael Robinton Michael Robinton authored on 7 Mar 2012
Gitpan committed on 21 Oct 2014
Showing 12 changed files
View
7
Changes
Revision history for Perl extension NetAddr::IP
 
4.059 Wed Mar 7 12:50:04 PST 2012
add is_rfc1918 to Lite.pm v1.42
 
documentation updates
 
4.058 Fri Nov 11 19:23:11 PST 2011
up rev for documentation update
update documentation in InetBase v0.06
Thanks to Mark Martinec and Steve Huff (SHUFF) * shuff@cpan.org
for spotting and replicating that bug
 
added new_cis and new_cis6 to Lite.pm v1.21 to accomodate
Cisco syntax that has IP and MASK seperated by a space.
Cisco syntax that has IP and MASK separated by a space.
 
Updated typo in documentation that left out example
print new6 stuff
 
View
34
IP.pm
package NetAddr::IP;
 
use strict;
#use diagnostics;
use NetAddr::IP::Lite 1.41 qw(Zero Zeros Ones V4mask V4net);
use NetAddr::IP::Lite 1.42 qw(Zero Zeros Ones V4mask V4net);
use NetAddr::IP::Util 1.46 qw(
sub128
inet_aton
inet_any2n
@EXPORT_FAIL = qw($_netlimit);
 
@ISA = qw(Exporter NetAddr::IP::Lite);
 
$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.58 $ =~ /\d+/g) };
$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.59 $ =~ /\d+/g) };
 
=pod
 
=head1 NAME
 
See L<NetAddr::IP::Util>
 
 
my $ip = new NetAddr::IP::Lite '127.0.0.1';
my $ip = new NetAddr::IP '127.0.0.1';
or if your prefer
my $ip = NetAddr::IP::Lite->new('127.0.0.1);
my $ip = NetAddr::IP->new('127.0.0.1);
or from a packed IPv4 address
my $ip = new_from_aton NetAddr::IP::Lite (inet_aton('127.0.0.1'));
my $ip = new_from_aton NetAddr::IP (inet_aton('127.0.0.1'));
or from an octal filtered IPv4 address
my $ip = new_no NetAddr::IP::Lite '127.012.0.0';
my $ip = new_no NetAddr::IP '127.012.0.0';
 
print "The address is ", $ip->addr, " with mask ", $ip->mask, "\n" ;
 
if ($ip->within(new NetAddr::IP "127.0.0.0", "255.0.0.0")) {
=head1 DESCRIPTION
 
This module provides an object-oriented abstraction on top of IP
addresses or IP subnets, that allows for easy manipulations.
Version 4.xx of NetAdder::IP will will work with older
Version 4.xx of NetAdder::IP will work with older
versions of Perl and is compatible with Math::BigInt.
 
The internal representation of all IP objects is in 128 bit IPv6 notation.
IPv4 and IPv6 objects may be freely mixed.
Add a 32 bit signed constant to the address part of a NetAddr object.
This operation changes the address part to point so many hosts above the
current objects start address. For instance, this code:
 
print NetAddr::IP::Lite->new('127.0.0.1/8') + 5;
print NetAddr::IP->new('127.0.0.1/8') + 5;
 
will output 127.0.0.6/8. The address will wrap around at the broadcast
back to the network address. This code:
 
print NetAddr::IP::Lite->new('10.0.0.1/24') + 255;
print NetAddr::IP->new('10.0.0.1/24') + 255;
 
outputs 10.0.0.0/24.
 
Returns the the unchanged object when the constant is missing or out of
The complement of the addition of a constant.
 
=item B<Difference (C<->)>
 
Returns the difference between the address parts of two NetAddr::IP::Lite
Returns the difference between the address parts of two NetAddr::IP
objects address parts as a 32 bit signed number.
 
Returns B<undef> if the difference is out of range.
 
=item C<-E<gt>bigint()>
 
When called in scalar context, will return a Math::BigInt
representation of the address part of the IP address. When called in
an array context, it returns a list of tow elements, The first
an array context, it returns a list of two elements, The first
element is as described, the second element is the Math::BigInt
representation of the netmask.
 
=item C<-E<gt>wildcard()>
The complement of C<-E<gt>contains()>. Returns true when C<$me> is
completely contained within C<$other>.
 
Note that C<$me> and C<$other> must be C<NetAddr::IP> objects.
 
=item C-E<gt>is_rfc1918()>
 
Returns true when C<$me> is an RFC 1918 address.
 
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
 
=item C<-E<gt>splitref($bits,[optional $bits1,$bits2,...])>
 
Returns a reference to a list of objects, representing subnets of C<bits> mask
http://www.gnu.org/copyleft/gpl.html.
 
=head1 SEE ALSO
 
perl(1),NetAddr::IP::Lite, NetAddr::IP::Util.
perl(1) L<NetAddr::IP::Lite>, L<NetAddr::IP::Util>,
L<NetAddr::IP::InetBase>
 
=cut
 
1;
View
Lite/Changes
View
Lite/Lite.pm
View
Lite/MANIFEST
View
Lite/README
View
Lite/Util/Changes
View
Lite/Util/README
View
Lite/Util/Util.pm
View
Lite/t/rfc_1918.t 0 → 100644
View
MANIFEST
View
META.yml