line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DNS::RR::IPSECKEY; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
17
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
21
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
135
|
|
5
|
|
|
|
|
|
|
our $VERSION = (qw$Id: IPSECKEY.pm 1909 2023-03-23 11:36:16Z willem $)[2]; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
13
|
use base qw(Net::DNS::RR); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
220
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Net::DNS::RR::IPSECKEY - DNS IPSECKEY resource record |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
17
|
use integer; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
80
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
153
|
|
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
13
|
use Net::DNS::DomainName; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
81
|
|
21
|
2
|
|
|
2
|
|
492
|
use Net::DNS::RR::A; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
22
|
2
|
|
|
2
|
|
482
|
use Net::DNS::RR::AAAA; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
92
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
15
|
use constant BASE64 => defined eval { require MIME::Base64 }; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2597
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my %wireformat = ( |
27
|
|
|
|
|
|
|
0 => 'C3 a0 a*', |
28
|
|
|
|
|
|
|
1 => 'C3 a4 a*', |
29
|
|
|
|
|
|
|
2 => 'C3 a16 a*', |
30
|
|
|
|
|
|
|
3 => 'C3 a* a*', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _decode_rdata { ## decode rdata from wire-format octet string |
35
|
30
|
|
|
30
|
|
56
|
my ( $self, $data, $offset ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
30
|
|
|
|
|
50
|
my $limit = $offset + $self->{rdlength}; |
38
|
|
|
|
|
|
|
|
39
|
30
|
|
|
|
|
83
|
@{$self}{qw(precedence gatetype algorithm)} = unpack "\@$offset C3", $$data; |
|
30
|
|
|
|
|
93
|
|
40
|
30
|
|
|
|
|
63
|
$offset += 3; |
41
|
|
|
|
|
|
|
|
42
|
30
|
|
|
|
|
48
|
my $gatetype = $self->{gatetype}; |
43
|
30
|
100
|
|
|
|
98
|
if ( not $gatetype ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
44
|
7
|
|
|
|
|
16
|
$self->{gateway} = undef; # no gateway |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} elsif ( $gatetype == 1 ) { |
47
|
7
|
|
|
|
|
28
|
$self->{gateway} = unpack "\@$offset a4", $$data; |
48
|
7
|
|
|
|
|
15
|
$offset += 4; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} elsif ( $gatetype == 2 ) { |
51
|
7
|
|
|
|
|
28
|
$self->{gateway} = unpack "\@$offset a16", $$data; |
52
|
7
|
|
|
|
|
15
|
$offset += 16; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} elsif ( $gatetype == 3 ) { |
55
|
8
|
|
|
|
|
15
|
my $name; |
56
|
8
|
|
|
|
|
22
|
( $name, $offset ) = Net::DNS::DomainName->decode( $data, $offset ); |
57
|
8
|
|
|
|
|
56
|
$self->{gateway} = $name->encode; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} else { |
60
|
1
|
|
|
|
|
26
|
die "unknown gateway type ($gatetype)"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
29
|
|
|
|
|
104
|
$self->keybin( substr $$data, $offset, $limit - $offset ); |
64
|
29
|
|
|
|
|
67
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _encode_rdata { ## encode rdata as wire-format octet string |
69
|
9
|
|
|
9
|
|
16
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
9
|
|
|
|
|
15
|
my $gatetype = $self->gatetype; |
72
|
9
|
|
|
|
|
15
|
my $gateway = $self->{gateway}; |
73
|
9
|
|
|
|
|
16
|
my $precedence = $self->precedence; |
74
|
9
|
|
|
|
|
18
|
my $algorithm = $self->algorithm; |
75
|
9
|
|
|
|
|
18
|
my $keybin = $self->keybin; |
76
|
|
|
|
|
|
|
|
77
|
9
|
|
|
|
|
41
|
return pack $wireformat{$gatetype}, $precedence, $gatetype, $algorithm, $gateway, $keybin; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _format_rdata { ## format rdata portion of RR string. |
82
|
23
|
|
|
23
|
|
36
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
23
|
|
|
|
|
31
|
return $self->SUPER::_format_rdata() unless BASE64; |
85
|
23
|
|
|
|
|
32
|
my @rdata = map { $self->$_ } qw(precedence gatetype algorithm); |
|
69
|
|
|
|
|
135
|
|
86
|
23
|
|
|
|
|
54
|
my @base64 = split /\s+/, MIME::Base64::encode( $self->keybin ); |
87
|
23
|
|
|
|
|
65
|
push @rdata, ( $self->gateway, @base64 ); |
88
|
23
|
|
|
|
|
102
|
return @rdata; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _parse_rdata { ## populate RR from rdata in argument list |
93
|
7
|
|
|
7
|
|
20
|
my ( $self, @argument ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
7
|
|
|
|
|
14
|
foreach (qw(precedence gatetype algorithm gateway)) { $self->$_( shift @argument ) } |
|
28
|
|
|
|
|
66
|
|
96
|
7
|
|
|
|
|
34
|
$self->key(@argument); |
97
|
7
|
|
|
|
|
18
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub precedence { |
102
|
42
|
|
|
42
|
1
|
81
|
my ( $self, @value ) = @_; |
103
|
42
|
|
|
|
|
74
|
for (@value) { $self->{precedence} = 0 + $_ } |
|
8
|
|
|
|
|
25
|
|
104
|
42
|
|
100
|
|
|
123
|
return $self->{precedence} || 0; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub gatetype { |
109
|
71
|
|
100
|
71
|
1
|
1016
|
return shift->{gatetype} || 0; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub algorithm { |
114
|
42
|
|
|
42
|
1
|
921
|
my ( $self, @value ) = @_; |
115
|
42
|
|
|
|
|
69
|
for (@value) { $self->{algorithm} = 0 + $_ } |
|
8
|
|
|
|
|
21
|
|
116
|
42
|
|
100
|
|
|
141
|
return $self->{algorithm} || 0; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub gateway { |
121
|
42
|
|
|
42
|
1
|
2557
|
my ( $self, @value ) = @_; |
122
|
|
|
|
|
|
|
|
123
|
42
|
|
|
|
|
79
|
for (@value) { |
124
|
13
|
100
|
|
|
|
62
|
/^\.*$/ && do { |
125
|
2
|
|
|
|
|
5
|
$self->{gatetype} = 0; |
126
|
2
|
|
|
|
|
3
|
$self->{gateway} = ''; # no gateway |
127
|
2
|
|
|
|
|
4
|
last; |
128
|
|
|
|
|
|
|
}; |
129
|
11
|
100
|
|
|
|
29
|
/:.*:/ && do { |
130
|
2
|
|
|
|
|
4
|
$self->{gatetype} = 2; |
131
|
2
|
|
|
|
|
7
|
$self->{gateway} = Net::DNS::RR::AAAA::address( {}, $_ ); |
132
|
2
|
|
|
|
|
7
|
last; |
133
|
|
|
|
|
|
|
}; |
134
|
9
|
100
|
|
|
|
31
|
/\.\d+$/ && do { |
135
|
2
|
|
|
|
|
3
|
$self->{gatetype} = 1; |
136
|
2
|
|
|
|
|
8
|
$self->{gateway} = Net::DNS::RR::A::address( {}, $_ ); |
137
|
2
|
|
|
|
|
6
|
last; |
138
|
|
|
|
|
|
|
}; |
139
|
7
|
100
|
|
|
|
31
|
/\..+/ && do { |
140
|
6
|
|
|
|
|
12
|
$self->{gatetype} = 3; |
141
|
6
|
|
|
|
|
23
|
$self->{gateway} = Net::DNS::DomainName->new($_)->encode; |
142
|
6
|
|
|
|
|
13
|
last; |
143
|
|
|
|
|
|
|
}; |
144
|
1
|
|
|
|
|
121
|
croak 'unrecognised gateway type'; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
41
|
100
|
|
|
|
87
|
if ( defined wantarray ) { |
148
|
29
|
|
|
|
|
50
|
my $gateway = $self->{gateway}; |
149
|
29
|
|
|
|
|
49
|
for ( $self->gatetype ) { |
150
|
29
|
100
|
|
|
|
94
|
/^1$/ && return Net::DNS::RR::A::address( {address => $gateway} ); |
151
|
23
|
100
|
|
|
|
64
|
/^2$/ && return Net::DNS::RR::AAAA::address( {address => $gateway} ); |
152
|
17
|
100
|
|
|
|
66
|
/^3$/ && return Net::DNS::DomainName->decode( \$gateway )->name; |
153
|
|
|
|
|
|
|
} |
154
|
7
|
100
|
|
|
|
32
|
return wantarray ? '.' : undef; |
155
|
|
|
|
|
|
|
} |
156
|
12
|
|
|
|
|
27
|
return; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub key { |
161
|
12
|
|
|
12
|
1
|
814
|
my ( $self, @value ) = @_; |
162
|
12
|
100
|
|
|
|
31
|
return MIME::Base64::encode( $self->keybin(), "" ) unless scalar @value; |
163
|
8
|
|
|
|
|
39
|
return $self->keybin( MIME::Base64::decode( join "", @value ) ); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub keybin { |
168
|
75
|
|
|
75
|
1
|
1037
|
my ( $self, @value ) = @_; |
169
|
75
|
|
|
|
|
139
|
for (@value) { $self->{keybin} = $_ } |
|
37
|
|
|
|
|
86
|
|
170
|
75
|
|
100
|
|
|
294
|
return $self->{keybin} || ""; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
2
|
|
|
2
|
1
|
518
|
sub pubkey { return &key; } |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my $function = sub { ## sort RRs in numerically ascending order. |
178
|
|
|
|
|
|
|
return $Net::DNS::a->{'preference'} <=> $Net::DNS::b->{'preference'}; |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
__PACKAGE__->set_rrsort_func( 'preference', $function ); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__PACKAGE__->set_rrsort_func( 'default_sort', $function ); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |
187
|
|
|
|
|
|
|
__END__ |