Import isInNet6 in Safelib (#1201)

This commit is contained in:
Xavier Guimard 2017-03-17 16:31:17 +00:00
parent 0b4fd5f497
commit 760e7e2859

View File

@ -8,6 +8,7 @@ package Lemonldap::NG::Common::Safelib;
use strict;
use Encode;
use MIME::Base64;
use Lemonldap::NG::Common::IPv6;
#use AutoLoader qw(AUTOLOAD);
@ -17,7 +18,7 @@ our $VERSION = '2.0.0';
# Not that only functions, not methods, can be written here
our $functions =
[
qw(&checkLogonHours &date &checkDate &basic &unicode2iso &iso2unicode &groupMatch)
qw(&checkLogonHours &date &checkDate &basic &unicode2iso &iso2unicode &groupMatch &isInNet6)
];
## @function boolean checkLogonHours(string logon_hours, string syntax, string time_correction, boolean default_access)
@ -179,4 +180,11 @@ sub groupMatch {
return $match;
}
sub isInNet6 {
my ( $ip, $net ) = @_;
$net =~ s#/(\d+)##;
my $bits = $1;
return net6( $ip, $bits ) eq net6( $net, $bits ) ? 1 : 0;
}
1;