@SNMP::Info::Layer3::Foundry::ISA
=
qw/
SNMP::Info::FDP
SNMP::Info::Layer3
Exporter
/
;
@SNMP::Info::Layer3::Foundry::EXPORT_OK
=
qw//
;
our
(
$VERSION
,
%GLOBALS
,
%FUNCS
,
%MIBS
,
%MUNGE
);
$VERSION
=
'3.84'
;
%MIBS
= (
%SNMP::Info::Layer3::MIBS
,
%SNMP::Info::FDP::MIBS
,
'FOUNDRY-SN-ROOT-MIB'
=>
'foundry'
,
'FOUNDRY-SN-AGENT-MIB'
=>
'snChasPwrSupplyDescription'
,
'FOUNDRY-SN-SWITCH-GROUP-MIB'
=>
'snSwGroupOperMode'
,
'FOUNDRY-SN-STACKING-MIB'
=>
'snStackingOperUnitRole'
,
'FOUNDRY-POE-MIB'
=>
'snAgentPoeGblPowerCapacityTotal'
,
'BROCADE-PRODUCTS-MIB'
=>
'brocadeProducts'
,
);
%GLOBALS
= (
%SNMP::Info::Layer3::GLOBALS
,
%SNMP::Info::FDP::GLOBALS
,
'mac'
=>
'ifPhysAddress.1'
,
'chassis'
=>
'entPhysicalDescr.1'
,
'temp'
=>
'snChasActualTemperature'
,
'ps1_type'
=>
'snChasPwrSupplyDescription.1'
,
'ps1_status'
=>
'snChasPwrSupplyOperStatus.1'
,
'fan'
=>
'snChasFanOperStatus.1'
,
'img_ver'
=>
'snAgImgVer'
,
'ch_serial'
=>
'snChasSerNum'
,
);
%FUNCS
= (
%SNMP::Info::Layer3::FUNCS
,
%SNMP::Info::FDP::FUNCS
,
'sw_index'
=>
'snSwPortIfIndex'
,
'sw_duplex'
=>
'snSwPortInfoChnMode'
,
'sw_type'
=>
'snSwPortInfoMediaType'
,
'sw_speed'
=>
'snSwPortInfoSpeed'
,
'ag_mod2_type'
=>
'snAgentConfigModule2Type'
,
'ag_mod_type'
=>
'snAgentConfigModuleType'
,
'stp_i_id'
=>
'snVLanByPortVLanId'
,
'stp_i_mac'
=>
'snVLanByPortBaseBridgeAddress'
,
'stp_i_time'
=>
'snVLanByPortStpTimeSinceTopologyChange'
,
'stp_i_ntop'
=>
'snVLanByPortStpTopChanges'
,
'stp_i_root'
=>
'snVLanByPortStpDesignatedRoot'
,
'stp_i_root_port'
=>
'snVLanByPortStpRootPort'
,
'stp_i_priority'
=>
'snVLanByPortStpPriority'
,
'stp_p_id'
=>
'snPortStpPortNum'
,
'stp_p_stg_id'
=>
'snPortStpVLanId'
,
'stp_p_priority'
=>
'snPortStpPortPriority'
,
'stp_p_state'
=>
'snPortStpPortState'
,
'stp_p_cost'
=>
'snPortStpPortDesignatedCost'
,
'stp_p_root'
=>
'snPortStpPortDesignatedRoot'
,
'stp_p_bridge'
=>
'snPortStpPortDesignatedBridge'
,
'stp_p_port'
=>
'snPortStpPortDesignatedPort'
,
);
%MUNGE
= (
%SNMP::Info::Layer3::MUNGE
,
%SNMP::Info::FDP::MUNGE
,
'ag_mod2_type'
=> \
&SNMP::Info::munge_e_type
,
'ag_mod_type'
=> \
&SNMP::Info::munge_e_type
,
'stp_i_mac'
=> \
&SNMP::Info::munge_mac
,
'stp_i_root'
=> \
&SNMP::Info::munge_prio_mac
,
'stp_p_root'
=> \
&SNMP::Info::munge_prio_mac
,
'stp_p_bridge'
=> \
&SNMP::Info::munge_prio_mac
,
'stp_p_port'
=> \
&SNMP::Info::munge_prio_port
,
);
sub
i_ignore {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$interfaces
=
$foundry
->interfaces(
$partial
) || {};
my
%i_ignore
;
foreach
my
$if
(
keys
%$interfaces
) {
if
(
$interfaces
->{
$if
} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) {
$i_ignore
{
$if
}++;
}
}
return
\
%i_ignore
;
}
sub
i_duplex {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$sw_index
=
$foundry
->sw_index(
$partial
);
my
$sw_duplex
=
$foundry
->sw_duplex(
$partial
);
unless
(
defined
$sw_index
and
defined
$sw_duplex
) {
return
$foundry
->SUPER::i_duplex();
}
my
%i_duplex
;
foreach
my
$sw_port
(
keys
%$sw_duplex
) {
my
$iid
=
$sw_index
->{
$sw_port
};
my
$duplex
=
$sw_duplex
->{
$sw_port
};
next
if
$duplex
=~ /none/i;
$i_duplex
{
$iid
} =
'half'
if
$duplex
=~ /half/i;
$i_duplex
{
$iid
} =
'full'
if
$duplex
=~ /full/i;
}
return
\
%i_duplex
;
}
sub
model {
my
$foundry
=
shift
;
my
$id
=
$foundry
->id();
my
$model
=
&SNMP::translateObj
(
$id
);
if
(
$id
=~ /\.1991\.1\.[45]\./ ) {
my
$e_name
=
$foundry
->e_name();
my
$unit_iid
=
undef
;
foreach
my
$e
(
keys
%$e_name
) {
my
$name
=
$e_name
->{
$e
} ||
''
;
$unit_iid
=
$e
if
$name
eq
'unit.1'
;
}
my
$e_model
=
$foundry
->e_model();
if
(
defined
$e_model
->{
$unit_iid
} ) {
return
$e_model
->{
$unit_iid
};
}
}
return
$id
unless
defined
$model
;
$model
=~ s/^sn//;
$model
=~ s/Switch//;
return
$model
;
}
sub
os {
return
'brocade'
;
}
sub
vendor {
return
'brocade'
;
}
sub
os_ver {
my
$foundry
=
shift
;
return
$foundry
->img_ver()
if
(
defined
$foundry
->img_ver() );
my
$descr
=
$foundry
->description();
if
(
$descr
=~ m/Version (\d\S*)/ ) {
return
$1;
}
my
$e_name
=
$foundry
->e_name();
my
$unit_iid
=
undef
;
foreach
my
$e
(
keys
%$e_name
) {
my
$name
=
$e_name
->{
$e
} ||
''
;
$unit_iid
=
$e
if
$name
eq
'stackmanaget.1'
;
}
if
(
defined
$unit_iid
) {
my
$e_fwver
=
$foundry
->e_fwver();
if
(
defined
$e_fwver
->{
$unit_iid
} ) {
return
$e_fwver
->{
$unit_iid
};
}
}
return
$foundry
->snAgFlashImgVer()
if
(
defined
$foundry
->snAgFlashImgVer() );
return
$foundry
->SUPER::os_ver();
}
sub
serial {
my
$foundry
=
shift
;
return
$foundry
->ch_serial()
if
(
$foundry
->ch_serial() );
my
$mod_serials
=
$foundry
->snAgentConfigModuleSerialNumber() || {};
foreach
my
$mod
(
sort
keys
%$mod_serials
) {
my
$serial
=
$mod_serials
->{
$mod
} ||
''
;
next
unless
defined
$serial
;
return
$serial
;
}
my
$e_name
=
$foundry
->e_name();
my
$unit_iid
=
undef
;
foreach
my
$e
(
keys
%$e_name
) {
my
$name
=
$e_name
->{
$e
} ||
''
;
$unit_iid
=
$e
if
$name
eq
'unit.1'
;
}
if
(
defined
$unit_iid
) {
my
$e_serial
=
$foundry
->e_serial();
return
$e_serial
->{
$unit_iid
}
if
defined
$e_serial
->{
$unit_iid
};
}
return
$foundry
->SUPER::serial();
}
sub
interfaces {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$i_descr
=
$foundry
->i_description(
$partial
) || {};
my
$i_name
=
$foundry
->i_name(
$partial
) || {};
foreach
my
$iid
(
keys
%$i_name
) {
my
$name
=
$i_name
->{
$iid
};
next
unless
defined
$name
;
$i_descr
->{
$iid
} =
$name
if
$name
=~ /^port\d+/i;
}
return
$i_descr
;
}
sub
set_i_vlan {
my
(
$foundry
,
$vlan
,
$iid
) =
@_
;
my
$i_vlan
=
$foundry
->i_vlan(
$iid
);
if
(
defined
$i_vlan
) {
print
"Changing VLAN from $i_vlan->{$iid} to $vlan on IfIndex: $iid\n"
if
$foundry
->debug();
$foundry
->set_snVLanByPortMemberRowStatus( 3,
"${vlan}.${iid}"
);
sleep
1;
my
$rv_rem
=
$foundry
->set_snVLanByPortMemberRowStatus( 3,
"$i_vlan->{$iid}.$iid"
);
sleep
1;
unless
(
$rv_rem
) {
print
"Unable to remove untagged(?) VLAN $i_vlan->{$iid} from IfIndex: $iid\n"
if
$foundry
->debug();
}
my
$rv_add
=
$foundry
->set_multi([
[
'snVLanByPortMemberRowStatus'
,
"${vlan}.${iid}"
, 4],
[
'snVLanByPortMemberTagMode'
,
"${vlan}.${iid}"
, 2],
]);
sleep
1;
unless
(
$rv_add
) {
print
"Unable to add untagged VLAN $vlan to IfIndex: $iid\n"
if
$foundry
->debug();
my
$rv_add_tagged
=
$foundry
->set_multi([
[
'snVLanByPortMemberRowStatus'
,
"${vlan}.${iid}"
, 4],
[
'snVLanByPortMemberTagMode'
,
"${vlan}.${iid}"
, 1],
]);
sleep
1;
if
(
$rv_add_tagged
) {
my
$rv_change_untagged
=
$foundry
->set_snVLanByPortMemberTagMode( 2,
"${vlan}.${iid}"
);
sleep
1;
return
$rv_change_untagged
if
$rv_change_untagged
;
}
$foundry
->error_throw(
"Unable to add VLAN $vlan to interface: $iid"
);
return
;
}
return
$rv_add
;
}
$foundry
->error_throw(
"Can't find ifIndex: $iid - Is it an access port?"
);
return
;
}
sub
e_index {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_index(
$partial
)
||
$foundry
->brcd_e_index(
$partial
);
}
sub
e_class {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_class(
$partial
)
||
$foundry
->brcd_e_class(
$partial
);
}
sub
e_descr {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_descr(
$partial
)
||
$foundry
->brcd_e_descr(
$partial
);
}
sub
e_name {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_name(
$partial
)
||
$foundry
->brcd_e_name(
$partial
);
}
sub
e_parent {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_parent(
$partial
)
||
$foundry
->brcd_e_parent(
$partial
);
}
sub
e_pos {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_pos(
$partial
) ||
$foundry
->brcd_e_pos(
$partial
);
}
sub
e_serial {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_serial(
$partial
)
||
$foundry
->brcd_e_serial(
$partial
);
}
sub
e_type {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_type(
$partial
)
||
$foundry
->brcd_e_type(
$partial
);
}
sub
e_vendor {
my
$foundry
=
shift
;
my
$partial
=
shift
;
return
$foundry
->SUPER::e_vendor(
$partial
)
||
$foundry
->brcd_e_vendor(
$partial
);
}
sub
_brcd_stack_master {
my
$foundry
=
shift
;
my
$roles
=
$foundry
->snStackingOperUnitRole() || {};
foreach
my
$iid
(
keys
%$roles
) {
my
$role
=
$roles
->{
$iid
};
next
unless
$role
;
if
(
$role
eq
'active'
) {
return
$iid
;
}
}
return
;
}
sub
brcd_e_index {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$stack_master
=
$foundry
->_brcd_stack_master();
my
$brcd_e_idx
=
$foundry
->snAgentConfigModule2Description(
$partial
)
||
$foundry
->snAgentConfigModuleDescription(
$partial
)
|| {};
my
%brcd_e_index
;
if
(
$stack_master
) {
$brcd_e_index
{0} = 1;
}
foreach
my
$iid
(
keys
%$brcd_e_idx
) {
my
$index
=
$iid
;
if
(
$iid
=~ /(\d+)\.(\d+)/ ) {
$index
=
"$1"
.
sprintf
"%02d"
, $2;
}
$brcd_e_index
{
$iid
} =
$index
;
}
return
\
%brcd_e_index
;
}
sub
brcd_e_class {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
%e_class
;
foreach
my
$iid
(
keys
%$e_idx
) {
if
(
$iid
== 0 ) {
$e_class
{
$iid
} =
'stack'
;
}
elsif
(
$iid
=~ /1$/ ) {
$e_class
{
$iid
} =
'chassis'
;
}
else
{
$e_class
{
$iid
} =
'module'
;
}
}
return
\
%e_class
;
}
sub
brcd_e_descr {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$brcd_e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
$m_descrs
=
$foundry
->snAgentConfigModule2Description(
$partial
)
||
$foundry
->snAgentConfigModuleDescription(
$partial
)
|| {};
my
%brcd_e_descr
;
foreach
my
$iid
(
keys
%$brcd_e_idx
) {
if
(
$iid
== 0 ) {
$brcd_e_descr
{
$iid
} =
$foundry
->description();
}
my
$descr
=
$m_descrs
->{
$iid
};
next
unless
defined
$descr
;
$brcd_e_descr
{
$iid
} =
$descr
;
}
return
\
%brcd_e_descr
;
}
sub
brcd_e_name {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$stack_master
=
$foundry
->_brcd_stack_master();
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
%brcd_e_name
;
foreach
my
$iid
(
keys
%$e_idx
) {
if
(
$iid
== 0 ) {
$brcd_e_name
{
$iid
} =
'Stack Master Unit'
;
}
elsif
(
$stack_master
&&
$iid
=~ /(\d+)\.1$/ ) {
$brcd_e_name
{
$iid
} =
"Switch Stack Unit $1"
;
}
elsif
(
$iid
=~ /1$/ ) {
$brcd_e_name
{
$iid
} =
"Switch"
;
}
else
{
$brcd_e_name
{
$iid
} =
'Module'
;
}
}
return
\
%brcd_e_name
;
}
sub
brcd_e_vendor {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
%brcd_e_vendor
;
foreach
my
$iid
(
keys
%$e_idx
) {
my
$vendor
=
'brocade'
;
$brcd_e_vendor
{
$iid
} =
$vendor
;
}
return
\
%brcd_e_vendor
;
}
sub
brcd_e_serial {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
$serials
=
$foundry
->snAgentConfigModule2SerialNumber(
$partial
)
||
$foundry
->snAgentConfigModuleSerialNumber(
$partial
)
|| {};
my
%brcd_e_serial
;
foreach
my
$iid
(
keys
%$e_idx
) {
if
(
$iid
== 0 ) {
$brcd_e_serial
{
$iid
} =
$foundry
->serial();
}
my
$serial
=
$serials
->{
$iid
};
next
unless
defined
$serial
;
$brcd_e_serial
{
$iid
} =
$serial
;
}
return
\
%brcd_e_serial
;
}
sub
brcd_e_type {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
$types
=
$foundry
->ag_mod2_type(
$partial
)
||
$foundry
->ag_mod_type(
$partial
)
|| {};
my
%brcd_e_type
;
foreach
my
$iid
(
keys
%$e_idx
) {
if
(
$iid
== 0 ) {
$brcd_e_type
{
$iid
} =
$foundry
->model();
}
my
$type
=
$types
->{
$iid
};
next
unless
defined
$type
;
$brcd_e_type
{
$iid
} =
$type
;
}
return
\
%brcd_e_type
;
}
sub
brcd_e_pos {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
%brcd_e_pos
;
foreach
my
$iid
(
keys
%$e_idx
) {
my
$pos
;
if
(
$iid
== 0 ) {
$pos
= -1;
}
elsif
(
$iid
=~ /(\d+)\.1$/ ) {
$pos
= $1;
}
elsif
(
$iid
=~ /(\d+)$/ ) {
$pos
= $1;
}
$brcd_e_pos
{
$iid
} =
$pos
;
}
return
\
%brcd_e_pos
;
}
sub
brcd_e_parent {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$stack_master
=
$foundry
->_brcd_stack_master();
my
$e_idx
=
$foundry
->brcd_e_index(
$partial
) || {};
my
%brcd_e_parent
;
foreach
my
$iid
(
keys
%$e_idx
) {
if
(
$iid
== 0 ) {
$brcd_e_parent
{
$iid
} = 0;
}
elsif
(
$stack_master
&&
$iid
=~ /(\d+)\.1$/ ) {
$brcd_e_parent
{
$iid
} = 1;
}
elsif
(
$iid
=~ /1$/ ) {
$brcd_e_parent
{
$iid
} = 0;
}
elsif
(
$iid
=~ /(\d+).\d+/ ) {
$brcd_e_parent
{
$iid
} =
"$1"
.
"01"
;
}
else
{
$brcd_e_parent
{
$iid
} = 1;
}
}
return
\
%brcd_e_parent
;
}
sub
peth_port_ifindex {
my
$foundry
=
shift
;
my
$indexes
=
$foundry
->snAgentPoePortNumber();
my
$descrs
=
$foundry
->i_description();
my
$peth_port_ifindex
= {};
foreach
my
$i
(
keys
%$indexes
) {
my
$descr
=
$descrs
->{
$i
};
next
unless
$descr
;
my
$new_idx
=
"1.$i"
;
if
(
$descr
=~ /(\d+)\/\d+\/\d+/ ) {
$new_idx
=
"$1.$i"
;
}
$peth_port_ifindex
->{
$new_idx
} =
$i
;
}
return
$peth_port_ifindex
;
}
sub
peth_port_admin {
my
$foundry
=
shift
;
my
$p_index
=
$foundry
->peth_port_ifindex() || {};
my
$admin_states
=
$foundry
->snAgentPoePortControl() || {};
my
$peth_port_admin
= {};
foreach
my
$i
(
keys
%$p_index
) {
my
(
$module
,
$port
) =
split
( /\./,
$i
);
my
$state
=
$admin_states
->{
$port
};
if
(
$state
=~ /enable/ ) {
$peth_port_admin
->{
$i
} =
'true'
;
}
else
{
$peth_port_admin
->{
$i
} =
'false'
;
}
}
return
$peth_port_admin
;
}
sub
peth_port_neg_power {
my
$foundry
=
shift
;
my
$p_index
=
$foundry
->peth_port_ifindex() || {};
my
$peth_port_class
=
$foundry
->snAgentPoePortClass() || {};
my
$poemax
= {
'0'
=> 12950,
'1'
=> 3840,
'2'
=> 6490,
'3'
=> 12950,
'4'
=> 25500
};
my
$peth_port_neg_power
= {};
foreach
my
$i
(
keys
%$p_index
) {
my
(
$module
,
$port
) =
split
( /\./,
$i
);
my
$power
=
$poemax
->{
$peth_port_class
->{
$port
} };
next
unless
$power
;
$peth_port_neg_power
->{
$i
} =
$power
;
}
return
$peth_port_neg_power
;
}
sub
peth_port_power {
my
$foundry
=
shift
;
my
$p_index
=
$foundry
->peth_port_ifindex() || {};
my
$port_consumed
=
$foundry
->snAgentPoePortConsumed() || {};
my
$peth_port_power
= {};
foreach
my
$i
(
keys
%$p_index
) {
my
(
$module
,
$port
) =
split
( /\./,
$i
);
my
$power
=
$port_consumed
->{
$port
};
next
unless
$power
;
$peth_port_power
->{
$i
} =
$power
;
}
return
$peth_port_power
;
}
sub
peth_port_class {
my
$foundry
=
shift
;
my
$p_index
=
$foundry
->peth_port_ifindex() || {};
my
$port_class
=
$foundry
->snAgentPoePortClass() || {};
my
$peth_port_class
= {};
foreach
my
$i
(
keys
%$p_index
) {
my
(
$module
,
$port
) =
split
( /\./,
$i
);
my
$power
=
$port_class
->{
$port
};
next
unless
$power
;
$peth_port_class
->{
$i
} =
"class$power"
;
}
return
$peth_port_class
;
}
sub
peth_port_status {
my
$foundry
=
shift
;
my
$p_index
=
$foundry
->peth_port_ifindex() || {};
my
$admin_states
=
$foundry
->snAgentPoePortControl() || {};
my
$peth_port_status
= {};
foreach
my
$i
(
keys
%$p_index
) {
my
(
$module
,
$port
) =
split
( /\./,
$i
);
my
$state
=
$admin_states
->{
$port
};
if
(
$state
=~ /enable/ ) {
$peth_port_status
->{
$i
} =
'deliveringPower'
;
}
else
{
$peth_port_status
->{
$i
} =
'disabled'
;
}
}
return
$peth_port_status
;
}
sub
peth_power_status {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$watts
=
$foundry
->snAgentPoeUnitPowerCapacityTotal(
$partial
) || {};
my
$peth_power_status
= {};
foreach
my
$i
(
keys
%$watts
) {
$peth_power_status
->{
$i
} =
'on'
;
}
return
$peth_power_status
;
}
sub
peth_power_watts {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$watts_total
=
$foundry
->snAgentPoeUnitPowerCapacityTotal(
$partial
)
|| {};
my
$peth_power_watts
= {};
foreach
my
$i
(
keys
%$watts_total
) {
my
$total
=
$watts_total
->{
$i
};
next
unless
$total
;
$peth_power_watts
->{
$i
} =
$total
/ 1000;
}
return
$peth_power_watts
;
}
sub
peth_power_consumption {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$watts_total
=
$foundry
->snAgentPoeUnitPowerCapacityTotal(
$partial
)
|| {};
my
$watts_free
=
$foundry
->snAgentPoeUnitPowerCapacityFree(
$partial
)
|| {};
my
$peth_power_consumed
= {};
foreach
my
$i
(
keys
%$watts_total
) {
my
$total
=
$watts_total
->{
$i
};
next
unless
$total
;
my
$free
=
$watts_free
->{
$i
} || 0;
$peth_power_consumed
->{
$i
} = (
$total
-
$free
) / 1000;
}
return
$peth_power_consumed
;
}
sub
agg_ports {
my
$dev
=
shift
;
my
$trunks
=
$dev
->snMSTrunkPortList;
my
$ports
=
$dev
->snSwPortIfIndex;
return
{}
unless
ref
{} eq
ref
$trunks
and
scalar
keys
%$trunks
and
ref
{} eq
ref
$ports
and
scalar
keys
%$ports
;
my
$ret
= {};
foreach
my
$m
(
keys
%$trunks
) {
my
$skip
= 0;
while
(
my
$s
=
unpack
(
"x${skip}n2"
,
$trunks
->{
$m
})) {
$ret
->{
$ports
->{
$s
} } =
$ports
->{
$m
};
$skip
+= 2;
}
}
return
$ret
;
}
sub
i_stp_state {
my
$foundry
=
shift
;
my
$partial
=
shift
;
my
$bp_index
=
$foundry
->bp_index(
$partial
);
my
$stp_p_state
=
$foundry
->dot1dStpPortState(
$partial
);
my
%i_stp_state
;
foreach
my
$index
(
keys
%$stp_p_state
) {
my
$state
=
$stp_p_state
->{
$index
};
my
$iid
=
$bp_index
->{
$index
};
next
unless
defined
$iid
;
next
unless
defined
$state
;
$i_stp_state
{
$iid
} =
$state
;
}
return
\
%i_stp_state
;
}
1;