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

filter: Statementstmt 91.7% 134 / 146 Branchbran 78.5% 22 / 28 Conditioncond 63.1% 12 / 19 MC/DCmcdc 36.3% 4 / 11 Subroutinesub 74.1% 23 / 31 Podpod 14.2% 1 / 7 totaltotal 80.9% 196 / 242 CC 22 SCAR 11.5
CC
22
Cov
87%
RRput
6.3
instantiate
6.1
make_function
5.0
CRAP 3.2
« blib/lib/Net/DNS/ToolKit/RR/MX.pm ↑ Summary blib/lib/Net/DNS/ToolKit/RR/TXT.pm »
1 package Net::DNS::ToolKit::RR;
2  
3 #use 5.006;
4 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 #use diagnostics;
6 #use warnings;
7  
8 14 ▶use Net::DNS::Codes qw(:RRs);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use Net::DNS::ToolKit qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
10 get16
11 get32
12 put16
13 put32
14 getstring
15 dn_comp
16 dn_expand
17 14 );
18 14 ▶use vars qw($VERSION $autoload *sub);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 14 require Net::DNS::ToolKit::Question;
20  
21 14 $VERSION = do { my @r = (q$Revision: 0.09 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
22  
23 23 ▶sub remoteload {
Subroutine remoteload: called CC=1 SCAR=0.9
Pod undocumented
24 # *sub = $autoload;
25 23 (my $RRtype = $autoload ) =~ s/.*::(\w+):://;
26 # function = $1, one of get,put,parse
27 23 local $_;
28 23 ($autoload,$_) = instantiate($RRtype,$1);
29 # my $code = 'package '. __PACKAGE__ .'::'. $1 .'; '.'*'. $RRtype .'=\&'. $autoload;
30 23 my $code = 'package '. __PACKAGE__ .'::'. $1 .'; '.'*'. $RRtype .
31 q| = sub { unshift @_,'|. $autoload . q|'; &|. $_ .'};';
32 0 ▶ eval "$code";
Subroutine __ANON__: not called CC=1 SCAR=4.9
Subroutine __ANON__: not called CC=1 SCAR=4.9
Subroutine __ANON__: not called CC=1 SCAR=4.9
33  
34 # print "AUTOLOAD=",*sub,";\n";
35 # print "subname=$autoload RRtype=$RRtype func=$1\n";
36 # print 'code=', $code, "\n";
37  
38 # no strict;
39 # eval { *sub = sub { unshift @_,$autoload; &$_ } };
40 # goto &{*sub};
41 23 unshift @_,$autoload;
42 23 goto &$_;
43 }
44  
45 # return target function, target interpreter
46 28 ▶sub instantiate {
Subroutine instantiate: called CC=6 SCAR=18.0
Pod undocumented
47 28 my($RRtype,$func) = @_;
48 28 ▶ if ($RRtype eq 'DESTROY') { # should never get here
Branch: 1 branch
BranchTrueFalseTotal
if ($RRtype eq 'DESTROY') { } 0 28 28
49 0 die __PACKAGE__.".pm: DESTROY must be defined internally in the calling package\n";
50 } else {
51 28 my $filename = __PACKAGE__.'::'.$RRtype.'.pm';
52 28 $filename =~ s#::#/#g;
53 28 my $save = $@;
54 28 eval { local $SIG{__DIE__}; require $filename };
55 28 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 12 16 28
56 # die __PACKAGE__.'::RR'.$func.' not implemented'
57 # if $func eq 'put';
58 # $@ = $save;
59 # $RRtype = 'NotImplemented';
60 12 my $generic;
61 12 ▶ if ( $RRtype =~ /^TYPE(\d+)$/ &&
Branch: 1 branch
BranchTrueFalseTotal
if ($RRtype =~ /^TYPE(\d+)$/ and $generic = TypeTxt()->{$1} and $generic =~ /T_(.+)/) { } 2 10 12
Condition66%4/6
$RRtype =~ /^TYPE(\d+)$/ and $generic = TypeTxt()->{$1} and $generic =~ /T_(.+)/
!ll&&!rl&&r
1002
$RRtype =~ /^TYPE(\d+)$/ and $generic = TypeTxt()->{$1}
!ll&&!rl&&r
0102
MC/DC33%1/3
$RRtype =~ /^TYPE(\d+)$/ and $generic = TypeTxt()->{$1} and $generic =~ /T_(.+)/
$RRtype =~ /^TYPE(\d+)$/ $generic = TypeTxt()->{$1} $generic =~ /T_(.+)/
Truth table50%2/4
A and B and C
A= $RRtype =~ /^TYPE(\d+)$/B= $generic = TypeTxt()->{$1}C= $generic =~ /T_(.+)/
ABCresult
0XX0
10X0
1100
1111
62 ($generic = TypeTxt->{$1}) &&
63 $generic =~ /T_(.+)/) {
64 2 $generic = __PACKAGE__.'::'. $1;
65 } else {
66 10 $generic = __PACKAGE__.'::TYPE';
67 }
68 12 local $_ = $generic .'.pm';
69 12 s#::#/#g;
70 12 require $_;
71 12 my $code = 'package '. __PACKAGE__ .'::'. $RRtype .';
72 *get = \&'. $generic .'::get;
73 *put = \&'. $generic .'::put;
74 *parse = \&'. $generic .'::parse;';
75 12 eval "$code";
76 }
77 }
78 # package from local scope
79 28 return (__PACKAGE__.'::'.$RRtype.'::'.$func, __PACKAGE__.'::RR'.$func);
80 }
81  
82 # return instantiated function
83 10 ▶sub make_function {
Subroutine make_function: called CC=5 SCAR=16.1
Pod undocumented
84 10 my $type = shift;
85 10 (caller(1))[3] =~ /RR(\w+)$/;
86 10 my $action = $1;
87 10 local $_;
88 10 ▶ if (($_ = TypeTxt->{$type}) && $_ =~ /T_(.+)/) { # type is real?
Branch: 1 branch
BranchTrueFalseTotal
if ($_ = TypeTxt()->{$type} and $_ =~ /T_(.+)/) { } 4 6 10
Condition66%2/3
$_ = TypeTxt()->{$type} and $_ =~ /T_(.+)/
!ll&&!rl&&r
604
MC/DC50%1/2
$_ = TypeTxt()->{$type} and $_ =~ /T_(.+)/
$_ = TypeTxt()->{$type} $_ =~ /T_(.+)/
Truth table66%2/3
A and B
A= $_ = TypeTxt()->{$type}B= $_ =~ /T_(.+)/
ABresult
0X0
100
111
89 4 my $function = __PACKAGE__.'::'.$1;
90 4 ▶ if ($function->can($action)) { # if function is instantiated
Branch: 1 branch
BranchTrueFalseTotal
if ($function->can($action)) { } 3 1 4
91 3 return $function .= '::'.$action;
92 } else { # instantiate it or NotImplemented
93 1 return (instantiate($1,$action))[0];
94 }
95 } else {
96 # return __PACKAGE__.'::NotImplemented::'.$action;
97 6 my $function = __PACKAGE__.'::TYPE'. $type;
98 6 ▶ if ($function->can($action)) { # if function is instantiated
Branch: 1 branch
BranchTrueFalseTotal
if ($function->can($action)) { } 2 4 6
99 2 return $function .= '::'.$action;
100 } else { # instantiate it or NotImplemented
101 4 return (instantiate("TYPE$type",$action))[0];
102 }
103 }
104 }
105  
106 #########################################################
107 # implements the common portion of...
108 # ($newoff,$name,$type,$class,$ttl,$rdlength,$rdata,...)
109 # = $get->next(\$buffer,$offset);
110  
111 12 ▶sub RRget {
Subroutine RRget: called CC=2 SCAR=6.9
Pod undocumented
112 12 my($function,$self,$bp,$newoff) = @_;
113 12 my ($off,$name) = dn_expand($bp,$newoff);
114 12 (my $type, $off) = get16($bp,$off);
115 12 (my $class, $off) = get16($bp,$off);
116 12 (my $ttl, $off) = get32($bp,$off);
117 12 my $rdlength = get16($bp,$off); # scalar context, don't get offset
118 12 ▶ $function = make_function($type) unless $function;
Branch: 1 branch
BranchTrueFalseTotal
unless $function 7 5 12
119 14 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
120 12 ($off, my @results) = &$function($self,$bp,$off);
121 12 return($off,$name,$type,$class,$ttl,$rdlength,@results);
122 }
123  
124 #########################################################
125 # implements the common portions of...
126 # ($newoff,@dnptrs)=$put->XYZ(\$buffer,$offset,\@dnptrs,
127 # $name,$type,$class,$ttl,$rdata,...);
128  
129 10 ▶sub RRput {
Subroutine RRput: called CC=6 SCAR=18.5
Pod undocumented
130 # extract common elements from input, shrink input
131 # input was: $function,$self,\$buffer,$offset,\@dnptrs,$name,$type,$class,$ttl,@rdata
132 10 my ($func,$put,$bp,$off,$dnp,$name,$type,$class,$ttl) = @_;
133 10 ▶ if (exists $_[1]->{class}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_[1]{'class'}) { } 1 9 10
134 1 ($func,$put,$bp,$off,$dnp,$name,$ttl) = splice(@_,0,7);
135 1 $class = $put->{class};
136 1 $func =~ /.+::(.+)::put$/;
137 1 $type = 'T_'.$1;
138 14 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
139 1 $type = &$type;
140 } else {
141 9 ($func,$put,$bp,$off,$dnp,$name,$type,$class,$ttl) = splice(@_,0,9);
142 }
143 # input is now: @rdata
144 10 ▶ die "'names' ending in '.' are not allowed per RFC's\n"
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\.$/ 0 10 10
145 if $name =~ /\.$/;
146 10 ($off, my @dnptrs) = dn_comp($bp,$off,\$name,$dnp);
147 10 ▶ unless (@dnptrs) { # if not valid return
Branch: 1 branch
BranchTrueFalseTotal
unless (@dnptrs) 0 10 10
148 0 ▶ while(shift) {}; # empty the input array
Branch: 1 branch
BranchTrueFalseTotal
if (shift()) 0 0 0
149 0 return (); # error
150 }
151 10 ▶ return () unless ($off = put16($bp,$off,$type));
Branch: 1 branch
BranchTrueFalseTotal
unless $off = put16($bp, $off, $type) 0 10 10
152 # the rest should work since offset has been checked
153 10 $off = put16($bp,$off,$class);# class
154 10 $off = put32($bp,$off,$ttl);# ttl
155 14 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
156 10 &$func($self,$bp,$off,\@dnptrs,@_);
157 }
158  
159 ####################################################################
160 # implements the common portion of...
161 # ($name,$typeTXT,$classTXT,$ttl,$rdlength,$RDATA,...)
162 # = $parse->XYZ($name,$type,$class,$ttl,$rdlength,$rdata,...)
163  
164 11 ▶sub RRparse {
Subroutine RRparse: called CC=4 SCAR=13.9
Pod undocumented
165 # extract common elements from input, shrink input
166 # input was: $function,$self,$name,$type,$class,$ttl,$rdlength,@rdata
167 11 my $function = shift;
168 # input is now: $name,$type,$class,$ttl,$rdlength,@rdata
169 11 my ($name,$type,$class,$ttl,$rdlength) = splice(@_,1,5); # pass $self,@rdata to $function call
170 # if length is ever needed, add it here
171 # $_[0]->{len} = $rdlength;
172 11 $name .= '.'; # terminate domain name
173 11 ▶ $function = make_function($type) unless $function;
Branch: 1 branch
BranchTrueFalseTotal
unless $function 3 8 11
174 14 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
175 11 ▶ my $typetxt = TypeTxt->{$type} || "TYPE$type";
Condition100%2/2
TypeTxt()->{$type} || "TYPE$type"
l!l
56
MC/DC100%1/1
TypeTxt()->{$type} || "TYPE$type"
TypeTxt()->{$type}
Truth table100%2/2
A
A= TypeTxt()->{$type}
Aresult
11
00
176 11 ▶ my $classtxt = ClassTxt->{$class} || "CLASS$class";
Condition50%1/2
ClassTxt()->{$class} || "CLASS$class"
l!l
110
MC/DC0%0/1
ClassTxt()->{$class} || "CLASS$class"
ClassTxt()->{$class}
Truth table50%1/2
A
A= ClassTxt()->{$class}
Aresult
11
00
177 11 return($name,$typetxt,$classtxt,$ttl,$rdlength,&{$function}(@_));
178 }
179  
180 #####################################################################
181 ######################### sub PACKAGES ##############################
182 #####################################################################
183  
184 # this entire sub package is obsolete as of v0.07
185 #{
186 # package Net::DNS::ToolKit::RR::NotImplemented;
187 #
188 # sub get {
189 # my($self,$bp,$offset) = @_;
190 # (my $rdlength, $offset) = &Net::DNS::ToolKit::get16($bp,$offset);
191 # $offset += $rdlength;
192 # return($offset,"\0");
193 # }
194 #
195 ## die in loader, unimplemented
196 ## sub put {
197 ## my($bp,$off,$dp) = @_;
198 ## return($off,@$dp);
199 ## }
200 #
201 # sub parse {
202 # shift; # $self
203 # return(@_); # garbage in, garbage out
204 # }
205 #}
206  
207 {
208 package Net::DNS::ToolKit::RR::get;
209 14 ▶ use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
210  
211 # preload Question
212 14 *Question = \&Net::DNS::ToolKit::Question::get;
213  
214 5 ▶ sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
215 5 $Net::DNS::ToolKit::RR::autoload = $AUTOLOAD;
216 5 goto &Net::DNS::ToolKit::RR::remoteload;
217 }
218 7 ▶ sub next {
Subroutine next: called CC=1 SCAR=0.0
219 7 unshift @_,undef; # flag to RRget;
220 7 goto &Net::DNS::ToolKit::RR::RRget;
221 }
222 0 ▶ sub EmptyList {()};
Subroutine EmptyList: not called CC=1 SCAR=6.9
223 0 ▶ sub DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
224 }
225  
226 {
227 14 package Net::DNS::ToolKit::RR::put;
228 14 ▶ use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
229  
230 # preload Question
231 14 *Question = \&Net::DNS::ToolKit::Question::put;
232  
233 10 ▶ sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
234 10 $Net::DNS::ToolKit::RR::autoload = $AUTOLOAD;
235 10 goto &Net::DNS::ToolKit::RR::remoteload;
236 }
237 0 ▶ sub DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
238 }
239  
240 {
241 14 package Net::DNS::ToolKit::RR::parse;
242 14 ▶ use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
243  
244 # preload Question
245 14 *Question = \&Net::DNS::ToolKit::Question::parse;
246  
247 8 ▶ sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
248 8 $Net::DNS::ToolKit::RR::autoload = $AUTOLOAD;
249 8 goto &Net::DNS::ToolKit::RR::remoteload;
250 }
251 # this next sub has been in the distro a long time
252 # $parse->RR
253 # this was unintentional but does not hurt anything
254 0 ▶ sub RR {
Subroutine RR: not called CC=1 SCAR=6.9
255 0 unshift @_,undef; # flag to RRparse;
256 0 goto &Net::DNS::ToolKit::RR::RRparse;
257 }
258 # this SHOULD of been here instead of the above
259 3 ▶ sub next {
Subroutine next: called CC=1 SCAR=0.0
260 3 unshift @_,undef; # flag to RRparse;
261 3 goto &Net::DNS::ToolKit::RR::RRparse;
262 }
263 0 ▶ sub DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
264 }
265  
266 =head1 NAME
267  
268 Net::DNS::ToolKit::RR - Resource Record class loader
269  
270 =head1 SYNOPSIS
271  
272 use Net::DNS::ToolKit::RR;
273  
274 ($get,$put,$parse) = new Net::DNS::ToolKit::RR;
275 or
276 ($get,$put,$parse) = Net::DNS::ToolKit::RR->new;
277  
278 retrieve the next record (type unknown)
279 ($newoff,$name,$type,$class,$ttl,$rdlength,$rdata,...)
280 = $get->next(\$buffer,$offset);
281  
282 parse the current record (type in input fields)
283 ($name,$typeTXT,$classTXT,$ttlTXT,$rdlength,$RDATA,...)
284 = $parse->RR($name,$type,$class,$ttl,$rdlength,
285 $rdata,...);
286  
287 ($newoff,@dnptrs)=$put->XYZ(\$buffer,$offset,\@dnptrs,
288 $name,$type,$class,$ttl,$rdata,...);
289  
290 The 'get' and 'parse' operations can also be done
291 by specific record type...
292 ...but why would you use them instead of 'next' & 'RR'?
293  
294 ($newoff,$name,$type,$class,$ttl,$rdlength,$rdata,...)
295 = $get->XYZ(\$buffer,$offset);
296  
297 ($name,$typeTXT,$classTXT,$ttlTXT,$rdlength,$RDATA,...)
298 = $parse->XYZ($name,$type,$class,$ttl,$rdlength,
299 $rdata,...);
300  
301 or you can use the individual methods
302 directly without calling "new"
303  
304 @output=Net::DNS::ToolKit::RR::get->next(@input);
305 @output=Net::DNS::ToolKit::RR::get->XYZ(@input);
306 @output=Net::DNS::ToolKit::RR::put->XYZ(@input);
307 @output=Net::DNS::ToolKit::RR::parse->RR(@input);
308 @output=Net::DNS::ToolKit::RR::parse->XYZ(@input);
309  
310 The Question section is a special case:
311  
312 ($newoff,$name,type,class) =
313 $get->Question(\$buffer,$offset);
314 ($newoff,@dnptrs) =
315 $put->Question(\$buffer,$offset,
316 $name,$type,$class,\@dnptrs);
317 ($name,$typeTXT,$classTXT) =
318 $parse->Question($name,$type,$class);
319  
320 =head1 ALTERNATE PUT METHOD SYNOPSIS
321  
322 An alternate method for B<put> is available for class specific
323 submissions. This eliminates the need to specify TYPE and CLASS when doing a
324 put. The generic form of a put command using this method is shown below but
325 NOT detailed in the method descriptions.
326  
327 ($get,$put,$parse) = new Net::DNS::ToolKit::RR(class_type);
328 or
329 ($get,$put,$parse) = Net::DNS::ToolKit::RR->new(C_IN);
330  
331 The generic form of a C<put> operation then becomes:
332  
333 ($newoff,@dnptrs)=$put->XYZ(\$buffer,$offset,\@dnptrs,
334 $name,$ttl,$rdate,...)
335  
336 The only class currently supported at this time is C_IN.
337  
338 NOTE: the use of this alternate method changes the number of required
339 arguments to ALL put RR operations. These changes are NOT noted below in the
340 method descriptions.
341  
342 =head1 DESCRIPTION
343  
344 B<Net::DNS::ToolKit::RR> is the class loader for Resource Record classes.
345 It provides an extensible wrapper for existing
346 classes as well as the framework to easily add new RR classes. See:
347 B<Net::DNS::ToolKit::RR::Template>
348  
349 From RFC 1035
350  
351 3.2.1. Format
352  
353 All RRs have the same top level format shown below:
354  
355 1 1 1 1 1 1
356 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
357 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
358 | NAME |
359 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
360 | TYPE |
361 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
362 | CLASS |
363 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
364 | TTL |
365 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
366 | RDLENGTH |
367 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
368 | RDATA |
369 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
370  
371 NAME an owner name, i.e., the name of the node to which this
372 resource record pertains.
373  
374 TYPE two octets containing one of the RR TYPE codes.
375  
376 CLASS two octets containing one of the RR CLASS codes.
377  
378 TTL a 32 bit signed integer that specifies the time interval
379 that the resource record may be cached before the source
380 of the information should again be consulted. Zero
381 values are interpreted to mean that the RR can only be
382 used for the transaction in progress, and should not be
383 cached. For example, SOA records are always distributed
384 with a zero TTL to prohibit caching. Zero values can
385 also be used for extremely volatile data.
386  
387 RDLENGTH an unsigned 16 bit integer that specifies the length
388 in octets of the RDATA field.
389  
390 RDATA a variable length string of octets that describes the
391 resource. The format of this information varies
392 according to the TYPE and CLASS of the resource record.
393  
394 =over 4
395  
396 =item * ($get,$put,$parse) = new Net::DNS::ToolKit::RR;
397  
398 Retrieves the method pointers to B<get>, B<put>, and B<parse> for Queston
399 section and Resource Records of a particular type.
400  
401 =cut
402  
403 14 ▶sub new {
Subroutine new: called CC=4 SCAR=14.0
Pod documented
404 13 my ($proto,$class) = @_;
405 13 ▶ my $package = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0130
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
406 13 my $get = {};
407 13 bless ($get, "${package}::get");
408 13 ▶ my $put = ($class && ClassTxt->{$class})
Branch: 1 branch
BranchTrueFalseTotal
$class && ClassTxt()->{$class} ? : 2 11 13
Condition66%2/3
$class and ClassTxt()->{$class}
!ll&&!rl&&r
1102
MC/DC50%1/2
$class and ClassTxt()->{$class}
$class ClassTxt()->{$class}
Truth table66%2/3
A and B
A= $classB= ClassTxt()->{$class}
ABresult
0X0
100
111
409 ? { class => $class, } : {};
410 13 bless ($put, "${package}::put");
411 13 my $parse = {};
412 13 bless ($parse, "${package}::parse");
413 13 return ($get,$put,$parse);
414 }
415  
416 =item * ($newoff,@common,$rdata,...) =
417 $get->next(\$buffer,$offset);
418  
419 Get the next Resource Record.
420  
421 input: pointer to buffer,
422 offset into buffer
423  
424 returns: offset to next RR or section,
425 (items common to all RR's)
426 i.e. $name,$type,$class,$ttl,$rdlength,
427 $rdata,.... for this RR
428 or undef if the RR is unsupported.
429  
430 HERE IS THE OPPORTUNITY FOR YOU TO ADD TO THIS PACKAGE.
431 If your RR of interest is not supported, see:
432  
433 Net::DNS::ToolKit::RR::Template in:
434 .../Net/DNS/ToolKit/Template/Template.pm
435  
436 Build the support for your Resource Record and submit it to CPAN as an
437 extension to this package.
438  
439 UN-IMPLEMENTED methods: $get->[unimplemented] returns a correct offset to
440 the following RR, correct @common data and a single $rdata element
441 containing a null ... "\0" to be precise. This works as either a numeric 0
442 (zero) or an end of string.
443  
444 =cut
445  
446 =item * ($newoff,@dnptrs)=$put->XYZ(\$buffer,$offset,\@dnptrs,
447 $name,$type,$class,$ttl,$rdata,...);
448  
449  
450 Append a resource record of type XYZ to the current buffer. This is the
451 generic form of a B<put>.
452  
453 input: pointer to buffer,
454 offset, [should be end of buffer]
455 pointer to compressed name array,
456 (items common to all RR's)
457 i.e. $name,$type,$class,$ttl,
458 $rdata,.... for this RR
459 in binary form if appropriate
460  
461 returns: offset to end of RR,
462 new pointer array,
463 or empty list if the RR type is
464 unsupported
465  
466 See: note above about writing new RR's
467  
468 UN-IMPLEMENTED methods: $put->[unimplemented] fails miserably with a DIE
469 statement identifying the offending method.
470  
471 =cut
472  
473 =item * (@COMMON,$RDATA) = $parse->XYZ(@common,$rdata,...);
474  
475 Convert non-printable and numeric data common to all records and the RR
476 specific B<rdata> into ascii text. In many cases this is a null
477 operation. i.e. for a TXT record. However, for a RR of type B<A>, the
478 operation would be as follows:
479  
480 EXAMPLE
481 Common:
482  
483 name is already text.
484 type numeric to text
485 class numeric to text
486 ttl numeric to text
487 rdlength is a number
488 rdata RR specific conversion
489  
490 Resource Record B<A> returns $rdata containing a packed IPv4 network
491 address. The parse operation would be:
492  
493 input:
494  
495 name foo.bar.com
496 type 1
497 class 1
498 ttl 123
499 rdlength 4
500 rdata a packed IPv4 address
501  
502 output:
503  
504 name foo.bar.com
505 type T_A
506 class C_IN
507 ttl 123 # 2m 3s
508 rdlength 4
509 rdata 192.168.20.40
510  
511 The rdata conversion is implemented internally as:
512  
513 $dotquad = inet_ntoa($networkaddress);
514  
515 where $dotquad is a printable IP address like
516 192.168.20.55
517  
518 UN-IMPLEMENTED methods: $parse->[unimplemented] returns correct @common
519 elements insofar as the type and class are present in Net::DNS::Codes.
520 Other elements are passed through unchanged. i.e. garbage-in, garbage-out.
521  
522 =item * ($newoff,$name,type,class) =
523 $get->Question(\$buffer,$offset);
524  
525 Get the Question.
526  
527 input: pointer to buffer,
528 offset
529 returns: domain name,
530 question type,
531 question class
532  
533 =item * ($newoff,@dnptrs) =
534 $put->Question(\$buffer,$offset,
535 $name,$type,$class,\@dnptrs);
536  
537 Append a question to the $buffer. Returns a new pointer array for compressed
538 names and the offset to the next RR.
539  
540 NOTE: it is up to the user to update the question count. See: L<put_qdcount>
541  
542 Since the B<question> usually is the first record to be appended to the
543 buffer, @dnptrs may be ommitted. See the details at L<dn_comp>.
544  
545 Usage: ($newoff,@dnptrs)=$put->Question(\$buffer,$offset,
546 $name,$type,$class);
547  
548 input: pointer to buffer,
549 offset into buffer,
550 domain name,
551 question type,
552 question class,
553 pointer to array of
554 previously compressed names,
555 returns: offset to next record,
556 updated array of offsets to
557 previous compressed names
558  
559 =item * ($name,$typeTXT,$classTXT) =
560 $parse->Question($name,$type,$class);
561  
562 Convert non-printable and numeric data
563 into ascii text.
564  
565 input: domain name,
566 question type (numeric)
567 question class (numeric)
568 returns: domain name,
569 type TEXT,
570 class TEXT
571  
572 =back
573  
574 =cut
575  
576 14 1;
577 __END__
« blib/lib/Net/DNS/ToolKit/RR/MX.pm ↑ Summary blib/lib/Net/DNS/ToolKit/RR/TXT.pm »