Michael Shipper > Net-IP-RangeCompare-4.025 > Net::IP::RangeCompare

Download:
Net-IP-RangeCompare-4.025.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 4.025   Source  

NAME ^

Net::IP::RangeCompare - Perl extension for IP Range Comparisons

SYNOPSIS ^

  use Net::IP::RangeCompare;
  my $obj=Net::IP::RangeCompare::Simple->new;

  $obj->add_range('Tom','10.0.0.2 - 10.0.0.11');
  $obj->add_range('Tom','10.0.0.32 - 10.0.0.66');
  $obj->add_range('Tom','11/32');

  $obj->add_range('Sally','10.0.0.7 - 10.0.0.12');
  $obj->add_range('Sally','172.16/255.255.255');

  $obj->add_range('Harry','192.168.2');
  $obj->add_range('Harry','10.0.0.128/30');

  $obj->compare_ranges; # optional

        while(my ($common,%row)=$obj->get_row) {
                print "\nCommon Range: ",$common,"\n";
                my $tom=$row{Tom};
                my $sally=$row{Sally};
                my $harry=$row{Harry};
                print "Tom: ",$tom
                        ,' '
                        ,($tom->missing ? 'not used' : 'in use')
                        ,"\n";

                print "Sally: ",$sally
                        ,' '
                        , ($sally->missing ? 'not used' : 'in use')
                        ,"\n";

                print "Harry: ",$harry,
                        ' '
                        ,($harry->missing ? 'not used' : 'in use')
                        ,"\n";
        }


  Output: 

  Common Range: 10.0.0.2 - 10.0.0.6
  Tom: 10.0.0.2 - 10.0.0.11 in use
  Sally: 10.0.0.2 - 10.0.0.6 not used
  Harry: 10.0.0.2 - 10.0.0.127 not used

  Common Range: 10.0.0.7 - 10.0.0.11
  Tom: 10.0.0.2 - 10.0.0.11 in use
  Sally: 10.0.0.7 - 10.0.0.12 in use
  Harry: 10.0.0.2 - 10.0.0.127 not used

  Common Range: 10.0.0.12 - 10.0.0.12
  Tom: 10.0.0.12 - 10.0.0.31 not used
  Sally: 10.0.0.7 - 10.0.0.12 in use
  Harry: 10.0.0.2 - 10.0.0.127 not used

  Common Range: 10.0.0.32 - 10.0.0.66
  Tom: 10.0.0.32 - 10.0.0.66 in use
  Sally: 10.0.0.13 - 172.15.255.255 not used
  Harry: 10.0.0.2 - 10.0.0.127 not used

  Common Range: 10.0.0.128 - 10.0.0.131
  Tom: 10.0.0.67 - 10.255.255.255 not used
  Sally: 10.0.0.13 - 172.15.255.255 not used
  Harry: 10.0.0.128 - 10.0.0.131 in use

  Common Range: 11.0.0.0 - 11.0.0.0
  Tom: 11.0.0.0 - 11.0.0.0 in use
  Sally: 10.0.0.13 - 172.15.255.255 not used
  Harry: 10.0.0.132 - 192.168.1.255 not used

  Common Range: 172.16.0.0 - 172.16.0.255
  Tom: 11.0.0.1 - 192.168.2.0 not used
  Sally: 172.16.0.0 - 172.16.0.255 in use
  Harry: 10.0.0.132 - 192.168.1.255 not used

  Common Range: 172.16.1.0 - 192.168.1.255
  Tom: 11.0.0.1 - 192.168.2.0 not used
  Sally: 172.16.1.0 - 192.168.2.0 not used
  Harry: 10.0.0.132 - 192.168.1.255 not used

  Common Range: 192.168.2.0 - 192.168.2.0
  Tom: 11.0.0.1 - 192.168.2.0 not used
  Sally: 172.16.1.0 - 192.168.2.0 not used
  Harry: 192.168.2.0 - 192.168.2.0 in use

DESCRIPTION ^

Fast scalable ip range aggregation and summary tool kit. Find intersections across multiple lists of IP ranges, fast.

Although similar in functionality to Net::CIDR::Compare, Net::Netmask and NetAddr::IP, Net::IP::RangeCompare is a completely range driven ip management and evaluation tool allowing more flexibility and scalability when dealing with the somewhat organic nature of IP-Ranges.

If you have a large number of ipv4 ranges and need to inventory lists of ranges for intersections, this is the Module for you!

Export list

Net::IP::RangeCompare does not export anything by default. The functions listed in this section can be imported by using the standard import syntax.

Import example:

  use Net::IP::RangeCompare qw(consolidate_ranges sort_ranges);

To import all functions:

  use Net::IP::RangeCompare qw(:ALL);

Helper functions :HELPER

  use Net::IP::RangeCompare qw(:HELPER);

  Imports the following:

          hostmask
          ip_to_int
          int_to_ip
          cidr_to_int
          size_from_mask 
          base_int 
          broadcast_int 
          cmp_int
          sort_quad
          sort_notations
          add_one
          sub_one

Overlap functions :OVERLAP

  use Net::IP::RangeCompare qw(:OVERLAP);

  Imports the following:

          get_common_range
          get_overlapping_range
          grep_overlap
          grep_non_overlap

Sort Functions :SORT

  use Net::IP::RangeCompare qw(:SORT);

  Imports the following:

          sort_ranges
          sort_largest_first_int_first
          sort_smallest_last_int_first
          sort_largest_last_int_first
          sort_smallest_first_int_first

Range processing functions :PROCESS

  use Net::IP::RangeCompare qw(:PROCESS);

  Imports the following:

          consolidate_ranges
          fill_missing_ranges
          range_start_end_fill
          range_compare
          compare_row
          range_compare_force_cidr

OO Methods

This section defines the OO interfaces.

Helper functions

Overlap functions

This section documents the functions used to find and compute range overlaps.

Sort Functions

This section describes the order in wich each function sorts a list of Net::IP::RangeCompare objects.

All functions in this section use the following syntax modle

Example: my @list=sort sort_largest_last_int_first @netiprangecomapre_objects;

Net::IP::RangeCompare list processing functions

This section covers how to use the list and list of lists processing functions that do the actual comparison work.

Net::IP::RangeCompare::Simple ^

Helper Class that wraps the features of Net::IP::RangeCompare into a single easy to use OO instance.

DEPENDENCIES ^

Intersection computations are handled by: Data::Range::Compare

IPV4 computations are handled by: Data::IPV4::Range::Parse

Source Forge Project ^

If you find this software useful and wish to donate please see the project website.

Net IP Range Compare

AUTHOR ^

Michael Shipper

COPYRIGHT ^

Copyright 2010 Michael Shipper. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

Carp Data::IPV4::Range::Parse Data::Range::Compare

syntax highlighting: