| 1 | package Net::DNS::RR::OPT; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 12 | our $VERSION = (qw$Id: OPT.pm 2059 2026-08-28 10:04:18Z willem $)[2]; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use base qw(Net::DNS::RR); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Net::DNS::RR::OPT - DNS OPT resource record | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 12 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 12 | ▶ | use Net::DNS::Parameters qw(:ednsoption); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 12 | ▶ | use constant UTIL => scalar eval { require Scalar::Util; Scalar::Util->can('isdual') }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 12 | ▶ | use constant OPT => Net::DNS::Parameters::typebyname qw(OPT); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 12 | require Net::DNS::DomainName; | |||||||||||||||||||||||||||
| 26 | 12 | require Net::DNS::RR::A; | |||||||||||||||||||||||||||
| 27 | 12 | require Net::DNS::RR::AAAA; | |||||||||||||||||||||||||||
| 28 | 12 | require Net::DNS::Text; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 57 | ▶ | sub _decode_rdata { ## decode rdata from wire-format octet string | ||||||||||||||||||||||||||
|
Subroutine
_decode_rdata: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 32 | 57 | my ( $self, $data, $offset ) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 57 | my $class = delete $self->{class}; # OPT redefines CLASS and TTL fields | |||||||||||||||||||||||||||
| 35 | 57 | ▶ | $self->udpsize($class) if defined $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 57 | my $ttl = delete $self->{ttl}; | |||||||||||||||||||||||||||
| 38 | 57 | ▶ | $self->_ttl($ttl) if defined $ttl; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 57 | my $limit = $offset + $self->{rdlength} - 4; | |||||||||||||||||||||||||||
| 41 | 57 | ▶ | while ( $offset <= $limit ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 26 | my ( $code, $length ) = unpack "\@$offset nn", $$data; | |||||||||||||||||||||||||||
| 43 | 26 | my $value = unpack "\@$offset x4 a$length", $$data; | |||||||||||||||||||||||||||
| 44 | 26 | ▶ | my @value = map { ref($_) ? @$_ : defined($_) ? $_ : () } $self->{option}{$code}, $value; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 45 | 26 | ▶ | $self->{option}{$code} = ( scalar(@value) == 1 ) ? $value : \@value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 26 | $offset += $length + 4; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 57 | return; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 64 | ▶ | sub _encode_rdata { ## encode rdata as wire-format octet string | ||||||||||||||||||||||||||
|
Subroutine
_encode_rdata: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 53 | 64 | my $self = shift; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 64 | ▶ | my $option = $self->{option} || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'option'} || {}
MC/DC100%1/1
$self->{'option'} || {}
$self->{'option'}
Truth table100%2/2
A
A= $self->{'option'}
| |||||||||||||||||||||||||||||
| 56 | 64 | my @option = $self->options; | |||||||||||||||||||||||||||
| 57 | 64 | foreach my $item (@option) { | |||||||||||||||||||||||||||
| 58 | 21 | ▶ | my @value = map { ref($_) ? @$_ : $_ } $option->{$item}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 21 | $item = join '', map { pack( 'nna*', $item, length($_), $_ ) } @value; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 64 | return join '', @option; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 63 | ▶ | sub encode { ## override RR method | ||||||||||||||||||||||||||
|
Subroutine
encode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 63 | my $self = shift; | |||||||||||||||||||||||||||
| 67 | 63 | my $data = $self->_encode_rdata; | |||||||||||||||||||||||||||
| 68 | 63 | return pack 'C n n N na*', 0, OPT, $self->udpsize, $self->_ttl, length($data), $data; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 6 | ▶ | sub string { ## override RR method | ||||||||||||||||||||||||||
|
Subroutine
string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 6 | my @line = split /[\r\n]+/, shift->json; | |||||||||||||||||||||||||||
| 74 | 6 | return join '', map {";;$_\n"} @line; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | ▶ | sub class { ## override RR method | ||||||||||||||||||||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 2 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 79 | 2 | $self->_deprecate(qq[please use "UDPsize()"]); | |||||||||||||||||||||||||||
| 80 | 2 | return $self->udpsize(@value); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 2 | ▶ | sub ttl { ## override RR method | ||||||||||||||||||||||||||
|
Subroutine
ttl: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 2 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 85 | 2 | $self->_deprecate(qq[please use "flags()", "rcode()" or "version()"]); | |||||||||||||||||||||||||||
| 86 | 2 | return $self->_ttl(@value); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 122 | ▶ | sub _ttl { | ||||||||||||||||||||||||||
|
Subroutine
_ttl: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 90 | 122 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 91 | 122 | for (@value) { | |||||||||||||||||||||||||||
| 92 | 58 | @{$self}{qw(rcode version flags)} = unpack 'C2n', pack( 'N', $_ ); | |||||||||||||||||||||||||||
| 93 | 58 | $self->{rcode} = $self->{rcode} << 4; | |||||||||||||||||||||||||||
| 94 | 58 | return; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 64 | return unpack 'N', pack( 'C2n', $self->rcode >> 4, $self->version, $self->flags ); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | ▶ | sub generic { ## override RR method | ||||||||||||||||||||||||||
|
Subroutine
generic: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 1 | local $self->{class} = $self->udpsize; | |||||||||||||||||||||||||||
| 102 | 1 | local $self->{ttl} = $self->_ttl; | |||||||||||||||||||||||||||
| 103 | 1 | return $self->SUPER::generic; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 1 | ▶ | sub token { ## override RR method | ||||||||||||||||||||||||||
|
Subroutine
token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 1 | return grep { !m/^[()]$/ } split /\s+/, &generic; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 6 | ▶ | sub json { | ||||||||||||||||||||||||||
|
Subroutine
json: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 6 | my $self = shift; # uncoverable pod | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 6 | my $version = $self->version; | |||||||||||||||||||||||||||
| 114 | 6 | ▶ | unless ( $version == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 1 | my $content = unpack 'H*', $self->encode; | |||||||||||||||||||||||||||
| 116 | 1 | return <<"QQ"; | |||||||||||||||||||||||||||
| 117 | { "EDNS-VERSION": $version, | ||||||||||||||||||||||||||||
| 118 | "BASE16": "$content" | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 5 | my $flags = $self->flags; | |||||||||||||||||||||||||||
| 124 | 5 | my $rcode = $self->rcode; | |||||||||||||||||||||||||||
| 125 | 5 | my $size = $self->udpsize; | |||||||||||||||||||||||||||
| 126 | 5 | my @format = map { join( "\n\t\t\t", $self->_format_option($_) ) } $self->options; | |||||||||||||||||||||||||||
| 127 | 5 | ▶ | my @indent = scalar(@format) ? "\n\t\t" : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 5 | my @option = join ",\n\t\t", @format; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 5 | return <<"QQ"; | |||||||||||||||||||||||||||
| 131 | { "EDNS-VERSION": $version, | ||||||||||||||||||||||||||||
| 132 | "FLAGS": $flags, | ||||||||||||||||||||||||||||
| 133 | "RCODE": $rcode, | ||||||||||||||||||||||||||||
| 134 | "UDPSIZE": $size, | ||||||||||||||||||||||||||||
| 135 | "OPTIONS": [@indent@option ] | ||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 90 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 142 | 90 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 143 | 90 | for (@value) { $self->{version} = 0 + $_ } | |||||||||||||||||||||||||||
| 144 | 90 | ▶ | return $self->{version} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'version'} || 0
MC/DC100%1/1
$self->{'version'} || 0
$self->{'version'}
Truth table100%2/2
A
A= $self->{'version'}
| |||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 224 | ▶ | sub udpsize { | ||||||||||||||||||||||||||
|
Subroutine
udpsize: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 224 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 150 | 224 | ▶ | for (@value) { $self->{udpsize} = ( $_ > 512 ) ? $_ : 0 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 224 | ▶ | return $self->{udpsize} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'udpsize'} || 0
MC/DC100%1/1
$self->{'udpsize'} || 0
$self->{'udpsize'}
Truth table100%2/2
A
A= $self->{'udpsize'}
| |||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 2 | ▶ | sub size { | ||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 2 | my ( $self, @value ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 156 | 2 | $self->_deprecate(qq[size() is an alias of "UDPsize()"]); | |||||||||||||||||||||||||||
| 157 | 2 | return $self->udpsize(@value); | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 506 | ▶ | sub rcode { | ||||||||||||||||||||||||||
|
Subroutine
rcode: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | 506 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 163 | 506 | ▶ | for (@value) { $self->{rcode} = ( $_ < 16 ) ? 0 : $_ } # discard non-EDNS rcodes 1 .. 15 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 506 | ▶ | return $self->{rcode} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'rcode'} || 0
MC/DC100%1/1
$self->{'rcode'} || 0
$self->{'rcode'}
Truth table100%2/2
A
A= $self->{'rcode'}
| |||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 328 | ▶ | sub flags { | ||||||||||||||||||||||||||
|
Subroutine
flags: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | 328 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 170 | 328 | for (@value) { $self->{flags} = 0 + $_ } | |||||||||||||||||||||||||||
| 171 | 328 | ▶ | return $self->{flags} || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'flags'} || 0
MC/DC100%1/1
$self->{'flags'} || 0
$self->{'flags'}
Truth table100%2/2
A
A= $self->{'flags'}
| |||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 74 | ▶ | sub options { | ||||||||||||||||||||||||||
|
Subroutine
options: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 74 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | 74 | ▶ | my $option = $self->{option} || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'option'} || {}
MC/DC100%1/1
$self->{'option'} || {}
$self->{'option'}
Truth table100%2/2
A
A= $self->{'option'}
| |||||||||||||||||||||||||||||
| 178 | 74 | ▶ | @{$self->{index}} = sort { $a <=> $b } keys %$option unless defined $self->{index}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 74 | return @{$self->{index}}; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 140 | ▶ | sub option { | ||||||||||||||||||||||||||
|
Subroutine
option: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 140 | my ( $self, $name, @value ) = @_; | |||||||||||||||||||||||||||
| 184 | 140 | my $number = ednsoptionbyname($name); | |||||||||||||||||||||||||||
| 185 | 140 | ▶ | return $self->_get_option($number) unless scalar @value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 60 | my $value = $self->_set_option( $number, @value ); | |||||||||||||||||||||||||||
| 187 | 59 | ▶ | return $@ ? croak( ( split /\sat/i, $@ )[0] ) : $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | ######################################## | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 99 | ▶ | sub _get_option { | ||||||||||||||||||||||||||
|
Subroutine
_get_option: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 194 | 99 | my ( $self, $number ) = @_; | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 99 | ▶ | my $options = $self->{option} || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'option'} || {}
MC/DC100%1/1
$self->{'option'} || {}
$self->{'option'}
Truth table100%2/2
A
A= $self->{'option'}
| |||||||||||||||||||||||||||||
| 197 | 99 | ▶ | my @payload = map { ref($_) ? @$_ : $_ } $options->{$number}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 99 | ▶ | return shift @payload unless wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 45 | my $optname = ednsoptionbyval($number); | |||||||||||||||||||||||||||
| 200 | 45 | my $package = join '::', __PACKAGE__, $optname; | |||||||||||||||||||||||||||
| 201 | 45 | $package =~ s/-/_/g; | |||||||||||||||||||||||||||
| 202 | 45 | my $structured = $package->can('_decompose'); | |||||||||||||||||||||||||||
| 203 | 45 | foreach my $value (@payload) { | |||||||||||||||||||||||||||
| 204 | 49 | my @value; | |||||||||||||||||||||||||||
| 205 | 49 | ▶ | if ( length $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 43 | ▶ | @value = eval { $package->_decompose($value) } if $structured; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 43 | ▶ | @value = {BASE16 => pack 'U0a*', unpack 'H*', $value} unless scalar @value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 43 | ▶ | warn $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||
| 210 | 6 | ▶ | @value = $structured ? {'OPTION-LENGTH' => 0} : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | 49 | $value = {$optname => @value}; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | 45 | return @payload; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 60 | ▶ | sub _set_option { | ||||||||||||||||||||||||||
|
Subroutine
_set_option: called CC=13 SCAR=25.6
| |||||||||||||||||||||||||||||
| 219 | 60 | my ( $self, $number, @value ) = @_; | |||||||||||||||||||||||||||
| 220 | 60 | my ($arg) = @value; | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 60 | ▶ | my $options = $self->{option} || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'option'} || {}
MC/DC100%1/1
$self->{'option'} || {}
$self->{'option'}
Truth table100%2/2
A
A= $self->{'option'}
| |||||||||||||||||||||||||||||
| 223 | 60 | delete $options->{$number}; | |||||||||||||||||||||||||||
| 224 | 60 | delete $self->{index}; | |||||||||||||||||||||||||||
| 225 | 60 | ▶ | delete $self->{option} unless scalar( keys %$options ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 60 | ▶ | return unless defined $arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 59 | $self->{option} = $options; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 59 | ▶ | if ( ref($arg) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 27 | for ( keys %$arg ) { $$arg{uc $_} = $$arg{$_} } # tolerate mixed case | |||||||||||||||||||||||||||
| 232 | 27 | my $length = $$arg{'OPTION-LENGTH'}; | |||||||||||||||||||||||||||
| 233 | 27 | my $octets = $$arg{'OPTION-DATA'}; | |||||||||||||||||||||||||||
| 234 | 27 | ▶ | $octets = pack 'H*', $$arg{'BASE16'} if defined $$arg{'BASE16'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 27 | ▶ | $octets = '' if defined($length) && $length == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $length and $length == 0
MC/DC100%2/2
defined $length and $length == 0
defined $length
$length == 0
Truth table100%3/3
A and B
A= defined $lengthB= $length == 0
| |||||||||||||||||||||||||||||
| 236 | 27 | ▶ | return $options->{$number} = $octets if defined $octets; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 46 | my $option = ednsoptionbyval($number); | |||||||||||||||||||||||||||
| 240 | 46 | my $package = join '::', __PACKAGE__, $option; | |||||||||||||||||||||||||||
| 241 | 46 | $package =~ s/-/_/g; | |||||||||||||||||||||||||||
| 242 | 46 | ▶ | return eval { $options->{$number} = $package->_compose(@value) } if length($arg) && $package->can('_compose'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $arg and $package->can("_compose")
MC/DC100%2/2
length $arg and $package->can("_compose")
length $arg
$package->can("_compose")
Truth table100%3/3
A and B
A= length $argB= $package->can("_compose")
| |||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 6 | ▶ | croak "unable to compose option $number" if ref($arg); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | 5 | return $options->{$number} = $arg; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 217 | ▶ | sub _specified { | ||||||||||||||||||||||||||
|
Subroutine
_specified: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 250 | 217 | my $self = shift; | |||||||||||||||||||||||||||
| 251 | 217 | return scalar grep { $self->{$_} } qw(udpsize flags rcode option); | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 19 | ▶ | sub _format_option { | ||||||||||||||||||||||||||
|
Subroutine
_format_option: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 256 | 19 | my ( $self, $number ) = @_; | |||||||||||||||||||||||||||
| 257 | 19 | my @option = $self->_get_option($number); | |||||||||||||||||||||||||||
| 258 | 19 | return map { Net::DNS::RR::_wrap( _JSONify($_) ) } @option; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 106 | ▶ | sub _JSONify { | ||||||||||||||||||||||||||
|
Subroutine
_JSONify: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||
| 263 | 106 | my $value = shift; | |||||||||||||||||||||||||||
| 264 | 106 | ▶ | return 'null' unless defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 105 | ▶ | if ( ref($value) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 39 | my @tags = sort keys %$value; | |||||||||||||||||||||||||||
| 268 | 39 | ▶ | for ( $$value{BASE16} ) { $_ = pack( 'U0a*', $_ ) if defined } # mark as UTF-8 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 39 | my @list = map { my @x = ( qq("$_":), _JSONify( $$value{$_} ) ); $x[-1] .= ','; @x } @tags; | |||||||||||||||||||||||||||
| 270 | 39 | ▶ | return '{}' unless @list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 38 | $list[0] =~ s/^/\{/; | |||||||||||||||||||||||||||
| 272 | 38 | $list[-1] =~ s/,?$/\}/; | |||||||||||||||||||||||||||
| 273 | 38 | return @list; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 66 | ▶ | if ( ref($value) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 6 | my @list = map { my @x = _JSONify($_); $x[-1] .= ','; @x } @$value; | |||||||||||||||||||||||||||
| 278 | 6 | ▶ | return '[]' unless @list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 5 | $list[0] =~ s/^/\[/; | |||||||||||||||||||||||||||
| 280 | 5 | $list[-1] =~ s/,?$/\]/; | |||||||||||||||||||||||||||
| 281 | 5 | return @list; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 60 | my $string = "$value"; ## stringify, then use isdual() as discriminant | |||||||||||||||||||||||||||
| 285 | 60 | ▶ | return $string if UTIL && Scalar::Util::isdual($value); # native numeric representation | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | 28 | for ($string) { | |||||||||||||||||||||||||||
| 287 | 28 | ▶ | unless ( utf8::is_utf8($value) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 20 | ▶ | return $_ if /^-?\d+$/; # integer (string representation) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 19 | ▶ | return $_ if /^-?\d+\.\d*$/; # non-integer | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 18 | ▶ | return $_ if /^-?\d+(\.\d*)?[Ee][+-]?\d+$/; # with exponent | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | 25 | s/\\/\\\\/g; # escaped escape | |||||||||||||||||||||||||||
| 293 | 25 | s/^"(.*)"$/$1/; # strip enclosing quotes | |||||||||||||||||||||||||||
| 294 | 25 | s/"/\\"/g; # escape interior quotes | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 25 | return qq("$string"); | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | ## no critic ProhibitMultiplePackages | ||||||||||||||||||||||||||||
| 301 | package Net::DNS::RR::OPT::UPDATE_LEASE; # RFC9664 | ||||||||||||||||||||||||||||
| 302 | 12 | my @field2 = qw(LEASE KEY-LEASE); | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 2 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 305 | 2 | my ( undef, @argument ) = @_; | |||||||||||||||||||||||||||
| 306 | 2 | for ( ref( $argument[0] ) ) { | |||||||||||||||||||||||||||
| 307 | 2 | ▶ | @argument = @{$argument[0]} if /ARRAY/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 2 | ▶ | @argument = @{$argument[0]}{@field2} if /HASH/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | 2 | return pack 'NN*', grep {defined} @argument; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 314 | 2 | my @time = grep {defined} unpack 'N*', pop @_; | |||||||||||||||||||||||||||
| 315 | 2 | my ( %object, $i ); | |||||||||||||||||||||||||||
| 316 | 2 | $object{$field2[$i++]} = $_ foreach @time; | |||||||||||||||||||||||||||
| 317 | 2 | return \%object; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | package Net::DNS::RR::OPT::DAU; # RFC6975 | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 6 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 324 | 6 | ▶ | my ( undef, @argument ) = map { ref($_) ? @$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | 6 | return pack 'C*', @argument; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 6 | ▶ | sub _decompose { return [unpack 'C*', pop @_] } | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | package Net::DNS::RR::OPT::DHU; # RFC6975 | ||||||||||||||||||||||||||||
| 332 | 12 | our @ISA = qw(Net::DNS::RR::OPT::DAU); | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | package Net::DNS::RR::OPT::N3U; # RFC6975 | ||||||||||||||||||||||||||||
| 335 | 12 | our @ISA = qw(Net::DNS::RR::OPT::DAU); | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | package Net::DNS::RR::OPT::CLIENT_SUBNET; # RFC7871 | ||||||||||||||||||||||||||||
| 339 | 12 | my %family = qw(1 Net::DNS::RR::A 2 Net::DNS::RR::AAAA); | |||||||||||||||||||||||||||
| 340 | 12 | my @field8 = qw(FAMILY SOURCE-PREFIX SCOPE-PREFIX ADDRESS); | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 4 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 343 | 4 | shift @_; | |||||||||||||||||||||||||||
| 344 | 4 | ▶ | my %argument = ( map( ( $_ => 0 ), @field8 ), map { ref($_) ? %$_ : $_ } @_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 345 | 4 | ▶ | my $family = $family{$argument{FAMILY}} || die 'unrecognised address family'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$family{$argument{'FAMILY'}} || die('unrecognised address family')
MC/DC100%1/1
$family{$argument{'FAMILY'}} || die('unrecognised address family')
$family{$argument{'FAMILY'}}
Truth table100%2/2
A
A= $family{$argument{'FAMILY'}}
| |||||||||||||||||||||||||||||
| 346 | 3 | my $bitmask = $argument{'SOURCE-PREFIX'}; | |||||||||||||||||||||||||||
| 347 | 3 | my $address = bless( {}, $family )->address( $argument{ADDRESS} ); | |||||||||||||||||||||||||||
| 348 | 3 | return pack 'a* B*', pack( 'nC2', @argument{@field8} ), unpack "B$bitmask", $address; | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 4 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 352 | 4 | my %object; | |||||||||||||||||||||||||||
| 353 | 4 | @object{@field8} = unpack 'nC2a*', pop @_; | |||||||||||||||||||||||||||
| 354 | 4 | ▶ | my $family = $family{$object{FAMILY}} || die 'unrecognised address family'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$family{$object{'FAMILY'}} || die('unrecognised address family')
MC/DC100%1/1
$family{$object{'FAMILY'}} || die('unrecognised address family')
$family{$object{'FAMILY'}}
Truth table100%2/2
A
A= $family{$object{'FAMILY'}}
| |||||||||||||||||||||||||||||
| 355 | 3 | for ( $object{ADDRESS} ) { | |||||||||||||||||||||||||||
| 356 | 3 | $_ = bless( {address => $_}, $family )->address; | |||||||||||||||||||||||||||
| 357 | 3 | s/:[:0]+$/::/; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | 3 | return \%object; | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | package Net::DNS::RR::OPT::EXPIRE; # RFC7314 | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 2 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 366 | 2 | ▶ | my ( undef, @argument ) = map { ref($_) ? %$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 2 | return pack 'N', pop @argument; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 371 | 2 | return {'EXPIRE-TIMER' => unpack 'N', pop @_}; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | package Net::DNS::RR::OPT::COOKIE; # RFC7873 | ||||||||||||||||||||||||||||
| 376 | 12 | my @field10 = qw(CLIENT SERVER); | |||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 3 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 379 | 3 | my ( undef, @argument ) = @_; | |||||||||||||||||||||||||||
| 380 | 3 | for ( ref( $argument[0] ) ) { | |||||||||||||||||||||||||||
| 381 | 3 | ▶ | /HASH/ && ( @argument = @{$argument[0]}{@field10} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 382 | 3 | ▶ | /ARRAY/ && ( @argument = @{$argument[0]} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | 3 | ▶ | return pack 'a8a*', map { pack 'H*', $_ || '' } @argument; | ||||||||||||||||||||||||||
|
Condition100%2/2
$_ || ''
MC/DC100%1/1
$_ || ''
$_
Truth table100%2/2
A
A= $_
| |||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 388 | 2 | my %object; | |||||||||||||||||||||||||||
| 389 | 2 | @object{@field10} = map { pack 'U0a*', $_ } unpack 'H16H*', pop @_; # mark as UTF-8 | |||||||||||||||||||||||||||
| 390 | 2 | return \%object; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | package Net::DNS::RR::OPT::TCP_KEEPALIVE; # RFC7828 | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 2 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 397 | 2 | ▶ | my ( undef, @argument ) = map { ref($_) ? %$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | 2 | return pack 'n', pop @argument; | |||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 402 | 2 | return {'TIMEOUT' => unpack 'n', pop @_}; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | package Net::DNS::RR::OPT::PADDING; # RFC7830 | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 5 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 409 | 5 | ▶ | my ( undef, @argument ) = map { ref($_) ? %$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 5 | ▶ | my $length = pop(@argument) || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
pop @argument || 0
MC/DC100%1/1
pop @argument || 0
pop @argument
Truth table100%2/2
A
A= pop @argument
| |||||||||||||||||||||||||||||
| 411 | 5 | return pack "x$length"; | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 3 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 415 | 3 | my $argument = pop @_; | |||||||||||||||||||||||||||
| 416 | 3 | ▶ | return {'OPTION-LENGTH' => length $argument} if $argument =~ /^\000*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | 1 | return {'BASE16' => unpack 'H*', $argument}; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | package Net::DNS::RR::OPT::CHAIN; # RFC7901 | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 1 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 424 | 1 | ▶ | my ( undef, @argument ) = map { ref($_) ? %$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | 1 | return Net::DNS::DomainName->new( pop @argument )->encode; | |||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 429 | 2 | my $argument = pop @_; | |||||||||||||||||||||||||||
| 430 | 2 | return {'CLOSEST-TRUST-POINT' => Net::DNS::DomainName->decode( \$argument )->string}; | |||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | package Net::DNS::RR::OPT::KEY_TAG; # RFC8145 | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | 2 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 437 | 2 | ▶ | my ( undef, @argument ) = map { ref($_) ? @$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | 2 | return pack 'n*', @argument; | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 2 | ▶ | sub _decompose { return [unpack 'n*', pop @_] } | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | package Net::DNS::RR::OPT::EXTENDED_ERROR; # RFC8914 | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 6 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 447 | 6 | my ( undef, @arg ) = @_; | |||||||||||||||||||||||||||
| 448 | 6 | ▶ | my %arg = ( 'INFO-CODE' => 0, ref( $arg[0] ) ? %{$arg[0]} : @arg ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 449 | 6 | ▶ | my $text = join '', Net::DNS::RR::OPT::_JSONify( $arg{'EXTRA-TEXT'} || '' ); | ||||||||||||||||||||||||||
|
Condition100%2/2
$arg{'EXTRA-TEXT'} || ''
MC/DC100%1/1
$arg{'EXTRA-TEXT'} || ''
$arg{'EXTRA-TEXT'}
Truth table100%2/2
A
A= $arg{'EXTRA-TEXT'}
| |||||||||||||||||||||||||||||
| 450 | 6 | return pack 'na*', $arg{'INFO-CODE'}, Net::DNS::Text->new($text)->raw; | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 4 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 454 | 4 | my ( $code, $text ) = unpack 'na*', pop @_; | |||||||||||||||||||||||||||
| 455 | 4 | my $error = $Net::DNS::Parameters::dnserrorbyval{$code}; | |||||||||||||||||||||||||||
| 456 | 4 | ▶ | my @error = defined($error) ? ( 'ERROR-TEXT' => $error ) : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | 4 | my $extra = Net::DNS::Text->decode( \$text, 0, length $text ); | |||||||||||||||||||||||||||
| 458 | 4 | for ( $extra->value ) { | |||||||||||||||||||||||||||
| 459 | 4 | ▶ | last unless /^\s*[\{]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 460 | 3 | s/([\$\@])/\\$1/g; ## suppress interpolation within quoted strings | |||||||||||||||||||||||||||
| 461 | ## extract JSON lexical tokens, discard unmatched characters | ||||||||||||||||||||||||||||
| 462 | 3 | my $REGEX = q/("[^"]*")|([-+]?\d+\.?\d*(?:[Ee][-+]?\d+)?)|::|([{}:,\[\]])|./; | |||||||||||||||||||||||||||
| 463 | 3 | ▶ | my @split = grep { defined && length } split /$REGEX/o; | ||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && length $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||
| 464 | 3 | ▶ | my $value = eval join( ' ', 'no integer;', map { s/^:$/=>/; $_ } @split ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 465 | 3 | ▶ | return {'INFO-CODE' => $code, @error, 'EXTRA-TEXT' => $value} if ref($value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | 2 | return {'INFO-CODE' => $code, @error, 'EXTRA-TEXT' => $extra->value}; | |||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | package Net::DNS::RR::OPT::REPORT_CHANNEL; # RFC9567 | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 2 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 474 | 2 | ▶ | my ( undef, @argument ) = map { ref($_) ? %$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 2 | return Net::DNS::DomainName->new( pop @argument )->encode; | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 479 | 2 | my $argument = pop @_; | |||||||||||||||||||||||||||
| 480 | 2 | return {'AGENT-DOMAIN' => Net::DNS::DomainName->decode( \$argument )->string}; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | package Net::DNS::RR::OPT::ZONEVERSION; # RFC9660 | ||||||||||||||||||||||||||||
| 485 | 12 | my @field19 = qw(LABELCOUNT TYPE VERSION); | |||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | 3 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 488 | 3 | my ( undef, @argument ) = @_; | |||||||||||||||||||||||||||
| 489 | 3 | for ( ref( $argument[0] ) ) { | |||||||||||||||||||||||||||
| 490 | 3 | ▶ | /HASH/ && ( @argument = @{$argument[0]}{@field19} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 491 | 3 | ▶ | /ARRAY/ && ( @argument = @{$argument[0]} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | 3 | ▶ | return scalar(@argument) ? pack( 'C2H*', @argument ) : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 8 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 497 | 8 | my ( $l, $t, $v ) = unpack 'C2H*', pop @_; | |||||||||||||||||||||||||||
| 498 | 8 | my %object; | |||||||||||||||||||||||||||
| 499 | 8 | @object{@field19} = ( $l, $t, pack 'U0a*', $v ); # mark hex data as UTF-8 | |||||||||||||||||||||||||||
| 500 | 8 | return \%object; | |||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | package Net::DNS::RR::OPT::MQTYPE_RESPONSE; # RFC10029 | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | 2 | ▶ | sub _compose { | ||||||||||||||||||||||||||
|
Subroutine
_compose: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 507 | 2 | ▶ | my ( undef, @mqtype ) = map { ref($_) ? @$_ : $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 508 | 2 | return pack 'n*', map { Net::DNS::Parameters::typebyname($_) } @mqtype; | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 2 | ▶ | sub _decompose { | ||||||||||||||||||||||||||
|
Subroutine
_decompose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 512 | 2 | my @mqtype = unpack 'n*', pop @_; | |||||||||||||||||||||||||||
| 513 | 2 | return [map { Net::DNS::Parameters::typebyval($_) } @mqtype]; | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | package Net::DNS::RR::OPT::MQTYPE_QUERY; # RFC10029 | ||||||||||||||||||||||||||||
| 517 | 12 | our @ISA = qw(Net::DNS::RR::OPT::MQTYPE_RESPONSE); | |||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | ######################################## | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 12 | 1; | |||||||||||||||||||||||||||
| 523 | __END__ | ||||||||||||||||||||||||||||