lib/Net/NBName/NameQuery.pm

filter: Statementstmt 75.6% 31 / 41 Branchbran 50.0% 8 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 80.0% 4 / 5 totaltotal 70.4% 50 / 71 CC 10 SCAR 18.6
CC
10
Cov
68%
as_string
12.0
new
8.9
ttl
2.0
CRAP 6.4
« lib/Net/NBName.pm ↑ Summary lib/Net/NBName/NodeStatus/RR.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3
4 package Net::NBName::NameQuery;
5
6 2 ▶use Net::NBName::NameQuery::RR;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 $VERSION = '0.26';
10
11 sub new
12 1 ▶{
Subroutine new: called CC=8 SCAR=21.9
Pod undocumented
13 1 my $class = shift;
14 1 my $resp = shift;
15
16 1 my @header = unpack("n6", $resp);
17
18 1 my $rcode = $header[1] & 15;
19 1 ▶ if ($rcode == 0x0) { # positive name query response
Branch: 1 branch
BranchTrueFalseTotal
if ($rcode == 0) { } 1 0 1
20 1 my $results = substr($resp, 50); # skip original query data
21 1 my ($ttl, $rdlength) = unpack("Nn", $results);
22
23 1 my @rr = ();
24 1 ▶ for (my $i = 0; $i < $rdlength / 6; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $rdlength / 6) 3 1 4
25 3 my $nb_data = substr($results, 6+6*$i, 6);
26 3 push @rr, Net::NBName::NameQuery::RR->new($nb_data);
27 }
28
29 1 ▶ my $self = {'addresses' => \@rr,
Branch: 5 branches
BranchTrueFalseTotal
$header[1] & 1024 ? : 1 0 1
$header[1] & 512 ? : 0 1 1
$header[1] & 256 ? : 1 0 1
$header[1] & 128 ? : 1 0 1
$header[1] & 16 ? : 0 1 1
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 bless $self, $class;
37 1 return $self;
38 } else {
39 # probably rcode = 0x3, a negative name query response
40 0 return undef;
41 }
42 }
43
44 sub as_string
45 0 ▶{
Subroutine as_string: not called CC=3 SCAR=24.8
Pod documented
46 0 my $self = shift;
47
48 0 my $string = "";
49 0 for my $rr (@{$self->{addresses}}) {
50 0 $string .= $rr->as_string;
51 }
52 0 $string .= "ttl = $self->{ttl} (default is 300000)\n";
53 0 ▶ $string .= "RA set, this was an NBNS server\n" if $self->{'RA'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RA"} 0 0 0
54 0 return $string;
55 }
56
57 1 ▶sub addresses { return @{$_[0]->{'addresses'}}; }
Subroutine addresses: called CC=1 SCAR=0.0
Pod documented
58 0 ▶sub ttl { return $_[0]->{'ttl'}; }
Subroutine ttl: not called CC=1 SCAR=6.9
Pod documented
59 1 ▶sub RA { return $_[0]->{'RA'}; }
Subroutine RA: called CC=1 SCAR=0.0
Pod documented
60
61 2 1;
62
63 __END__
« lib/Net/NBName.pm ↑ Summary lib/Net/NBName/NodeStatus/RR.pm »