NAME
Net::IP::Match::Bin - Perl extension for match IP addresses against Net ranges
SYNOPSIS
use Net::IP::Match::Bin;
my $ipm = Net::IP::Match::Bin->new();
$ipm->add("10.1.1.0/25", ...);
...
$ipm->add("192.168.2.128/26", ...);
$cidr = $ipm->match_ip("192.168.2.131");
DESCRIPTION
This module is XS implementation of matching IP addresses against Net ranges. Using similar method to Net::IP::Match::Regexp in storing Net ranges into memory. By implementing in XS C-code, and does not use regexp, more fast setup time and less using memory. This module is useful when Net ranges change often or reusing range data won't be suitable.
METHODS
- new()
-
Create IP range object and initialize it.
- $ipm->add( $net | $arrayref | $hashref, ... )
-
Add Network address (xxx.xxx.xxx.xxx/mask) into the object. mask is 1 .. 32 CIDR mask bit value.
$ipm->add( [ "10.1.0.0/16", "10.2.2.128/25", "192.168.0.0/27" ] ); $ipm->add( { "10.1.0.0/17" => "Net A", "10.2.2.0/24" => "Net B", "192.168.0.0/27" => "Net X" } ); When HASH ref is used as arguments, match_ip() returns the value when matched.
- $cidr = $ipm->match_ip( $ip )
-
Searches matching $ip against previously setup networks. Returns matched Network in CIDR format (xxx.xxx.xxx.xxx/mask). or undef unless matched.
SEE ALSO
Net::IP::Match::Regexp
AUTHOR
Tomo, <tomo at c-wind com>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Tomo
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.