DNS/Parameters.pm

filter: Statementstmt 100% 119 / 119 Branchbran 100% 46 / 46 Conditioncond 95.8% 23 / 24 MC/DCmcdc 75.0% 9 / 12 Subroutinesub 100% 19 / 19 Podpod 100% 12 / 12 totaltotal 98.2% 228 / 232 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-07-06)
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 2054 2026-07-10 09:37:11Z 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 SPF => 99, # RFC7208
125 UINFO => 100, # IANA-Reserved
126 UID => 101, # IANA-Reserved
127 GID => 102, # IANA-Reserved
128 UNSPEC => 103, # IANA-Reserved
129 NID => 104, # RFC6742
130 L32 => 105, # RFC6742
131 L64 => 106, # RFC6742
132 LP => 107, # RFC6742
133 EUI48 => 108, # RFC7043
134 EUI64 => 109, # RFC7043
135 NXNAME => 128, # RFC9824
136 TKEY => 249, # RFC2930
137 TSIG => 250, # RFC8945
138 IXFR => 251, # RFC1995
139 AXFR => 252, # RFC1035 RFC5936
140 MAILB => 253, # RFC1035
141 MAILA => 254, # RFC1035
142 ANY => 255, # RFC1035 RFC6895 RFC8482
143 URI => 256, # RFC7553
144 CAA => 257, # RFC8659
145 AVC => 258, #
146 DOA => 259, # draft-durand-doa-over-dns-02
147 AMTRELAY => 260, # RFC8777
148 RESINFO => 261, # RFC9606
149 WALLET => 262, #
150 CLA => 263, # draft-johnson-dns-ipn-cla-07
151 IPN => 264, # draft-johnson-dns-ipn-cla-07
152 TA => 32768, # http://www.watson.org/~weiler/INI1999-19.pdf
153 DLV => 32769, # RFC8749 RFC4431
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, # RFC-ietf-dnssd-multi-qtypes-14
225 'MQTYPE-RESPONSE' => 21, # RFC-ietf-dnssd-multi-qtypes-14
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 'UMBRELLA-IDENT' => 20292, # https://developer.cisco.com/docs/cloud-security/#!integrating-network-devic
231 DEVICEID => 26946, # https://developer.cisco.com/docs/cloud-security/#!network-devices-getting-s
232 );
233 98 our %ednsoptionbyval = reverse @ednsoptionbyname;
234 98 ▶push @ednsoptionbyname, map { /^\d/ ? $_ : lc($_) } @ednsoptionbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 2548 2548 5096
235 98 our %ednsoptionbyname = @ednsoptionbyname;
236  
237  
238 # Registry: DNS Header Flags
239 98 my @dnsflagbyname = (
240 AA => 0x0400, # RFC1035
241 TC => 0x0200, # RFC1035
242 RD => 0x0100, # RFC1035
243 RA => 0x0080, # RFC1035
244 AD => 0x0020, # RFC4035 RFC6840
245 CD => 0x0010, # RFC4035 RFC6840
246 );
247 98 ▶push @dnsflagbyname, map { /^\d/ ? $_ : lc($_) } @dnsflagbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 588 588 1176
248 98 our %dnsflagbyname = @dnsflagbyname;
249  
250  
251 # Registry: EDNS Header Flags (16 bits)
252 98 my @ednsflagbyname = (
253 DO => 0x8000, # RFC4035 RFC3225 RFC6840
254 CO => 0x4000, # RFC9824
255 );
256 98 ▶push @ednsflagbyname, map { /^\d/ ? $_ : lc($_) } @ednsflagbyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 196 196 392
257 98 our %ednsflagbyname = @ednsflagbyname;
258  
259  
260 # Registry: DSO Type Codes
261 98 my @dsotypebyname = (
262 KEEPALIVE => 0x0001, # RFC8490
263 RETRYDELAY => 0x0002, # RFC8490
264 ENCRYPTIONPADDING => 0x0003, # RFC8490
265 SUBSCRIBE => 0x0040, # RFC8765
266 PUSH => 0x0041, # RFC8765
267 UNSUBSCRIBE => 0x0042, # RFC8765
268 RECONFIRM => 0x0043, # RFC8765
269 );
270 98 our %dsotypebyval = reverse @dsotypebyname;
271 98 ▶push @dsotypebyname, map { /^\d/ ? $_ : lc($_) } @dsotypebyname;
Branch: 1 branch
BranchTrueFalseTotal
/^\d/ ? : 686 686 1372
272 98 our %dsotypebyname = @dsotypebyname;
273  
274  
275 # Registry: Extended DNS Error Codes
276 98 my @dnserrorbyval = (
277 0 => 'Other Error', # RFC8914
278 1 => 'Unsupported DNSKEY Algorithm', # RFC8914
279 2 => 'Unsupported DS Digest Type', # RFC8914
280 3 => 'Stale Answer', # RFC8914 RFC8767
281 4 => 'Forged Answer', # RFC8914
282 5 => 'DNSSEC Indeterminate', # RFC8914
283 6 => 'DNSSEC Bogus', # RFC8914
284 7 => 'Signature Expired', # RFC8914
285 8 => 'Signature Not Yet Valid', # RFC8914
286 9 => 'DNSKEY Missing', # RFC8914
287 10 => 'RRSIGs Missing', # RFC8914
288 11 => 'No Zone Key Bit Set', # RFC8914
289 12 => 'NSEC Missing', # RFC8914
290 13 => 'Cached Error', # RFC8914
291 14 => 'Not Ready', # RFC8914
292 15 => 'Blocked', # RFC8914
293 16 => 'Censored', # RFC8914
294 17 => 'Filtered', # RFC8914
295 18 => 'Prohibited', # RFC8914
296 19 => 'Stale NXDomain Answer', # RFC8914
297 20 => 'Not Authoritative', # RFC8914
298 21 => 'Not Supported', # RFC8914
299 22 => 'No Reachable Authority', # RFC8914
300 23 => 'Network Error', # RFC8914
301 24 => 'Invalid Data', # RFC8914
302 25 => 'Signature Expired before Valid', # https://github.com/NLnetLabs/unbound/pull/604#discussion_r802678343
303 26 => 'Too Early', # RFC9250
304 27 => 'Unsupported NSEC3 Iterations Value', # RFC9276
305 28 => 'Unable to conform to policy', # draft-homburg-dnsop-codcp-00
306 29 => 'Synthesized', # https://github.com/PowerDNS/pdns/pull/12334
307 30 => 'Invalid Query Type', # RFC9824
308 31 => 'Rate Limited', # draft-muks-dns-ede-rate-limited-02
309 32 => 'Over Quota', # draft-muks-dns-ede-rate-limited-02
310 33 => 'Negative Trust Anchor', # draft-farrokhi-dnsop-ede-nta-00
311 34 => 'New Delegation Only', # draft-ietf-deleg-10
312 );
313 98 our %dnserrorbyval = @dnserrorbyval;
314  
315  
316 ########
317  
318 # The following functions are wrappers around similarly named hashes.
319  
320 sub classbyname {
321 1284 ▶ my $name = shift;
Subroutine classbyname: called CC=5 SCAR=16.1
Pod documented
322  
323 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
324 23 ▶ croak qq[unknown class "$name"] unless $name =~ m/^(CLASS)?(\d+)/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /^(CLASS)?(\d+)/i 1 22 23
325 22 my $val = 0 + $2;
326 22 ▶ croak qq[classbyname("$name") out of range] if $val > 0x7fff;
Branch: 1 branch
BranchTrueFalseTotal
if $val > 32767 2 20 22
327 20 return $val;
328 }
329 }
330  
331 sub classbyval {
332 1245 ▶ my $arg = shift;
Subroutine classbyval: called CC=4 SCAR=13.9
Pod documented
333  
334 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
335 2 my $val = ( $arg += 0 ) & 0x7fff; # MSB used by mDNS
336 2 ▶ croak qq[classbyval($arg) out of range] if $arg > 0xffff;
Branch: 1 branch
BranchTrueFalseTotal
if $arg > 65535 1 1 2
337 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
338 }
339 }
340  
341  
342 sub typebyname {
343 1050 ▶ my $name = shift;
Subroutine typebyname: called CC=6 SCAR=17.9
Pod documented
344  
345 1050 ▶ 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
99258
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
346 58 ▶ if ( $name =~ m/^(TYPE)?(\d+)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(TYPE)?(\d+)/i) 53 5 58
347 53 my $val = 0 + $2;
348 53 ▶ croak qq[typebyname("$name") out of range] if $val > 0xffff;
Branch: 1 branch
BranchTrueFalseTotal
if $val > 65535 1 52 53
349 52 return $val;
350 }
351 5 ▶ _typespec("$name.RRNAME") unless $typebyname{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $Net::DNS::Parameters::typebyname{uc $name} 3 2 5
352 5 ▶ return $typebyname{uc $name} || croak qq[unknown type "$name"];
Condition100%3/3
$Net::DNS::Parameters::typebyname{uc $name} || croak(qq[unknown type "$name"])
l!l&&r!l&&!r
221
MC/DC0%0/2
$Net::DNS::Parameters::typebyname{uc $name} || croak(qq[unknown type "$name"])
$Net::DNS::Parameters::typebyname{uc $name} croak(qq[unknown type "$name"])
Truth table33%1/3
A || B
A= $Net::DNS::Parameters::typebyname{uc $name}B= croak(qq[unknown type "$name"])
ABresult
1X1
011
000
353 }
354 }
355  
356 sub typebyval {
357 2876 ▶ my $val = shift;
Subroutine typebyval: called CC=3 SCAR=11.0
Pod documented
358  
359 2876 ▶ 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
28742
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
360 2 $val += 0;
361 2 ▶ croak qq[typebyval($val) out of range] if $val > 0xffff;
Branch: 1 branch
BranchTrueFalseTotal
if $val > 65535 1 1 2
362 1 $typebyval{$val} = "TYPE$val";
363 1 _typespec("$val.RRTYPE");
364 1 return $typebyval{$val};
365 }
366 }
367  
368  
369 sub opcodebyname {
370 68 ▶ my $arg = shift;
Subroutine opcodebyname: called CC=3 SCAR=11.0
Pod documented
371 68 my $val = $opcodebyname{$arg};
372 68 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 66 2 68
373 2 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 1 1 2
374 1 croak qq[unknown opcode "$arg"];
375 }
376  
377 sub opcodebyval {
378 70 ▶ my $val = shift;
Subroutine opcodebyval: called CC=2 SCAR=6.9
Pod documented
379 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
380 }
381  
382  
383 sub rcodebyname {
384 58 ▶ my $arg = shift;
Subroutine rcodebyname: called CC=3 SCAR=11.0
Pod documented
385 58 my $val = $rcodebyname{$arg};
386 58 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 50 8 58
387 8 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 7 1 8
388 1 croak qq[unknown rcode "$arg"];
389 }
390  
391 sub rcodebyval {
392 278 ▶ my $val = shift;
Subroutine rcodebyval: called CC=2 SCAR=6.9
Pod documented
393 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
394 }
395  
396  
397 sub ednsoptionbyname {
398 186 ▶ my $arg = shift;
Subroutine ednsoptionbyname: called CC=3 SCAR=11.0
Pod documented
399 186 my $val = $ednsoptionbyname{$arg};
400 186 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 146 40 186
401 40 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 39 1 40
402 1 croak qq[unknown option "$arg"];
403 }
404  
405 sub ednsoptionbyval {
406 122 ▶ my $val = shift;
Subroutine ednsoptionbyval: called CC=2 SCAR=6.9
Pod documented
407 122 ▶ return $ednsoptionbyval{$val} || return "$val";
Condition100%2/2
$Net::DNS::Parameters::ednsoptionbyval{$val} || (return "$val")
l!l
1166
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
408 }
409  
410  
411 sub dsotypebyname {
412 9 ▶ my $arg = shift;
Subroutine dsotypebyname: called CC=3 SCAR=11.0
Pod documented
413 9 my $val = $dsotypebyname{$arg};
414 9 ▶ return $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 7 2 9
415 2 ▶ return $arg if $arg =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /^\d/ 1 1 2
416 1 croak qq[unknown DSO type "$arg"];
417 }
418  
419 sub dsotypebyval {
420 9 ▶ my $val = shift;
Subroutine dsotypebyval: called CC=2 SCAR=6.9
Pod documented
421 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
422 }
423  
424  
425 98 ▶use constant EXTLANG => defined eval { require Net::DNS::Extlang };
Subroutine BEGIN: called CC=1 SCAR=0.0
426  
427 sub _typespec {
428 5 ▶ my $generate = defined wantarray;
Subroutine _typespec: called CC=1 SCAR=0.0
429 5 return EXTLANG ? eval <<'END' : ''; ## no critic
430 my ($node) = @_;
431 my $instance = Net::DNS::Extlang->new(); ## draft-levine-dnsextlang
432 my $basename = $instance->domain || return '';
433  
434 require Net::DNS::Resolver;
435 my $resolver = Net::DNS::Resolver->new();
436 my $response = $resolver->send( "$node.$basename", 'TXT' ) || return '';
437  
438 foreach my $txt ( grep { $_->type eq 'TXT' } $response->answer ) {
439 my @stanza = $txt->txtdata;
440 my ( $tag, $identifier, @attribute ) = @stanza;
441 next unless defined($tag) && $tag =~ /^RRTYPE=\d+$/;
442 if ( $identifier =~ /^(\w+):(\d+)\W*/ ) {
443 my ( $mnemonic, $rrtype ) = ( uc($1), $2 );
444 croak qq["$mnemonic" is a CLASS identifier] if $classbyname{$mnemonic};
445 for ( typebyval($rrtype) ) {
446 next if /^$mnemonic$/i; # duplicate registration
447 croak qq["$mnemonic" conflicts with TYPE$rrtype ($_)] unless /^TYPE\d+$/;
448 my $known = $typebyname{$mnemonic};
449 croak qq["$mnemonic" conflicts with TYPE$known] if $known;
450 $typebyval{$rrtype} = $mnemonic;
451 $typebyname{$mnemonic} = $rrtype;
452 }
453 }
454 return unless $generate;
455  
456 my $recipe = $instance->xlstorerecord( $identifier, @attribute );
457 return $instance->compilerr($recipe);
458 }
459 END
460 }
461  
462  
463 98 1;
464 __END__
« DNS/RR/DNSKEY.pm ↑ Summary DNS/RR/NSEC3.pm »