DNS/Parameters.pm

filter: Statementstmt 100% 119 / 119 Branchbran 100% 46 / 46 Conditioncond 95.6% 22 / 23 MC/DCmcdc 90.9% 10 / 11 Subroutinesub 100% 19 / 19 Podpod 100% 12 / 12 totaltotal 99.1% 228 / 230 CC 27 SCAR 11.7
CC
27
Cov
99%
typebyname
6.0
classbyname
5.0
classbyval
4.0
CRAP 3.2
« DNS/RR/DNSKEY.pm ↑ Summary DNS/RR/NSEC3.pm »
1 package Net::DNS::Parameters;
2  
3 ################################################
4 ##
5 ## Domain Name System (DNS) Parameters
6 ## (last updated 2026-08-24)
7 ##
8 ################################################
9  
10 98 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 98 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 98 our $VERSION = (qw$Id: Parameters.pm 2059 2026-08-28 10:04:18Z willem $)[2];
13  
14 98 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 98 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 98 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 98 our @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  
28 98 our %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
39 98 my @classbyname = (
40 IN => 1, # RFC1035
41 CH => 3, # Chaosnet
42 HS => 4, # Hesiod
43 NONE => 254, # RFC2136
44 ANY => 255, # RFC1035
45 );
46 98 our %classbyval = reverse( CLASS0 => 0, @classbyname );
47 98 ▶push @classbyname, map { /^\d/ ? $_ : lc($_) } @classbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 490 490 980
48 98 our %classbyname = ( '*' => 255, @classbyname );
49  
50  
51 # Registry: Resource Record (RR) TYPEs
52 98 my @typebyname = (
53 DELEG => 65432, # draft-ietf-deleg-02
54 DELEG => 61440, # draft-ietf-deleg-03
55 DELEGPARAM => 65433, # draft-ietf-deleg-07
56 DELEGI => 65433, # draft-ietf-deleg-03
57 A => 1, # RFC1035
58 NS => 2, # RFC1035
59 MD => 3, # RFC1035
60 MF => 4, # RFC1035
61 CNAME => 5, # RFC1035
62 SOA => 6, # RFC1035
63 MB => 7, # RFC1035
64 MG => 8, # RFC1035
65 MR => 9, # RFC1035
66 NULL => 10, # RFC1035
67 WKS => 11, # RFC1035
68 PTR => 12, # RFC1035
69 HINFO => 13, # RFC1035
70 MINFO => 14, # RFC1035
71 MX => 15, # RFC1035
72 TXT => 16, # RFC1035
73 RP => 17, # RFC1183
74 AFSDB => 18, # RFC1183 RFC5864
75 X25 => 19, # RFC1183
76 ISDN => 20, # RFC1183
77 RT => 21, # RFC1183
78 NSAP => 22, # RFC1706 https://datatracker.ietf.org/doc/status-change-int-tlds-to-historic
79 'NSAP-PTR' => 23, # RFC1706 https://datatracker.ietf.org/doc/status-change-int-tlds-to-historic
80 SIG => 24, # RFC2536 RFC2931 RFC3110 RFC4034
81 KEY => 25, # RFC2536 RFC2539 RFC3110 RFC4034
82 PX => 26, # RFC2163
83 GPOS => 27, # RFC1712
84 AAAA => 28, # RFC3596
85 LOC => 29, # RFC1876
86 NXT => 30, # RFC2535 RFC3755
87 EID => 31, # http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
88 NIMLOC => 32, # http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt
89 SRV => 33, # RFC2782
90 ATMA => 34, # http://www.broadband-forum.org/ftp/pub/approved-specs/af-dans-0152.000.pdf
91 NAPTR => 35, # RFC3403
92 KX => 36, # RFC2230
93 CERT => 37, # RFC4398
94 A6 => 38, # RFC2874 RFC3226 RFC6563
95 DNAME => 39, # RFC6672
96 SINK => 40, # draft-eastlake-kitchen-sink-02
97 OPT => 41, # RFC3225 RFC6891
98 APL => 42, # RFC3123
99 DS => 43, # RFC4034
100 SSHFP => 44, # RFC4255
101 IPSECKEY => 45, # RFC4025
102 RRSIG => 46, # RFC4034
103 NSEC => 47, # RFC4034 RFC9077
104 DNSKEY => 48, # RFC4034
105 DHCID => 49, # RFC4701
106 NSEC3 => 50, # RFC5155 RFC9077
107 NSEC3PARAM => 51, # RFC5155
108 TLSA => 52, # RFC6698
109 SMIMEA => 53, # RFC8162
110 HIP => 55, # RFC8005
111 NINFO => 56, #
112 RKEY => 57, #
113 TALINK => 58, #
114 CDS => 59, # RFC7344
115 CDNSKEY => 60, # RFC7344
116 OPENPGPKEY => 61, # RFC7929
117 CSYNC => 62, # RFC7477
118 ZONEMD => 63, # RFC8976
119 SVCB => 64, # RFC9460
120 HTTPS => 65, # RFC9460
121 DSYNC => 66, # RFC9859
122 HHIT => 67, # RFC9886
123 BRID => 68, # RFC9886
124 UNECE => 69, # draft-woodcock-faltstrom-external-registry-rrtypes-00
125 ISO => 70, # draft-woodcock-faltstrom-external-registry-rrtypes-00
126 SPF => 99, # RFC7208
127 UINFO => 100, # IANA-Reserved
128 UID => 101, # IANA-Reserved
129 GID => 102, # IANA-Reserved
130 UNSPEC => 103, # IANA-Reserved
131 NID => 104, # RFC6742
132 L32 => 105, # RFC6742
133 L64 => 106, # RFC6742
134 LP => 107, # RFC6742
135 EUI48 => 108, # RFC7043
136 EUI64 => 109, # RFC7043
137 NXNAME => 128, # RFC9824
138 TKEY => 249, # RFC2930
139 TSIG => 250, # RFC8945
140 IXFR => 251, # RFC1995
141 AXFR => 252, # RFC1035 RFC5936
142 MAILB => 253, # RFC1035
143 MAILA => 254, # RFC1035
144 ANY => 255, # RFC1035 RFC6895 RFC8482
145 URI => 256, # RFC7553
146 CAA => 257, # RFC8659
147 AVC => 258, #
148 DOA => 259, # draft-durand-doa-over-dns-02
149 AMTRELAY => 260, # RFC8777
150 RESINFO => 261, # RFC9606
151 WALLET => 262, #
152 CLA => 263, # draft-johnson-dns-ipn-cla-07
153 IPN => 264, # draft-johnson-dns-ipn-cla-07
154 TA => 32768, # http://www.watson.org/~weiler/INI1999-19.pdf
155 DLV => 32769, # RFC8749 RFC4431
156 );
157 98 our %typebyval = reverse( TYPE0 => 0, @typebyname );
158 98 ▶push @typebyname, map { /^\d/ ? $_ : lc($_) } @typebyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 10094 10094 20188
159 98 our %typebyname = ( '*' => 255, @typebyname );
160  
161  
162 # Registry: DNS OpCodes
163 98 my @opcodebyname = (
164 QUERY => 0, # RFC1035
165 IQUERY => 1, # RFC3425
166 STATUS => 2, # RFC1035
167 NOTIFY => 4, # RFC1996
168 UPDATE => 5, # RFC2136
169 DSO => 6, # RFC8490
170 );
171 98 our %opcodebyval = reverse @opcodebyname;
172 98 ▶push @opcodebyname, map { /^\d/ ? $_ : lc($_) } @opcodebyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 588 588 1176
173 98 our %opcodebyname = ( NS_NOTIFY_OP => 4, @opcodebyname );
174  
175  
176 # Registry: DNS RCODEs
177 98 my @rcodebyname = (
178 NOERROR => 0, # RFC1035
179 FORMERR => 1, # RFC1035
180 SERVFAIL => 2, # RFC1035
181 NXDOMAIN => 3, # RFC1035
182 NOTIMP => 4, # RFC1035
183 REFUSED => 5, # RFC1035
184 YXDOMAIN => 6, # RFC2136 RFC6672
185 YXRRSET => 7, # RFC2136
186 NXRRSET => 8, # RFC2136
187 NOTAUTH => 9, # RFC2136
188 NOTAUTH => 9, # RFC8945
189 NOTZONE => 10, # RFC2136
190 DSOTYPENI => 11, # RFC8490
191 BADVERS => 16, # RFC6891
192 BADSIG => 16, # RFC8945
193 BADKEY => 17, # RFC8945
194 BADTIME => 18, # RFC8945
195 BADMODE => 19, # RFC2930
196 BADNAME => 20, # RFC2930
197 BADALG => 21, # RFC2930
198 BADTRUNC => 22, # RFC8945
199 BADCOOKIE => 23, # RFC7873
200 );
201 98 our %rcodebyval = reverse( BADSIG => 16, @rcodebyname );
202 98 ▶push @rcodebyname, map { /^\d/ ? $_ : lc($_) } @rcodebyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 2156 2156 4312
203 98 our %rcodebyname = @rcodebyname;
204  
205  
206 # Registry: DNS EDNS0 Option Codes (OPT)
207 98 my @ednsoptionbyname = (
208 LLQ => 1, # RFC8764
209 'UPDATE-LEASE' => 2, # RFC9664
210 NSID => 3, # RFC5001
211 DAU => 5, # RFC6975
212 DHU => 6, # RFC6975
213 N3U => 7, # RFC6975
214 'CLIENT-SUBNET' => 8, # RFC7871
215 EXPIRE => 9, # RFC7314
216 COOKIE => 10, # RFC7873
217 'TCP-KEEPALIVE' => 11, # RFC7828
218 PADDING => 12, # RFC7830
219 CHAIN => 13, # RFC7901
220 'KEY-TAG' => 14, # RFC8145
221 'EXTENDED-ERROR' => 15, # RFC8914
222 'CLIENT-TAG' => 16, # draft-bellis-dnsop-edns-tags-01
223 'SERVER-TAG' => 17, # draft-bellis-dnsop-edns-tags-01
224 'REPORT-CHANNEL' => 18, # RFC9567
225 ZONEVERSION => 19, # RFC9660
226 'MQTYPE-QUERY' => 20, # RFC10029
227 'MQTYPE-RESPONSE' => 21, # RFC10029
228 'EDE-EXTRA-TEXT-LANGUAGE' => 22, # draft-muks-dns-filtering-05
229 'FILTERING-CONTACT' => 23, # draft-muks-dns-filtering-05
230 'FILTERING-ORGANIZATION' => 24, # draft-muks-dns-filtering-05
231 'FILTERING-DB' => 25, # draft-muks-dns-filtering-05
232 'STRUCTURED-ERROR' => 26, # RFC-ietf-dnsop-structured-dns-error-27
233 'UMBRELLA-IDENT' => 20292, # https://developer.cisco.com/docs/cloud-security/#!integrating-network-devic
234 DEVICEID => 26946, # https://developer.cisco.com/docs/cloud-security/#!network-devices-getting-s
235 );
236 98 our %ednsoptionbyval = reverse @ednsoptionbyname;
237 98 ▶push @ednsoptionbyname, map { /^\d/ ? $_ : lc($_) } @ednsoptionbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 2646 2646 5292
238 98 our %ednsoptionbyname = @ednsoptionbyname;
239  
240  
241 # Registry: DNS Header Flags
242 98 my @dnsflagbyname = (
243 AA => 0x0400, # RFC1035
244 TC => 0x0200, # RFC1035
245 RD => 0x0100, # RFC1035
246 RA => 0x0080, # RFC1035
247 AD => 0x0020, # RFC4035 RFC6840
248 CD => 0x0010, # RFC4035 RFC6840
249 );
250 98 ▶push @dnsflagbyname, map { /^\d/ ? $_ : lc($_) } @dnsflagbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 588 588 1176
251 98 our %dnsflagbyname = @dnsflagbyname;
252  
253  
254 # Registry: EDNS Header Flags (16 bits)
255 98 my @ednsflagbyname = (
256 DO => 0x8000, # RFC4035 RFC3225 RFC6840
257 CO => 0x4000, # RFC9824
258 DE => 0x2000, # draft-ietf-dnsop-delext-08
259 );
260 98 ▶push @ednsflagbyname, map { /^\d/ ? $_ : lc($_) } @ednsflagbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 294 294 588
261 98 our %ednsflagbyname = @ednsflagbyname;
262  
263  
264 # Registry: DSO Type Codes
265 98 my @dsotypebyname = (
266 KEEPALIVE => 0x0001, # RFC8490
267 RETRYDELAY => 0x0002, # RFC8490
268 ENCRYPTIONPADDING => 0x0003, # RFC8490
269 SUBSCRIBE => 0x0040, # RFC8765
270 PUSH => 0x0041, # RFC8765
271 UNSUBSCRIBE => 0x0042, # RFC8765
272 RECONFIRM => 0x0043, # RFC8765
273 );
274 98 our %dsotypebyval = reverse @dsotypebyname;
275 98 ▶push @dsotypebyname, map { /^\d/ ? $_ : lc($_) } @dsotypebyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 686 686 1372
276 98 our %dsotypebyname = @dsotypebyname;
277  
278  
279 # Registry: Extended DNS Error Codes
280 98 my @dnserrorbyval = (
281 0 => 'Other Error', # RFC8914
282 1 => 'Unsupported DNSKEY Algorithm', # RFC8914
283 2 => 'Unsupported DS Digest Type', # RFC8914
284 3 => 'Stale Answer', # RFC8914 RFC8767
285 4 => 'Forged Answer', # RFC8914
286 5 => 'DNSSEC Indeterminate', # RFC8914
287 6 => 'DNSSEC Bogus', # RFC8914
288 7 => 'Signature Expired', # RFC8914
289 8 => 'Signature Not Yet Valid', # RFC8914
290 9 => 'DNSKEY Missing', # RFC8914
291 10 => 'RRSIGs Missing', # RFC8914
292 11 => 'No Zone Key Bit Set', # RFC8914
293 12 => 'NSEC Missing', # RFC8914
294 13 => 'Cached Error', # RFC8914
295 14 => 'Not Ready', # RFC8914
296 15 => 'Blocked', # RFC8914
297 16 => 'Censored', # RFC8914
298 17 => 'Filtered', # RFC8914
299 18 => 'Prohibited', # RFC8914
300 19 => 'Stale NXDomain Answer', # RFC8914
301 20 => 'Not Authoritative', # RFC8914
302 21 => 'Not Supported', # RFC8914
303 22 => 'No Reachable Authority', # RFC8914
304 23 => 'Network Error', # RFC8914
305 24 => 'Invalid Data', # RFC8914
306 25 => 'Signature Expired before Valid', # https://github.com/NLnetLabs/unbound/pull/604#discussion_r802678343
307 26 => 'Too Early', # RFC9250
308 27 => 'Unsupported NSEC3 Iterations Value', # RFC9276
309 28 => 'Unable to conform to policy', # draft-homburg-dnsop-codcp-00
310 29 => 'Synthesized', # https://github.com/PowerDNS/pdns/pull/12334
311 30 => 'Invalid Query Type', # RFC9824
312 31 => 'Rate Limited', # draft-muks-dns-ede-rate-limited-02
313 32 => 'Over Quota', # draft-muks-dns-ede-rate-limited-02
314 33 => 'Negative Trust Anchor', # draft-farrokhi-dnsop-ede-nta-00
315 34 => 'New Delegation Only', # draft-ietf-deleg-10
316 35 => 'Blocked by Upstream DNS Server', # RFC-ietf-dnsop-structured-dns-error-27
317 );
318 98 our %dnserrorbyval = @dnserrorbyval;
319  
320  
321 ########
322  
323 # The following functions are wrappers around similarly named hashes.
324  
325 1284 ▶sub classbyname {
Subroutine classbyname: called CC=5 SCAR=16.1
Pod documented
326 1284 my $name = shift;
327  
328 1284 ▶ return $classbyname{$name} || $classbyname{uc $name} || return do {
Condition100%5/5
$Net::DNS::Parameters::classbyname{$name} || $Net::DNS::Parameters::classbyname{uc $name} || (return do { croak(qq[unknown class "$name"]) unless $name =~ /^(CLASS)?(\d+)/i; my $val = 0 + $2; croak(qq[classbyname("$name") out of range]) if $val > 32767; return $val })
l!l
126123
$Net::DNS::Parameters::classbyname{$name} or $Net::DNS::Parameters::classbyname{uc $name}
l!l&&r!l&&!r
1260123
MC/DC100%2/2
$Net::DNS::Parameters::classbyname{$name} || $Net::DNS::Parameters::classbyname{uc $name} || (return do { croak(qq[unknown class "$name"]) unless $name =~ /^(CLASS)?(\d+)/i; my $val = 0 + $2; croak(qq[classbyname("$name") out of range]) if $val > 32767; return $val })
$Net::DNS::Parameters::classbyname{$name} $Net::DNS::Parameters::classbyname{uc $name}
Truth table100%3/3
A or B
A= $Net::DNS::Parameters::classbyname{$name}B= $Net::DNS::Parameters::classbyname{uc $name}
ABresult
1X1
011
000
329 23 ▶ croak qq[unknown class "$name"] unless $name =~ m/^(CLASS)?(\d+)/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^(CLASS)?(\d+)/i 1 22 23
330 22 my $val = 0 + $2;
331 22 ▶ croak qq[classbyname("$name") out of range] if $val > 0x7fff;
Branch: 1 branch
BranchTrueFalseTotal
if $val > 32767 2 20 22
332 20 return $val;
333 }
334 }
335  
336 1245 ▶sub classbyval {
Subroutine classbyval: called CC=4 SCAR=13.9
Pod documented
337 1245 my $arg = shift;
338  
339 1245 ▶ return $classbyval{$arg} || return do {
Condition100%2/2
$Net::DNS::Parameters::classbyval{$arg} || (return do { my $val = ($arg += 0) & 32767; croak("classbyval($arg) out of range") if $arg > 65535; return $Net::DNS::Parameters::classbyval{$arg} = $Net::DNS::Parameters::classbyval{$val} || "CLASS$val" })
l!l
12432
MC/DC100%1/1
$Net::DNS::Parameters::classbyval{$arg} || (return do { my $val = ($arg += 0) & 32767; croak("classbyval($arg) out of range") if $arg > 65535; return $Net::DNS::Parameters::classbyval{$arg} = $Net::DNS::Parameters::classbyval{$val} || "CLASS$val" })
$Net::DNS::Parameters::classbyval{$arg}
Truth table100%2/2
A
A= $Net::DNS::Parameters::classbyval{$arg}
Aresult
11
00
340 2 my $val = ( $arg += 0 ) & 0x7fff; # MSB used by mDNS
341 2 ▶ croak qq[classbyval($arg) out of range] if $arg > 0xffff;
Branch: 1 branch
BranchTrueFalseTotal
if $arg > 65535 1 1 2
342 1 ▶ return $classbyval{$arg} = $classbyval{$val} || "CLASS$val";
Condition50%1/2
$Net::DNS::Parameters::classbyval{$val} || "CLASS$val"
l!l
01
MC/DC0%0/1
$Net::DNS::Parameters::classbyval{$val} || "CLASS$val"
$Net::DNS::Parameters::classbyval{$val}
Truth table50%1/2
A
A= $Net::DNS::Parameters::classbyval{$val}
Aresult
11
00
343 }
344 }
345  
346  
347 1056 ▶sub typebyname {
Subroutine typebyname: called CC=6 SCAR=17.9
Pod documented
348 1056 my $name = shift;
349  
350 1056 ▶ return $typebyname{$name} || return do {
Condition100%2/2
$Net::DNS::Parameters::typebyname{$name} || (return do { if ($name =~ /^(TYPE)?(\d+)/i) { my $val = 0 + $2; croak(qq[typebyname("$name") out of range]) if $val > 65535; return $val; } ; _typespec("$name.RRNAME") unless $Net::DNS::Parameters::typebyname{uc $name}; return $Net::DNS::Parameters::typebyname{uc $name} || croak(qq[unknown type "$name"]) })
l!l
99660
MC/DC100%1/1
$Net::DNS::Parameters::typebyname{$name} || (return do { if ($name =~ /^(TYPE)?(\d+)/i) { my $val = 0 + $2; croak(qq[typebyname("$name") out of range]) if $val > 65535; return $val; } ; _typespec("$name.RRNAME") unless $Net::DNS::Parameters::typebyname{uc $name}; return $Net::DNS::Parameters::typebyname{uc $name} || croak(qq[unknown type "$name"]) })
$Net::DNS::Parameters::typebyname{$name}
Truth table100%2/2
A
A= $Net::DNS::Parameters::typebyname{$name}
Aresult
11
00
351 60 ▶ if ( $name =~ m/^(TYPE)?(\d+)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(TYPE)?(\d+)/i) 55 5 60
352 55 my $val = 0 + $2;
353 55 ▶ croak qq[typebyname("$name") out of range] if $val > 0xffff;
Branch: 1 branch
BranchTrueFalseTotal
if $val > 65535 1 54 55
354 54 return $val;
355 }
356 5 ▶ _typespec("$name.RRNAME") unless $typebyname{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $Net::DNS::Parameters::typebyname{uc $name} 3 2 5
357 5 ▶ return $typebyname{uc $name} || croak qq[unknown type "$name"];
Condition100%2/2
$Net::DNS::Parameters::typebyname{uc $name} || croak(qq[unknown type "$name"])
l!l
23
MC/DC100%1/1
$Net::DNS::Parameters::typebyname{uc $name} || croak(qq[unknown type "$name"])
$Net::DNS::Parameters::typebyname{uc $name}
Truth table100%2/2
A
A= $Net::DNS::Parameters::typebyname{uc $name}
Aresult
11
00
358 }
359 }
360  
361 2938 ▶sub typebyval {
Subroutine typebyval: called CC=3 SCAR=11.0
Pod documented
362 2938 my $val = shift;
363  
364 2938 ▶ return $typebyval{$val} || return do {
Condition100%2/2
$Net::DNS::Parameters::typebyval{$val} || (return do { $val += 0; croak("typebyval($val) out of range") if $val > 65535; $Net::DNS::Parameters::typebyval{$val} = "TYPE$val"; _typespec("$val.RRTYPE"); return $Net::DNS::Parameters::typebyval{$val} })
l!l
29362
MC/DC100%1/1
$Net::DNS::Parameters::typebyval{$val} || (return do { $val += 0; croak("typebyval($val) out of range") if $val > 65535; $Net::DNS::Parameters::typebyval{$val} = "TYPE$val"; _typespec("$val.RRTYPE"); return $Net::DNS::Parameters::typebyval{$val} })
$Net::DNS::Parameters::typebyval{$val}
Truth table100%2/2
A
A= $Net::DNS::Parameters::typebyval{$val}
Aresult
11
00
365 2 $val += 0;
366 2 ▶ croak qq[typebyval($val) out of range] if $val > 0xffff;
Branch: 1 branch
BranchTrueFalseTotal
if $val > 65535 1 1 2
367 1 $typebyval{$val} = "TYPE$val";
368 1 _typespec("$val.RRTYPE");
369 1 return $typebyval{$val};
370 }
371 }
372  
373  
374 68 ▶sub opcodebyname {
Subroutine opcodebyname: called CC=3 SCAR=11.0
Pod documented
375 68 my $arg = shift;
376 68 my $val = $opcodebyname{$arg};
377 68 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 66 2 68
378 2 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 1 1 2
379 1 croak qq[unknown opcode "$arg"];
380 }
381  
382 70 ▶sub opcodebyval {
Subroutine opcodebyval: called CC=2 SCAR=6.9
Pod documented
383 70 my $val = shift;
384 70 ▶ return $opcodebyval{$val} || return "$val";
Condition100%2/2
$Net::DNS::Parameters::opcodebyval{$val} || (return "$val")
l!l
691
MC/DC100%1/1
$Net::DNS::Parameters::opcodebyval{$val} || (return "$val")
$Net::DNS::Parameters::opcodebyval{$val}
Truth table100%2/2
A
A= $Net::DNS::Parameters::opcodebyval{$val}
Aresult
11
00
385 }
386  
387  
388 58 ▶sub rcodebyname {
Subroutine rcodebyname: called CC=3 SCAR=11.0
Pod documented
389 58 my $arg = shift;
390 58 my $val = $rcodebyname{$arg};
391 58 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 50 8 58
392 8 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 7 1 8
393 1 croak qq[unknown rcode "$arg"];
394 }
395  
396 278 ▶sub rcodebyval {
Subroutine rcodebyval: called CC=2 SCAR=6.9
Pod documented
397 278 my $val = shift;
398 278 ▶ return $rcodebyval{$val} || return "$val";
Condition100%2/2
$Net::DNS::Parameters::rcodebyval{$val} || (return "$val")
l!l
25919
MC/DC100%1/1
$Net::DNS::Parameters::rcodebyval{$val} || (return "$val")
$Net::DNS::Parameters::rcodebyval{$val}
Truth table100%2/2
A
A= $Net::DNS::Parameters::rcodebyval{$val}
Aresult
11
00
399 }
400  
401  
402 169 ▶sub ednsoptionbyname {
Subroutine ednsoptionbyname: called CC=3 SCAR=11.0
Pod documented
403 169 my $arg = shift;
404 169 my $val = $ednsoptionbyname{$arg};
405 169 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 155 14 169
406 14 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 13 1 14
407 1 croak qq[unknown option "$arg"];
408 }
409  
410 119 ▶sub ednsoptionbyval {
Subroutine ednsoptionbyval: called CC=2 SCAR=6.9
Pod documented
411 119 my $val = shift;
412 119 ▶ return $ednsoptionbyval{$val} || return "$val";
Condition100%2/2
$Net::DNS::Parameters::ednsoptionbyval{$val} || (return "$val")
l!l
1136
MC/DC100%1/1
$Net::DNS::Parameters::ednsoptionbyval{$val} || (return "$val")
$Net::DNS::Parameters::ednsoptionbyval{$val}
Truth table100%2/2
A
A= $Net::DNS::Parameters::ednsoptionbyval{$val}
Aresult
11
00
413 }
414  
415  
416 9 ▶sub dsotypebyname {
Subroutine dsotypebyname: called CC=3 SCAR=11.0
Pod documented
417 9 my $arg = shift;
418 9 my $val = $dsotypebyname{$arg};
419 9 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 7 2 9
420 2 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 1 1 2
421 1 croak qq[unknown DSO type "$arg"];
422 }
423  
424 9 ▶sub dsotypebyval {
Subroutine dsotypebyval: called CC=2 SCAR=6.9
Pod documented
425 9 my $val = shift;
426 9 ▶ return $dsotypebyval{$val} || return "$val";
Condition100%2/2
$Net::DNS::Parameters::dsotypebyval{$val} || (return "$val")
l!l
81
MC/DC100%1/1
$Net::DNS::Parameters::dsotypebyval{$val} || (return "$val")
$Net::DNS::Parameters::dsotypebyval{$val}
Truth table100%2/2
A
A= $Net::DNS::Parameters::dsotypebyval{$val}
Aresult
11
00
427 }
428  
429  
430 98 ▶use constant EXTLANG => defined eval { require Net::DNS::Extlang };
Subroutine BEGIN: called CC=1 SCAR=0.0
431  
432 5 ▶sub _typespec {
Subroutine _typespec: called CC=1 SCAR=0.0
433 5 my $generate = defined wantarray;
434 5 return EXTLANG ? eval <<'END' : ''; ## no critic
435 my ($node) = @_;
436 my $instance = Net::DNS::Extlang->new(); ## draft-levine-dnsextlang
437 my $basename = $instance->domain || return '';
438  
439 require Net::DNS::Resolver;
440 my $resolver = Net::DNS::Resolver->new();
441 my $response = $resolver->send( "$node.$basename", 'TXT' ) || return '';
442  
443 foreach my $txt ( grep { $_->type eq 'TXT' } $response->answer ) {
444 my @stanza = $txt->txtdata;
445 my ( $tag, $identifier, @attribute ) = @stanza;
446 next unless defined($tag) && $tag =~ /^RRTYPE=\d+$/;
447 if ( $identifier =~ /^(\w+):(\d+)\W*/ ) {
448 my ( $mnemonic, $rrtype ) = ( uc($1), $2 );
449 croak qq["$mnemonic" is a CLASS identifier] if $classbyname{$mnemonic};
450 for ( typebyval($rrtype) ) {
451 next if /^$mnemonic$/i; # duplicate registration
452 croak qq["$mnemonic" conflicts with TYPE$rrtype ($_)] unless /^TYPE\d+$/;
453 my $known = $typebyname{$mnemonic};
454 croak qq["$mnemonic" conflicts with TYPE$known] if $known;
455 $typebyval{$rrtype} = $mnemonic;
456 $typebyname{$mnemonic} = $rrtype;
457 }
458 }
459 return unless $generate;
460  
461 my $recipe = $instance->xlstorerecord( $identifier, @attribute );
462 return $instance->compilerr($recipe);
463 }
464 END
465 }
466  
467  
468 98 1;
469 __END__
« DNS/RR/DNSKEY.pm ↑ Summary DNS/RR/NSEC3.pm »