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