blib/lib/Net/DNS/ToolKit/RR/MINFO.pm

filter: Statementstmt 100% 30 / 30 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 77.3% 41 / 53 CC 5 SCAR 12.0
CC
5
Cov
85%
put
6.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
« blib/lib/Net/DNS/ToolKit/RR/RT.pm ↑ Summary blib/lib/Net/DNS/ToolKit/RR/MX.pm »
1 package Net::DNS::ToolKit::RR::MINFO;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 #use warnings;
5  
6 2 ▶use Net::DNS::ToolKit qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 get16
8 get32
9 put16
10 put32
11 dn_comp
12 dn_expand
13 2 );
14 2 ▶use Net::DNS::Codes qw(:constants);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 $VERSION = do { my @r = (q$Revision: 0.01 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
18  
19 =head1 NAME
20  
21 Net::DNS::ToolKit::RR::MINFO - Resource Record Handler
22  
23 =head1 SYNOPSIS
24  
25 DO NOT use Net::DNS::ToolKit::RR::MINFO
26 DO NOT require Net::DNS::ToolKit::RR::MINFO
27  
28 Net::DNS::ToolKit::RR::MINFO 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 ) = $get->MINFO(\$buffer,$offset);
37  
38 Note: the $get->MINFO method is normally called
39 via: @stuff = $get->next(\$buffer,$offset);
40  
41 ($newoff,@dnptrs)=$put->MINFO(\$buffer,$offset,\@dnptrs,
42 $name,$type,$class,$ttl,
43 $mname,$errname);
44  
45 $NAME,$TYPE,$CLASS,$TTL,$rdlength,
46 $MNAME,$RNAME,$serial,$refresh,$retry,$expire,$min)
47 = $parse->MINFO($name,$type,$class,$ttl,$rdlength,
48 $mname,$errname);
49  
50 =head1 DESCRIPTION
51  
52 B<Net::DNS::ToolKit::RR:MINFO> appends an MINFO resource record to a DNS packet
53 under construction, recovers an MINFO resource record from a packet being decoded, and
54 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, MINFO 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 3.3.13. MINFO RDATA format
103  
104 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
105 / RMAILBX /
106 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
107 / EMAILBX /
108 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
109  
110 where:
111  
112 RMAILBX A <domain-name> which specifies a mailbox which is
113 responsible for the mailing list or mailbox. If this
114 domain name names the root, the owner of the MINFO RR is
115 responsible for itself. Note that many existing mailing
116 lists use a mailbox X-request for the RMAILBX field of
117 mailing list X, e.g., Msgroup-request for Msgroup. This
118 field provides a more general mechanism.
119  
120 EMAILBX A <domain-name> which specifies a mailbox which is to
121 receive error messages related to the mailing list or
122 mailbox specified by the owner of the MINFO RR (similar
123 to the ERRORS-TO: field which has been proposed). If
124 this domain name names the root, errors should be
125 returned to the sender of the message.
126  
127 MINFO records cause no additional section processing.
128  
129 =over 4
130  
131 =item * @stuff = $get->MINFO(\$buffer,$offset);
132  
133 Get the contents of the resource record.
134  
135 USE: @stuff = $get->next(\$buffer,$offset);
136  
137 where: @stuff = (
138 $newoff $name,$type,$class,$ttl,$rdlength,
139 $rname,$errname);
140  
141 All except the last five (2) items,
142 B<$mname,$errname>, are provided by
143 the class loader, B<Net::DNS::ToolKit::RR>. The code in this method knows
144 how to retrieve B<$mname,$errname>.
145  
146 input: pointer to buffer,
147 offset into buffer
148 returns: offset to next resource,
149 @common RR elements,
150 responsible.mail.box
151 error.mail.box
152  
153 =cut
154  
155 2 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
156 2 my($self,$bp,$offset) = @_;
157 2 $offset += INT16SZ; # don't need rdlength
158 2 ($offset, my $mname) = dn_expand($bp,$offset);
159 2 ($offset, my $errname) = dn_expand($bp,$offset);
160 2 return($offset,$mname,$errname);
161 }
162  
163 =item * ($newoff,@dnptrs)=$put->MINFO(\$buffer,$offset,\@dnptrs,
164 $name,$type,$class,$ttl,
165 $mname,$errname);
166  
167 Append an MINFO record to $buffer.
168  
169 where @common = (
170 $name,$type,$class,$ttl);
171  
172 The method will insert the $rdlength,
173 $mname, $errname then
174 return the updated pointer to the array of compressed names
175  
176 The class loader, B<Net::DNS::ToolKit::RR>, inserts the @common elements and
177 returns updated @dnptrs. This module knows how to insert its RDATA and
178 calculate the $rdlength.
179  
180 input: pointer to buffer,
181 offset (normally end of buffer),
182 pointer to compressed name array,
183 @common RR elements,
184 responsible.mail.box
185 error.mail.box
186
187 output: offset to next RR,
188 new compressed name pointer array,
189 or empty list () on error.
190  
191 =cut
192  
193 2 ▶sub put {
Subroutine put: called CC=5 SCAR=18.1
Pod undocumented
194 2 ▶ return () unless @_; # always return on error
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 2 2
195 2 my($self,$bp,$off,$dnp,$mname,$errname) = @_;
196 2 my $rdlp = $off; # save pointer to rdlength
197 2 my ($doff,@dnptrs); # data start, pointer array
198 2 ▶ return () unless # check for valid and get
Branch: 1 branch
BranchTrueFalseTotal
unless $doff = put16($bp, $off, 0) and ($off, @dnptrs) = &dn_comp($bp, $doff, \$mname, $dnp) and ($off, @dnptrs) = &dn_comp($bp, $off, \$errname, \@dnptrs) 0 2 2
Condition33%2/6
$doff = put16($bp, $off, 0) and ($off, @dnptrs) = &dn_comp($bp, $doff, \$mname, $dnp) and ($off, @dnptrs) = &dn_comp($bp, $off, \$errname, \@dnptrs)
!ll&&!rl&&r
002
$doff = put16($bp, $off, 0) and ($off, @dnptrs) = &dn_comp($bp, $doff, \$mname, $dnp)
!ll&&!rl&&r
002
MC/DC0%0/3
$doff = put16($bp, $off, 0) and ($off, @dnptrs) = &dn_comp($bp, $doff, \$mname, $dnp) and ($off, @dnptrs) = &dn_comp($bp, $off, \$errname, \@dnptrs)
$doff = put16($bp, $off, 0) ($off, @dnptrs) = &dn_comp($bp, $doff, \$mname, $dnp) ($off, @dnptrs) = &dn_comp($bp, $off, \$errname, \@dnptrs)
Truth table25%1/4
A and B and C
A= $doff = put16($bp, $off, 0)B= ($off, @dnptrs) = &dn_comp($bp, $doff, \$mname, $dnp)C= ($off, @dnptrs) = &dn_comp($bp, $off, \$errname, \@dnptrs)
ABCresult
0XX0
10X0
1100
1111
199 ($doff = put16($bp,$off,0)) && # offset for names
200 (($off,@dnptrs) = dn_comp($bp,$doff,\$mname,$dnp)) &&
201 (($off,@dnptrs) = dn_comp($bp,$off,\$errname,\@dnptrs));
202  
203 # rdlength = new offset - previous offset
204 2 put16($bp,$rdlp, $off - $doff);
205 2 return($off,@dnptrs);
206 }
207  
208 =item * (@COMMON,$MNAME,$ERRNAME)
209 = $parse->A(@common,
210 $mname,$errname);
211  
212 Converts binary/numeric field data into human readable form. The common RR
213 elements are supplied by the class loader, B<Net::DNS::ToolKit::RR>.
214 For MINFO RR's, this returns $mxdname terminated with '.'
215  
216 input: responsible.mail.box
217 error.mail.box
218 returns: responsible.mail.box '.' terminated
219 error.mail.box '.' terminated
220  
221 =back
222  
223 =cut
224  
225 4 ▶sub parse {
Subroutine parse: called CC=1 SCAR=0.0
Pod undocumented
226 4 my($self,$mname,$errname) = @_;
227 4 return($mname.'.',$errname.'.');
228 }
229  
230 =head1 DEPENDENCIES
231  
232 Net::DNS::ToolKit
233 Net::DNS::Codes
234  
235 =head1 EXPORT
236  
237 none
238  
239 =head1 AUTHOR
240  
241 Michael Robinton <michael@bizsystems.com>
242  
243 =head1 COPYRIGHT
244  
245 Copyright 2003 - 2011, Michael Robinton <michael@bizsystems.com>
246
247 Michael Robinton <michael@bizsystems.com>
248  
249 All rights reserved.
250  
251 This program is free software; you can redistribute it and/or modify
252 it under the terms of either:
253  
254 a) the GNU General Public License as published by the Free
255 Software Foundation; either version 2, or (at your option) any
256 later version, or
257  
258 b) the "Artistic License" which comes with this distribution.
259  
260 This program is distributed in the hope that it will be useful,
261 but WITHOUT ANY WARRANTY; without even the implied warranty of
262 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
263 the GNU General Public License or the Artistic License for more details.
264  
265 You should have received a copy of the Artistic License with this
266 distribution, in the file named "Artistic". If not, I'll be glad to provide
267 one.
268  
269 You should also have received a copy of the GNU General Public License
270 along with this program in the file named "Copying". If not, write to the
271  
272 Free Software Foundation, Inc.
273 59 Temple Place, Suite 330
274 Boston, MA 02111-1307, USA
275  
276 or visit their web page on the internet at:
277  
278 http://www.gnu.org/copyleft/gpl.html.
279  
280 =head1 See also:
281  
282 Net::DNS::Codes(3), Net::DNS::ToolKit(3)
283  
284 =cut
285  
286 2 1;
« blib/lib/Net/DNS/ToolKit/RR/RT.pm ↑ Summary blib/lib/Net/DNS/ToolKit/RR/MX.pm »