Filename | /usr/local/lib/perl5/site_perl/mach/5.24/Net/Patricia.pm |
Statements | Executed 125 statements in 6.35ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 6.94ms | 7.46ms | BEGIN@108 | Net::Patricia::
1 | 1 | 1 | 2.63ms | 4.75ms | BEGIN@31 | Net::Patricia::
4 | 1 | 1 | 385µs | 755µs | add_string | Net::Patricia::
4 | 1 | 1 | 135µs | 221µs | add | Net::Patricia::AF_INET6::
4 | 1 | 1 | 112µs | 149µs | _ip_bits | Net::Patricia::
3 | 1 | 1 | 70µs | 119µs | new | Net::Patricia::
1 | 1 | 1 | 67µs | 67µs | bootstrap (xsub) | Net::Patricia::
4 | 1 | 1 | 55µs | 55µs | _add (xsub) | Net::Patricia::
3 | 1 | 1 | 49µs | 49µs | _new (xsub) | Net::Patricia::
1 | 1 | 1 | 47µs | 63µs | BEGIN@26 | Net::Patricia::
1 | 1 | 1 | 43µs | 43µs | BEGIN@152 | Net::Patricia::AF_INET::
1 | 1 | 1 | 42µs | 42µs | BEGIN@239 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 38µs | 38µs | BEGIN@36 | Net::Patricia::
4 | 1 | 1 | 36µs | 36µs | CORE:subst (opcode) | Net::Patricia::
1 | 1 | 1 | 32µs | 237µs | BEGIN@33 | Net::Patricia::
1 | 1 | 1 | 32µs | 238µs | BEGIN@32 | Net::Patricia::
1 | 1 | 1 | 32µs | 186µs | BEGIN@150 | Net::Patricia::AF_INET::
1 | 1 | 1 | 31µs | 200µs | BEGIN@236 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 30µs | 2.86ms | BEGIN@34 | Net::Patricia::
1 | 1 | 1 | 26µs | 196µs | BEGIN@149 | Net::Patricia::AF_INET::
1 | 1 | 1 | 26µs | 209µs | BEGIN@234 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 25µs | 243µs | BEGIN@148 | Net::Patricia::AF_INET::
1 | 1 | 1 | 23µs | 62µs | BEGIN@27 | Net::Patricia::
1 | 1 | 1 | 22µs | 147µs | BEGIN@235 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 21µs | 157µs | BEGIN@237 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 12µs | 12µs | CORE:match (opcode) | Net::Patricia::
0 | 0 | 0 | 0s | 0s | add_integer | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | exact | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | exact_integer | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | match | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | match_integer | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | remove | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | remove_integer | Net::Patricia::AF_INET6::
0 | 0 | 0 | 0s | 0s | add | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | add_integer | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | exact | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | exact_integer | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | match | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | match_integer | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | remove | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | remove_integer | Net::Patricia::AF_INET::
0 | 0 | 0 | 0s | 0s | add_cidr | Net::Patricia::
0 | 0 | 0 | 0s | 0s | match_exact_integer | Net::Patricia::
0 | 0 | 0 | 0s | 0s | match_exact_string | Net::Patricia::
0 | 0 | 0 | 0s | 0s | match_string | Net::Patricia::
0 | 0 | 0 | 0s | 0s | remove_cidr | Net::Patricia::
0 | 0 | 0 | 0s | 0s | remove_string | Net::Patricia::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # Net::Patricia - Patricia Trie perl module for fast IP address lookups | ||||
2 | # Copyright (C) 2000-2005 Dave Plonka | ||||
3 | # Copyright (C) 2009 Dave Plonka & Philip Prindeville | ||||
4 | # | ||||
5 | # This program is free software; you can redistribute it and/or modify | ||||
6 | # it under the terms of the GNU General Public License as published by | ||||
7 | # the Free Software Foundation; either version 2 of the License, or | ||||
8 | # (at your option) any later version. | ||||
9 | # | ||||
10 | # This program is distributed in the hope that it will be useful, | ||||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | # GNU General Public License for more details. | ||||
14 | # | ||||
15 | # You should have received a copy of the GNU General Public License | ||||
16 | # along with this program; if not, write to the Free Software | ||||
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||||
18 | # MA 02110-1301, USA. | ||||
19 | |||||
20 | # Dave Plonka <plonka@doit.wisc.edu> | ||||
21 | # Philip Prindeville <philipp@redfish-solutions.com> | ||||
22 | # Anton Berezin <tobez@tobez.org> | ||||
23 | |||||
24 | package Net::Patricia; | ||||
25 | |||||
26 | 2 | 74µs | 2 | 78µs | # spent 63µs (47+16) within Net::Patricia::BEGIN@26 which was called:
# once (47µs+16µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 26 # spent 63µs making 1 call to Net::Patricia::BEGIN@26
# spent 16µs making 1 call to strict::import |
27 | 2 | 90µs | 2 | 101µs | # spent 62µs (23+39) within Net::Patricia::BEGIN@27 which was called:
# once (23µs+39µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 27 # spent 62µs making 1 call to Net::Patricia::BEGIN@27
# spent 39µs making 1 call to warnings::import |
28 | |||||
29 | 1 | 40µs | require 5.008; | ||
30 | |||||
31 | 2 | 335µs | 2 | 4.85ms | # spent 4.75ms (2.63+2.11) within Net::Patricia::BEGIN@31 which was called:
# once (2.63ms+2.11ms) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 31 # spent 4.75ms making 1 call to Net::Patricia::BEGIN@31
# spent 108µs making 1 call to version::import |
32 | 2 | 98µs | 2 | 444µs | # spent 238µs (32+206) within Net::Patricia::BEGIN@32 which was called:
# once (32µs+206µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 32 # spent 238µs making 1 call to Net::Patricia::BEGIN@32
# spent 206µs making 1 call to Exporter::import |
33 | 2 | 72µs | 2 | 441µs | # spent 237µs (32+204) within Net::Patricia::BEGIN@33 which was called:
# once (32µs+204µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 33 # spent 237µs making 1 call to Net::Patricia::BEGIN@33
# spent 204µs making 1 call to vars::import |
34 | 2 | 127µs | 2 | 5.69ms | # spent 2.86ms (30µs+2.83) within Net::Patricia::BEGIN@34 which was called:
# once (30µs+2.83ms) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 34 # spent 2.86ms making 1 call to Net::Patricia::BEGIN@34
# spent 2.83ms making 1 call to Exporter::import |
35 | |||||
36 | # spent 38µs within Net::Patricia::BEGIN@36 which was called:
# once (38µs+0s) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 41 | ||||
37 | 1 | 6µs | require Exporter; | ||
38 | 1 | 2µs | require DynaLoader; | ||
39 | 1 | 20µs | @ISA = qw(Exporter DynaLoader); | ||
40 | 1 | 21µs | @EXPORT = qw(AF_INET AF_INET6); | ||
41 | 1 | 1.31ms | 1 | 38µs | } # spent 38µs making 1 call to Net::Patricia::BEGIN@36 |
42 | |||||
43 | 1 | 32µs | 1 | 12µs | '$Revision: 1.22 $' =~ m/(\d+)\.(\d+)((_\d+)|)/ && ( $VERSION = "$1.$2$3"); # spent 12µs making 1 call to Net::Patricia::CORE:match |
44 | |||||
45 | 1 | 20µs | 1 | 632µs | bootstrap Net::Patricia $VERSION; # spent 632µs making 1 call to DynaLoader::bootstrap |
46 | |||||
47 | # spent 119µs (70+49) within Net::Patricia::new which was called 3 times, avg 40µs/call:
# 3 times (70µs+49µs) by Mail::SpamAssassin::NetSet::new at line 55 of Mail/SpamAssassin/NetSet.pm, avg 40µs/call | ||||
48 | 3 | 6µs | my ($class, $type) = @_; | ||
49 | |||||
50 | 3 | 5µs | $type ||= AF_INET; | ||
51 | |||||
52 | 3 | 6µs | if ($type == AF_INET) { | ||
53 | return bless _new(32), 'Net::Patricia::AF_INET'; | ||||
54 | } | ||||
55 | |||||
56 | 3 | 6µs | if ($type == AF_INET6) { | ||
57 | 3 | 111µs | 3 | 49µs | return bless _new(128), 'Net::Patricia::AF_INET6'; # spent 49µs making 3 calls to Net::Patricia::_new, avg 16µs/call |
58 | } | ||||
59 | |||||
60 | croak "new: unimplemented type"; | ||||
61 | } | ||||
62 | |||||
63 | ## | ||||
64 | ## Compat functions | ||||
65 | ## | ||||
66 | |||||
67 | # spent 149µs (112+36) within Net::Patricia::_ip_bits which was called 4 times, avg 37µs/call:
# 4 times (112µs+36µs) by Net::Patricia::add_string at line 83, avg 37µs/call | ||||
68 | 4 | 8µs | my ($self, $str) = @_; | ||
69 | 4 | 7µs | my $bits; | ||
70 | |||||
71 | 4 | 28µs | if (ref ($self) eq 'Net::Patricia::AF_INET6') { | ||
72 | 4 | 83µs | 4 | 36µs | $bits = ($str =~ s|/(\d+)$||) ? $1 : 128; # spent 36µs making 4 calls to Net::Patricia::CORE:subst, avg 9µs/call |
73 | } else { | ||||
74 | $bits = ($str =~ s|/(\d+)$||) ? $1 : 32; | ||||
75 | } | ||||
76 | 4 | 305µs | ($str,$bits); | ||
77 | } | ||||
78 | |||||
79 | # spent 755µs (385+370) within Net::Patricia::add_string which was called 4 times, avg 189µs/call:
# 4 times (385µs+370µs) by Mail::SpamAssassin::NetSet::add_cidr at line 147 of Mail/SpamAssassin/NetSet.pm, avg 189µs/call | ||||
80 | 4 | 10µs | croak "add_string: wrong number of args" if (@_ < 2 || @_ > 3); | ||
81 | 4 | 9µs | my ($self,$str,$data) = @_; | ||
82 | 4 | 8µs | $data = $str unless @_ > 2; | ||
83 | 4 | 79µs | 8 | 370µs | $self->add($self->_ip_bits($str),$data); # spent 221µs making 4 calls to Net::Patricia::AF_INET6::add, avg 55µs/call
# spent 149µs making 4 calls to Net::Patricia::_ip_bits, avg 37µs/call |
84 | } | ||||
85 | |||||
86 | sub match_string { | ||||
87 | croak "match_string: wrong number of args" if (@_ != 2); | ||||
88 | my ($self,$str) = @_; | ||||
89 | $self->match($self->_ip_bits($str)) | ||||
90 | } | ||||
91 | |||||
92 | sub match_exact_string { | ||||
93 | croak "match_exact_string: wrong number of args" if (@_ != 2); | ||||
94 | my ($self,$str) = @_; | ||||
95 | $self->exact($self->_ip_bits($str)) | ||||
96 | } | ||||
97 | |||||
98 | sub match_exact_integer { | ||||
99 | shift->exact_integer(@_) | ||||
100 | } | ||||
101 | |||||
102 | sub remove_string { | ||||
103 | croak "remove_string: wrong number of args" if (@_ != 2); | ||||
104 | my ($self,$str) = @_; | ||||
105 | $self->remove($self->_ip_bits($str)) | ||||
106 | } | ||||
107 | |||||
108 | # spent 7.46ms (6.94+518µs) within Net::Patricia::BEGIN@108 which was called:
# once (6.94ms+518µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 140 | ||||
109 | 1 | 5µs | eval { | ||
110 | 1 | 2µs | my $class = 'Net::CIDR::Lite'; | ||
111 | 1 | 49µs | eval "require $class"; # spent 214µs executing statements in string eval | ||
112 | }; | ||||
113 | 1 | 13µs | last if (@_); | ||
114 | |||||
115 | sub add_cidr { | ||||
116 | croak "add_cidr: wrong number of args" if (@_ != 3); | ||||
117 | my ($self, $range, $data) = @_; | ||||
118 | my $cidr = Net::CIDR::Lite->new(); | ||||
119 | $cidr->add_range($range); | ||||
120 | |||||
121 | my @list = (); | ||||
122 | for ($cidr->list()) { | ||||
123 | push(@list, $_) if ($self->add_string($_, $data)); | ||||
124 | } | ||||
125 | @list; | ||||
126 | } | ||||
127 | |||||
128 | sub remove_cidr { | ||||
129 | croak "remove_cidr: wrong number of args" if (@_ != 2); | ||||
130 | my ($self, $range) = @_; | ||||
131 | my $cidr = Net::CIDR::Lite->new(); | ||||
132 | $cidr->add_range($range); | ||||
133 | |||||
134 | my @list = (); | ||||
135 | for ($cidr->list()) { | ||||
136 | push(@list, $_) if ($self->remove_string($_)); | ||||
137 | } | ||||
138 | @list; | ||||
139 | } | ||||
140 | 1 | 66µs | 1 | 7.46ms | } # spent 7.46ms making 1 call to Net::Patricia::BEGIN@108 |
141 | |||||
142 | ## | ||||
143 | ## AF_INET | ||||
144 | ## | ||||
145 | |||||
146 | package Net::Patricia::AF_INET; | ||||
147 | |||||
148 | 2 | 70µs | 2 | 462µs | # spent 243µs (25+218) within Net::Patricia::AF_INET::BEGIN@148 which was called:
# once (25µs+218µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 148 # spent 243µs making 1 call to Net::Patricia::AF_INET::BEGIN@148
# spent 218µs making 1 call to Exporter::import |
149 | 2 | 75µs | 2 | 365µs | # spent 196µs (26+170) within Net::Patricia::AF_INET::BEGIN@149 which was called:
# once (26µs+170µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 149 # spent 196µs making 1 call to Net::Patricia::AF_INET::BEGIN@149
# spent 170µs making 1 call to Exporter::import |
150 | 2 | 118µs | 2 | 340µs | # spent 186µs (32+154) within Net::Patricia::AF_INET::BEGIN@150 which was called:
# once (32µs+154µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 150 # spent 186µs making 1 call to Net::Patricia::AF_INET::BEGIN@150
# spent 154µs making 1 call to vars::import |
151 | |||||
152 | # spent 43µs within Net::Patricia::AF_INET::BEGIN@152 which was called:
# once (43µs+0s) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 157 | ||||
153 | 1 | 2µs | require Exporter; | ||
154 | 1 | 2µs | require DynaLoader; | ||
155 | 1 | 27µs | @ISA = qw(Exporter DynaLoader Net::Patricia); | ||
156 | 1 | 17µs | @EXPORT = qw(AF_INET); | ||
157 | 1 | 1.18ms | 1 | 43µs | } # spent 43µs making 1 call to Net::Patricia::AF_INET::BEGIN@152 |
158 | |||||
159 | sub add { | ||||
160 | croak "add: wrong number of args" if (@_ < 2 || @_ > 4); | ||||
161 | my ($self, $ip, $bits, $data) = @_; | ||||
162 | $data = (defined $bits ? "$ip/$bits" : $ip) if (@_ < 4); | ||||
163 | my $packed = inet_aton($ip); | ||||
164 | croak("invalid key") unless (defined $packed); | ||||
165 | $bits = 32 if (@_ < 3); | ||||
166 | $self->SUPER::_add(AF_INET, $packed, $bits, $data); | ||||
167 | } | ||||
168 | |||||
169 | sub add_integer { | ||||
170 | croak "add_integer: wrong number of args" if (@_ < 2 || @_ > 4); | ||||
171 | my ($self, $num, $bits, $data) = @_; | ||||
172 | my $packed = pack("N", $num); | ||||
173 | my $ip = inet_ntoa($packed); | ||||
174 | croak("invalid address") unless (defined $ip); | ||||
175 | $data = (defined $bits ? "$ip/$bits" : $ip) if (@_ < 4); | ||||
176 | $bits = 32 if (@_ < 3); | ||||
177 | $self->SUPER::_add(AF_INET, $packed, $bits, $data); | ||||
178 | } | ||||
179 | |||||
180 | sub match_integer { | ||||
181 | croak "match_integer: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
182 | my ($self, $num, $bits) = @_; | ||||
183 | $bits = 32 if (@_ < 3); | ||||
184 | $self->SUPER::_match(AF_INET, pack("N",$num), $bits); | ||||
185 | } | ||||
186 | |||||
187 | sub exact_integer { | ||||
188 | croak "exact_integer: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
189 | my ($self, $num, $bits) = @_; | ||||
190 | $bits = 32 if (@_ < 3); | ||||
191 | $self->SUPER::_exact(AF_INET, pack("N",$num), $bits); | ||||
192 | } | ||||
193 | |||||
194 | sub match { | ||||
195 | croak "match: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
196 | my ($self, $ip, $bits) = @_; | ||||
197 | my $packed = inet_aton($ip); | ||||
198 | croak("invalid key") unless (defined $packed); | ||||
199 | $bits = 32 if (@_ < 3); | ||||
200 | $self->SUPER::_match(AF_INET, $packed, $bits); | ||||
201 | } | ||||
202 | |||||
203 | sub exact { | ||||
204 | croak "exact: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
205 | my ($self, $ip, $bits) = @_; | ||||
206 | my $packed = inet_aton($ip); | ||||
207 | croak("invalid key") unless (defined $packed); | ||||
208 | $bits = 32 if (@_ < 3); | ||||
209 | $self->SUPER::_exact(AF_INET, $packed, $bits); | ||||
210 | } | ||||
211 | |||||
212 | sub remove { | ||||
213 | croak "remove: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
214 | my ($self, $ip, $bits) = @_; | ||||
215 | my $packed = inet_aton($ip); | ||||
216 | croak("invalid key") unless (defined $packed); | ||||
217 | $bits = 32 if (@_ < 3); | ||||
218 | $self->SUPER::_remove(AF_INET, $packed, $bits); | ||||
219 | } | ||||
220 | |||||
221 | sub remove_integer { | ||||
222 | croak "remote_integer: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
223 | my ($self, $num, $bits) = @_; | ||||
224 | $bits = 32 if (@_ < 3); | ||||
225 | $self->SUPER::_remove(AF_INET, pack("N",$num), $bits); | ||||
226 | } | ||||
227 | |||||
228 | ## | ||||
229 | ## AF_INET6 | ||||
230 | ## | ||||
231 | |||||
232 | package Net::Patricia::AF_INET6; | ||||
233 | |||||
234 | 2 | 61µs | 2 | 393µs | # spent 209µs (26+184) within Net::Patricia::AF_INET6::BEGIN@234 which was called:
# once (26µs+184µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 234 # spent 209µs making 1 call to Net::Patricia::AF_INET6::BEGIN@234
# spent 184µs making 1 call to Exporter::import |
235 | 2 | 71µs | 2 | 272µs | # spent 147µs (22+125) within Net::Patricia::AF_INET6::BEGIN@235 which was called:
# once (22µs+125µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 235 # spent 147µs making 1 call to Net::Patricia::AF_INET6::BEGIN@235
# spent 125µs making 1 call to Exporter::import |
236 | 2 | 76µs | 2 | 369µs | # spent 200µs (31+169) within Net::Patricia::AF_INET6::BEGIN@236 which was called:
# once (31µs+169µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 236 # spent 200µs making 1 call to Net::Patricia::AF_INET6::BEGIN@236
# spent 169µs making 1 call to Exporter::import |
237 | 2 | 116µs | 2 | 293µs | # spent 157µs (21+136) within Net::Patricia::AF_INET6::BEGIN@237 which was called:
# once (21µs+136µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 237 # spent 157µs making 1 call to Net::Patricia::AF_INET6::BEGIN@237
# spent 136µs making 1 call to vars::import |
238 | |||||
239 | # spent 42µs within Net::Patricia::AF_INET6::BEGIN@239 which was called:
# once (42µs+0s) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 244 | ||||
240 | 1 | 2µs | require Exporter; | ||
241 | 1 | 2µs | require DynaLoader; | ||
242 | 1 | 26µs | @ISA = qw(Exporter DynaLoader Net::Patricia); | ||
243 | 1 | 18µs | @EXPORT = qw(AF_INET6); | ||
244 | 1 | 1.18ms | 1 | 42µs | } # spent 42µs making 1 call to Net::Patricia::AF_INET6::BEGIN@239 |
245 | |||||
246 | # spent 221µs (135+86) within Net::Patricia::AF_INET6::add which was called 4 times, avg 55µs/call:
# 4 times (135µs+86µs) by Net::Patricia::add_string at line 83, avg 55µs/call | ||||
247 | 4 | 10µs | croak "add: wrong number of args" if (@_ < 2 || @_ > 4); | ||
248 | 4 | 12µs | my ($self, $ip, $bits, $data) = @_; | ||
249 | 4 | 7µs | $data = (defined $bits ? "$ip/$bits" : $ip) if (@_ < 3); | ||
250 | 4 | 63µs | 4 | 30µs | my $packed = inet_pton(AF_INET6, $ip); # spent 30µs making 4 calls to Socket6::inet_pton, avg 8µs/call |
251 | 4 | 7µs | croak("invalid key") unless (defined $packed); | ||
252 | 4 | 8µs | $bits = 128 if (@_ < 4); | ||
253 | 4 | 125µs | 4 | 55µs | $self->SUPER::_add(AF_INET6, $packed, $bits, $data); # spent 55µs making 4 calls to Net::Patricia::_add, avg 14µs/call |
254 | } | ||||
255 | |||||
256 | sub add_integer { | ||||
257 | croak "add_integer: wrong number of args" if (@_ < 2 || @_ > 4); | ||||
258 | my ($self, $num, $bits, $data) = @_; | ||||
259 | my $packed = pack("N", $num); | ||||
260 | my $ip = inet_ntop(AF_INET6, $packed); | ||||
261 | croak("invalid address") unless (defined $ip); | ||||
262 | $data = (defined $bits ? "$ip/$bits" : $ip) if (@_ < 3); | ||||
263 | $bits = 128 if (@_ < 4); | ||||
264 | $self->SUPER::_add(AF_INET6, $packed, $bits, $data); | ||||
265 | } | ||||
266 | |||||
267 | sub match_integer { | ||||
268 | croak "match_integer: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
269 | my ($self, $num, $bits) = @_; | ||||
270 | $bits = 128 if (@_ < 3); | ||||
271 | $self->SUPER::_match(AF_INET6, pack("N",$num), $bits); | ||||
272 | } | ||||
273 | |||||
274 | sub exact_integer { | ||||
275 | croak "exact_integer: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
276 | my ($self, $num, $bits) = @_; | ||||
277 | $bits = 128 if (@_ < 3); | ||||
278 | $self->SUPER::_exact(AF_INET6, pack("N",$num), $bits); | ||||
279 | } | ||||
280 | |||||
281 | sub match { | ||||
282 | croak "match: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
283 | my ($self, $ip, $bits) = @_; | ||||
284 | my $packed = inet_pton(AF_INET6, $ip); | ||||
285 | croak("invalid key") unless (defined $packed); | ||||
286 | $bits = 128 if (@_ < 3); | ||||
287 | $self->SUPER::_match(AF_INET6, $packed, $bits); | ||||
288 | } | ||||
289 | |||||
290 | sub exact { | ||||
291 | croak "exact: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
292 | my ($self, $ip, $bits) = @_; | ||||
293 | my $packed = inet_pton(AF_INET6, $ip); | ||||
294 | croak("invalid key") unless (defined $packed); | ||||
295 | $bits = 128 if (@_ < 3); | ||||
296 | $self->SUPER::_exact(AF_INET6, $packed, $bits); | ||||
297 | } | ||||
298 | |||||
299 | sub remove { | ||||
300 | croak "remove: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
301 | my ($self, $ip, $bits) = @_; | ||||
302 | my $packed = inet_pton(AF_INET6, $ip); | ||||
303 | croak("invalid key") unless (defined $packed); | ||||
304 | $bits = 128 if (@_ < 3); | ||||
305 | $self->SUPER::_remove(AF_INET6, $packed, $bits); | ||||
306 | } | ||||
307 | |||||
308 | sub remove_integer { | ||||
309 | croak "remote_integer: wrong number of args" if (@_ < 2 || @_ > 3); | ||||
310 | my ($self, $num, $bits) = @_; | ||||
311 | $bits = 128 if (@_ < 3); | ||||
312 | $self->SUPER::_remove(AF_INET6, pack("N",$num), $bits); | ||||
313 | } | ||||
314 | |||||
315 | 1 | 21µs | 1; | ||
316 | __END__ | ||||
# spent 12µs within Net::Patricia::CORE:match which was called:
# once (12µs+0s) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 43 | |||||
# spent 36µs within Net::Patricia::CORE:subst which was called 4 times, avg 9µs/call:
# 4 times (36µs+0s) by Net::Patricia::_ip_bits at line 72, avg 9µs/call | |||||
# spent 55µs within Net::Patricia::_add which was called 4 times, avg 14µs/call:
# 4 times (55µs+0s) by Net::Patricia::AF_INET6::add at line 253, avg 14µs/call | |||||
# spent 49µs within Net::Patricia::_new which was called 3 times, avg 16µs/call:
# 3 times (49µs+0s) by Net::Patricia::new at line 57, avg 16µs/call | |||||
# spent 67µs within Net::Patricia::bootstrap which was called:
# once (67µs+0s) by DynaLoader::bootstrap at line 210 of DynaLoader.pm |