line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- mode: coding: utf-8; -*- |
2
|
|
|
|
|
|
|
package Net::IP::Match::Trie; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
44
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
330
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01_01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require XSLoader; |
10
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
0
|
2
|
my($class, %opt) = @_; |
14
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
15
|
1
|
|
|
|
|
10
|
$self->_initialize(); |
16
|
1
|
|
|
|
|
2
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# name => [ cidr1, cidr2, ... ] |
20
|
|
|
|
|
|
|
sub add { |
21
|
4
|
|
|
4
|
1
|
19
|
my($self, $name, $cidrs) = @_; |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
5
|
for my $cidr (@$cidrs) { |
24
|
6
|
|
|
|
|
11
|
my($network, $netmask) = split m{/}, $cidr; |
25
|
6
|
|
50
|
|
|
8
|
$netmask ||= 32; |
26
|
6
|
|
|
|
|
1944
|
$self->_add($name, $network, $netmask); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub impl { |
31
|
1
|
|
|
1
|
0
|
6
|
my($self) = @_; |
32
|
1
|
|
|
|
|
4
|
return "XS"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |