line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DNS::RR::AMTRELAY; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
5
|
|
|
|
|
|
|
our $VERSION = (qw$Id: AMTRELAY.pm 1896 2023-01-30 12:59:25Z willem $)[2]; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw(Net::DNS::RR); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Net::DNS::RR::AMTRELAY - DNS AMTRELAY resource record |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
7
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
34
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
7
|
use Net::DNS::DomainName; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
21
|
1
|
|
|
1
|
|
463
|
use Net::DNS::RR::A; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
22
|
1
|
|
|
1
|
|
464
|
use Net::DNS::RR::AAAA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1118
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _decode_rdata { ## decode rdata from wire-format octet string |
26
|
5
|
|
|
5
|
|
10
|
my ( $self, $data, $offset ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
9
|
my $size = $self->{rdlength} - 2; |
29
|
5
|
|
|
|
|
21
|
@{$self}{qw(precedence relaytype relay)} = unpack "\@$offset C2 a$size", $$data; |
|
5
|
|
|
|
|
16
|
|
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
11
|
for ( $self->relaytype ) { |
32
|
5
|
100
|
|
|
|
20
|
/^3$/ && return $self->{relay} = Net::DNS::DomainName->decode( $data, $offset + 2 ); |
33
|
3
|
100
|
|
|
|
11
|
/^2$/ && return $self->{relay} = pack( 'a16', $self->{relay} ); |
34
|
2
|
100
|
|
|
|
10
|
/^1$/ && return $self->{relay} = pack( 'a4', $self->{relay} ); |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
2
|
$self->{relay} = ''; |
37
|
1
|
|
|
|
|
3
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _encode_rdata { ## encode rdata as wire-format octet string |
42
|
9
|
|
|
9
|
|
16
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
9
|
|
|
|
|
17
|
for ( $self->relaytype ) { |
45
|
9
|
100
|
|
|
|
40
|
/^3$/ && return pack( 'C2 a*', @{$self}{qw(precedence relaytype)}, $self->{relay}->encode ); |
|
6
|
|
|
|
|
18
|
|
46
|
3
|
100
|
|
|
|
9
|
/^2$/ && return pack( 'C2 a16', @{$self}{qw(precedence relaytype relay)} ); |
|
1
|
|
|
|
|
6
|
|
47
|
2
|
100
|
|
|
|
10
|
/^1$/ && return pack( 'C2 a4', @{$self}{qw(precedence relaytype relay)} ); |
|
1
|
|
|
|
|
5
|
|
48
|
|
|
|
|
|
|
} |
49
|
1
|
|
|
|
|
3
|
return pack( 'C2', @{$self}{qw(precedence relaytype)} ); |
|
1
|
|
|
|
|
4
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _format_rdata { ## format rdata portion of RR string. |
54
|
23
|
|
|
23
|
|
36
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
23
|
|
|
|
|
38
|
my @rdata = map { $self->$_ } qw(precedence dbit relaytype relay); |
|
92
|
|
|
|
|
180
|
|
57
|
23
|
|
|
|
|
70
|
return @rdata; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _parse_rdata { ## populate RR from rdata in argument list |
62
|
7
|
|
|
7
|
|
18
|
my ( $self, @argument ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
7
|
|
|
|
|
12
|
foreach (qw(precedence dbit relaytype relay)) { |
65
|
28
|
|
|
|
|
69
|
$self->$_( shift @argument ); |
66
|
|
|
|
|
|
|
} |
67
|
7
|
|
|
|
|
15
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _defaults { ## specify RR attribute default values |
72
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
2
|
@{$self}{qw(precedence relaytype relay)} = ( 0, 0, '' ); |
|
1
|
|
|
|
|
7
|
|
75
|
1
|
|
|
|
|
2
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub precedence { |
80
|
33
|
|
|
33
|
1
|
63
|
my ( $self, @value ) = @_; |
81
|
33
|
|
|
|
|
60
|
for (@value) { $self->{precedence} = 0 + $_ } |
|
8
|
|
|
|
|
24
|
|
82
|
33
|
|
100
|
|
|
107
|
return $self->{precedence} || 0; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub dbit { |
87
|
61
|
|
|
61
|
0
|
102
|
my ( $self, @value ) = @_; # uncoverable pod |
88
|
61
|
100
|
|
|
|
88
|
for (@value) { $self->{relaytype} = $self->relaytype | ( $_ ? 0x80 : 0 ) } |
|
12
|
|
|
|
|
25
|
|
89
|
61
|
|
100
|
|
|
195
|
return ( $self->{relaytype} || 0 ) >> 7; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
11
|
|
|
11
|
0
|
28
|
sub d { return &dbit } # uncoverable pod |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub relaytype { |
96
|
100
|
|
|
100
|
1
|
926
|
my ( $self, @value ) = @_; |
97
|
100
|
100
|
|
|
|
155
|
for (@value) { $self->{relaytype} = $self->dbit ? ( 0x80 | $_ ) : $_ } |
|
20
|
|
|
|
|
30
|
|
98
|
100
|
|
100
|
|
|
287
|
return 0x7f & ( $self->{relaytype} || 0 ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub relay { |
103
|
42
|
|
|
42
|
1
|
1089
|
my ( $self, @value ) = @_; |
104
|
|
|
|
|
|
|
|
105
|
42
|
|
|
|
|
74
|
for (@value) { |
106
|
13
|
100
|
|
|
|
55
|
/^\.*$/ && do { |
107
|
2
|
|
|
|
|
6
|
$self->relaytype(0); |
108
|
2
|
|
|
|
|
4
|
$self->{relay} = ''; # no relay |
109
|
2
|
|
|
|
|
2
|
last; |
110
|
|
|
|
|
|
|
}; |
111
|
11
|
100
|
|
|
|
30
|
/:.*:/ && do { |
112
|
2
|
|
|
|
|
6
|
$self->relaytype(2); |
113
|
2
|
|
|
|
|
7
|
$self->{relay} = Net::DNS::RR::AAAA::address( {}, $_ ); |
114
|
2
|
|
|
|
|
6
|
last; |
115
|
|
|
|
|
|
|
}; |
116
|
9
|
100
|
|
|
|
29
|
/\.\d+$/ && do { |
117
|
2
|
|
|
|
|
6
|
$self->relaytype(1); |
118
|
2
|
|
|
|
|
8
|
$self->{relay} = Net::DNS::RR::A::address( {}, $_ ); |
119
|
2
|
|
|
|
|
6
|
last; |
120
|
|
|
|
|
|
|
}; |
121
|
7
|
100
|
|
|
|
23
|
/\..+/ && do { |
122
|
6
|
|
|
|
|
14
|
$self->relaytype(3); |
123
|
6
|
|
|
|
|
22
|
$self->{relay} = Net::DNS::DomainName->new($_); |
124
|
6
|
|
|
|
|
15
|
last; |
125
|
|
|
|
|
|
|
}; |
126
|
1
|
|
|
|
|
202
|
croak 'unrecognised relay type'; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
41
|
100
|
|
|
|
78
|
if ( defined wantarray ) { |
130
|
29
|
|
|
|
|
46
|
for ( $self->relaytype ) { |
131
|
29
|
100
|
|
|
|
116
|
/^1$/ && return Net::DNS::RR::A::address( {address => $self->{relay}} ); |
132
|
23
|
100
|
|
|
|
79
|
/^2$/ && return Net::DNS::RR::AAAA::address( {address => $self->{relay}} ); |
133
|
17
|
100
|
|
|
|
80
|
/^3$/ && return wantarray ? $self->{relay}->string : $self->{relay}->name; |
|
|
100
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
19
|
100
|
|
|
|
62
|
return wantarray ? '.' : undef; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $function = sub { ## sort RRs in numerically ascending order. |
141
|
|
|
|
|
|
|
$Net::DNS::a->{'preference'} <=> $Net::DNS::b->{'preference'}; |
142
|
|
|
|
|
|
|
}; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__PACKAGE__->set_rrsort_func( 'preference', $function ); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__PACKAGE__->set_rrsort_func( 'default_sort', $function ); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
__END__ |