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