From f96d0df182ebbbffec6b5413a214102500df76ee Mon Sep 17 00:00:00 2001 From: Andrey Pazychev Date: Fri, 8 May 2020 20:47:41 +0300 Subject: [PATCH] Qtech and Carelink support --- lib/SNMP/Info.pm | 3 + lib/SNMP/Info/Layer2/Carelink.pm | 133 ++++++++++++++++++++++++ lib/SNMP/Info/Layer3/Qtech.pm | 172 +++++++++++++++++++++++++++++++ 3 files changed, 308 insertions(+) create mode 100755 lib/SNMP/Info/Layer2/Carelink.pm create mode 100644 lib/SNMP/Info/Layer3/Qtech.pm diff --git a/lib/SNMP/Info.pm b/lib/SNMP/Info.pm index 1e55c886..6f799aeb 100644 --- a/lib/SNMP/Info.pm +++ b/lib/SNMP/Info.pm @@ -1717,6 +1717,7 @@ sub device_type { 25506 => 'SNMP::Info::Layer3::H3C', 26543 => 'SNMP::Info::Layer3::IBMGbTor', 26928 => 'SNMP::Info::Layer2::Aerohive', + 27514 => 'SNMP::Info::Layer3::Qtech', 30065 => 'SNMP::Info::Layer3::Arista', 30803 => 'SNMP::Info::Layer3::VyOS', 35098 => 'SNMP::Info::Layer3::Pica8', @@ -1733,6 +1734,7 @@ sub device_type { 171 => 'SNMP::Info::Layer3::DLink', 207 => 'SNMP::Info::Layer2::Allied', 266 => 'SNMP::Info::Layer2::Nexans', + 655 => 'SNMP::Info::Layer2::Carelink', 664 => 'SNMP::Info::Layer2::Adtran', 674 => 'SNMP::Info::Layer3::Dell', 1872 => 'SNMP::Info::Layer3::AlteonAD', @@ -1760,6 +1762,7 @@ sub device_type { 21091 => 'SNMP::Info::Layer2::Exinda', 26543 => 'SNMP::Info::Layer3::IBMGbTor', 26928 => 'SNMP::Info::Layer2::Aerohive', + 27514 => 'SNMP::Info::Layer3::Qtech', ); my %l1sysoidmap = ( diff --git a/lib/SNMP/Info/Layer2/Carelink.pm b/lib/SNMP/Info/Layer2/Carelink.pm new file mode 100755 index 00000000..a2f6b7d2 --- /dev/null +++ b/lib/SNMP/Info/Layer2/Carelink.pm @@ -0,0 +1,133 @@ +# SNMP::Info::Layer2::Carelink - SNMP Interface to Carelink Devices +# +# Copyright (c) 2020 by 135. + +package SNMP::Info::Layer2::Carelink; + +use strict; +use warnings; +use Exporter; +use SNMP::Info::Layer2; +use SNMP::Info::Layer3; + +@SNMP::Info::Layer2::Carelink::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Carelink::EXPORT_OK = qw//; + +our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); + +$VERSION = '3.70-135'; + +# This will be filled in with the device's index into the EntPhysicalEntry +# table by the serial() function. +our $index = undef; + +%MIBS = ( + %SNMP::Info::Layer2::MIBS, +); + +%GLOBALS = ( + %SNMP::Info::Layer2::GLOBALS, + 'serial_oid' => '.1.3.6.1.2.1.47.1.1.1.1.11.1', + 'os_ver_oid' => '.1.3.6.1.2.1.47.1.1.1.1.9.1', + 'hw_oid' => '.1.3.6.1.2.1.47.1.1.1.1.2.1', + 'fw_mac_oid' => '.1.3.6.1.2.1.47.1.1.1.1.11.1', +); + +%FUNCS = ( %SNMP::Info::Layer2::FUNCS, ); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, ); + +sub vendor { + return 'carelink'; +} +sub os { + return 'caos'; +} + +sub os_ver { + my $carelink = shift; + my $ver = $carelink->os_ver_oid() || undef; + return $ver if (defined $ver); + return 'Unknown'; +} +sub model { + my $carelink = shift; + my $id = $carelink->id(); + my $mod = $carelink->hw_oid() || undef; + return $mod if (defined $mod); + return 'Unknown'; +} + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer2::Carelink - SNMP Interface to Carelink Devices + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $carelink = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $carelink->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +Subclass for carelink Devices running IOS-like software + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer2 + +=item SNMP::Info::Layer3 + +=back + +=head2 Inherited Classes' MIBs + +See L for its own MIB requirements. + +See L for its own MIB requirements. + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $carelink->vendor() + +Returns 'adtran' + +=item $carelink->os() + +Returns 'caos' + +=item $carelink->layers() + +Ensures that layer two is reported, at least. + +=item $carelink->os_ver() + +Returns the software version. + +=item $carelink->model() + +Returns the model extracted. + +=item $carelink->serial() + +Returns serial number. + +=cut diff --git a/lib/SNMP/Info/Layer3/Qtech.pm b/lib/SNMP/Info/Layer3/Qtech.pm new file mode 100644 index 00000000..47f7f278 --- /dev/null +++ b/lib/SNMP/Info/Layer3/Qtech.pm @@ -0,0 +1,172 @@ +# SNMP::Info::Layer3::Qtech - SNMP Interface to Qtech Devices +# +# Copyright (c) 2020 by The 135. + + +package SNMP::Info::Layer3::Qtech; + +use strict; +use warnings; +use Exporter; +use SNMP::Info::Layer2; +use SNMP::Info::Layer3; + +@SNMP::Info::Layer3::Qtech::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Qtech::EXPORT_OK = qw//; + +our ($VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE); + +$VERSION = '3.70-135'; + +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + %SNMP::Info::Layer3::MIBS, +); + +%GLOBALS = ( + %SNMP::Info::Layer2::GLOBALS, + %SNMP::Info::Layer3::GLOBALS, + 'hostname' => '.1.3.6.1.2.1.47.1.1.1.1.7.1', + 'model_oid' => '.1.3.6.1.2.1.47.1.1.1.1.13.1', + 'hw_oid' => '.1.3.6.1.2.1.47.1.1.1.1.8.1', + 'serial_oid' => '.1.3.6.1.2.1.47.1.1.1.1.11.1', + 'bootrom_oid' => '.1.3.6.1.2.1.47.1.1.1.1.9.1', + 'os_ver_oid' => '.1.3.6.1.2.1.47.1.1.1.1.10.1', +); + +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::Layer3::FUNCS, +); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer3::MUNGE, ); + +sub model { + my $qtech = shift; + my $model = $qtech->model_oid; + my $hw = $qtech->hw_oid; + return $model . ' HW:(' . $hw . ')'; +} + +# ifDescr is the same for all interfaces in a class, but the ifName is +# unique, so let's use that for port name. +sub interfaces { + my $qtech = shift; + my $partial = shift; + + my $interfaces = $qtech->orig_i_name($partial); + return $interfaces; +} + +sub vendor { + return 'qtech'; +} + +sub os { + return 'qsw'; +} + +sub os_ver { + my $qtech = shift; + my $os_ver = $qtech->os_ver_oid(); + return $os_ver . ' Bootrom: ' . $qtech->bootrom_oid; +} + +sub serial { + my $qtech = shift; + my $serial = $qtech->serial_oid(); + return $serial; +} + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer3::Qtech - SNMP Interface to Qtech Devices + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $qtech = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $qtech->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +Subclass for Qtech 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 $qtech->model() + +Returns the ID or else description. + +=item $qtech->vendor() + +Returns 'dlink'. + +=item $qtech->serial() + +Returns serial number. + +=item $qtech->fwver() + +Returns the firmware version. + +=item $qtech->hwver() + +Returns the hardware version. + +=item $qtech->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 $qtech->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