diff --git a/lib/SNMP/Info.pm b/lib/SNMP/Info.pm index 8709ca50..f5df303e 100644 --- a/lib/SNMP/Info.pm +++ b/lib/SNMP/Info.pm @@ -25,7 +25,7 @@ our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE, $AUTOLOAD, $INIT, $DEBUG, %SPEED_MAP, $NOSUCH, $BIGINT, $REPEATERS); -$VERSION = '3.70-135.20.5.1'; +$VERSION = '3.70-135.20.5.2'; =head1 NAME @@ -1350,7 +1350,7 @@ sub new { delete $sess_args{Offline}; } - if ( defined $args{Cache} and ref {} eq ref $args{Cache} ) { + if ( defined $args{Cache} and ref({}) eq ref $args{Cache} ) { $new_obj->{$_} = $args{Cache}->{$_} for keys %{$args{Cache}}; delete $sess_args{Cache}; } @@ -1571,7 +1571,7 @@ sub cache { my $self = shift; my $data = shift; - if ( defined $data and ref {} eq ref $data ) { + if ( defined $data and ref({}) eq ref $data ) { $self->{$_} = $data->{$_} for keys %$data; } @@ -1676,6 +1676,7 @@ sub device_type { 655 => 'SNMP::Info::Layer2::Carelink', 664 => 'SNMP::Info::Layer2::Adtran', 674 => 'SNMP::Info::Layer3::Dell', + 776 => 'SNMP::Info::Layer2::Telindus', 890 => 'SNMP::Info::Layer2::Zyxel', 1588 => 'SNMP::Info::Layer3::Foundry', 1872 => 'SNMP::Info::Layer3::AlteonAD', @@ -1743,6 +1744,7 @@ sub device_type { 655 => 'SNMP::Info::Layer2::Carelink', 664 => 'SNMP::Info::Layer2::Adtran', 674 => 'SNMP::Info::Layer3::Dell', + 776 => 'SNMP::Info::Layer2::Telindus', 890 => 'SNMP::Info::Layer2::Zyxel', 1872 => 'SNMP::Info::Layer3::AlteonAD', 1890 => 'SNMP::Info::Layer3::Redlion', @@ -2883,7 +2885,7 @@ sub ip_index { my $o_ip_idx = $self->old_ip_index(); return $o_ip_idx - if ( ref {} eq ref $o_ip_idx and scalar keys %$o_ip_idx ); + if ( ref({}) eq ref $o_ip_idx and scalar keys %$o_ip_idx ); # Since callers may be using the old iid to get the IP, strip protocol # and length from the index @@ -2909,7 +2911,7 @@ sub ip_table { my $o_ip_table = $self->old_ip_table(); return $o_ip_table - if ( ref {} eq ref $o_ip_table and scalar keys %$o_ip_table ); + if ( ref({}) eq ref $o_ip_table and scalar keys %$o_ip_table ); my $n_ip_idx = $self->new_ip_index() || {}; my $n_ip_type = $self->new_ip_type() || {}; @@ -2933,7 +2935,7 @@ sub ip_netmask { my $o_ip_mask = $self->old_ip_netmask(); return $o_ip_mask - if ( ref {} eq ref $o_ip_mask and scalar keys %$o_ip_mask ); + if ( ref({}) eq ref $o_ip_mask and scalar keys %$o_ip_mask ); my $n_ip_pfx = $self->new_ip_prefix() || {}; my $n_ip_type = $self->new_ip_type() || {}; @@ -4814,7 +4816,7 @@ sub _cache { my ($attr, $data) = @_; my $store = $self->store(); - if (ref {} eq ref $data) { + if (ref({}) eq ref $data) { $self->{"_${attr}"}++; $store->{$attr} = $data; } @@ -4842,7 +4844,7 @@ sub _munge { return $data unless defined $munge->{$attr}; - if (ref {} eq ref $data) { + if (ref({}) eq ref $data) { my $subref = $munge->{$attr}; my %munged; foreach my $key ( keys %$data ) { diff --git a/lib/SNMP/Info/Layer2/Telindus.pm b/lib/SNMP/Info/Layer2/Telindus.pm new file mode 100755 index 00000000..5d8805ae --- /dev/null +++ b/lib/SNMP/Info/Layer2/Telindus.pm @@ -0,0 +1,119 @@ +# SNMP::Info::Layer2::Telindus - SNMP Interface to Telindus Devices +# +# Copyright (c) 2020 by 135. + +package SNMP::Info::Layer2::Telindus; + +use strict; +use warnings; +use Exporter; +use SNMP::Info::Layer2; + +@SNMP::Info::Layer2::Telindus::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Telindus::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, +); + +%FUNCS = ( %SNMP::Info::Layer2::FUNCS, ); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, ); + +sub vendor { + return 'telindus'; +} + +sub os { + return 'telind-os'; +} + +sub os_ver { + my $obj = shift; + $obj->description =~ /\$Telindus\s(\d+)(\$\s(.*)|\s(.*)\$)\s(T\d+\/\d+)/; + return $5; +} +sub model { + my $obj = shift; + $obj->description =~ /\$Telindus\s(\d+)(\$\s(.*)|\s(.*)\$)\s(T\d+\/\d+)/; + if (defined $3) { + return $1 . ' ' . $3; + } + else { + return $1 . ' ' . $4; + } +} + +1; +__END__ + +=head1 NAME + +SNMP::Info::Layer2::Telindus - SNMP Interface to Telindus Devices + +=head1 SYNOPSIS + + # Let SNMP::Info determine the correct subclass for you. + my $obj = new SNMP::Info( + AutoSpecify => 1, + Debug => 1, + DestHost => 'myrouter', + Community => 'public', + Version => 2 + ) + or die "Can't connect to DestHost.\n"; + + my $class = $obj->class(); + print "SNMP::Info determined this device to fall under subclass : $class\n"; + +=head1 DESCRIPTION + +Subclass for Telindus Devices + +=head2 Inherited Classes + +=over + +=item SNMP::Info::Layer2 + +=back + +=head1 GLOBALS + +These are methods that return scalar value from SNMP + +=over + +=item $obj->vendor() + +Returns 'zyxel' + +=item $obj->os() + +Returns 'zynos' + +=item $obj->layers() + +Ensures that layer two is reported, at least. + +=item $obj->os_ver() + +Returns the software version. + +=item $obj->model + +Returns the model extracted. + +=cut + +=back \ No newline at end of file diff --git a/lib/SNMP/Info/Layer2/Zyxel.pm b/lib/SNMP/Info/Layer2/Zyxel.pm index 4205c883..20bdaf0d 100755 --- a/lib/SNMP/Info/Layer2/Zyxel.pm +++ b/lib/SNMP/Info/Layer2/Zyxel.pm @@ -24,6 +24,7 @@ $VERSION = '3.70-135'; %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, + 'serial_oid' => 'transmission.94.1.1.2.1.1.1', ); %FUNCS = ( %SNMP::Info::Layer2::FUNCS, ); @@ -51,6 +52,11 @@ sub model { return 'unknown'; } +sub serial { + my $obj = shift; + return $obj->serial_oid; +} + 1; __END__ diff --git a/lib/SNMP/Info/Layer3/Eltex.pm b/lib/SNMP/Info/Layer3/Eltex.pm index cdc490d7..bc6cf337 100644 --- a/lib/SNMP/Info/Layer3/Eltex.pm +++ b/lib/SNMP/Info/Layer3/Eltex.pm @@ -8,7 +8,6 @@ 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/; @@ -21,18 +20,19 @@ $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', + 'model_oid_mes' => 'mib-2.47.1.1.1.1.13.67108992', + #'hw_oid' => 'mib-2.47.1.1.1.1.8.67108992', + 'model_oid' => 'iso.0.8802.1.1.2.1.3.4.0', + 'hw_oid' => 'iso.0.8802.1.1.2.1.5.4795.1.2.2.0', + 'serial_oid' => 'mib-2.47.1.1.1.1.11.67108992', + 'serial_oid_22' => 'enterprises.35265.1.22.1.18.4.0', + 'os_ver_oid' => 'mib-2.47.1.1.1.1.10.67108992', + 'bootrom_oid' => 'mib-2.47.1.1.1.1.9.67108992', #'serial_oid_140' => '', - 'os_ver_oid_140' => 'mib-2.47.1.1.1.1.9.1', + 'os_ver_oid_140' => 'mib-2.47.1.1.1.1.9.1', #'bootrom_oid_140' => '', + 'descr_oid' => 'iso.0.8802.1.1.2.1.3.4.0', ); @@ -41,21 +41,28 @@ $VERSION = '3.70-135'; %MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub model { - my $eltex = shift; + my $obj = shift; my $model; my $hw; - my $id = $eltex->id(); - if ($id =~ /35265\.(140|158)$/) { - return; + my $id = $obj->id(); + $model = $obj->model_oid || undef; + $hw = $obj->hw_oid || undef; + if ( $id =~ /35265\.1\.22/ ) { + my $descr = $obj->descr_oid; + $descr =~ /Eltex\s(.*)\ssoftware\sversion\s(.*)\sbuild\s(\d+)/; + return $1; } - # 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; + elsif ($model !~ /MES\d+/) { + $model = $obj->model_oid_mes . ' ' . $obj->model_oid || undef; + } + if (defined $model and defined $hw) { + return $model . ' HW:' . $hw; + } + elsif (defined $model) { + return $model; } else { return 'unknown'; } - return $model . ' HW:' . $hw; } sub vendor { @@ -67,16 +74,21 @@ sub os { } sub os_ver { - my $eltex = shift; + my $obj = shift; my $os_ver; my $bootrom; - my $id = $eltex->id(); + my $id = $obj->id(); if ($id =~ /35265\.(140|158)$/) { - $os_ver = $eltex->os_ver_oid_140; + $os_ver = $obj->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; + $os_ver = $obj->os_ver_oid; + $bootrom = $obj->bootrom_oid; + } + elsif ( $id =~ /35265\.1\.22/ ) { + my $descr = $obj->descr_oid; + $descr =~ /Eltex\s(.*)\ssoftware\sversion\s(.*)\sbuild\s(\d+)/; + return $2; } else { return 'unknown'; @@ -85,14 +97,17 @@ sub os_ver { } sub serial { - my $eltex = shift; + my $obj = shift; my $serial; - my $id = $eltex->id(); + my $id = $obj->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; + $serial = $obj->serial_oid; + } + elsif ( $id =~ /35265\.1\.22/ ) { + $serial = $obj->serial_oid_22; } else { return 'unknown'; @@ -110,7 +125,7 @@ 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( + my $obj = new SNMP::Info( AutoSpecify => 1, Debug => 1, DestHost => 'myrouter', @@ -119,7 +134,7 @@ SNMP::Info::Layer3::Eltex - SNMP Interface to Eltex Devices ) or die "Can't connect to DestHost.\n"; - my $class = $eltex->class(); + my $class = $obj->class(); print "SNMP::Info determined this device to fall under subclass : $class\n"; =head1 DESCRIPTION @@ -144,27 +159,27 @@ These are methods that return scalar value from SNMP =over -=item $eltex->model() +=item $obj->model() Returns the ID or else description. -=item $eltex->vendor() +=item $obj->vendor() Returns 'eltex'. -=item $eltex->serial() +=item $obj->serial() Returns serial number. -=item $eltex->fwver() +=item $obj->fwver() Returns the firmware version. -=item $eltex->hwver() +=item $obj->hwver() Returns the hardware version. -=item $eltex->stp_i_root_port() +=item $obj->stp_i_root_port() Returns the STP root port. @@ -181,7 +196,7 @@ to a hash. =over -=item $eltex->interfaces(); +=item $obj->interfaces(); Returns the map between SNMP Interface Identifier (iid) and C. diff --git a/lib/SNMP/Info/Layer3/Raisecom.pm b/lib/SNMP/Info/Layer3/Raisecom.pm index 926ee5e3..b992abf0 100755 --- a/lib/SNMP/Info/Layer3/Raisecom.pm +++ b/lib/SNMP/Info/Layer3/Raisecom.pm @@ -44,9 +44,9 @@ sub os { } sub os_ver { - my $rcios = shift; - my $os_ver = $rcios->os_ver_oid || undef; - my $brom = $rcios->brom_oid || undef; + my $obj = shift; + my $os_ver = $obj->os_ver_oid || undef; + my $brom = $obj->brom_oid || undef; if (defined $os_ver and defined $brom) { return $os_ver . ' bootrom: ' . $brom; } @@ -56,9 +56,9 @@ sub os_ver { return 'unknown'; } sub model { - my $rcios = shift; - my $model = $rcios->model_oid || undef; - my $hw = $rcios->hw_oid || undef; + my $obj = shift; + my $model = $obj->model_oid || undef; + my $hw = $obj->hw_oid || undef; if (defined $model and defined $hw) { return $model . ' HW:' . $hw; } @@ -69,8 +69,8 @@ sub model { } sub serial { - my $rcios = shift; - my $serial = $rcios->serial_oid || 'unknown'; + my $obj = shift; + my $serial = $obj->serial_oid || 'unknown'; return $serial; } @@ -84,7 +84,7 @@ SNMP::Info::Layer3::Raisecom - SNMP Interface to Raisecom Devices =head1 SYNOPSIS # Let SNMP::Info determine the correct subclass for you. - my $rcios = new SNMP::Info( + my $obj = new SNMP::Info( AutoSpecify => 1, Debug => 1, DestHost => 'myrouter', @@ -93,12 +93,12 @@ SNMP::Info::Layer3::Raisecom - SNMP Interface to Raisecom Devices ) or die "Can't connect to DestHost.\n"; - my $class = $rcios->class(); + my $class = $obj->class(); print "SNMP::Info determined this device to fall under subclass : $class\n"; =head1 DESCRIPTION -Subclass for rcios Devices running IOS-like software +Subclass for Raisecom Devices =head2 Inherited Classes @@ -118,28 +118,30 @@ These are methods that return scalar value from SNMP =over -=item $rcios->vendor() +=item $obj->vendor() Returns 'adtran' -=item $rcios->os() +=item $obj->os() Returns 'caos' -=item $rcios->layers() +=item $obj->layers() Ensures that layer two is reported, at least. -=item $rcios->os_ver() +=item $obj->os_ver() Returns the software version. -=item $rcios->model() +=item $obj->model() Returns the model extracted. -=item $rcios->serial() +=item $obj->serial() Returns serial number. =cut + +=back \ No newline at end of file