lib/NetworkInfo/Discovery/Detect.pm

filter: Statementstmt 16.6% 7 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 20.0% 2 / 10 Podpod 100% 8 / 8 totaltotal 23.2% 17 / 73 CC 7 SCAR 20.6
CC
7
Cov
13%
new
20.0
add_interface
6.0
add_gateway
6.0
CRAP 7.8
« blib/lib/NetworkInfo/Discovery/Scan.pm ↑ Summary blib/lib/NetworkInfo/Discovery.pm »
1 package NetworkInfo::Discovery::Detect;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 NetworkInfo::Discovery::Detect - Super Class for all detection modules
9  
10 =head1 SYNOPSIS
11  
12 See NetworkInfo::Discovery::(Sniff|Traceroute|Scan)
13 for examples.
14  
15 =head1 DESCRIPTION
16  
17 NetworkInfo::Discovery::Detect is set up to be the super class of all the detection modules.
18 It sets up the methods for setting and getting the discovered information about interfaces, gateways, and subnets.
19  
20  
21 =head1 METHODS
22  
23 =over 4
24  
25 =item new
26  
27 just set up lists for holding interfaces, subnets, and gateways
28  
29 =cut
30  
31 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
32 0 my $proto = shift;
33 0 my %args = @_;
34 0 my $err;
35  
36 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
37  
38 0 my $self = {};
39 0 bless ($self, $class);
40  
41 #set defaults
42 0 $self->{'interfacelist'} = [];
43 0 $self->{'gwlist'} = [];
44 0 $self->{'subnetlist'} = [];
45  
46 # for all args, see if we can autoload them
47 0 foreach my $attr (keys %args) {
48 0 ▶ if ($self->can($attr) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($attr)) { } 0 0 0
49 0 $self->$attr( $args{$attr} );
50 } else {
51 0 print "error calling $class->$attr ( $args{$attr} ) : no method $attr \n";
52 }
53 }
54  
55 0 return $self;
56 }
57  
58 =pod
59  
60 =item do_it
61  
62 this needs to be implemented in the subclass.
63 it should do what ever it does to detect interfaces, gateways, or subnets adding them to our lists by using the add_* methods below.
64  
65 =cut
66  
67 0 ▶sub do_it {
Subroutine do_it: not called CC=1 SCAR=0.0
Pod documented
68  
69 }
70  
71 =pod
72  
73 =item get_interfaces
74  
75 =item get_gateways
76  
77 =item get_subnets
78  
79 returns a list of hash references for interfaces, gateways, or subnets.
80  
81 =cut
82  
83 0 ▶sub get_interfaces {
Subroutine get_interfaces: not called CC=1 SCAR=6.9
Pod documented
84 0 my $self = shift;
85  
86 0 return @{$self->{'interfacelist'}};
87 }
88 0 ▶sub get_gateways {
Subroutine get_gateways: not called CC=1 SCAR=6.9
Pod documented
89 0 my $self = shift;
90  
91 0 return @{$self->{'gwlist'}};
92 }
93 0 ▶sub get_subnets {
Subroutine get_subnets: not called CC=1 SCAR=6.9
Pod documented
94 0 my $self = shift;
95  
96 0 return @{$self->{'subnetlist'}};
97 }
98  
99 =pod
100  
101 =item add_interface ($hashref)
102  
103 =item add_gateway ($hashref)
104  
105 =item add_subnet ($hashref)
106  
107 adds the hash ref to the list of interfaces, gateways, or subnets.
108  
109 =cut
110  
111 0 ▶sub add_interface {
Subroutine add_interface: not called CC=2 SCAR=17.9
Pod documented
112 0 my $self = shift;
113  
114 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
115 0 push (@{$self->{'interfacelist'}}, shift);
116 }
117 }
118  
119 0 ▶sub add_gateway {
Subroutine add_gateway: not called CC=2 SCAR=17.9
Pod documented
120 0 my $self = shift;
121  
122 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
123 0 push (@{$self->{'gwlist'}}, shift);
124 }
125 }
126  
127 0 ▶sub add_subnet {
Subroutine add_subnet: not called CC=2 SCAR=17.9
Pod documented
128 0 my $self = shift;
129  
130 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
131 0 push (@{$self->{'subnetlist'}}, shift);
132 }
133 }
134  
135 =back
136  
137 =head1 AUTHOR
138  
139 Tom Scanlan <tscanlan@they.gotdns.org>
140  
141 =head1 SEE ALSO
142  
143 L<NetworkInfo::Discovery::Sniff>
144  
145 L<NetworkInfo::Discovery::Traceroute>
146  
147 L<NetworkInfo::Discovery::Scan>
148  
149 =head1 BUGS
150  
151 Please send any bugs to Tom Scanlan <tscanlan@they.gotdns.org>
152  
153 =cut
154  
155 1 1;
« blib/lib/NetworkInfo/Discovery/Scan.pm ↑ Summary blib/lib/NetworkInfo/Discovery.pm »