Info/Layer7/CiscoIPS.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 101 CC 7 SCAR 16.3
CC
7
Cov
0%
b_mac
12.0
_fetch_info
6.0
serial
6.0
CRAP 5.1
1 # SNMP::Info::Layer7::CiscoIPS
2 #
3 # Copyright (c) 2013 Moe Kraus
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # * Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # * Neither the name of the University of California, Santa Cruz nor the
15 # names of its contributors may be used to endorse or promote products
16 # derived from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 # LIABLE FOR
23 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30  
31 package SNMP::Info::Layer7::CiscoIPS;
32  
33 use strict;
34 use warnings;
35 use Exporter;
36 use SNMP::Info::CiscoStats;
37 use SNMP::Info::Layer7;
38 use SNMP::Info::Entity;
39  
40 @SNMP::Info::Layer7::CiscoIPS::ISA = qw/
41 SNMP::Info::CiscoStats
42 SNMP::Info::Layer7
43 Exporter/;
44 @SNMP::Info::Layer7::CiscoIPS::EXPORT_OK = qw//;
45  
46 our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
47  
48 $VERSION = '3.985003';
49  
50 %MIBS = ( %SNMP::Info::Layer7::MIBS, %SNMP::Info::Entity::MIBS, );
51  
52 %GLOBALS
53 = ( %SNMP::Info::Layer7::GLOBALS, %SNMP::Info::Entity::GLOBALS, );
54  
55 %FUNCS = (
56 %SNMP::Info::Layer7::FUNCS,
57 %SNMP::Info::Entity::FUNCS,
58 );
59  
60 %MUNGE = (
61 %SNMP::Info::Layer7::MUNGE,
62 %SNMP::Info::Entity::MUNGE,
63 );
64  
65 my ($serial, $descr, $model);
66  
67 sub _fetch_info {
68 my $self = shift;
69 foreach my $id ( keys %{ $self->e_id() } ){
70  
71 if (
72 $self->e_name->{$id} =~ m/^Module$/ and
73 $self->e_model->{$id} =~ m/IPS/
74 ) {
75 $serial = $self->e_serial->{$id};
76 $descr = $self->e_descr->{$id};
77 $model = $self->e_model->{$id};
78 }
79  
80 }
81  
82 }
83  
84 sub layers {
85 return '01001000';
86 }
87  
88 sub serial {
89 my $self = shift;
90 _fetch_info($self) unless defined $serial;
91 return $serial;
92 }
93  
94 sub sysdescr {
95 my $self = shift;
96 _fetch_info($self) unless defined $descr;
97 return $descr;
98 }
99  
100 sub model {
101 my $self = shift;
102 _fetch_info($self) unless defined $descr;
103 $descr =~ s/ Security Services Processor//g;
104 $descr =~ s/ /-/g;
105 return $descr;
106 }
107  
108 sub productname {
109 my $self = shift;
110 return $self->model;
111 }
112  
113 sub b_mac {
114 my ( $self ) = shift;
115  
116 foreach my $mac ( values %{$self->i_mac()} ){
117  
118 next unless defined $mac;
119 next unless $mac =~ m/^e4:d3:f1/;
120 return $mac;
121 }
122  
123 return '';
124 }
125  
126 sub e_index {
127 my $self = shift();
128 my %index;
129 foreach my $id ( keys %{$self->e_id} ){
130 $index{$id} = $id;
131 }
132 return \%index;
133 }
134  
135 1;
136 __END__