Info/Layer3/Siemens.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 82 CC 12 SCAR 35.0
CC
12
Cov
0%
model
72.0
os_ver
12.0
serial
12.0
CRAP 33.0
1 # SNMP::Info::Layer3::Siemens - SNMP interface to Siemens automation devices
2 #
3 # Copyright (c) 2026 The SNMP::Info Developers
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 copyright holder nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # 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 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
29 #
30  
31 package SNMP::Info::Layer3::Siemens;
32  
33 use strict;
34 use warnings;
35 use Exporter;
36 use SNMP::Info::Layer3;
37  
38 @SNMP::Info::Layer3::Siemens::ISA = qw/SNMP::Info::Layer3 Exporter/;
39 @SNMP::Info::Layer3::Siemens::EXPORT_OK = qw//;
40  
41 our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
42  
43 $VERSION = '3.985003';
44  
45 %MIBS = (
46 %SNMP::Info::Layer3::MIBS,
47 );
48  
49 %GLOBALS = (
50 %SNMP::Info::Layer3::GLOBALS,
51 );
52  
53 %FUNCS = (
54 %SNMP::Info::Layer3::FUNCS,
55 );
56  
57 %MUNGE = (
58 %SNMP::Info::Layer3::MUNGE,
59 );
60  
61 sub vendor {
62 return 'siemens';
63 }
64  
65 sub os {
66 return 'siemens';
67 }
68  
69 sub model {
70 my $siemens = shift;
71 my $descr = $siemens->description();
72  
73 return unless defined $descr;
74  
75 if ( $descr =~ /^Siemens,?\s*SIMATIC\s+(?:S7|HMI),\s*([^,]+)/i ) {
76 return $1 if lc($1) ne 'unknown';
77 }
78 return $1 if $descr =~ /^Siemens,?\s*(SIMOCODE\s+[^,]+)/i;
79 return $1 if $descr =~ /^Siemens,?\s*SINAMICS,\s*([^,]+)/i;
80 return $1 if $descr =~ /^Siemens\s+Soft\s+starter\s+([^,]+)/i;
81 return $1 if $descr =~ /\b(6[A-Z0-9]{3}\s+\d{3}-[A-Z0-9]+-[A-Z0-9]+)\b/i;
82  
83 return;
84 }
85  
86 sub os_ver {
87 my $siemens = shift;
88 my $descr = $siemens->description();
89  
90 return unless defined $descr;
91  
92 if ( $descr =~ /\b(?:FW|SW):\s*(?:Version\s*)?V?\.?\s*(\d+(?:[.\s]\d+)*)/i ) {
93 my $version = $1;
94 $version =~ s/\s+/./g;
95 return $version;
96 }
97  
98 return;
99 }
100  
101 sub serial {
102 my $siemens = shift;
103 my $descr = $siemens->description();
104  
105 return unless defined $descr;
106  
107 return $1 if $descr =~ /,\s+(?:SN:\s*)?(S\s+C-[A-Z0-9]+)\b/i;
108  
109 return $siemens->SUPER::serial();
110 }
111  
112 1;
113 __END__