line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DNS::ToolKit::RR::AAAA; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1151
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
46
|
|
4
|
|
|
|
|
|
|
#use warnings; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# This file contains the working code for |
7
|
|
|
|
|
|
|
# the RR_AAAA record methods. |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
66
|
use Net::DNS::ToolKit qw( |
10
|
|
|
|
|
|
|
put16 |
11
|
|
|
|
|
|
|
getIPv6 |
12
|
|
|
|
|
|
|
putIPv6 |
13
|
|
|
|
|
|
|
ipv6_aton |
14
|
|
|
|
|
|
|
ipv6_n2x |
15
|
1
|
|
|
1
|
|
18
|
); |
|
1
|
|
|
|
|
2
|
|
16
|
1
|
|
|
1
|
|
5
|
use Net::DNS::Codes qw(:constants); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
274
|
|
17
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
420
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$VERSION = do { my @r = (q$Revision: 0.01 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Net::DNS::ToolKit::RR::AAAA - Resource Record Handler |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
DO NOT use Net::DNS::ToolKit::RR::AAAA |
28
|
|
|
|
|
|
|
DO NOT require Net::DNS::ToolKit::RR::AAAA |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Net::DNS::ToolKit::RR::AAAA is autoloaded by |
31
|
|
|
|
|
|
|
class Net::DNS::ToolKit::RR and its methods |
32
|
|
|
|
|
|
|
are instantiated in a 'special' manner. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Net::DNS::ToolKit::RR; |
35
|
|
|
|
|
|
|
($get,$put,$parse) = new Net::DNS::ToolKit::RR; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
($newoff,$name,$type,$class,$ttl,$rdlength, |
38
|
|
|
|
|
|
|
$netaddr) = $get->AAAA(\$buffer,$offset); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Note: the $get->AAAA method is normally called |
41
|
|
|
|
|
|
|
via: @stuff = $get->next(\$buffer,$offset); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
($newoff,@dnptrs)=$put->AAAA(\$buffer,$offset,\@dnptrs, |
44
|
|
|
|
|
|
|
$name,$type,$class,$ttl,$ipv6addr); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$name,$TYPE,$CLASS,$TTL,$rdlength,$IP6addr) |
47
|
|
|
|
|
|
|
= $parse->AAAA($name,$type,$class,$ttl,$rdlength, |
48
|
|
|
|
|
|
|
$ipv6addr); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
B appends an AAAA resource record to a DNS packet |
53
|
|
|
|
|
|
|
under construction, recovers an AAAA resource record from a packet being decoded, |
54
|
|
|
|
|
|
|
and converts the numeric/binary portions of the resource record to human |
55
|
|
|
|
|
|
|
readable form. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Description from RFC1035.txt |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
3.2.1. Format |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
All RRs have the same top level format shown below: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1 1 1 1 1 1 |
64
|
|
|
|
|
|
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
65
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
66
|
|
|
|
|
|
|
| NAME | |
67
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
68
|
|
|
|
|
|
|
| TYPE | |
69
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
70
|
|
|
|
|
|
|
| CLASS | |
71
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
72
|
|
|
|
|
|
|
| TTL | |
73
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
74
|
|
|
|
|
|
|
| RDLENGTH | |
75
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| |
76
|
|
|
|
|
|
|
| RDATA | |
77
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
NAME an owner name, i.e., the name of the node to which this |
80
|
|
|
|
|
|
|
resource record pertains. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
TYPE two octets containing one of the RR TYPE codes. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
CLASS two octets containing one of the RR CLASS codes. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
TTL a 32 bit signed integer that specifies the time interval |
87
|
|
|
|
|
|
|
that the resource record may be cached before the source |
88
|
|
|
|
|
|
|
of the information should again be consulted. Zero |
89
|
|
|
|
|
|
|
values are interpreted to mean that the RR can only be |
90
|
|
|
|
|
|
|
used for the transaction in progress, and should not be |
91
|
|
|
|
|
|
|
cached. For example, SOA records are always distributed |
92
|
|
|
|
|
|
|
with a zero TTL to prohibit caching. Zero values can |
93
|
|
|
|
|
|
|
also be used for extremely volatile data. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
RDLENGTH an unsigned 16 bit integer that specifies the length |
96
|
|
|
|
|
|
|
in octets of the RDATA field. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
RDATA a variable length string of octets that describes the |
99
|
|
|
|
|
|
|
resource. The format of this information varies |
100
|
|
|
|
|
|
|
according to the TYPE and CLASS of the resource record. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Description from RFC1884.txt |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
AAAA RDATA format |
105
|
|
|
|
|
|
|
1 1 1 1 1 1 |
106
|
|
|
|
|
|
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
107
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
108
|
|
|
|
|
|
|
| | |
109
|
|
|
|
|
|
|
+ + |
110
|
|
|
|
|
|
|
| 128 bit | |
111
|
|
|
|
|
|
|
+ IPv6 ADDRESS + |
112
|
|
|
|
|
|
|
| | |
113
|
|
|
|
|
|
|
+ + |
114
|
|
|
|
|
|
|
| | |
115
|
|
|
|
|
|
|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * @stuff = $get->AAAA(\$buffer,$offset); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Get the contents of the resource record. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
USE: @stuff = $get->next(\$buffer,$offset); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
where: @stuff = ( |
126
|
|
|
|
|
|
|
$newoff $name,$type,$class,$ttl,$rdlength, |
127
|
|
|
|
|
|
|
$ipv6addr ); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
All except the last item, B<$ipv6addr>, is provided by |
130
|
|
|
|
|
|
|
the class loader, B. The code in this method knows |
131
|
|
|
|
|
|
|
how to retrieve B<$ipv6addr>. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
input: pointer to buffer, |
134
|
|
|
|
|
|
|
offset into buffer |
135
|
|
|
|
|
|
|
returns: offset to next resource, |
136
|
|
|
|
|
|
|
@common RR elements, |
137
|
|
|
|
|
|
|
128 bit IPv6 address |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
NOTE: convert IPv6 address to hex or hex + dotquad |
140
|
|
|
|
|
|
|
using Net::DNS::ToolKit::ipv6_n2x or ipv6_ntd |
141
|
|
|
|
|
|
|
respectively. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub get { |
146
|
1
|
|
|
1
|
0
|
109
|
my($self,$bp,$offset) = @_; |
147
|
1
|
|
|
|
|
8
|
$offset += INT16SZ; # don't need rdlength |
148
|
1
|
|
|
|
|
26
|
my($ipv6addr,$newoff) = getIPv6($bp,$offset); |
149
|
1
|
|
|
|
|
5
|
return ($newoff,$ipv6addr); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * ($newoff,@dnptrs)=$put->AAAA(\$buffer,$offset,\@dnptrs, |
153
|
|
|
|
|
|
|
@common,$ipv6addr); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Append an AAAA record to $buffer. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
where @common = ( |
158
|
|
|
|
|
|
|
$name,$type,$class,$ttl); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
The method will insert the $rdlength and $ipv6addr, then |
161
|
|
|
|
|
|
|
pass through the updated pointer to the array of compressed names |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The class loader, B, inserts the @common elements and |
164
|
|
|
|
|
|
|
returns updated @dnptrs. This module knows how to insert its RDATA and |
165
|
|
|
|
|
|
|
calculate the $rdlength. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
input: pointer to buffer, |
168
|
|
|
|
|
|
|
offset (normally end of buffer), |
169
|
|
|
|
|
|
|
pointer to compressed name array, |
170
|
|
|
|
|
|
|
@common RR elements, |
171
|
|
|
|
|
|
|
128 bit IPv6 address |
172
|
|
|
|
|
|
|
output: offset to next RR, |
173
|
|
|
|
|
|
|
new compressed name pointer array, |
174
|
|
|
|
|
|
|
or empty list () on error. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub put { |
179
|
1
|
50
|
|
1
|
0
|
1294
|
return () unless @_; # always return on error |
180
|
1
|
|
|
|
|
3
|
my($self,$bp,$off,$dnp,$ipv6addr) = @_; |
181
|
1
|
50
|
|
|
|
4
|
return () unless |
182
|
|
|
|
|
|
|
($off = put16($bp,$off,NS_IN6ADDRSZ)); |
183
|
1
|
|
|
|
|
28
|
return(putIPv6($bp,$off,$ipv6addr), @$dnp); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * (@COMMON,$IPaddr) = $parse->AAAA(@common,$ipv6addr); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Converts binary/numeric field data into human readable form. The common RR |
189
|
|
|
|
|
|
|
elements are supplied by the class loader, B. This |
190
|
|
|
|
|
|
|
module knows how to parse its RDATA. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
EXAMPLE |
193
|
|
|
|
|
|
|
Common is: name,$type,$class,$ttl,$rdlength |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
name '.' is appended |
196
|
|
|
|
|
|
|
type numeric to text |
197
|
|
|
|
|
|
|
class numeric to text |
198
|
|
|
|
|
|
|
ttl numeric to text |
199
|
|
|
|
|
|
|
rdlength is a number |
200
|
|
|
|
|
|
|
rdata RR specific conversion |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Resource Record B returns $rdata containing a 128 bit IPv6 |
203
|
|
|
|
|
|
|
address. The parse operation would be: |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
input: |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
name foo.bar.com |
208
|
|
|
|
|
|
|
type 1 |
209
|
|
|
|
|
|
|
class 1 |
210
|
|
|
|
|
|
|
ttl 123 |
211
|
|
|
|
|
|
|
rdlength 4 |
212
|
|
|
|
|
|
|
rdata a 128 bit IPv6 address |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
output: |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
name foo.bar.com |
217
|
|
|
|
|
|
|
type T_AAAA |
218
|
|
|
|
|
|
|
class C_IN |
219
|
|
|
|
|
|
|
ttl 2m 3s |
220
|
|
|
|
|
|
|
rdlength 16 |
221
|
|
|
|
|
|
|
rdata FE:0:0:0:1:2:3:4 |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=back |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub parse { |
228
|
1
|
|
|
1
|
0
|
33
|
shift; # $self |
229
|
1
|
|
|
|
|
4
|
ipv6_n2x(shift); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Net::DNS::ToolKit |
235
|
|
|
|
|
|
|
Net::DNS::Codes |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 EXPORT |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
none |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Michael Robinton |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 COPYRIGHT |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Copyright 2003 - 2011, Michael Robinton |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Michael Robinton |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
All rights reserved. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
254
|
|
|
|
|
|
|
it under the terms of either: |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
a) the GNU General Public License as published by the Free |
257
|
|
|
|
|
|
|
Software Foundation; either version 2, or (at your option) any |
258
|
|
|
|
|
|
|
later version, or |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
b) the "Artistic License" which comes with this distribution. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
263
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
264
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either |
265
|
|
|
|
|
|
|
the GNU General Public License or the Artistic License for more details. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
You should have received a copy of the Artistic License with this |
268
|
|
|
|
|
|
|
distribution, in the file named "Artistic". If not, I'll be glad to provide |
269
|
|
|
|
|
|
|
one. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
You should also have received a copy of the GNU General Public License |
272
|
|
|
|
|
|
|
along with this program in the file named "Copying". If not, write to the |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Free Software Foundation, Inc. |
275
|
|
|
|
|
|
|
59 Temple Place, Suite 330 |
276
|
|
|
|
|
|
|
Boston, MA 02111-1307, USA |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
or visit their web page on the internet at: |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
http://www.gnu.org/copyleft/gpl.html. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 See also: |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Net::DNS::Codes(3), Net::DNS::ToolKit(3) |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=cut |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
1; |