line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
854
|
use strict;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
83
|
|
2
|
2
|
|
|
2
|
|
11
|
use warnings;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
85
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Net::NBName::NameQuery;
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1520
|
use Net::NBName::NameQuery::RR;
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1557
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
14
|
use vars '$VERSION';
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
984
|
|
9
|
|
|
|
|
|
|
$VERSION = '0.26';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new
|
12
|
|
|
|
|
|
|
{
|
13
|
1
|
|
|
1
|
0
|
3
|
my $class = shift;
|
14
|
1
|
|
|
|
|
2
|
my $resp = shift;
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
4
|
my @header = unpack("n6", $resp);
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
3
|
my $rcode = $header[1] & 15;
|
19
|
1
|
50
|
|
|
|
4
|
if ($rcode == 0x0) { # positive name query response
|
20
|
1
|
|
|
|
|
4
|
my $results = substr($resp, 50); # skip original query data
|
21
|
1
|
|
|
|
|
4
|
my ($ttl, $rdlength) = unpack("Nn", $results);
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
my @rr = ();
|
24
|
1
|
|
|
|
|
6
|
for (my $i = 0; $i < $rdlength / 6; $i++) {
|
25
|
3
|
|
|
|
|
11
|
my $nb_data = substr($results, 6+6*$i, 6);
|
26
|
3
|
|
|
|
|
17
|
push @rr, Net::NBName::NameQuery::RR->new($nb_data);
|
27
|
|
|
|
|
|
|
}
|
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
21
|
my $self = {'addresses' => \@rr,
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
30
|
|
|
|
|
|
|
'ttl' => $ttl,
|
31
|
|
|
|
|
|
|
'AA' => ($header[1] & 0x0400) ? 1 : 0,
|
32
|
|
|
|
|
|
|
'TC' => ($header[1] & 0x0200) ? 1 : 0,
|
33
|
|
|
|
|
|
|
'RD' => ($header[1] & 0x0100) ? 1 : 0,
|
34
|
|
|
|
|
|
|
'RA' => ($header[1] & 0x0080) ? 1 : 0,
|
35
|
|
|
|
|
|
|
'B' => ($header[1] & 0x0010) ? 1 : 0};
|
36
|
1
|
|
|
|
|
4
|
bless $self, $class;
|
37
|
1
|
|
|
|
|
5
|
return $self;
|
38
|
|
|
|
|
|
|
} else {
|
39
|
|
|
|
|
|
|
# probably rcode = 0x3, a negative name query response
|
40
|
0
|
|
|
|
|
0
|
return undef;
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub as_string
|
45
|
|
|
|
|
|
|
{
|
46
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $string = "";
|
49
|
0
|
|
|
|
|
0
|
for my $rr (@{$self->{addresses}}) {
|
|
0
|
|
|
|
|
0
|
|
50
|
0
|
|
|
|
|
0
|
$string .= $rr->as_string;
|
51
|
|
|
|
|
|
|
}
|
52
|
0
|
|
|
|
|
0
|
$string .= "ttl = $self->{ttl} (default is 300000)\n";
|
53
|
0
|
0
|
|
|
|
0
|
$string .= "RA set, this was an NBNS server\n" if $self->{'RA'};
|
54
|
0
|
|
|
|
|
0
|
return $string;
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
1
|
1
|
47
|
sub addresses { return @{$_[0]->{'addresses'}}; }
|
|
1
|
|
|
|
|
5
|
|
58
|
0
|
|
|
0
|
1
|
0
|
sub ttl { return $_[0]->{'ttl'}; }
|
59
|
1
|
|
|
1
|
1
|
7
|
sub RA { return $_[0]->{'RA'}; }
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1;
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__
|