← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:13 2021

Filename/usr/local/lib/perl5/site_perl/Net/DNS/Parameters.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sNet::DNS::Parameters::::BEGIN@10Net::DNS::Parameters::BEGIN@10
0000s0sNet::DNS::Parameters::::BEGIN@11Net::DNS::Parameters::BEGIN@11
0000s0sNet::DNS::Parameters::::BEGIN@14Net::DNS::Parameters::BEGIN@14
0000s0sNet::DNS::Parameters::::BEGIN@15Net::DNS::Parameters::BEGIN@15
0000s0sNet::DNS::Parameters::::BEGIN@17Net::DNS::Parameters::BEGIN@17
0000s0sNet::DNS::Parameters::::BEGIN@377Net::DNS::Parameters::BEGIN@377
0000s0sNet::DNS::Parameters::::CORE:matchNet::DNS::Parameters::CORE:match (opcode)
0000s0sNet::DNS::Parameters::::_typespecNet::DNS::Parameters::_typespec
0000s0sNet::DNS::Parameters::::classbynameNet::DNS::Parameters::classbyname
0000s0sNet::DNS::Parameters::::classbyvalNet::DNS::Parameters::classbyval
0000s0sNet::DNS::Parameters::::dsotypebynameNet::DNS::Parameters::dsotypebyname
0000s0sNet::DNS::Parameters::::dsotypebyvalNet::DNS::Parameters::dsotypebyval
0000s0sNet::DNS::Parameters::::ednsoptionbynameNet::DNS::Parameters::ednsoptionbyname
0000s0sNet::DNS::Parameters::::ednsoptionbyvalNet::DNS::Parameters::ednsoptionbyval
0000s0sNet::DNS::Parameters::::opcodebynameNet::DNS::Parameters::opcodebyname
0000s0sNet::DNS::Parameters::::opcodebyvalNet::DNS::Parameters::opcodebyval
0000s0sNet::DNS::Parameters::::rcodebynameNet::DNS::Parameters::rcodebyname
0000s0sNet::DNS::Parameters::::rcodebyvalNet::DNS::Parameters::rcodebyval
0000s0sNet::DNS::Parameters::::registerNet::DNS::Parameters::register
0000s0sNet::DNS::Parameters::::typebynameNet::DNS::Parameters::typebyname
0000s0sNet::DNS::Parameters::::typebyvalNet::DNS::Parameters::typebyval
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Net::DNS::Parameters;
2
3################################################
4##
5## Domain Name System (DNS) Parameters
6## (last updated 2021-03-08)
7##
8################################################
9
10use strict;
11use warnings;
12our $VERSION = (qw$Id: Parameters.pm 1832 2021-03-22 08:33:36Z willem $)[2];
13
14use integer;
15use Carp;
16
17use base qw(Exporter);
18
19our @EXPORT_OK = qw(
20 classbyname classbyval %classbyname
21 typebyname typebyval %typebyname
22 opcodebyname opcodebyval
23 rcodebyname rcodebyval
24 ednsoptionbyname ednsoptionbyval
25 dsotypebyname dsotypebyval
26 );
27
28our %EXPORT_TAGS = (
29 class => [qw(classbyname classbyval)],
30 type => [qw(typebyname typebyval)],
31 opcode => [qw(opcodebyname opcodebyval)],
32 rcode => [qw(rcodebyname rcodebyval)],
33 ednsoption => [qw(ednsoptionbyname ednsoptionbyval)],
34 dsotype => [qw(dsotypebyname dsotypebyval)],
35 );
36
37
38# Registry: DNS CLASSes
39my @classbyname = (
40 IN => 1, # RFC1035
41 CH => 3, # Chaosnet
42 HS => 4, # Hesiod
43 NONE => 254, # RFC2136
44 ANY => 255, # RFC1035
45 );
46our %classbyval = reverse( CLASS0 => 0, @classbyname );
47push @classbyname, map { /^\d/ ? $_ : lc($_) } @classbyname;
48our %classbyname = ( '*' => 255, @classbyname );
49
50
51# Registry: Resource Record (RR) TYPEs
52my @typebyname = (
53 A => 1, # RFC1035
54 NS => 2, # RFC1035
55 MD => 3, # RFC1035
56 MF => 4, # RFC1035
57 CNAME => 5, # RFC1035
58 SOA => 6, # RFC1035
59 MB => 7, # RFC1035
60 MG => 8, # RFC1035
61 MR => 9, # RFC1035
62 NULL => 10, # RFC1035
63 WKS => 11, # RFC1035
64 PTR => 12, # RFC1035
65 HINFO => 13, # RFC1035
66 MINFO => 14, # RFC1035
67 MX => 15, # RFC1035
68 TXT => 16, # RFC1035
69 RP => 17, # RFC1183
70 AFSDB => 18, # RFC1183 RFC5864
71 X25 => 19, # RFC1183
72 ISDN => 20, # RFC1183
73 RT => 21, # RFC1183
74 NSAP => 22, # RFC1706
75 'NSAP-PTR' => 23, # RFC1348 RFC1637 RFC1706
76 SIG => 24, # RFC4034 RFC3755 RFC2535 RFC2536 RFC2537 RFC2931 RFC3110 RFC3008
77 KEY => 25, # RFC4034 RFC3755 RFC2535 RFC2536 RFC2537 RFC2539 RFC3008 RFC3110
78 PX => 26, # RFC2163
79 GPOS => 27, # RFC1712
80 AAAA => 28, # RFC3596
81 LOC => 29, # RFC1876
82 NXT => 30, # RFC3755 RFC2535
83 EID => 31, # http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
84 NIMLOC => 32, # http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
85 SRV => 33, # RFC2782
86 ATMA => 34, # http://www.broadband-forum.org/ftp/pub/approved-specs/af-dans-0152.000.pdf
87 NAPTR => 35, # RFC2915 RFC2168 RFC3403
88 KX => 36, # RFC2230
89 CERT => 37, # RFC4398
90 A6 => 38, # RFC3226 RFC2874 RFC6563
91 DNAME => 39, # RFC6672
92 SINK => 40, # http://tools.ietf.org/html/draft-eastlake-kitchen-sink
93 OPT => 41, # RFC6891 RFC3225
94 APL => 42, # RFC3123
95 DS => 43, # RFC4034 RFC3658
96 SSHFP => 44, # RFC4255
97 IPSECKEY => 45, # RFC4025
98 RRSIG => 46, # RFC4034 RFC3755
99 NSEC => 47, # RFC4034 RFC3755
100 DNSKEY => 48, # RFC4034 RFC3755
101 DHCID => 49, # RFC4701
102 NSEC3 => 50, # RFC5155
103 NSEC3PARAM => 51, # RFC5155
104 TLSA => 52, # RFC6698
105 SMIMEA => 53, # RFC8162
106 HIP => 55, # RFC8005
107 NINFO => 56, #
108 RKEY => 57, #
109 TALINK => 58, #
110 CDS => 59, # RFC7344
111 CDNSKEY => 60, # RFC7344
112 OPENPGPKEY => 61, # RFC7929
113 CSYNC => 62, # RFC7477
114 ZONEMD => 63, # RFC8976
115 SVCB => 64, # draft-ietf-dnsop-svcb-https-00
116 HTTPS => 65, # draft-ietf-dnsop-svcb-https-00
117 SPF => 99, # RFC7208
118 UINFO => 100, # IANA-Reserved
119 UID => 101, # IANA-Reserved
120 GID => 102, # IANA-Reserved
121 UNSPEC => 103, # IANA-Reserved
122 NID => 104, # RFC6742
123 L32 => 105, # RFC6742
124 L64 => 106, # RFC6742
125 LP => 107, # RFC6742
126 EUI48 => 108, # RFC7043
127 EUI64 => 109, # RFC7043
128 TKEY => 249, # RFC2930
129 TSIG => 250, # RFC8945
130 IXFR => 251, # RFC1995
131 AXFR => 252, # RFC1035 RFC5936
132 MAILB => 253, # RFC1035
133 MAILA => 254, # RFC1035
134 ANY => 255, # RFC1035 RFC6895 RFC8482
135 URI => 256, # RFC7553
136 CAA => 257, # RFC8659
137 AVC => 258, #
138 DOA => 259, # draft-durand-doa-over-dns
139 AMTRELAY => 260, # RFC8777
140 TA => 32768, # http://cameo.library.cmu.edu/ http://www.watson.org/~weiler/INI1999-19.pdf
141 DLV => 32769, # RFC8749 RFC4431
142 );
143our %typebyval = reverse( TYPE0 => 0, @typebyname );
144push @typebyname, map { /^\d/ ? $_ : lc($_) } @typebyname;
145our %typebyname = ( '*' => 255, @typebyname );
146
147
148# Registry: DNS OpCodes
149my @opcodebyname = (
150 QUERY => 0, # RFC1035
151 IQUERY => 1, # RFC3425
152 STATUS => 2, # RFC1035
153 NOTIFY => 4, # RFC1996
154 UPDATE => 5, # RFC2136
155 DSO => 6, # RFC8490
156 );
157our %opcodebyval = reverse @opcodebyname;
158push @opcodebyname, map { /^\d/ ? $_ : lc($_) } @opcodebyname;
159our %opcodebyname = ( NS_NOTIFY_OP => 4, @opcodebyname );
160
161
162# Registry: DNS RCODEs
163my @rcodebyname = (
164 NOERROR => 0, # RFC1035
165 FORMERR => 1, # RFC1035
166 SERVFAIL => 2, # RFC1035
167 NXDOMAIN => 3, # RFC1035
168 NOTIMP => 4, # RFC1035
169 REFUSED => 5, # RFC1035
170 YXDOMAIN => 6, # RFC2136 RFC6672
171 YXRRSET => 7, # RFC2136
172 NXRRSET => 8, # RFC2136
173 NOTAUTH => 9, # RFC2136
174 NOTAUTH => 9, # RFC8945
175 NOTZONE => 10, # RFC2136
176 DSOTYPENI => 11, # RFC8490
177 BADVERS => 16, # RFC6891
178 BADSIG => 16, # RFC8945
179 BADKEY => 17, # RFC8945
180 BADTIME => 18, # RFC8945
181 BADMODE => 19, # RFC2930
182 BADNAME => 20, # RFC2930
183 BADALG => 21, # RFC2930
184 BADTRUNC => 22, # RFC8945
185 BADCOOKIE => 23, # RFC7873
186 );
187our %rcodebyval = reverse( BADSIG => 16, @rcodebyname );
188push @rcodebyname, map { /^\d/ ? $_ : lc($_) } @rcodebyname;
189our %rcodebyname = @rcodebyname;
190
191
192# Registry: DNS EDNS0 Option Codes (OPT)
193my @ednsoptionbyname = (
194 LLQ => 1, # RFC8764
195 UL => 2, # http://files.dns-sd.org/draft-sekar-dns-ul.txt
196 NSID => 3, # RFC5001
197 DAU => 5, # RFC6975
198 DHU => 6, # RFC6975
199 N3U => 7, # RFC6975
200 'CLIENT-SUBNET' => 8, # RFC7871
201 EXPIRE => 9, # RFC7314
202 COOKIE => 10, # RFC7873
203 'TCP-KEEPALIVE' => 11, # RFC7828
204 PADDING => 12, # RFC7830
205 CHAIN => 13, # RFC7901
206 'KEY-TAG' => 14, # RFC8145
207 'EXTENDED-ERROR' => 15, # RFC8914
208 'CLIENT-TAG' => 16, # draft-bellis-dnsop-edns-tags
209 'SERVER-TAG' => 17, # draft-bellis-dnsop-edns-tags
210 DEVICEID => 26946, # https://docs.umbrella.com/developer/networkdevices-api/identifying-dns-traffic2
211 );
212our %ednsoptionbyval = reverse @ednsoptionbyname;
213push @ednsoptionbyname, map { /^\d/ ? $_ : lc($_) } @ednsoptionbyname;
214our %ednsoptionbyname = @ednsoptionbyname;
215
216
217# Registry: DNS Header Flags
218my @dnsflagbyname = (
219 AA => 0x0400, # RFC1035
220 TC => 0x0200, # RFC1035
221 RD => 0x0100, # RFC1035
222 RA => 0x0080, # RFC1035
223 AD => 0x0020, # RFC4035 RFC6840
224 CD => 0x0010, # RFC4035 RFC6840
225 );
226push @dnsflagbyname, map { /^\d/ ? $_ : lc($_) } @dnsflagbyname;
227our %dnsflagbyname = @dnsflagbyname;
228
229
230# Registry: EDNS Header Flags (16 bits)
231my @ednsflagbyname = (
232 DO => 0x8000, # RFC4035 RFC3225 RFC6840
233 );
234push @ednsflagbyname, map { /^\d/ ? $_ : lc($_) } @ednsflagbyname;
235our %ednsflagbyname = @ednsflagbyname;
236
237
238# Registry: DSO Type Codes
239my @dsotypebyname = (
240 KEEPALIVE => 0x0001, # RFC8490
241 RETRYDELAY => 0x0002, # RFC8490
242 ENCRYPTIONPADDING => 0x0003, # RFC8490
243 SUBSCRIBE => 0x0040, # RFC8765
244 PUSH => 0x0041, # RFC8765
245 UNSUBSCRIBE => 0x0042, # RFC8765
246 RECONFIRM => 0x0043, # RFC8765
247 );
248our %dsotypebyval = reverse @dsotypebyname;
249push @dsotypebyname, map { /^\d/ ? $_ : lc($_) } @dsotypebyname;
250our %dsotypebyname = @dsotypebyname;
251
252
253########
254
255# The following functions are wrappers around similarly named hashes.
256
257sub classbyname {
258 my $name = shift;
259
260 return $classbyname{$name} || $classbyname{uc $name} || return do {
261 croak qq[unknown class "$name"] unless $name =~ m/^(CLASS)?(\d+)/i;
262 my $val = 0 + $2;
263 croak qq[classbyname("$name") out of range] if $val > 0xffff;
264 return $val;
265 }
266}
267
268sub classbyval {
269 my $val = shift;
270
271 return $classbyval{$val} || return do {
272 $val += 0;
273 croak qq[classbyval($val) out of range] if $val > 0xffff;
274 return "CLASS$val";
275 }
276}
277
278
279sub typebyname {
280 my $name = shift;
281
282 return $typebyname{$name} || return do {
283 if ( $name =~ m/^(TYPE)?(\d+)/i ) {
284 my $val = 0 + $2;
285 croak qq[typebyname("$name") out of range] if $val > 0xffff;
286 return $val;
287 }
288 _typespec("$name.RRNAME") unless $typebyname{uc $name};
289 return $typebyname{uc $name} || croak qq[unknown type "$name"];
290 }
291}
292
293sub typebyval {
294 my $val = shift;
295
296 return $typebyval{$val} || return do {
297 $val += 0;
298 croak qq[typebyval($val) out of range] if $val > 0xffff;
299 $typebyval{$val} = "TYPE$val";
300 _typespec("$val.RRTYPE");
301 return $typebyval{$val};
302 }
303}
304
305
306sub opcodebyname {
307 my $arg = shift;
308 my $val = $opcodebyname{$arg};
309 return $val if defined $val;
310 return $arg if $arg =~ /^\d/;
311 croak qq[unknown opcode "$arg"];
312}
313
314sub opcodebyval {
315 my $val = shift;
316 return $opcodebyval{$val} || return "$val";
317}
318
319
320sub rcodebyname {
321 my $arg = shift;
322 my $val = $rcodebyname{$arg};
323 return $val if defined $val;
324 return $arg if $arg =~ /^\d/;
325 croak qq[unknown rcode "$arg"];
326}
327
328sub rcodebyval {
329 my $val = shift;
330 return $rcodebyval{$val} || return "$val";
331}
332
333
334sub ednsoptionbyname {
335 my $arg = shift;
336 my $val = $ednsoptionbyname{$arg};
337 return $val if defined $val;
338 return $arg if $arg =~ /^\d/;
339 croak qq[unknown option "$arg"];
340}
341
342sub ednsoptionbyval {
343 my $val = shift;
344 return $ednsoptionbyval{$val} || return "$val";
345}
346
347
348sub dsotypebyname {
349 my $arg = shift;
350 my $val = $dsotypebyname{$arg};
351 return $val if defined $val;
352 return $arg if $arg =~ /^\d/;
353 croak qq[unknown DSO type "$arg"];
354}
355
356sub dsotypebyval {
357 my $val = shift;
358 return $dsotypebyval{$val} || return "$val";
359}
360
361
362sub register { ## register( 'TOY', 1234 ) (NOT part of published API)
363 my ( $mnemonic, $rrtype ) = @_; # uncoverable pod
364 $rrtype = rand(255) + 65280 unless $rrtype;
365 croak qq["$mnemonic" is a CLASS identifier] if defined $classbyname{$mnemonic = uc($mnemonic)};
366 for ( typebyval( $rrtype = int $rrtype ) ) {
367 return $rrtype if /^$mnemonic$/; # duplicate registration
368 croak qq["$mnemonic" conflicts with TYPE$rrtype ($_)] unless /^TYPE\d+$/;
369 my $known = $typebyname{$mnemonic};
370 croak qq["$mnemonic" conflicts with TYPE$known] if $known;
371 }
372 $typebyval{$rrtype} = $mnemonic;
373 return $typebyname{$mnemonic} = $rrtype;
374}
375
376
377use constant EXTLANG => defined eval { require Net::DNS::Extlang };
378
379our $DNSEXTLANG = EXTLANG ? eval { Net::DNS::Extlang->new()->domain } : undef;
380
381sub _typespec {
382 eval { ## draft-levine-dnsextlang
383 <<'END' } if EXTLANG && $DNSEXTLANG;
384 my ($node) = @_;
385
386 require Net::DNS::Resolver;
387 my $resolver = Net::DNS::Resolver->new() || return;
388 my $response = $resolver->send( "$node.$DNSEXTLANG", 'TXT' ) || return;
389
390 foreach my $txt ( grep { $_->type eq 'TXT' } $response->answer ) {
391 my @stanza = $txt->txtdata;
392 my ( $tag, $identifier, @attribute ) = @stanza;
393 next unless defined($tag) && $tag =~ /^RRTYPE=\d+$/;
394 register( $1, $2 ) if $identifier =~ /^(\w+):(\d+)\W*/;
395 return unless defined wantarray;
396
397 my $extobj = Net::DNS::Extlang->new();
398 my $recipe = $extobj->xlstorerecord( $identifier, @attribute );
399 my @source = split /\n/, $extobj->compilerr($recipe);
400 return sub { defined( $_ = shift @source ) };
401 }
402END
403 return;
404}
405
406
4071;
408__END__