From e7fcd9810773726396c0d211d48ab823a1bde997 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 21 Mar 2018 10:35:09 +0000 Subject: [PATCH] #12 add Cisco PortFast support via CiscoStpExtensions::i_faststart_enabled --- Changes | 4 +++ lib/SNMP/Info/Bridge.pm | 5 ++++ lib/SNMP/Info/CiscoStpExtensions.pm | 42 ++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index d5761cac..496af1c3 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Version 3.53 () + [NEW FEATURES] + + * #12 add Cisco PortFast support via CiscoStpExtensions::i_faststart_enabled + [ENHANCEMENTS] * Report serial/version on Netgear FSM (paecker) diff --git a/lib/SNMP/Info/Bridge.pm b/lib/SNMP/Info/Bridge.pm index f97776b7..a2603670 100644 --- a/lib/SNMP/Info/Bridge.pm +++ b/lib/SNMP/Info/Bridge.pm @@ -47,6 +47,7 @@ $VERSION = '3.52'; %MIBS = ( 'BRIDGE-MIB' => 'dot1dBaseBridgeAddress', 'Q-BRIDGE-MIB' => 'dot1qPvid', + 'RSTP-MIB' => 'dot1dStpPortOperEdgePort', ); %GLOBALS = ( @@ -104,6 +105,10 @@ $VERSION = '3.52'; 'stp_p_bridge' => 'dot1dStpPortDesignatedBridge', 'stp_p_port' => 'dot1dStpPortDesignatedPort', + # Rapid Spanning Tree Protocol Table : dot1dStpExtPortEntry + 'is_edgeport_admin' => 'dot1dStpPortAdminEdgePort', + 'is_edgeport_oper' => 'dot1dStpPortOperEdgePort', + # Q-BRIDGE-MIB : dot1qPortVlanTable 'qb_i_vlan' => 'dot1qPvid', 'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes', diff --git a/lib/SNMP/Info/CiscoStpExtensions.pm b/lib/SNMP/Info/CiscoStpExtensions.pm index 47456a0c..fdda197f 100644 --- a/lib/SNMP/Info/CiscoStpExtensions.pm +++ b/lib/SNMP/Info/CiscoStpExtensions.pm @@ -54,12 +54,15 @@ $VERSION = '3.52'; 'stpx_stp_type' => 'stpxSpanningTreeType', 'stpx_bpduguard_enable' => 'stpxFastStartBpduGuardEnable', 'stpx_bpdufilter_enable' => 'stpxFastStartBpduFilterEnable', + 'stpx_faststart_default' => 'stpxFastStartGlobalDefaultMode', ); %FUNCS = ( %SNMP::Info::Bridge::FUNCS, 'stpx_rootguard_enabled' => 'stpxRootGuardConfigEnabled', 'stpx_loopguard_enabled' => 'stpxLoopGuardConfigEnabled', + 'stpx_faststart_enabled' => 'stpxFastStartPortEnable', + 'stpx_faststart_operational' => 'stpxFastStartPortMode', 'stpx_port_bpduguard_mode' => 'stpxFastStartPortBpduGuardMode', 'stpx_port_bpdufilter_mode' => 'stpxFastStartPortBpduFilterMode', 'stpx_smst_root' => 'stpxSMSTInstanceCISTRegionalRoot', @@ -69,7 +72,7 @@ $VERSION = '3.52'; %MUNGE = ( %SNMP::Info::Bridge::MUNGE, - 'stpx_mst_config_digest' => \&SNMP::Info::CiscoStpExtensions::oct2str, + 'stpx_mst_config_digest' => \&SNMP::Info::CiscoStpExtensions::oct2str, ); @@ -225,6 +228,36 @@ sub i_bpdufilter_enabled { return \%res; } +sub i_faststart_enabled { + my $self = shift; + my $partial = shift; + + my $faststart_default = $self->stpx_faststart_default(); + my $bp_index = $self->bp_index($partial); + my $faststart = $self->stpx_faststart_enabled(); + my $faststart_oper = $self->stpx_faststart_operational(); + + my %res; + # stpxFastStartPortEnable is deprecated in favour of stpxFastStartPortMode + # see https://github.com/netdisco/netdisco/issues/12 + foreach my $index ( keys %$faststart, keys %$faststart_oper ){ + my $mode = $faststart_oper->{$index} || $faststart->{$index}; + my $iid = $bp_index->{$index}; + next unless defined $iid; + next unless defined $mode; + if ( $mode eq 'default' ){ + $res{$iid} = $faststart_default; + }else{ + $res{$iid} = $mode; + } + $res{$iid} = 'enable' if $res{$iid} eq 'true'; + $res{$iid} = 'disable' if $res{$iid} eq 'false'; + $res{$iid} = 1 if $res{$iid} =~ m/enable/i; # enableForTrunk + $res{$iid} = 0 if $res{$iid} eq 'disable'; + } + return \%res; +} + sub oct2str { my ($v) = @_; @@ -340,6 +373,13 @@ Format is a hash reference with key = C, value = [1|0] (C) +=item $stpx->i_faststart_enabled() + +Returns 1 or 0 depending on whether FastStart (aka PortFast) is enabled on a +given port. Format is a hash reference with key = C, value = [1|0] + +(C and C) + =back =head1 MUNGES