Info/Layer2/Hirschmann.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 92 CC 6 SCAR 16.8
CC
6
Cov
0%
os_ver
12.0
serial
6.0
model
6.0
CRAP 5.4
1 # SNMP::Info::Layer2::Hirschmann - SNMP Interface to Hirschmann Devices
2 #
3 # Copyright (c) 2019 by The Netdisco Developer Team.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of the University of California, Santa Cruz nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28  
29 package SNMP::Info::Layer2::Hirschmann;
30  
31 use strict;
32 use warnings;
33 use Exporter;
34 use SNMP::Info::Layer2;
35 use SNMP::Info::CDP;
36  
37 @SNMP::Info::Layer2::Hirschmann::ISA = qw/SNMP::Info::Layer2 Exporter/;
38 @SNMP::Info::Layer2::Hirschmann::EXPORT_OK = qw//;
39  
40 our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE, $AUTOLOAD);
41  
42 $VERSION = '3.985003';
43  
44 %MIBS = (
45 %SNMP::Info::Layer2::MIBS,
46 'HMPRIV-MGMT-SNMP-MIB' => 'hirschmann',
47 );
48  
49 %GLOBALS = (
50 %SNMP::Info::Layer2::GLOBALS,
51 'h_serial_number' => 'hmSysGroupTable.hmSysGroupEntry.hmSysGroupSerialNum.1',
52 'os_version' => 'hmSysVersion.0',
53 );
54  
55 %FUNCS = (
56 %SNMP::Info::Layer2::FUNCS,
57 );
58  
59 %MUNGE = (
60 %SNMP::Info::Layer2::MUNGE,
61 );
62  
63 sub os {
64 return 'hirschmann';
65 }
66  
67 sub serial {
68 my $hirschmann = shift;
69 my $model = $hirschmann->model();
70 my $id = $hirschmann->id();
71 my $serial;
72  
73 return $hirschmann->h_serial_number() if ( $hirschmann->h_serial_number() );
74  
75 }
76  
77 sub os_ver {
78 my $hirschmann = shift;
79 my $model = $hirschmann->model();
80 my $id = $hirschmann->id();
81  
82 my $os_version = $hirschmann->os_version();
83 if ( $os_version =~ m/(SW:\sL2.-\d{1,2}\.\d\.\d{2})/ ) {
84 return $1;
85 }
86  
87 return $id unless defined $os_version;
88  
89 return $os_version;
90 }
91  
92 sub vendor {
93 return 'hirschmann';
94 }
95  
96 sub model {
97 my $hmodel = shift;
98 my $id = $hmodel->id();
99  
100 my $model = &SNMP::translateObj($id) || $id;
101  
102 # model return by snmp is rs30 also if its a rs40
103 if (defined $model && $model !~ /rs30/) {
104 return uc $model;
105 } else {
106 return 'RS40-30';
107 }
108  
109 return;
110 }
111  
112 sub mac {
113 my $hirschmann = shift;
114 my $i_descr = $hirschmann->i_description();
115 my $i_mac = $hirschmann->i_mac();
116  
117 # Return Interface MAC addresse of the switch (on the CPU pseudo interface)
118 foreach my $entry ( sort keys %$i_descr ) {
119 my $descr = $i_descr->{$entry};
120 if ($descr =~ m/(^CPU.)/) {
121 my $sn = $i_mac->{$entry};
122 # next unless $sn;
123 return $sn;
124 }
125 }
126 return;
127 }
128  
129 1;
130 __END__