From 8317923f28456cdd120fd7c4c2e3cb374f4feadb Mon Sep 17 00:00:00 2001 From: Andrey Pazychev Date: Sat, 9 May 2020 05:04:39 +0300 Subject: [PATCH] Eltex support. Added one Lucend OID --- lib/SNMP/Info.pm | 2 + lib/SNMP/Info/Layer3/Eltex.pm | 194 ++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 lib/SNMP/Info/Layer3/Eltex.pm diff --git a/lib/SNMP/Info.pm b/lib/SNMP/Info.pm index 6f799aeb..a8ce93da 100644 --- a/lib/SNMP/Info.pm +++ b/lib/SNMP/Info.pm @@ -1672,6 +1672,7 @@ sub device_type { 171 => 'SNMP::Info::Layer3::DLink', 244 => 'SNMP::Info::Layer3::Lantronix', 311 => 'SNMP::Info::Layer3::Microsoft', + 637 => 'SNMP::Info::Layer3::AlcatelLucent', 664 => 'SNMP::Info::Layer2::Adtran', 674 => 'SNMP::Info::Layer3::Dell', 1588 => 'SNMP::Info::Layer3::Foundry', @@ -1721,6 +1722,7 @@ sub device_type { 30065 => 'SNMP::Info::Layer3::Arista', 30803 => 'SNMP::Info::Layer3::VyOS', 35098 => 'SNMP::Info::Layer3::Pica8', + 35265 => 'SNMP::Info::Layer3::Eltex', 40310 => 'SNMP::Info::Layer3::Cumulus', 41112 => 'SNMP::Info::Layer2::Ubiquiti', 44641 => 'SNMP::Info::Layer3::VyOS', diff --git a/lib/SNMP/Info/Layer3/Eltex.pm b/lib/SNMP/Info/Layer3/Eltex.pm new file mode 100644 index 00000000..cdc490d7 --- /dev/null +++ b/lib/SNMP/Info/Layer3/Eltex.pm @@ -0,0 +1,194 @@ +# SNMP::Info::Layer3::Eltex - SNMP Interface to Eltex Devices +# +# Copyright (c) 2020 by The 135. + + +package SNMP::Info::Layer3::Eltex; + +use strict; +use warnings; +use Exporter; +#use SNMP::Info::Layer2; +use SNMP::Info::Layer3; + +@SNMP::Info::Layer3::Eltex::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Eltex::EXPORT_OK = qw//; + +our ( $VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE ); + +$VERSION = '3.70-135'; + +%MIBS = ( %SNMP::Info::Layer3::MIBS, ); + +%GLOBALS = ( + #%SNMP::Info::Layer2::GLOBALS, + %SNMP::Info::Layer3::GLOBALS, + 'model_oid' => 'mib-2.47.1.1.1.1.13.67108992', + 'hw_oid' => 'mib-2.47.1.1.1.1.8.67108992', + 'serial_oid' => 'mib-2.47.1.1.1.1.11.67108992', + 'os_ver_oid' => 'mib-2.47.1.1.1.1.10.67108992', + 'bootrom_oid' => 'mib-2.47.1.1.1.1.9.67108992', + #'model_oid_140' => '', + 'hw_oid_140' => 'mib-2.47.1.1.1.1.8.1', + #'serial_oid_140' => '', + 'os_ver_oid_140' => 'mib-2.47.1.1.1.1.9.1', + #'bootrom_oid_140' => '', + +); + +%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); + +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); + +sub model { + my $eltex = shift; + my $model; my $hw; + my $id = $eltex->id(); + if ($id =~ /35265\.(140|158)$/) { + return; + } + # default behaviour for 35265.1.120 + elsif ($id =~ /35265\.1\.(24|43|30|120|5[2,4]|74|8[1,9])$/) { + $model = $eltex->model_oid; + $hw = $eltex->hw_oid; + } + else { + return 'unknown'; + } + return $model . ' HW:' . $hw; +} + +sub vendor { + return 'eltex'; +} + +sub os { + return 'eltex'; +} + +sub os_ver { + my $eltex = shift; + my $os_ver; my $bootrom; + my $id = $eltex->id(); + if ($id =~ /35265\.(140|158)$/) { + $os_ver = $eltex->os_ver_oid_140; + return $os_ver; + } + elsif ($id =~ /35265\.1\.(24|43|30|120|5[2,4]|74|8[1,9])$/) { + $os_ver = $eltex->os_ver_oid; + $bootrom = $eltex->bootrom_oid; + } + else { + return 'unknown'; + } + return $os_ver . ' bootrom: ' . $bootrom; +} + +sub serial { + my $eltex = shift; + my $serial; + my $id = $eltex->id(); + if ($id =~ /35265\.(140|158)$/) { + return; + } + elsif ($id =~ /35265\.1\.(24|43|30|120|5[2,4]|74|8[1,9]])$/) { + $serial = $eltex->serial_oid; + } + else { + return 'unknown'; + } + return $serial; +} + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer3::Eltex - SNMP Interface to Eltex Devices + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $eltex = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $eltex->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +Subclass for Eltex devices. + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer3 + +=back + +=head2 Inherited Classes' MIBs + +See L for its own MIB requirements. + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $eltex->model() + +Returns the ID or else description. + +=item $eltex->vendor() + +Returns 'eltex'. + +=item $eltex->serial() + +Returns serial number. + +=item $eltex->fwver() + +Returns the firmware version. + +=item $eltex->hwver() + +Returns the hardware version. + +=item $eltex->stp_i_root_port() + +Returns the STP root port. + +=back + +=head2 Globals imported from SNMP::Info::Layer3 + +See documentation in L for details. + +=head1 TABLE METHODS + +These are methods that return tables of information in the form of a reference +to a hash. + +=over + +=item $eltex->interfaces(); + +Returns the map between SNMP Interface Identifier (iid) and C. + +=back + +=head2 Table Methods imported from SNMP::Info::Layer3 + +See documentation in L for details. + +=cut