DNS/RR/URI.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 100% 2 / 2 Conditioncond 57.1% 4 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 92.3% 12 / 13 Podpod 100% 3 / 3 totaltotal 90.2% 74 / 82 CC 9 SCAR 8.9
CC
9
Cov
92%
__ANON__
6.0
priority
3.0
weight
3.0
CRAP 2.4
« DNS/RR/GPOS.pm ↑ Summary DNS/RR/NSEC3PARAM.pm »
1 package Net::DNS::RR::URI;
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: URI.pm 2003 2025-01-21 12:06:06Z 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::URI - DNS URI resource record
13  
14 =cut
15  
16 1 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use Net::DNS::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 1 ▶sub _decode_rdata { ## decode rdata from wire-format octet string
Subroutine _decode_rdata: called CC=1 SCAR=0.0
22 1 my ( $self, $data, $offset ) = @_;
23  
24 1 my $limit = $offset + $self->{rdlength};
25 1 @{$self}{qw(priority weight)} = unpack( "\@$offset n2", $$data );
26 1 $offset += 4;
27 1 $self->{target} = Net::DNS::Text->decode( $data, $offset, $limit - $offset );
28 1 return;
29 }
30  
31  
32 5 ▶sub _encode_rdata { ## encode rdata as wire-format octet string
Subroutine _encode_rdata: called CC=1 SCAR=0.0
33 5 my $self = shift;
34  
35 5 my $target = $self->{target};
36 5 return pack 'n2 a*', @{$self}{qw(priority weight)}, $target->raw;
37 }
38  
39  
40 2 ▶sub _format_rdata { ## format rdata portion of RR string.
Subroutine _format_rdata: called CC=1 SCAR=0.0
41 2 my $self = shift;
42  
43 2 my $target = $self->{target};
44 2 my @rdata = ( $self->priority, $self->weight, $target->string );
45 2 return @rdata;
46 }
47  
48  
49 1 ▶sub _parse_rdata { ## populate RR from rdata in argument list
Subroutine _parse_rdata: called CC=2 SCAR=6.9
50 1 my ( $self, @argument ) = @_;
51  
52 1 for (qw(priority weight target)) { $self->$_( shift @argument ) }
53 1 return;
54 }
55  
56  
57 6 ▶sub priority {
Subroutine priority: called CC=3 SCAR=11.0
Pod documented
58 6 my ( $self, @value ) = @_;
59 6 for (@value) { $self->{priority} = 0 + $_ }
60 6 ▶ return $self->{priority} || 0;
Condition100%2/2
$self->{'priority'} || 0
l!l
51
MC/DC100%1/1
$self->{'priority'} || 0
$self->{'priority'}
Truth table100%2/2
A
A= $self->{'priority'}
Aresult
11
00
61 }
62  
63  
64 6 ▶sub weight {
Subroutine weight: called CC=3 SCAR=11.0
Pod documented
65 6 my ( $self, @value ) = @_;
66 6 for (@value) { $self->{weight} = 0 + $_ }
67 6 ▶ return $self->{weight} || 0;
Condition100%2/2
$self->{'weight'} || 0
l!l
51
MC/DC100%1/1
$self->{'weight'} || 0
$self->{'weight'}
Truth table100%2/2
A
A= $self->{'weight'}
Aresult
11
00
68 }
69  
70  
71 4 ▶sub target {
Subroutine target: called CC=3 SCAR=11.0
Pod documented
72 4 my ( $self, @value ) = @_;
73 4 for (@value) { $self->{target} = Net::DNS::Text->new($_) }
74 4 ▶ return $self->{target} ? $self->{target}->value : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'target'} ? : 3 1 4
75 }
76  
77  
78 # order RRs by numerically increasing priority, decreasing weight
79 0 ▶my $function = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
80 0 my ( $a, $b ) = ( $Net::DNS::a, $Net::DNS::b );
81 return $a->{priority} <=> $b->{priority}
82 0 ▶ || $b->{weight} <=> $a->{weight};
Condition0%0/3
$a->{'priority'} <=> $b->{'priority'} || $b->{'weight'} <=> $a->{'weight'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$a->{'priority'} <=> $b->{'priority'} || $b->{'weight'} <=> $a->{'weight'}
$a->{'priority'} <=> $b->{'priority'} $b->{'weight'} <=> $a->{'weight'}
Truth table0%0/3
A || B
A= $a->{'priority'} <=> $b->{'priority'}B= $b->{'weight'} <=> $a->{'weight'}
ABresult
1X1
011
000
83 1 };
84  
85 1 __PACKAGE__->set_rrsort_func( 'priority', $function );
86  
87 1 __PACKAGE__->set_rrsort_func( 'default_sort', $function );
88  
89  
90 1 1;
91 __END__
« DNS/RR/GPOS.pm ↑ Summary DNS/RR/NSEC3PARAM.pm »