SNMP::Info::Bridge - Perl5 Interface to SNMP data available through the BRIDGE-MIB (RFC1493)
Max Baker (max@warped.org)
my $bridge = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'switch',
Community => 'public',
Version => 2
);
my $class = $cdp->class(); print " Using device sub class : $class\n";
# Grab Forwarding Tables my $interfaces = $bridge->interfaces(); my $fw_mac = $bridge->fw_mac(); my $fw_port = $bridge->fw_port(); my $bp_index = $bridge->bp_index();
foreach my $fw_index (keys %$fw_mac){
my $mac = $fw_mac->{$fw_index};
my $bp_id = $fw_port->{$fw_index};
my $iid = $bp_index->{$bp_id};
my $port = $interfaces->{$iid};
print "Port:$port forwarding to $mac\n";
}
BRIDGE-MIB is used by most Layer 2 devices, and holds information like the MAC Forwarding Table and Spanning Tree Protocol info.
Q-BRIDGE-MIB holds 802.11q information -- VLANs and Trunking. Cisco tends not to use this MIB, but some
proprietary ones. HP and some nicer vendors use this. This is from RFC2674_q.
Create or use a subclass of SNMP::Info that inherits this class. Do not use directly.
For debugging you can call new() directly as you would in SNMP::Info
my $bridge = new SNMP::Info::Bridge(...);
None.
BRIDGE-MIB needs to be extracted from ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
These are methods that return scalar values from SNMP
b_mac()(dot1dBaseBridgeAddress)
b_ports()(dot1dBaseNumPorts)
b_type()(dot1dBaseType)
stp_ver()(dot1dStpProtocolSpecification)
stp_time()(dot1dStpTimeSinceTopologyChange)
stp_root()(dot1dStpDesignatedRoot)
qb_vlans_max()qb_vlans()(dot1qNumVlans)
These are methods that return tables of information in the form of a reference to a hash.
fw_mac()(dot1dTpFdbAddress)
fw_port()(dot1dTpFdbPort)
fw_status()(dot2dTpFdbStatus)
bp_index()(dot1dBasePortIfIndex)
bp_port()(dot1dBasePortCircuit)
Descriptions are lifted straight from BRIDGE-MIB.my
stp_p_id()(dot1dStpPort)
stp_p_priority()(dot1dStpPortPriority)
stp_p_state()broken(6) state. For ports which
are disabled (see dot1dStpPortEnable), this object will have a value of disabled(1).''
disabled(1) blocking(2) listening(3) learning(4) forwarding(5) broken(6)
(dot1dStpPortState)
stp_p_cost()(dot1dStpPortPathCost)
stp_p_root()(dot1dStpPortDesignatedRoot)
stp_p_bridge()(dot1dStpPortDesignatedBridge)
stp_p_port()``The Port Identifier of the port on the Designated Bridge for this port's segment.''
qb_i_vlan()(dot1qPvid)
qb_i_vlan_type()admitAll or admitOnlyVlanTagged. This is a good spot to find
trunk ports.
(dot1qPortAcceptableFrameTypes)
qb_v_name()(dot1qVlanStaticName)
qb_v_stat()active !
(dot1qVlanStaticRowStatus)