DNS/RR/TKEY.pm

filter: Statementstmt 100% 86 / 86 Branchbran 100% 6 / 6 Conditioncond 100% 14 / 14 MC/DCmcdc 100% 7 / 7 Subroutinesub 100% 20 / 20 Podpod 100% 8 / 9 (1 uncoverable) totaltotal 100% 141 / 142 (1 uncoverable) CC 18 SCAR 8.3
CC
18
Cov
100%
algorithm
3.0
inception
3.0
expiration
3.0
CRAP 2.3
« DNS/RR/CAA.pm ↑ Summary DNS/RR/TXT.pm »
1 package Net::DNS::RR::TKEY;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our $VERSION = (qw$Id: TKEY.pm 2035 2025-08-14 11:49:15Z willem $)[2];
6  
7 1 ▶use base qw(Net::DNS::RR);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 =head1 NAME
11  
12 Net::DNS::RR::TKEY - DNS TKEY resource record
13  
14 =cut
15  
16 1 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DNS::Parameters qw(:class :type);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DNS::DomainName;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use constant ANY => classbyname qw(ANY);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use constant TKEY => typebyname qw(TKEY);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26  
27 3 ▶sub _decode_rdata { ## decode rdata from wire-format octet string
Subroutine _decode_rdata: called CC=2 SCAR=6.9
28 3 my ( $self, $data, $offset ) = @_;
29  
30 3 my $limit = $offset + $self->{rdlength};
31  
32 3 ( $self->{algorithm}, $offset ) = Net::DNS::DomainName->decode( $data, $offset );
33  
34 3 @{$self}{qw(inception expiration mode error)} = unpack "\@$offset N2n2", $$data;
35 3 $offset += 12;
36  
37 3 my $key_size = unpack "\@$offset n", $$data;
38 3 $self->{key} = substr $$data, $offset + 2, $key_size;
39 3 $offset += $key_size + 2;
40  
41 3 my $other_size = unpack "\@$offset n", $$data;
42 3 $self->{other} = substr $$data, $offset + 2, $other_size;
43 3 $offset += $other_size + 2;
44  
45 3 ▶ croak('corrupt TKEY data') unless $offset == $limit; # more or less FUBAR
Branch: 1 branch
BranchTrueFalseTotal
unless $offset == $limit 1 2 3
46 2 return;
47 }
48  
49  
50 11 ▶sub _encode_rdata { ## encode rdata as wire-format octet string
Subroutine _encode_rdata: called CC=2 SCAR=6.9
51 11 my $self = shift;
52  
53 11 ▶ return '' unless defined $self->{algorithm};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"algorithm"} 2 9 11
54 9 my $rdata = $self->{algorithm}->encode;
55  
56 9 $rdata .= pack 'N2n2', $self->inception, $self->expiration, $self->mode, $self->error;
57  
58 9 my $key = $self->key; # RFC2930(2.7)
59 9 $rdata .= pack 'na*', length $key, $key;
60  
61 9 my $other = $self->other; # RFC2930(2.8)
62 9 $rdata .= pack 'na*', length $other, $other;
63 9 return $rdata;
64 }
65  
66  
67 6 ▶sub encode { ## override RR method
Subroutine encode: called CC=2 SCAR=6.9
Pod documented
68 6 my $self = shift;
69  
70 6 my $owner = $self->{owner}->encode();
71 6 ▶ my $rdata = eval { $self->_encode_rdata() } || '';
Condition100%2/2
eval { do { $self->_encode_rdata } } || ''
l!l
42
MC/DC100%1/1
eval { do { $self->_encode_rdata } } || ''
eval { do { $self->_encode_rdata } }
Truth table100%2/2
A
A= eval { do { $self->_encode_rdata } }
Aresult
11
00
72 6 return pack 'a* n2 N n a*', $owner, TKEY, ANY, 0, length $rdata, $rdata;
73 }
74  
75  
76 3 ▶sub algorithm {
Subroutine algorithm: called CC=3 SCAR=11.0
Pod documented
77 3 my ( $self, @value ) = @_;
78 3 for (@value) { $self->{algorithm} = Net::DNS::DomainName->new($_) }
79 3 ▶ return $self->{algorithm} ? $self->{algorithm}->name : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'algorithm'} ? : 2 1 3
80 }
81  
82  
83 12 ▶sub inception {
Subroutine inception: called CC=3 SCAR=11.0
Pod documented
84 12 my ( $self, @value ) = @_;
85 12 for (@value) { $self->{inception} = 0 + $_ }
86 12 ▶ return $self->{inception} || 0;
Condition100%2/2
$self->{'inception'} || 0
l!l
111
MC/DC100%1/1
$self->{'inception'} || 0
$self->{'inception'}
Truth table100%2/2
A
A= $self->{'inception'}
Aresult
11
00
87 }
88  
89  
90 12 ▶sub expiration {
Subroutine expiration: called CC=3 SCAR=11.0
Pod documented
91 12 my ( $self, @value ) = @_;
92 12 for (@value) { $self->{expiration} = 0 + $_ }
93 12 ▶ return $self->{expiration} || 0;
Condition100%2/2
$self->{'expiration'} || 0
l!l
111
MC/DC100%1/1
$self->{'expiration'} || 0
$self->{'expiration'}
Truth table100%2/2
A
A= $self->{'expiration'}
Aresult
11
00
94 }
95  
96  
97 12 ▶sub mode {
Subroutine mode: called CC=3 SCAR=11.0
Pod documented
98 12 my ( $self, @value ) = @_;
99 12 for (@value) { $self->{mode} = 0 + $_ }
100 12 ▶ return $self->{mode} || 0;
Condition100%2/2
$self->{'mode'} || 0
l!l
111
MC/DC100%1/1
$self->{'mode'} || 0
$self->{'mode'}
Truth table100%2/2
A
A= $self->{'mode'}
Aresult
11
00
101 }
102  
103  
104 12 ▶sub error {
Subroutine error: called CC=3 SCAR=11.0
Pod documented
105 12 my ( $self, @value ) = @_;
106 12 for (@value) { $self->{error} = 0 + $_ }
107 12 ▶ return $self->{error} || 0;
Condition100%2/2
$self->{'error'} || 0
l!l
111
MC/DC100%1/1
$self->{'error'} || 0
$self->{'error'}
Truth table100%2/2
A
A= $self->{'error'}
Aresult
11
00
108 }
109  
110  
111 12 ▶sub key {
Subroutine key: called CC=3 SCAR=11.0
Pod documented
112 12 my ( $self, @value ) = @_;
113 12 for (@value) { $self->{key} = $_ }
114 12 ▶ return $self->{key} || "";
Condition100%2/2
$self->{'key'} || ''
l!l
111
MC/DC100%1/1
$self->{'key'} || ''
$self->{'key'}
Truth table100%2/2
A
A= $self->{'key'}
Aresult
11
00
115 }
116  
117  
118 14 ▶sub other {
Subroutine other: called CC=3 SCAR=11.0
Pod documented
119 14 my ( $self, @value ) = @_;
120 14 for (@value) { $self->{other} = $_ }
121 14 ▶ return $self->{other} || "";
Condition100%2/2
$self->{'other'} || ''
l!l
131
MC/DC100%1/1
$self->{'other'} || ''
$self->{'other'}
Truth table100%2/2
A
A= $self->{'other'}
Aresult
11
00
122 }
123  
124  
125 2 ▶sub other_data { return &other; } # uncoverable pod
Subroutine other_data: called CC=1 SCAR=0.0
Pod undocumented (uncoverable)
126  
127  
128 1 1;
129 __END__
« DNS/RR/CAA.pm ↑ Summary DNS/RR/TXT.pm »