File Coverage

blib/lib/Net/DNS/ToolKit/RR/CNAME.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


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