line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: Question.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::Frame::Layer::DNS::Question; |
5
|
9
|
|
|
9
|
|
8362
|
use strict; use warnings; |
|
9
|
|
|
9
|
|
18
|
|
|
9
|
|
|
|
|
206
|
|
|
9
|
|
|
|
|
41
|
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
229
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
401
|
use Net::Frame::Layer qw(:consts :subs); |
|
9
|
|
|
|
|
50176
|
|
|
9
|
|
|
|
|
1323
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Net::Frame::Layer Exporter); |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
406
|
use Net::Frame::Layer::DNS::Constants qw(:consts); |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
3560
|
|
11
|
|
|
|
|
|
|
my @consts; |
12
|
|
|
|
|
|
|
for my $c (sort(keys(%constant::declared))) { |
13
|
|
|
|
|
|
|
if ($c =~ /^Net::Frame::Layer::DNS::Constants::/) { |
14
|
|
|
|
|
|
|
$c =~ s/^Net::Frame::Layer::DNS::Constants:://; |
15
|
|
|
|
|
|
|
push @consts, $c |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
19
|
|
|
|
|
|
|
consts => [@consts] |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
22
|
|
|
|
|
|
|
@{$EXPORT_TAGS{consts}}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @AS = qw( |
26
|
|
|
|
|
|
|
name |
27
|
|
|
|
|
|
|
type |
28
|
|
|
|
|
|
|
class |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
31
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
9
|
|
377
|
use Net::Frame::Layer::DNS qw(:subs); |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
3360
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
|
|
|
|
|
|
shift->SUPER::new( |
37
|
4
|
|
|
4
|
1
|
968
|
name => '', |
38
|
|
|
|
|
|
|
type => NF_DNS_TYPE_A, |
39
|
|
|
|
|
|
|
class => NF_DNS_CLASS_IN, |
40
|
|
|
|
|
|
|
@_, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub getLength { |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# 1 byte leading length, name, 1 byte trailing null, 2 bytes type, 2 bytes class |
48
|
0
|
0
|
|
|
|
0
|
if (length($self->name) == 0) { |
49
|
0
|
|
|
|
|
0
|
return length($self->name) + 5 |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
|
|
|
|
0
|
return length($self->name) + 6 |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub pack { |
56
|
1
|
|
|
1
|
1
|
275
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
4
|
my $name = dnsAton($self->name); |
59
|
|
|
|
|
|
|
|
60
|
1
|
50
|
|
|
|
4
|
$self->raw($self->SUPER::pack('H* nn', |
61
|
|
|
|
|
|
|
$name, $self->type, $self->class, |
62
|
|
|
|
|
|
|
)) or return; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
50
|
return $self->raw; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub unpack { |
68
|
1
|
|
|
1
|
1
|
44
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
5
|
my @parts = split /\0/, $self->raw, 2; |
71
|
1
|
|
|
|
|
14
|
my ($name) = dnsNtoa($parts[0]); |
72
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
7
|
my ($type, $class, $payload) = |
74
|
|
|
|
|
|
|
$self->SUPER::unpack('nn a*', $parts[1]) |
75
|
|
|
|
|
|
|
or return; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
25
|
$self->name($name); |
78
|
1
|
|
|
|
|
12
|
$self->type($type); |
79
|
1
|
|
|
|
|
11
|
$self->class($class); |
80
|
1
|
|
|
|
|
11
|
$self->payload($payload); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
10
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub encapsulate { |
86
|
1
|
|
|
1
|
1
|
6
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
1
|
50
|
|
|
|
6
|
return $self->nextLayer if $self->nextLayer; |
89
|
|
|
|
|
|
|
|
90
|
1
|
50
|
|
|
|
13
|
if ($self->payload) { |
91
|
0
|
|
|
|
|
0
|
return 'DNS::RR'; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
14
|
NF_LAYER_NONE; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub print { |
98
|
1
|
|
|
1
|
1
|
4
|
my $self = shift; |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
4
|
my $l = $self->layer; |
101
|
1
|
|
|
|
|
14
|
my $buf = sprintf |
102
|
|
|
|
|
|
|
"$l: name:%s\n". |
103
|
|
|
|
|
|
|
"$l: type:%d class:%d", |
104
|
|
|
|
|
|
|
$self->name, |
105
|
|
|
|
|
|
|
$self->type, $self->class; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
49
|
return $buf; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |