Filename | /usr/local/lib/perl5/site_perl/Net/DNS/RR/OPT.pm |
Statements | Executed 55136 statements in 354ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1968 | 1 | 1 | 148ms | 267ms | encode | Net::DNS::RR::OPT::
3936 | 2 | 2 | 62.3ms | 62.3ms | size | Net::DNS::RR::OPT::
1968 | 1 | 1 | 38.2ms | 38.2ms | _encode_rdata | Net::DNS::RR::OPT::
1968 | 1 | 1 | 26.5ms | 26.5ms | _specified | Net::DNS::RR::OPT::
1968 | 1 | 1 | 15.3ms | 15.3ms | rcode | Net::DNS::RR::OPT::
1968 | 1 | 1 | 14.9ms | 14.9ms | flags | Net::DNS::RR::OPT::
1968 | 1 | 1 | 14.3ms | 14.3ms | version | Net::DNS::RR::OPT::
1969 | 2 | 1 | 6.62ms | 6.62ms | CORE:pack (opcode) | Net::DNS::RR::OPT::
1 | 1 | 1 | 1.46ms | 1.87ms | BEGIN@241 | Net::DNS::RR::OPT::CLIENT_SUBNET::
1 | 1 | 1 | 934µs | 1.39ms | BEGIN@240 | Net::DNS::RR::OPT::CLIENT_SUBNET::
1 | 1 | 1 | 50µs | 63µs | BEGIN@9 | Net::DNS::RR::OPT::
1 | 1 | 1 | 36µs | 221µs | BEGIN@25 | Net::DNS::RR::OPT::
1 | 1 | 1 | 31µs | 208µs | BEGIN@27 | Net::DNS::RR::OPT::
1 | 1 | 1 | 31µs | 553µs | BEGIN@233 | Net::DNS::RR::OPT::DHU::
1 | 1 | 1 | 28µs | 424µs | BEGIN@236 | Net::DNS::RR::OPT::N3U::
1 | 1 | 1 | 26µs | 33µs | BEGIN@20 | Net::DNS::RR::OPT::
1 | 1 | 1 | 26µs | 230µs | BEGIN@22 | Net::DNS::RR::OPT::
1 | 1 | 1 | 25µs | 264µs | BEGIN@11 | Net::DNS::RR::OPT::
1 | 1 | 1 | 24µs | 63µs | BEGIN@10 | Net::DNS::RR::OPT::
1 | 1 | 1 | 23µs | 742µs | BEGIN@23 | Net::DNS::RR::OPT::
1 | 1 | 1 | 16µs | 16µs | BEGIN@325 | Net::DNS::RR::OPT::CHAIN::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::CHAIN::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::CHAIN::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::CHAIN::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::CLIENT_SUBNET::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::CLIENT_SUBNET::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::CLIENT_SUBNET::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::COOKIE::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::COOKIE::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::DAU::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::DAU::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::DAU::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::EXPIRE::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::EXPIRE::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::EXPIRE::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::KEY_TAG::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::KEY_TAG::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::KEY_TAG::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::PADDING::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::PADDING::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::PADDING::
0 | 0 | 0 | 0s | 0s | _compose | Net::DNS::RR::OPT::TCP_KEEPALIVE::
0 | 0 | 0 | 0s | 0s | _decompose | Net::DNS::RR::OPT::TCP_KEEPALIVE::
0 | 0 | 0 | 0s | 0s | _image | Net::DNS::RR::OPT::TCP_KEEPALIVE::
0 | 0 | 0 | 0s | 0s | _decode_rdata | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | _format_option | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | _get_option | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | _set_option | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | class | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | option | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | options | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | string | Net::DNS::RR::OPT::
0 | 0 | 0 | 0s | 0s | ttl | Net::DNS::RR::OPT::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Net::DNS::RR::OPT; | ||||
2 | |||||
3 | # | ||||
4 | # $Id: OPT.pm 1578 2017-06-20 12:49:23Z willem $ | ||||
5 | # | ||||
6 | 1 | 2µs | our $VERSION = (qw$LastChangedRevision: 1578 $)[1]; | ||
7 | |||||
8 | |||||
9 | 2 | 68µs | 2 | 75µs | # spent 63µs (50+12) within Net::DNS::RR::OPT::BEGIN@9 which was called:
# once (50µs+12µs) by Net::DNS::RR::_subclass at line 9 # spent 63µs making 1 call to Net::DNS::RR::OPT::BEGIN@9
# spent 12µs making 1 call to strict::import |
10 | 2 | 73µs | 2 | 102µs | # spent 63µs (24+39) within Net::DNS::RR::OPT::BEGIN@10 which was called:
# once (24µs+39µs) by Net::DNS::RR::_subclass at line 10 # spent 63µs making 1 call to Net::DNS::RR::OPT::BEGIN@10
# spent 39µs making 1 call to warnings::import |
11 | 2 | 89µs | 2 | 504µs | # spent 264µs (25+239) within Net::DNS::RR::OPT::BEGIN@11 which was called:
# once (25µs+239µs) by Net::DNS::RR::_subclass at line 11 # spent 264µs making 1 call to Net::DNS::RR::OPT::BEGIN@11
# spent 239µs making 1 call to base::import |
12 | |||||
13 | =head1 NAME | ||||
14 | |||||
15 | Net::DNS::RR::OPT - DNS OPT resource record | ||||
16 | |||||
17 | =cut | ||||
18 | |||||
19 | |||||
20 | 2 | 74µs | 2 | 40µs | # spent 33µs (26+7) within Net::DNS::RR::OPT::BEGIN@20 which was called:
# once (26µs+7µs) by Net::DNS::RR::_subclass at line 20 # spent 33µs making 1 call to Net::DNS::RR::OPT::BEGIN@20
# spent 7µs making 1 call to integer::import |
21 | |||||
22 | 2 | 62µs | 2 | 435µs | # spent 230µs (26+204) within Net::DNS::RR::OPT::BEGIN@22 which was called:
# once (26µs+204µs) by Net::DNS::RR::_subclass at line 22 # spent 230µs making 1 call to Net::DNS::RR::OPT::BEGIN@22
# spent 204µs making 1 call to Exporter::import |
23 | 2 | 115µs | 2 | 1.46ms | # spent 742µs (23+719) within Net::DNS::RR::OPT::BEGIN@23 which was called:
# once (23µs+719µs) by Net::DNS::RR::_subclass at line 23 # spent 742µs making 1 call to Net::DNS::RR::OPT::BEGIN@23
# spent 719µs making 1 call to Exporter::import |
24 | |||||
25 | 2 | 110µs | 3 | 406µs | # spent 221µs (36+185) within Net::DNS::RR::OPT::BEGIN@25 which was called:
# once (36µs+185µs) by Net::DNS::RR::_subclass at line 25 # spent 221µs making 1 call to Net::DNS::RR::OPT::BEGIN@25
# spent 176µs making 1 call to constant::import
# spent 9µs making 1 call to Net::DNS::RR::OPT::CORE:pack |
26 | |||||
27 | 2 | 2.74ms | 3 | 384µs | # spent 208µs (31+177) within Net::DNS::RR::OPT::BEGIN@27 which was called:
# once (31µs+177µs) by Net::DNS::RR::_subclass at line 27 # spent 208µs making 1 call to Net::DNS::RR::OPT::BEGIN@27
# spent 169µs making 1 call to constant::import
# spent 8µs making 1 call to Net::DNS::Parameters::typebyname |
28 | |||||
29 | |||||
30 | sub _decode_rdata { ## decode rdata from wire-format octet string | ||||
31 | my $self = shift; | ||||
32 | my ( $data, $offset ) = @_; | ||||
33 | |||||
34 | my $index = $offset - CLASS_TTL_RDLENGTH; # OPT redefines class and TTL fields | ||||
35 | @{$self}{qw(size rcode version flags)} = unpack "\@$index n C2 n", $$data; | ||||
36 | @{$self}{rcode} = @{$self}{rcode} << 4; | ||||
37 | delete @{$self}{qw(class ttl)}; | ||||
38 | |||||
39 | my $limit = $offset + $self->{rdlength} - 4; | ||||
40 | |||||
41 | while ( $offset <= $limit ) { | ||||
42 | my ( $code, $length ) = unpack "\@$offset nn", $$data; | ||||
43 | my $value = unpack "\@$offset x4 a$length", $$data; | ||||
44 | $self->{option}{$code} = $value; | ||||
45 | $offset += $length + 4; | ||||
46 | } | ||||
47 | } | ||||
48 | |||||
49 | |||||
50 | # spent 38.2ms within Net::DNS::RR::OPT::_encode_rdata which was called 1968 times, avg 19µs/call:
# 1968 times (38.2ms+0s) by Net::DNS::RR::OPT::encode at line 61, avg 19µs/call | ||||
51 | 1968 | 3.68ms | my $self = shift; | ||
52 | |||||
53 | 1968 | 9.25ms | my $option = $self->{option} || {}; | ||
54 | 1968 | 30.9ms | join '', map pack( 'nna*', $_, length $option->{$_}, $option->{$_} ), keys %$option; | ||
55 | } | ||||
56 | |||||
57 | |||||
58 | # spent 267ms (148+120) within Net::DNS::RR::OPT::encode which was called 1968 times, avg 136µs/call:
# 1968 times (148ms+120ms) by Net::DNS::Packet::encode at line 205 of Net/DNS/Packet.pm, avg 136µs/call | ||||
59 | 1968 | 3.91ms | my $self = shift; | ||
60 | |||||
61 | 1968 | 14.3ms | 1968 | 38.2ms | my $data = $self->_encode_rdata; # spent 38.2ms making 1968 calls to Net::DNS::RR::OPT::_encode_rdata, avg 19µs/call |
62 | 1968 | 13.2ms | 1968 | 30.5ms | my $size = $self->size; # spent 30.5ms making 1968 calls to Net::DNS::RR::OPT::size, avg 15µs/call |
63 | 1968 | 39.4ms | 5904 | 44.5ms | my @xttl = ( $self->rcode >> 4, $self->version, $self->flags ); # spent 15.3ms making 1968 calls to Net::DNS::RR::OPT::rcode, avg 8µs/call
# spent 14.9ms making 1968 calls to Net::DNS::RR::OPT::flags, avg 8µs/call
# spent 14.3ms making 1968 calls to Net::DNS::RR::OPT::version, avg 7µs/call |
64 | 1968 | 42.1ms | 1968 | 6.61ms | pack 'C n n C2n n a*', 0, OPT, $size, @xttl, length($data), $data; # spent 6.61ms making 1968 calls to Net::DNS::RR::OPT::CORE:pack, avg 3µs/call |
65 | } | ||||
66 | |||||
67 | |||||
68 | sub string { ## overide RR method | ||||
69 | my $self = shift; | ||||
70 | |||||
71 | my $edns = $self->version; | ||||
72 | my $flags = sprintf '%04x', $self->flags; | ||||
73 | my $rcode = $self->rcode; | ||||
74 | my $size = $self->size; | ||||
75 | my @option = sort { $a <=> $b } $self->options; | ||||
76 | my @lines = map $self->_format_option($_), @option; | ||||
77 | my @format = join "\n;;\t\t", @lines; | ||||
78 | |||||
79 | $rcode = 0 if $rcode < 16; # weird: 1 .. 15 not EDNS codes!! | ||||
80 | |||||
81 | my $rc = exists( $self->{rdlength} ) && $rcode ? "$rcode + [4-bits]" : rcodebyval($rcode); | ||||
82 | |||||
83 | $rc = 'BADVERS' if $rcode == 16; # code 16 unambiguous here | ||||
84 | |||||
85 | return <<"QQ"; | ||||
86 | ;; EDNS version $edns | ||||
87 | ;; flags: $flags | ||||
88 | ;; rcode: $rc | ||||
89 | ;; size: $size | ||||
90 | ;; option: @format | ||||
91 | |||||
92 | } | ||||
93 | |||||
94 | |||||
95 | 1 | 2µs | my ( $class, $ttl ); | ||
96 | |||||
97 | sub class { ## overide RR method | ||||
98 | carp qq[Usage: OPT has no "class" attribute, please use "size()"] unless $class++; | ||||
99 | &size; | ||||
100 | } | ||||
101 | |||||
102 | sub ttl { ## overide RR method | ||||
103 | my $self = shift; | ||||
104 | carp qq[Usage: OPT has no "ttl" attribute, please use "flags()" or "rcode()"] unless $ttl++; | ||||
105 | my @rcode = map unpack( 'C', pack 'N', $_ ), @_; | ||||
106 | my @flags = map unpack( 'x2n', pack 'N', $_ ), @_; | ||||
107 | pack 'C2n', $self->rcode(@rcode), $self->version, $self->flags(@flags); | ||||
108 | } | ||||
109 | |||||
110 | |||||
111 | # spent 14.3ms within Net::DNS::RR::OPT::version which was called 1968 times, avg 7µs/call:
# 1968 times (14.3ms+0s) by Net::DNS::RR::OPT::encode at line 63, avg 7µs/call | ||||
112 | 1968 | 4.35ms | my $version = shift->{version}; | ||
113 | 1968 | 15.7ms | return defined($version) ? $version : 0; | ||
114 | } | ||||
115 | |||||
116 | |||||
117 | # spent 62.3ms within Net::DNS::RR::OPT::size which was called 3936 times, avg 16µs/call:
# 1968 times (31.9ms+0s) by Mail::SpamAssassin::DnsResolver::new_dns_packet at line 603 of Mail/SpamAssassin/DnsResolver.pm, avg 16µs/call
# 1968 times (30.5ms+0s) by Net::DNS::RR::OPT::encode at line 62, avg 15µs/call | ||||
118 | 3936 | 7.33ms | my $self = shift; | ||
119 | 3936 | 10.5ms | for ( $self->{size} ) { | ||
120 | 3936 | 6.98ms | my $UDP_size = 0; | ||
121 | 3936 | 8.01ms | ( $UDP_size, $_ ) = ( shift || 0 ) if scalar @_; | ||
122 | 3936 | 22.8ms | return $UDP_size < 512 ? 512 : ( $_ = $UDP_size ) unless $_; | ||
123 | 1968 | 19.0ms | return $_ > 512 ? $_ : 512; | ||
124 | } | ||||
125 | } | ||||
126 | |||||
127 | |||||
128 | # spent 15.3ms within Net::DNS::RR::OPT::rcode which was called 1968 times, avg 8µs/call:
# 1968 times (15.3ms+0s) by Net::DNS::RR::OPT::encode at line 63, avg 8µs/call | ||||
129 | 1968 | 3.59ms | my $self = shift; | ||
130 | 1968 | 17.0ms | return $self->{rcode} || 0 unless scalar @_; | ||
131 | delete $self->{rdlength}; # (ab)used to signal incomplete value | ||||
132 | my $val = shift || 0; | ||||
133 | $self->{rcode} = $val < 16 ? 0 : $val; # discard non-EDNS rcodes 1 .. 15 | ||||
134 | } | ||||
135 | |||||
136 | |||||
137 | # spent 14.9ms within Net::DNS::RR::OPT::flags which was called 1968 times, avg 8µs/call:
# 1968 times (14.9ms+0s) by Net::DNS::RR::OPT::encode at line 63, avg 8µs/call | ||||
138 | 1968 | 3.81ms | my $self = shift; | ||
139 | 1968 | 29.2ms | return $self->{flags} || 0 unless scalar @_; | ||
140 | $self->{flags} = shift; | ||||
141 | } | ||||
142 | |||||
143 | |||||
144 | sub options { | ||||
145 | my ($self) = @_; | ||||
146 | my $options = $self->{option} || {}; | ||||
147 | return keys %$options; | ||||
148 | } | ||||
149 | |||||
150 | sub option { | ||||
151 | my $self = shift; | ||||
152 | my $number = ednsoptionbyname(shift); | ||||
153 | return $self->_get_option($number) unless scalar @_; | ||||
154 | $self->_set_option( $number, @_ ); | ||||
155 | } | ||||
156 | |||||
157 | |||||
158 | sub _format_option { | ||||
159 | my ( $self, $number ) = @_; | ||||
160 | my $option = ednsoptionbyval($number); | ||||
161 | my $options = $self->{option} || {}; | ||||
162 | my $payload = $options->{$number}; | ||||
163 | return () unless defined $payload; | ||||
164 | my $package = join '::', __PACKAGE__, $option; | ||||
165 | $package =~ s/-/_/g; | ||||
166 | my $defined = length($payload) && $package->can('_image'); | ||||
167 | my @payload = $defined ? eval { $package->_image($payload) } : unpack 'H*', $payload; | ||||
168 | Net::DNS::RR::_wrap( "$option\t=> (", @payload, ')' ); | ||||
169 | } | ||||
170 | |||||
171 | |||||
172 | sub _get_option { | ||||
173 | my ( $self, $number ) = @_; | ||||
174 | |||||
175 | my $options = $self->{option} || {}; | ||||
176 | my $payload = $options->{$number}; | ||||
177 | return $payload unless wantarray; | ||||
178 | return () unless $payload; | ||||
179 | my $package = join '::', __PACKAGE__, ednsoptionbyval($number); | ||||
180 | $package =~ s/-/_/g; | ||||
181 | return ( 'OPTION-DATA' => $payload ) unless $package->can('_decompose'); | ||||
182 | my @payload = eval { $package->_decompose($payload) }; | ||||
183 | } | ||||
184 | |||||
185 | |||||
186 | sub _set_option { | ||||
187 | my ( $self, $number, $value, @etc ) = @_; | ||||
188 | |||||
189 | my $options = $self->{option} ||= {}; | ||||
190 | delete $options->{$number}; | ||||
191 | if ( ref($value) || scalar(@etc) ) { | ||||
192 | my $option = ednsoptionbyval($number); | ||||
193 | my @arg = ( $value, @etc ); | ||||
194 | @arg = @$value if ref($value) eq 'ARRAY'; | ||||
195 | @arg = %$value if ref($value) eq 'HASH'; | ||||
196 | if ( $arg[0] eq 'OPTION-DATA' ) { | ||||
197 | $value = $arg[1]; | ||||
198 | } else { | ||||
199 | my $package = join '::', __PACKAGE__, $option; | ||||
200 | $package =~ s/-/_/g; | ||||
201 | croak "unable to compose option $option" unless $package->can('_compose'); | ||||
202 | $value = $package->_compose(@arg); | ||||
203 | } | ||||
204 | } | ||||
205 | $options->{$number} = $value if defined $value; | ||||
206 | } | ||||
207 | |||||
208 | |||||
209 | # spent 26.5ms within Net::DNS::RR::OPT::_specified which was called 1968 times, avg 13µs/call:
# 1968 times (26.5ms+0s) by Net::DNS::Packet::encode at line 194 of Net/DNS/Packet.pm, avg 13µs/call | ||||
210 | 1968 | 3.72ms | my $self = shift; | ||
211 | 1968 | 12.3ms | my @spec = grep $self->{$_}, qw(size flags rcode option); | ||
212 | 1968 | 27.5ms | scalar @spec; | ||
213 | } | ||||
214 | |||||
215 | |||||
216 | ######################################## | ||||
217 | |||||
218 | package Net::DNS::RR::OPT::DAU; # RFC6975 | ||||
219 | |||||
220 | sub _compose { | ||||
221 | my ( $class, @argument ) = @_; | ||||
222 | pack 'C*', @argument; | ||||
223 | } | ||||
224 | |||||
225 | sub _decompose { | ||||
226 | my @payload = unpack 'C*', $_[1]; | ||||
227 | } | ||||
228 | |||||
229 | sub _image { &_decompose; } | ||||
230 | |||||
231 | |||||
232 | package Net::DNS::RR::OPT::DHU; # RFC6975 | ||||
233 | 2 | 123µs | 2 | 1.07ms | # spent 553µs (31+522) within Net::DNS::RR::OPT::DHU::BEGIN@233 which was called:
# once (31µs+522µs) by Net::DNS::RR::_subclass at line 233 # spent 553µs making 1 call to Net::DNS::RR::OPT::DHU::BEGIN@233
# spent 522µs making 1 call to base::import |
234 | |||||
235 | package Net::DNS::RR::OPT::N3U; # RFC6975 | ||||
236 | 2 | 96µs | 2 | 821µs | # spent 424µs (28+396) within Net::DNS::RR::OPT::N3U::BEGIN@236 which was called:
# once (28µs+396µs) by Net::DNS::RR::_subclass at line 236 # spent 424µs making 1 call to Net::DNS::RR::OPT::N3U::BEGIN@236
# spent 396µs making 1 call to base::import |
237 | |||||
238 | |||||
239 | package Net::DNS::RR::OPT::CLIENT_SUBNET; # RFC7871 | ||||
240 | 2 | 343µs | 1 | 1.39ms | # spent 1.39ms (934µs+458µs) within Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@240 which was called:
# once (934µs+458µs) by Net::DNS::RR::_subclass at line 240 # spent 1.39ms making 1 call to Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@240 |
241 | 2 | 1.42ms | 1 | 1.87ms | # spent 1.87ms (1.46+407µs) within Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@241 which was called:
# once (1.46ms+407µs) by Net::DNS::RR::_subclass at line 241 # spent 1.87ms making 1 call to Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@241 |
242 | |||||
243 | 1 | 6µs | my %family = qw(1 Net::DNS::RR::A 2 Net::DNS::RR::AAAA); | ||
244 | 1 | 3µs | my @field = qw(FAMILY SOURCE-PREFIX-LENGTH SCOPE-PREFIX-LENGTH ADDRESS); | ||
245 | |||||
246 | sub _compose { | ||||
247 | my ( $class, %argument ) = @_; | ||||
248 | my $address = bless( {}, $family{$argument{FAMILY}} )->address( $argument{ADDRESS} ); | ||||
249 | my $preamble = pack 'nC2', map $_ ||= 0, @argument{@field}; | ||||
250 | my $bitmask = $argument{'SOURCE-PREFIX-LENGTH'}; | ||||
251 | pack "a* B$bitmask", $preamble, unpack 'B*', $address; | ||||
252 | } | ||||
253 | |||||
254 | sub _decompose { | ||||
255 | my %hash; | ||||
256 | @hash{@field} = unpack 'nC2a*', $_[1]; | ||||
257 | $hash{ADDRESS} = bless( {address => $hash{ADDRESS}}, $family{$hash{FAMILY}} )->address; | ||||
258 | my @payload = map { ( $_ => $hash{$_} ) } @field; | ||||
259 | } | ||||
260 | |||||
261 | sub _image { &_decompose; } | ||||
262 | |||||
263 | |||||
264 | package Net::DNS::RR::OPT::EXPIRE; # RFC7314 | ||||
265 | |||||
266 | sub _compose { | ||||
267 | my ( $class, %argument ) = @_; | ||||
268 | pack 'N', values %argument; | ||||
269 | } | ||||
270 | |||||
271 | sub _decompose { | ||||
272 | my @payload = ( 'EXPIRE-TIMER' => unpack 'N', $_[1] ); | ||||
273 | } | ||||
274 | |||||
275 | sub _image { &_decompose; } | ||||
276 | |||||
277 | |||||
278 | package Net::DNS::RR::OPT::COOKIE; # RFC7873 | ||||
279 | |||||
280 | 1 | 2µs | my @key = qw(CLIENT-COOKIE SERVER-COOKIE); | ||
281 | |||||
282 | sub _compose { | ||||
283 | my ( $class, %argument ) = @_; | ||||
284 | pack 'a8 a*', map $_ || '', @argument{@key}; | ||||
285 | } | ||||
286 | |||||
287 | sub _decompose { | ||||
288 | my %hash; | ||||
289 | my $template = ( length( $_[1] ) < 16 ) ? 'a8' : 'a8 a*'; | ||||
290 | @hash{@key} = unpack $template, $_[1]; | ||||
291 | my @payload = map { ( $_ => $hash{$_} ) } @key; | ||||
292 | } | ||||
293 | |||||
294 | |||||
295 | package Net::DNS::RR::OPT::TCP_KEEPALIVE; # RFC7828 | ||||
296 | |||||
297 | sub _compose { | ||||
298 | my ( $class, %argument ) = @_; | ||||
299 | pack 'n', values %argument; | ||||
300 | } | ||||
301 | |||||
302 | sub _decompose { | ||||
303 | my @payload = ( TIMEOUT => unpack 'n', $_[1] ); | ||||
304 | } | ||||
305 | |||||
306 | sub _image { &_decompose; } | ||||
307 | |||||
308 | |||||
309 | package Net::DNS::RR::OPT::PADDING; # RFC7830 | ||||
310 | |||||
311 | sub _compose { | ||||
312 | my ( $class, %argument ) = @_; | ||||
313 | my ($size) = values %argument; | ||||
314 | pack "x$size"; | ||||
315 | } | ||||
316 | |||||
317 | sub _decompose { | ||||
318 | my @payload = ( 'OPTION-LENGTH' => length( $_[1] ) ); | ||||
319 | } | ||||
320 | |||||
321 | sub _image { &_decompose; } | ||||
322 | |||||
323 | |||||
324 | package Net::DNS::RR::OPT::CHAIN; # RFC7901 | ||||
325 | 2 | 454µs | 1 | 16µs | # spent 16µs within Net::DNS::RR::OPT::CHAIN::BEGIN@325 which was called:
# once (16µs+0s) by Net::DNS::RR::_subclass at line 325 # spent 16µs making 1 call to Net::DNS::RR::OPT::CHAIN::BEGIN@325 |
326 | |||||
327 | sub _compose { | ||||
328 | my ( $class, %argument ) = @_; | ||||
329 | my ($trust_point) = values %argument; | ||||
330 | Net::DNS::DomainName->new( $trust_point || return '' )->encode; | ||||
331 | } | ||||
332 | |||||
333 | sub _decompose { | ||||
334 | my ( $class, $payload ) = @_; | ||||
335 | my $fqdn = Net::DNS::DomainName->decode( \$payload )->string; | ||||
336 | my @payload = ( 'CLOSEST-TRUST-POINT' => $fqdn ); | ||||
337 | } | ||||
338 | |||||
339 | sub _image { &_decompose; } | ||||
340 | |||||
341 | |||||
342 | package Net::DNS::RR::OPT::KEY_TAG; # RFC8145 | ||||
343 | |||||
344 | sub _compose { | ||||
345 | my ( $class, @argument ) = @_; | ||||
346 | pack 'n*', @argument; | ||||
347 | } | ||||
348 | |||||
349 | sub _decompose { | ||||
350 | my @payload = unpack 'n*', $_[1]; | ||||
351 | } | ||||
352 | |||||
353 | sub _image { &_decompose; } | ||||
354 | |||||
355 | |||||
356 | 1 | 25µs | 1; | ||
357 | __END__ | ||||
sub Net::DNS::RR::OPT::CORE:pack; # opcode |