lib/Net/NBName/NodeStatus.pm

filter: Statementstmt 82.0% 32 / 39 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 75.0% 3 / 4 totaltotal 83.6% 46 / 55 CC 4 SCAR 9.0
CC
4
Cov
84%
as_string
6.0
new
3.0
BEGIN
1.0
CRAP 2.5
« lib/Net/NBName/NodeStatus/RR.pm ↑ Summary script/namequery.pl »
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::NodeStatus;
5
6 2 ▶use Net::NBName::NodeStatus::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 2 ▶{
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
13 2 my $class = shift;
14 2 my $resp = shift;
15
16 2 my @rr = ();
17 2 my $mac_address = "";
18
19 # Don't attempt to extract any names or the mac address
20 # if the response is truncated
21 2 ▶ if (length($resp) > 56) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $resp > 56) 1 1 2
22 1 my $num_names = unpack("C", substr($resp, 56));
23 1 my $name_data = substr($resp, 57);
24
25 1 ▶ for (my $i = 0; $i < $num_names; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num_names) 10 1 11
26 10 my $rr_data = substr($name_data, 18*$i, 18);
27 10 push @rr, Net::NBName::NodeStatus::RR->new($rr_data);
28 }
29
30 1 $mac_address = join "-", map { sprintf "%02X", $_ }
31 unpack("C*", substr($name_data, 18 * $num_names, 6));
32 }
33
34 2 my $self = {'names' => \@rr, 'mac_address' => $mac_address};
35 2 bless $self, $class;
36 2 return $self;
37 }
38
39 sub as_string
40 0 ▶{
Subroutine as_string: not called CC=2 SCAR=17.9
Pod documented
41 0 my $self = shift;
42
43 0 my $string = "";
44 0 for my $rr (@{$self->{names}}) {
45 0 $string .= $rr->as_string;
46 }
47 0 $string .= "MAC Address = " . $self->{mac_address} . "\n";
48 0 return $string;
49 }
50
51 2 ▶sub names { return @{$_[0]->{'names'}}; }
Subroutine names: called CC=1 SCAR=0.0
Pod documented
52 2 ▶sub mac_address { return $_[0]->{'mac_address'}; }
Subroutine mac_address: called CC=1 SCAR=0.0
Pod documented
53
54 2 1;
55
56 __END__
« lib/Net/NBName/NodeStatus/RR.pm ↑ Summary script/namequery.pl »