From b6720a2b4367e328c745d9bd49bbfdecaf23c5d0 Mon Sep 17 00:00:00 2001 From: nick n <39005454+inphobia@users.noreply.github.com> Date: Sun, 18 Aug 2019 01:50:34 +0200 Subject: [PATCH] duplex support for ciscosb (#352) --- Changes | 6 ++++++ lib/SNMP/Info/Layer2/CiscoSB.pm | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Changes b/Changes index 9dce238a..ca8a0753 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +Version 3.69 (2019-xx-xx) + + [ENHANCEMENTS] + + * duplex support for ciscosb + Version 3.68 (2019-04-28) [NEW FEATURES] diff --git a/lib/SNMP/Info/Layer2/CiscoSB.pm b/lib/SNMP/Info/Layer2/CiscoSB.pm index 53424b1d..d48523e7 100644 --- a/lib/SNMP/Info/Layer2/CiscoSB.pm +++ b/lib/SNMP/Info/Layer2/CiscoSB.pm @@ -34,6 +34,7 @@ package SNMP::Info::Layer2::CiscoSB; use strict; +use warnings; use Exporter; use SNMP::Info::Layer2; use SNMP::Info::Entity; @@ -137,6 +138,26 @@ sub model { return $ciscosb->description(); } +# CISCOSBinterfaces.mib also contains duplex info if needed +sub i_duplex { + my $ciscosb = shift; + my $partial = shift; + + my $el_duplex = $ciscosb->el_duplex($partial); + + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { + my %i_duplex; + foreach my $el_port ( keys %$el_duplex ) { + my $duplex = $el_duplex->{$el_port}; + next unless defined $duplex; + + $i_duplex{$el_port} = 'half' if $duplex =~ /half/i; + $i_duplex{$el_port} = 'full' if $duplex =~ /full/i; + } + return \%i_duplex; + } +} + # 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 { @@ -256,6 +277,14 @@ See documentation in L for details. =head1 TABLE METHODS +=over + +=item $ciscosb->i_duplex() + +Return duplex based upon the result of EtherLike->el_duplex(). + +=back + =head2 Overrides =over