Filename | /usr/local/lib/perl5/site_perl/mach/5.24/Net/Patricia.pm |
Statements | Executed 125 statements in 5.75ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 6.55ms | 6.93ms | BEGIN@108 | Net::Patricia::
1 | 1 | 1 | 2.44ms | 4.01ms | BEGIN@31 | Net::Patricia::
4 | 1 | 1 | 393µs | 696µs | add_string | Net::Patricia::
4 | 1 | 1 | 124µs | 190µs | add | Net::Patricia::AF_INET6::
4 | 1 | 1 | 90µs | 114µs | _ip_bits | Net::Patricia::
3 | 1 | 1 | 71µs | 113µs | new | Net::Patricia::
1 | 1 | 1 | 68µs | 68µs | bootstrap (xsub) | Net::Patricia::
1 | 1 | 1 | 47µs | 55µs | BEGIN@26 | Net::Patricia::
3 | 1 | 1 | 42µs | 42µs | _new (xsub) | Net::Patricia::
4 | 1 | 1 | 36µs | 36µs | _add (xsub) | Net::Patricia::
1 | 1 | 1 | 34µs | 34µs | BEGIN@36 | Net::Patricia::
1 | 1 | 1 | 30µs | 30µs | BEGIN@152 | Net::Patricia::AF_INET::
1 | 1 | 1 | 28µs | 2.41ms | BEGIN@34 | Net::Patricia::
1 | 1 | 1 | 26µs | 26µs | BEGIN@239 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 26µs | 173µs | BEGIN@32 | Net::Patricia::
1 | 1 | 1 | 25µs | 128µs | BEGIN@236 | Net::Patricia::AF_INET6::
4 | 1 | 1 | 23µs | 23µs | CORE:subst (opcode) | Net::Patricia::
1 | 1 | 1 | 23µs | 160µs | BEGIN@148 | Net::Patricia::AF_INET::
1 | 1 | 1 | 23µs | 136µs | BEGIN@149 | Net::Patricia::AF_INET::
1 | 1 | 1 | 21µs | 159µs | BEGIN@234 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 20µs | 117µs | BEGIN@150 | Net::Patricia::AF_INET::
1 | 1 | 1 | 19µs | 143µs | BEGIN@33 | Net::Patricia::
1 | 1 | 1 | 19µs | 41µs | BEGIN@27 | Net::Patricia::
1 | 1 | 1 | 19µs | 104µs | BEGIN@235 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 18µs | 109µs | BEGIN@237 | Net::Patricia::AF_INET6::
1 | 1 | 1 | 13µs | 13µ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 | 55µs | 2 | 63µs | # spent 55µs (47+8) within Net::Patricia::BEGIN@26 which was called:
# once (47µs+8µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 26 # spent 55µs making 1 call to Net::Patricia::BEGIN@26
# spent 8µs making 1 call to strict::import |
27 | 2 | 59µs | 2 | 64µs | # spent 41µs (19+22) within Net::Patricia::BEGIN@27 which was called:
# once (19µs+22µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 27 # spent 41µs making 1 call to Net::Patricia::BEGIN@27
# spent 22µs making 1 call to warnings::import |
28 | |||||
29 | 1 | 38µs | require 5.008; | ||
30 | |||||
31 | 2 | 294µs | 2 | 4.09ms | # spent 4.01ms (2.44+1.57) within Net::Patricia::BEGIN@31 which was called:
# once (2.44ms+1.57ms) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 31 # spent 4.01ms making 1 call to Net::Patricia::BEGIN@31
# spent 82µs making 1 call to version::import |
32 | 2 | 68µs | 2 | 320µs | # spent 173µs (26+147) within Net::Patricia::BEGIN@32 which was called:
# once (26µs+147µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 32 # spent 173µs making 1 call to Net::Patricia::BEGIN@32
# spent 147µs making 1 call to Exporter::import |
33 | 2 | 58µs | 2 | 267µs | # spent 143µs (19+124) within Net::Patricia::BEGIN@33 which was called:
# once (19µs+124µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 33 # spent 143µs making 1 call to Net::Patricia::BEGIN@33
# spent 124µs making 1 call to vars::import |
34 | 2 | 124µs | 2 | 4.79ms | # spent 2.41ms (28µs+2.38) within Net::Patricia::BEGIN@34 which was called:
# once (28µs+2.38ms) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 34 # spent 2.41ms making 1 call to Net::Patricia::BEGIN@34
# spent 2.38ms making 1 call to Exporter::import |
35 | |||||
36 | # spent 34µs within Net::Patricia::BEGIN@36 which was called:
# once (34µs+0s) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 41 | ||||
37 | 1 | 2µs | require Exporter; | ||
38 | 1 | 4µs | require DynaLoader; | ||
39 | 1 | 18µs | @ISA = qw(Exporter DynaLoader); | ||
40 | 1 | 10µs | @EXPORT = qw(AF_INET AF_INET6); | ||
41 | 1 | 1.19ms | 1 | 34µs | } # spent 34µs making 1 call to Net::Patricia::BEGIN@36 |
42 | |||||
43 | 1 | 33µs | 1 | 13µs | '$Revision: 1.22 $' =~ m/(\d+)\.(\d+)((_\d+)|)/ && ( $VERSION = "$1.$2$3"); # spent 13µs making 1 call to Net::Patricia::CORE:match |
44 | |||||
45 | 1 | 17µs | 1 | 594µs | bootstrap Net::Patricia $VERSION; # spent 594µs making 1 call to DynaLoader::bootstrap |
46 | |||||
47 | # spent 113µs (71+42) within Net::Patricia::new which was called 3 times, avg 38µs/call:
# 3 times (71µs+42µs) by Mail::SpamAssassin::NetSet::new at line 55 of Mail/SpamAssassin/NetSet.pm, avg 38µs/call | ||||
48 | 3 | 7µ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 | 92µs | 3 | 42µs | return bless _new(128), 'Net::Patricia::AF_INET6'; # spent 42µs making 3 calls to Net::Patricia::_new, avg 14µs/call |
58 | } | ||||
59 | |||||
60 | croak "new: unimplemented type"; | ||||
61 | } | ||||
62 | |||||
63 | ## | ||||
64 | ## Compat functions | ||||
65 | ## | ||||
66 | |||||
67 | # spent 114µs (90+23) within Net::Patricia::_ip_bits which was called 4 times, avg 28µs/call:
# 4 times (90µs+23µs) by Net::Patricia::add_string at line 83, avg 28µs/call | ||||
68 | 4 | 8µs | my ($self, $str) = @_; | ||
69 | 4 | 7µs | my $bits; | ||
70 | |||||
71 | 4 | 20µs | if (ref ($self) eq 'Net::Patricia::AF_INET6') { | ||
72 | 4 | 57µs | 4 | 23µs | $bits = ($str =~ s|/(\d+)$||) ? $1 : 128; # spent 23µs making 4 calls to Net::Patricia::CORE:subst, avg 6µs/call |
73 | } else { | ||||
74 | $bits = ($str =~ s|/(\d+)$||) ? $1 : 32; | ||||
75 | } | ||||
76 | 4 | 316µs | ($str,$bits); | ||
77 | } | ||||
78 | |||||
79 | # spent 696µs (393+303) within Net::Patricia::add_string which was called 4 times, avg 174µs/call:
# 4 times (393µs+303µs) by Mail::SpamAssassin::NetSet::add_cidr at line 147 of Mail/SpamAssassin/NetSet.pm, avg 174µs/call | ||||
80 | 4 | 11µs | croak "add_string: wrong number of args" if (@_ < 2 || @_ > 3); | ||
81 | 4 | 9µs | my ($self,$str,$data) = @_; | ||
82 | 4 | 7µs | $data = $str unless @_ > 2; | ||
83 | 4 | 70µs | 8 | 303µs | $self->add($self->_ip_bits($str),$data); # spent 190µs making 4 calls to Net::Patricia::AF_INET6::add, avg 47µs/call
# spent 114µs making 4 calls to Net::Patricia::_ip_bits, avg 28µ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 6.93ms (6.55+381µs) within Net::Patricia::BEGIN@108 which was called:
# once (6.55ms+381µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 140 | ||||
109 | 1 | 6µs | eval { | ||
110 | 1 | 3µs | my $class = 'Net::CIDR::Lite'; | ||
111 | 1 | 47µs | eval "require $class"; # spent 258µ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 | 68µs | 1 | 6.93ms | } # spent 6.93ms making 1 call to Net::Patricia::BEGIN@108 |
141 | |||||
142 | ## | ||||
143 | ## AF_INET | ||||
144 | ## | ||||
145 | |||||
146 | package Net::Patricia::AF_INET; | ||||
147 | |||||
148 | 2 | 63µs | 2 | 296µs | # spent 160µs (23+137) within Net::Patricia::AF_INET::BEGIN@148 which was called:
# once (23µs+137µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 148 # spent 160µs making 1 call to Net::Patricia::AF_INET::BEGIN@148
# spent 137µs making 1 call to Exporter::import |
149 | 2 | 58µs | 2 | 249µs | # spent 136µs (23+113) within Net::Patricia::AF_INET::BEGIN@149 which was called:
# once (23µs+113µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 149 # spent 136µs making 1 call to Net::Patricia::AF_INET::BEGIN@149
# spent 113µs making 1 call to Exporter::import |
150 | 2 | 95µs | 2 | 214µs | # spent 117µs (20+97) within Net::Patricia::AF_INET::BEGIN@150 which was called:
# once (20µs+97µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 150 # spent 117µs making 1 call to Net::Patricia::AF_INET::BEGIN@150
# spent 97µs making 1 call to vars::import |
151 | |||||
152 | # spent 30µs within Net::Patricia::AF_INET::BEGIN@152 which was called:
# once (30µ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 | 17µs | @ISA = qw(Exporter DynaLoader Net::Patricia); | ||
156 | 1 | 12µs | @EXPORT = qw(AF_INET); | ||
157 | 1 | 1.13ms | 1 | 30µs | } # spent 30µ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 | 57µs | 2 | 296µs | # spent 159µs (21+138) within Net::Patricia::AF_INET6::BEGIN@234 which was called:
# once (21µs+138µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 234 # spent 159µs making 1 call to Net::Patricia::AF_INET6::BEGIN@234
# spent 138µs making 1 call to Exporter::import |
235 | 2 | 63µs | 2 | 189µs | # spent 104µs (19+85) within Net::Patricia::AF_INET6::BEGIN@235 which was called:
# once (19µs+85µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 235 # spent 104µs making 1 call to Net::Patricia::AF_INET6::BEGIN@235
# spent 85µs making 1 call to Exporter::import |
236 | 2 | 67µs | 2 | 231µs | # spent 128µs (25+103) within Net::Patricia::AF_INET6::BEGIN@236 which was called:
# once (25µs+103µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 236 # spent 128µs making 1 call to Net::Patricia::AF_INET6::BEGIN@236
# spent 103µs making 1 call to Exporter::import |
237 | 2 | 112µs | 2 | 199µs | # spent 109µs (18+91) within Net::Patricia::AF_INET6::BEGIN@237 which was called:
# once (18µs+91µs) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 237 # spent 109µs making 1 call to Net::Patricia::AF_INET6::BEGIN@237
# spent 91µs making 1 call to vars::import |
238 | |||||
239 | # spent 26µs within Net::Patricia::AF_INET6::BEGIN@239 which was called:
# once (26µ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 | 14µs | @ISA = qw(Exporter DynaLoader Net::Patricia); | ||
243 | 1 | 12µs | @EXPORT = qw(AF_INET6); | ||
244 | 1 | 1.09ms | 1 | 26µs | } # spent 26µs making 1 call to Net::Patricia::AF_INET6::BEGIN@239 |
245 | |||||
246 | # spent 190µs (124+65) within Net::Patricia::AF_INET6::add which was called 4 times, avg 47µs/call:
# 4 times (124µs+65µs) by Net::Patricia::add_string at line 83, avg 47µ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 | 8µs | $data = (defined $bits ? "$ip/$bits" : $ip) if (@_ < 3); | ||
250 | 4 | 60µs | 4 | 29µs | my $packed = inet_pton(AF_INET6, $ip); # spent 29µs making 4 calls to Socket6::inet_pton, avg 7µs/call |
251 | 4 | 7µs | croak("invalid key") unless (defined $packed); | ||
252 | 4 | 7µs | $bits = 128 if (@_ < 4); | ||
253 | 4 | 90µs | 4 | 36µs | $self->SUPER::_add(AF_INET6, $packed, $bits, $data); # spent 36µs making 4 calls to Net::Patricia::_add, avg 9µ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 | 18µs | 1; | ||
316 | __END__ | ||||
# spent 13µs within Net::Patricia::CORE:match which was called:
# once (13µs+0s) by Mail::SpamAssassin::NetSet::BEGIN@35 at line 43 | |||||
# spent 23µs within Net::Patricia::CORE:subst which was called 4 times, avg 6µs/call:
# 4 times (23µs+0s) by Net::Patricia::_ip_bits at line 72, avg 6µs/call | |||||
# spent 36µs within Net::Patricia::_add which was called 4 times, avg 9µs/call:
# 4 times (36µs+0s) by Net::Patricia::AF_INET6::add at line 253, avg 9µs/call | |||||
# spent 42µs within Net::Patricia::_new which was called 3 times, avg 14µs/call:
# 3 times (42µs+0s) by Net::Patricia::new at line 57, avg 14µs/call | |||||
# spent 68µs within Net::Patricia::bootstrap which was called:
# once (68µs+0s) by DynaLoader::bootstrap at line 210 of DynaLoader.pm |