File Coverage

blib/lib/Net/DNS/ToolKit/RR/NULL.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 3 0.0
total 35 42 83.3


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