Hi list,

There's one module of mine that I though I could upload on CPAN. But I've still got some open questions about its usefulness and the like.

So, few words about what it is and why it is so.
My task was to track ranges of available IP addresses (IPv6 as well as IPv4), to print reports (which addresses are free, which aren't), to be able to grab one free IP and so on. I couldn't find any suitable module (btw, is there any?), so I decided to implement one.

Here's the module's synopsis:

=head1 SYNOPSIS

    use Net::IP::Range ":iterators";

    # Initialization

    my $range = Net::IP::Range->new( cidr => '192.168.10.0/24' );
    # or ...
    $range = Net::IP::Range->new( cidr => 'dead:beaf:aa:bb::/64' );
    # or ...
$range = Net::IP::Range->new( network => '127.0.0.0', netmask => '255.0.0.0' );


    # Range info

    print "Max addr: ", $range->max_addr;
    print "Min addr: ", $range->min_addr;
    print "Range size: ", $range->size;
    print "Free address number: ", $range->free_addrs;


    # Free address management

    # 1. populate range

    while( ($ip, $hostname) = each %ips_from_a_storage ) {
        $range->occupy( $ip, $hostname );
    }

    # .. and perhaps later ...

    $range->free($some_ip);

    # 2. inspect free/busy addresses if needed

    $it = $range->iterator(ITER_FREE);
    print "Free addresses:\n";
    while ( $subrange = $it->next ) {
        # $subrange is another Net::IP::Range instance
        print "\t", $subrange->min_addr, "-" , $subrange->max_addr, "\n";
    }

    $it = $range->iterator(ITER_OCCUPIED);
    print "Occupied addresses:\n";
    while ( my ($ip, $host) = $it->next ) {
        # $ip is Net::IP instance
        print "\t $ip - $host->[1]\n";
    }

    # 3. allocate one free IP
    $ip = $range->allocate_ip( $hostname );


So, the questions are:

1. Does that module have a right to exists or its completely useles (perhaps because there's a bunch of similar modules that I didn't find)?
 2. Should it be renamed to something that describes it better?
3. Does its interface have to be rewrited somehow or is it okay the way it is?

--
BR,
Evgeniy Kosov


Reply via email to