File Coverage

blib/lib/Net/DNS/ToolKit/RR/MG.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::MG;
2              
3 1     1   2083 use strict;
  1         2  
  1         38  
4             #use warnings;
5              
6 1     1   5 use vars qw($VERSION);
  1         2  
  1         155  
7              
8             $VERSION = do { my @r = (q$Revision: 0.03 $ =~ /\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::MG - Resource Record Handler
19              
20             =head1 SYNOPSIS
21              
22             DO NOT use Net::DNS::ToolKit::RR::MG
23             DO NOT require Net::DNS::ToolKit::RR::MG
24              
25             Net::DNS::ToolKit::RR::MG 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             $madname) = $get->MG(\$buffer,$offset);
34              
35             Note: the $get->MG method is normally called
36             via: @stuff = $get->next(\$buffer,$offset);
37              
38             ($newoff,@dnptrs)=$put->MG(\$buffer,$offset,\@dnptrs,
39             $name,$type,$class,$ttl,$madname);
40              
41             $NAME,$TYPE,$CLASS,$TTL,$rdlength,$MADNAME)
42             = $parse->MG($name,$type,$class,$ttl,$rdlength,
43             $madname);
44              
45             =head1 DESCRIPTION
46              
47             B appends an MG resource record to a DNS packet under
48             construction, recovers an MG 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.3. MG RDATA format (EXPERIMENTAL)
98              
99             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
100             / MADNAME /
101             / /
102             +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
103              
104             where:
105              
106             MADNAME A which specifies a host which
107             has the specified mailbox.
108              
109             =over 4
110              
111             =item * @stuff = $get->MG(\$buffer,$offset);
112              
113             Get the contents of the resource record.
114              
115             USE: @stuff = $get->next(\$buffer,$offset);
116              
117             where: @stuff = (
118             $newoff $name,$type,$class,$ttl,$rdlength,
119             $madname );
120              
121             All except the last item, B<$madname>, is provided by
122             the class loader, B. The code in this method knows
123             how to retrieve B<$madname>.
124              
125             input: pointer to buffer,
126             offset into buffer
127             returns: offset to next resource,
128             @common RR elements,
129             MG Domain Name
130              
131             =item * ($newoff,@dnptrs)=$put->MG(\$buffer,$offset,\@dnptrs,
132             $name,$type,$class,$ttl,$madname);
133              
134             Append an MG record to $buffer.
135              
136             where @common = (
137             $name,$type,$class,$ttl);
138              
139             The method will insert the $rdlength and $madname, then
140             pass through the updated pointer to the array of compressed names
141              
142             The class loader, B, inserts the @common elements and
143             returns updated @dnptrs. This module knows how to insert its RDATA and
144             calculate the $rdlength.
145              
146             input: pointer to buffer,
147             offset (normally end of buffer),
148             pointer to compressed name array,
149             @common RR elements,
150             MG Domain Name
151             output: offset to next RR,
152             new compressed name pointer array,
153             or empty list () on error.
154              
155             =item * (@COMMON,$MADNAME) = $parse->MG(@common,$madname);
156              
157             Converts binary/numeric field data into human readable form. The common RR
158             elements are supplied by the class loader, B.
159             For MG RR's, this returns the $madname terminated with '.'
160              
161             input: MG Domain Name
162             returns: MG Domain Name.
163              
164             =back
165              
166             =head1 DEPENDENCIES
167              
168             Net::DNS::ToolKit
169             Net::DNS::Codes
170             Net::DNS::ToolKit::RR::NS
171              
172             =head1 EXPORT
173              
174             none
175              
176             =head1 AUTHOR
177              
178             Michael Robinton
179              
180             =head1 COPYRIGHT
181              
182             Copyright 2003 - 2011, Michael Robinton
183            
184             Michael Robinton
185              
186             All rights reserved.
187              
188             This program is free software; you can redistribute it and/or modify
189             it under the terms of either:
190              
191             a) the GNU General Public License as published by the Free
192             Software Foundation; either version 2, or (at your option) any
193             later version, or
194              
195             b) the "Artistic License" which comes with this distribution.
196              
197             This program is distributed in the hope that it will be useful,
198             but WITHOUT ANY WARRANTY; without even the implied warranty of
199             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
200             the GNU General Public License or the Artistic License for more details.
201              
202             You should have received a copy of the Artistic License with this
203             distribution, in the file named "Artistic". If not, I'll be glad to provide
204             one.
205              
206             You should also have received a copy of the GNU General Public License
207             along with this program in the file named "Copying". If not, write to the
208              
209             Free Software Foundation, Inc.
210             59 Temple Place, Suite 330
211             Boston, MA 02111-1307, USA
212              
213             or visit their web page on the internet at:
214              
215             http://www.gnu.org/copyleft/gpl.html.
216              
217             =head1 See also:
218              
219             Net::DNS::Codes(3), Net::DNS::ToolKit(3)
220              
221             =cut
222              
223             1;