| 1 | package Net::DNS::ToolKit::Question; | ||||||||||||||||||||||||||||
| 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::ToolKit qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | get16 | ||||||||||||||||||||||||||||
| 10 | put16 | ||||||||||||||||||||||||||||
| 11 | dn_comp | ||||||||||||||||||||||||||||
| 12 | dn_expand | ||||||||||||||||||||||||||||
| 13 | 14 | ); | |||||||||||||||||||||||||||
| 14 | 14 | ▶ | use Net::DNS::Codes qw(TypeTxt ClassTxt); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 14 | $VERSION = do { my @r = (q$Revision: 0.03 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Net::DNS::ToolKit::Question - Resource Handler | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | DO NOT use Net::DNS::ToolKit::Question | ||||||||||||||||||||||||||||
| 29 | DO NOT require Net::DNS::ToolKit::Question | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Net::DNS::ToolKit::Question is autoloaded by | ||||||||||||||||||||||||||||
| 32 | class Net::DNS::ToolKit::RR and its methods | ||||||||||||||||||||||||||||
| 33 | are instantiated in a 'special' manner. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =over 4 | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =item * ($newoff,$name,$type,$class) = | ||||||||||||||||||||||||||||
| 40 | $get->Question(\$buffer,$offset); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | Get question from $buffer. Returns the expanded name, type and class. | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | input: pointer to buffer, | ||||||||||||||||||||||||||||
| 45 | offset into buffer | ||||||||||||||||||||||||||||
| 46 | returns: new offset, | ||||||||||||||||||||||||||||
| 47 | expanded name, | ||||||||||||||||||||||||||||
| 48 | type, | ||||||||||||||||||||||||||||
| 49 | class | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 13 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 13 | my($self,$bp,$off) = @_; | |||||||||||||||||||||||||||
| 55 | 13 | ($off, my $name) = dn_expand($bp,$off); | |||||||||||||||||||||||||||
| 56 | 13 | (my $type,$off) = get16($bp,$off); | |||||||||||||||||||||||||||
| 57 | 13 | (my $class,$off) = get16($bp,$off); | |||||||||||||||||||||||||||
| 58 | 13 | return ($off,$name,$type,$class); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =item * ($newoff,@dnptrs) = | ||||||||||||||||||||||||||||
| 62 | $put->Question(\$buffer,$offset, | ||||||||||||||||||||||||||||
| 63 | $name,$type,$class,\@dnptrs); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Append a question to the $buffer. Returns a new pointer array for compressed | ||||||||||||||||||||||||||||
| 66 | names and the offset to the next RR. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | NOTE: it is up to the user to update the question count. See: L<put_qdcount> | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Since the B<question> usually is the first record to be appended to the | ||||||||||||||||||||||||||||
| 71 | buffer, @dnptrs may be ommitted. See the details at L<dn_comp>. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Usage: ($newoff,@dnptrs)=$put->Question(\$buffer,$offset, | ||||||||||||||||||||||||||||
| 74 | $name,$type,$class); | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | input: pointer to buffer, | ||||||||||||||||||||||||||||
| 77 | offset into buffer, | ||||||||||||||||||||||||||||
| 78 | domain name, | ||||||||||||||||||||||||||||
| 79 | question type, | ||||||||||||||||||||||||||||
| 80 | question class, | ||||||||||||||||||||||||||||
| 81 | pointer to array of | ||||||||||||||||||||||||||||
| 82 | previously compressed names, | ||||||||||||||||||||||||||||
| 83 | returns: offset to next record, | ||||||||||||||||||||||||||||
| 84 | updated array of offsets to | ||||||||||||||||||||||||||||
| 85 | previous compressed names | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 13 | ▶ | sub put { | ||||||||||||||||||||||||||
|
Subroutine
put: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 13 | my($self,$bp,$off,$name,$type,$class,$dp) = @_; | |||||||||||||||||||||||||||
| 91 | 13 | ($off, my @dnptrs)=dn_comp($bp,$off,\$name,$dp); | |||||||||||||||||||||||||||
| 92 | 13 | $off = put16($bp,$off,$type); | |||||||||||||||||||||||||||
| 93 | 13 | ▶ | if (! $class && exists $self->{class}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $class and exists $self->{"class"}
MC/DC50%1/2
not $class and exists $self->{"class"}
not $class
exists $self->{"class"}
Truth table66%2/3
not(A) and B
A= not $classB= exists $self->{"class"}
| |||||||||||||||||||||||||||||
| 94 | 1 | $class = $self->{class}; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 13 | $off = put16($bp,$off,$class); | |||||||||||||||||||||||||||
| 97 | 13 | ▶ | return $off unless wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 13 | return($off,@dnptrs); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =item * ($name,$typeTXT,$classTXT) = | ||||||||||||||||||||||||||||
| 102 | $parse->Question($name,$type,$class); | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Convert non-printable and numeric data | ||||||||||||||||||||||||||||
| 105 | into ascii text. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | input: domain name, | ||||||||||||||||||||||||||||
| 108 | question type (numeric) | ||||||||||||||||||||||||||||
| 109 | question class (numeric) | ||||||||||||||||||||||||||||
| 110 | returns: domain name, | ||||||||||||||||||||||||||||
| 111 | type TEXT, | ||||||||||||||||||||||||||||
| 112 | class TEXT | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =back | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 13 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 13 | my($self,$name,$type,$class) = @_; | |||||||||||||||||||||||||||
| 120 | 13 | return ($name.'.',TypeTxt->{$type},ClassTxt->{$class}); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head1 DEPENDENCIES | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | Net::DNS::ToolKit | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =head1 EXPORT | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | none | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | Michael Robinton <michael@bizsystems.com> | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | Copyright 2003 - 2011, Michael Robinton <michael@bizsystems.com> | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | Michael Robinton <michael@bizsystems.com> | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | All rights reserved. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 144 | it under the terms of either: | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | a) the GNU General Public License as published by the Free | ||||||||||||||||||||||||||||
| 147 | Software Foundation; either version 2, or (at your option) any | ||||||||||||||||||||||||||||
| 148 | later version, or | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | b) the "Artistic License" which comes with this distribution. | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 153 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 154 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either | ||||||||||||||||||||||||||||
| 155 | the GNU General Public License or the Artistic License for more details. | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | You should have received a copy of the Artistic License with this | ||||||||||||||||||||||||||||
| 158 | distribution, in the file named "Artistic". If not, I'll be glad to provide | ||||||||||||||||||||||||||||
| 159 | one. | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | You should also have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||
| 162 | along with this program in the file named "Copying". If not, write to the | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | Free Software Foundation, Inc. | ||||||||||||||||||||||||||||
| 165 | 59 Temple Place, Suite 330 | ||||||||||||||||||||||||||||
| 166 | Boston, MA 02111-1307, USA | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | or visit their web page on the internet at: | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | http://www.gnu.org/copyleft/gpl.html. | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =head1 See also: | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Net::DNS::ToolKit(3) | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =cut | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 14 | 1; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||