Info/Layer7.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 68 CC 4 SCAR 17.6
CC
4
Cov
0%
vendor
12.0
interfaces
6.0
model
2.0
CRAP 5.8
1 # SNMP::Info::Layer7 - SNMP Interface to Layer7 Devices
2 #
3 # Copyright (c) 2011 Jeroen van Ingen
4 #
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 #
10 # * Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # * Neither the name of the University of California, Santa Cruz nor the
16 # names of its contributors may be used to endorse or promote products
17 # derived from this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 # LIABLE FOR # 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;
32  
33 use strict;
34 use warnings;
35 use Exporter;
36 use SNMP::Info;
37  
38 @SNMP::Info::Layer7::ISA = qw/SNMP::Info Exporter/;
39 @SNMP::Info::Layer7::EXPORT_OK = qw//;
40  
41 our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
42  
43 $VERSION = '3.985003';
44  
45 %MIBS = (
46 %SNMP::Info::MIBS,
47 );
48  
49 %GLOBALS = (
50 %SNMP::Info::GLOBALS,
51 );
52  
53 %FUNCS = (
54 %SNMP::Info::FUNCS,
55 );
56  
57 %MUNGE = (
58 # Inherit all the built in munging
59 %SNMP::Info::MUNGE,
60 );
61  
62  
63 # $l7->model() - Looks at sysObjectID which gives the oid of the system
64 # name, contained in a proprietary MIB.
65 sub model {
66 my $l7 = shift;
67 my $id = $l7->id();
68 my $model = &SNMP::translateObj($id);
69  
70 return $model;
71 }
72  
73 sub vendor {
74 my $l7 = shift;
75 my $id = $l7->id();
76 my $vendor = 'unknown';
77 if ( defined($id) && $id =~ /^(\.1\.3\.6\.1\.4\.1\.\d+)/ ) {
78 my $enterprise = &SNMP::translateObj($1);
79 $vendor = $enterprise if defined $enterprise;
80 }
81 return $vendor;
82 }
83  
84 # By Default we'll use the description field
85 sub interfaces {
86 my $l7 = shift;
87 my $partial = shift;
88  
89 my $interfaces = $l7->i_index($partial) || {};
90 my $i_descr = $l7->i_description($partial) || {};
91  
92 # Replace the Index with the ifDescr field.
93 foreach my $iid ( keys %$i_descr ) {
94 my $port = $i_descr->{$iid};
95 next unless defined $port;
96 $interfaces->{$iid} = $port;
97 }
98 return $interfaces;
99 }
100  
101 1;
102 __END__