| 1 | package Net::DNS::RR::NSEC; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 14 | our $VERSION = (qw$Id: NSEC.pm 2002 2025-01-07 09:57:46Z willem $)[2]; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use base qw(Net::DNS::RR); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Net::DNS::RR::NSEC - DNS NSEC resource record | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 14 | ▶ | use Net::DNS::DomainName; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 14 | ▶ | use Net::DNS::Parameters qw(:type); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | sub _decode_rdata { ## decode rdata from wire-format octet string | ||||||||||||||||||||||||||
|
Subroutine
_decode_rdata: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | my ( $self, $data, $offset ) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | my $limit = $offset + $self->{rdlength}; | |||||||||||||||||||||||||||
| 26 | 1 | ( $self->{nxtdname}, $offset ) = Net::DNS::DomainName->decode( $data, $offset ); | |||||||||||||||||||||||||||
| 27 | 1 | $self->{typebm} = substr $$data, $offset, $limit - $offset; | |||||||||||||||||||||||||||
| 28 | 1 | return; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 20 | ▶ | sub _encode_rdata { ## encode rdata as wire-format octet string | ||||||||||||||||||||||||||
|
Subroutine
_encode_rdata: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 20 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 20 | my $nxtdname = $self->{nxtdname}; | |||||||||||||||||||||||||||
| 36 | 20 | return join '', $nxtdname->encode(), $self->{typebm}; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | ▶ | sub _format_rdata { ## format rdata portion of RR string. | ||||||||||||||||||||||||||
|
Subroutine
_format_rdata: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 3 | my $nxtdname = $self->{nxtdname}; | |||||||||||||||||||||||||||
| 44 | 3 | return ( $nxtdname->string(), $self->typelist ); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 40 | ▶ | sub _parse_rdata { ## populate RR from rdata in argument list | ||||||||||||||||||||||||||
|
Subroutine
_parse_rdata: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 40 | my ( $self, @argument ) = @_; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 40 | $self->nxtdname( shift @argument ); | |||||||||||||||||||||||||||
| 52 | 40 | $self->typelist(@argument); | |||||||||||||||||||||||||||
| 53 | 40 | return; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | ▶ | sub _defaults { ## specify RR attribute default values | ||||||||||||||||||||||||||
|
Subroutine
_defaults: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 5 | $self->_parse_rdata('.'); | |||||||||||||||||||||||||||
| 61 | 5 | return; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 44 | ▶ | sub nxtdname { | ||||||||||||||||||||||||||
|
Subroutine
nxtdname: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 44 | my ( $self, @value ) = @_; | |||||||||||||||||||||||||||
| 67 | 44 | for (@value) { $self->{nxtdname} = Net::DNS::DomainName->new($_) } | |||||||||||||||||||||||||||
| 68 | 44 | ▶ | return $self->{nxtdname} ? $self->{nxtdname}->name : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 244 | ▶ | sub typelist { | ||||||||||||||||||||||||||
|
Subroutine
typelist: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 244 | my ( $self, @argument ) = @_; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 244 | ▶ | if ( scalar(@argument) || !defined(wantarray) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
scalar @argument or not defined wantarray
MC/DC100%2/2
scalar @argument or not defined wantarray
scalar @argument
not defined wantarray
Truth table100%3/3
A or not(B)
A= scalar @argumentB= not defined wantarray
| |||||||||||||||||||||||||||||
| 76 | 229 | $self->{typebm} = &_type2bm(@argument); | |||||||||||||||||||||||||||
| 77 | 229 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 15 | my @type = &_bm2type( $self->{typebm} ); | |||||||||||||||||||||||||||
| 81 | 15 | ▶ | return wantarray ? (@type) : "@type"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 126 | ▶ | sub typemap { | ||||||||||||||||||||||||||
|
Subroutine
typemap: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 126 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 126 | my $number = typebyname($type); | |||||||||||||||||||||||||||
| 89 | 126 | my $window = $number >> 8; | |||||||||||||||||||||||||||
| 90 | 126 | my $bitnum = $number & 255; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 126 | ▶ | my $typebm = $self->{typebm} || return; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'typebm'} || (return)
MC/DC100%1/1
$self->{'typebm'} || (return)
$self->{'typebm'}
Truth table100%2/2
A
A= $self->{'typebm'}
| |||||||||||||||||||||||||||||
| 93 | 125 | my @bitmap; | |||||||||||||||||||||||||||
| 94 | 125 | my $index = 0; | |||||||||||||||||||||||||||
| 95 | 125 | ▶ | while ( $index < length $typebm ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 125 | my ( $block, $size ) = unpack "\@$index C2", $typebm; | |||||||||||||||||||||||||||
| 97 | 125 | $bitmap[$block] = unpack "\@$index xxa$size", $typebm; | |||||||||||||||||||||||||||
| 98 | 125 | $index += $size + 2; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 125 | ▶ | my @bit = split //, unpack 'B*', ( $bitmap[$window] || return ); | ||||||||||||||||||||||||||
|
Condition100%2/2
$bitmap[$window] || (return)
MC/DC100%1/1
$bitmap[$window] || (return)
$bitmap[$window]
Truth table100%2/2
A
A= $bitmap[$window]
| |||||||||||||||||||||||||||||
| 102 | 124 | return $bit[$bitnum]; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 8 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 8 | my ( $self, $qname ) = @_; | |||||||||||||||||||||||||||
| 108 | 8 | my $name = Net::DNS::DomainName->new($qname)->canonical; | |||||||||||||||||||||||||||
| 109 | 8 | return $name eq $self->{owner}->canonical; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 29 | ▶ | sub covers { | ||||||||||||||||||||||||||
|
Subroutine
covers: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 29 | my ( $self, $qname ) = @_; | |||||||||||||||||||||||||||
| 115 | 29 | my $name = join chr(0), reverse Net::DNS::DomainName->new($qname)->_wire; | |||||||||||||||||||||||||||
| 116 | 29 | my $this = join chr(0), reverse $self->{owner}->_wire; | |||||||||||||||||||||||||||
| 117 | 29 | my $next = join chr(0), reverse $self->{nxtdname}->_wire; | |||||||||||||||||||||||||||
| 118 | 29 | foreach ( $name, $this, $next ) {tr /\101-\132/\141-\172/} | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 29 | ▶ | return ( $name cmp $this ) + ( "$next\001" cmp $name ) == 2 unless $next gt $this; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 23 | return ( $name cmp $this ) + ( $next cmp $name ) == 2; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 42 | ▶ | sub encloser { | ||||||||||||||||||||||||||
|
Subroutine
encloser: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 126 | 42 | my ( $self, $qname ) = @_; | |||||||||||||||||||||||||||
| 127 | 42 | my @label = Net::DNS::Domain->new($qname)->label; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 42 | my @owner = $self->{owner}->label; | |||||||||||||||||||||||||||
| 130 | 42 | my $depth = scalar(@owner); | |||||||||||||||||||||||||||
| 131 | 42 | my $next; | |||||||||||||||||||||||||||
| 132 | 42 | ▶ | while ( scalar(@label) > $depth ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 36 | $next = shift @label; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 42 | ▶ | return unless defined $next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 20 | my $nextcloser = join( '.', $next, @label ); | |||||||||||||||||||||||||||
| 139 | 20 | ▶ | return if lc($nextcloser) ne lc( join '.', $next, @owner ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 12 | $self->{nextcloser} = $nextcloser; | |||||||||||||||||||||||||||
| 142 | 12 | $self->{wildcard} = join( '.', '*', @label ); | |||||||||||||||||||||||||||
| 143 | 12 | return $self->owner; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 2 | ▶ | sub nextcloser { return shift->{nextcloser}; } | ||||||||||||||||||||||||||
|
Subroutine
nextcloser: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 2 | ▶ | sub wildcard { return shift->{wildcard}; } | ||||||||||||||||||||||||||
|
Subroutine
wildcard: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | ######################################## | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 229 | ▶ | sub _type2bm { | ||||||||||||||||||||||||||
|
Subroutine
_type2bm: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 155 | 229 | my @typelist = @_; | |||||||||||||||||||||||||||
| 156 | 229 | my @typearray; | |||||||||||||||||||||||||||
| 157 | 229 | foreach my $typename ( map { split() } @typelist ) { | |||||||||||||||||||||||||||
| 158 | 302 | my $number = typebyname($typename); | |||||||||||||||||||||||||||
| 159 | 302 | my $window = $number >> 8; | |||||||||||||||||||||||||||
| 160 | 302 | my $bitnum = $number & 255; | |||||||||||||||||||||||||||
| 161 | 302 | my $octet = $bitnum >> 3; | |||||||||||||||||||||||||||
| 162 | 302 | my $bit = $bitnum & 7; | |||||||||||||||||||||||||||
| 163 | 302 | $typearray[$window][$octet] |= 0x80 >> $bit; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 229 | my $bitmap = ''; | |||||||||||||||||||||||||||
| 167 | 229 | my $window = 0; | |||||||||||||||||||||||||||
| 168 | 229 | foreach (@typearray) { | |||||||||||||||||||||||||||
| 169 | 234 | ▶ | if ( my $pane = $typearray[$window] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 214 | ▶ | my @content = map { $_ || 0 } @$pane; | ||||||||||||||||||||||||||
|
Condition100%2/2
$_ || 0
MC/DC100%1/1
$_ || 0
$_
Truth table100%2/2
A
A= $_
| |||||||||||||||||||||||||||||
| 171 | 214 | $bitmap .= pack 'CC C*', $window, scalar(@content), @content; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | 234 | $window++; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 229 | return $bitmap; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 15 | ▶ | sub _bm2type { | ||||||||||||||||||||||||||
|
Subroutine
_bm2type: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 181 | 15 | my @empty; | |||||||||||||||||||||||||||
| 182 | 15 | ▶ | my $bitmap = shift || return @empty; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || (return @empty)
MC/DC100%1/1
shift() || (return @empty)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 13 | my $index = 0; | |||||||||||||||||||||||||||
| 185 | 13 | my $limit = length $bitmap; | |||||||||||||||||||||||||||
| 186 | 13 | my @typelist; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 13 | ▶ | while ( $index < $limit ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 13 | my ( $block, $size ) = unpack "\@$index C2", $bitmap; | |||||||||||||||||||||||||||
| 190 | 13 | my $typenum = $block << 8; | |||||||||||||||||||||||||||
| 191 | 13 | foreach my $octet ( unpack "\@$index xxC$size", $bitmap ) { | |||||||||||||||||||||||||||
| 192 | 69 | my $i = $typenum += 8; | |||||||||||||||||||||||||||
| 193 | 69 | my @name; | |||||||||||||||||||||||||||
| 194 | 69 | ▶ | while ($octet) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 155 | --$i; | |||||||||||||||||||||||||||
| 196 | 155 | ▶ | unshift @name, typebyval($i) if $octet & 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 155 | $octet = $octet >> 1; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 69 | push @typelist, @name; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | 13 | $index += $size + 2; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 13 | return @typelist; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1 | ▶ | sub typebm { ## historical | ||||||||||||||||||||||||||
|
Subroutine
typebm: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 209 | 1 | my ( $self, @typebm ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 210 | 1 | for (@typebm) { $self->{typebm} = $_ } | |||||||||||||||||||||||||||
| 211 | 1 | $self->_deprecate('prefer $rr->typelist() or $rr->typemap()'); | |||||||||||||||||||||||||||
| 212 | 1 | return $self->{typebm}; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 1 | ▶ | sub covered { ## historical | ||||||||||||||||||||||||||
|
Subroutine
covered: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 1 | my ( $self, @argument ) = @_; # uncoverable pod | |||||||||||||||||||||||||||
| 217 | 1 | return $self->covers(@argument); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | ######################################## | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 14 | 1; | |||||||||||||||||||||||||||
| 224 | __END__ | ||||||||||||||||||||||||||||