SNMP::Info::Bridge - SNMP Interface to SNMP data available through the BRIDGE-MIB (RFC1493)
Max Baker
my $bridge = new SNMP::Info ( AutoSpecify => 1, Debug => 1, DestHost => 'switch', Community => 'public', Version => 2 ); my $class = $bridge->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.1q 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.
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
Returns the MAC Address of the root bridge port
(dot1dBaseBridgeAddress)
dot1dBaseBridgeAddress
Returns the number of ports in device
(dot1dBaseNumPorts)
dot1dBaseNumPorts
Returns the type of bridging this bridge can perform, transparent and/or source route.
(dot1dBaseType)
dot1dBaseType
Returns what version of STP the device is running.
(dot1dStpProtocolSpecification)
dot1dStpProtocolSpecification
Returns time since last topology change detected. (100ths/second)
(dot1dStpTimeSinceTopologyChange)
dot1dStpTimeSinceTopologyChange
Returns root of STP.
(dot1dStpDesignatedRoot)
dot1dStpDesignatedRoot
Maximum number of VLANS supported on this device.
(dot1qMaxSupportedVlans)
dot1qMaxSupportedVlans
Current number of VLANs that are configured in this device.
(dot1qNumVlans)
dot1qNumVlans
The next available value for dot1qVlanIndex of a local VLAN entry in dot1qVlanStaticTable
dot1qVlanIndex
dot1qVlanStaticTable
(dot1qNextFreeLocalVlanIndex)
dot1qNextFreeLocalVlanIndex
These are methods that return tables of information in the form of a reference to a hash.
Returns a mapping between ifIndex and the PVID or default VLAN.
ifIndex
An alias for i_vlan.
i_vlan
Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs. These are the VLANs which are members of the egress list for the port.
Example: my $interfaces = $bridge->interfaces(); my $vlans = $bridge->i_vlan_membership(); foreach my $iid (sort keys %$interfaces) { my $port = $interfaces->{$iid}; my $vlan = join(',', sort(@{$vlans->{$iid}})); print "Port: $port VLAN: $vlan\n"; }
Returns reference to hash: key = dot1dBasePort, value = either 'trunk' for tagged ports or the VLAN ID.
dot1dBasePort
Returns VLAN IDs
dot1dTpFdbEntry
Returns reference to hash of forwarding table MAC Addresses
(dot1dTpFdbAddress)
dot1dTpFdbAddress
Returns reference to hash of forwarding table entries port interface identifier (iid)
(dot1dTpFdbPort)
dot1dTpFdbPort
Returns reference to hash of forwarding table entries status
(dot1dTpFdbStatus)
dot1dTpFdbStatus
dot1dBasePortEntry
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
(dot1dBasePortIfIndex)
dot1dBasePortIfIndex
Returns reference to hash of bridge port table entries for a port which (potentially) has the same value of dot1dBasePortIfIndex as another port on the same bridge, this object contains the name of an object instance unique to this port.
(dot1dBasePortCircuit)
dot1dBasePortCircuit
dot1dStpPortTable
Descriptions are straight from BRIDGE-MIB.my
"The port number of the port for which this entry contains Spanning Tree Protocol management information."
(dot1dStpPort)
dot1dStpPort
"The value of the priority field which is contained in the first (in network byte order) octet of the (2 octet long) Port ID. The other octet of the Port ID is given by the value of dot1dStpPort."
(dot1dStpPortPriority)
dot1dStpPortPriority
"The port's current state as defined by application of the Spanning Tree Protocol. This state controls what action a port takes on reception of a frame. If the bridge has detected a port that is malfunctioning it will place that port into the broken(6) state. For ports which are disabled (see dot1dStpPortEnable), this object will have a value of disabled(1)."
dot1dStpPortEnable
disabled(1) blocking(2) listening(3) learning(4) forwarding(5) broken(6)
(dot1dStpPortState)
dot1dStpPortState
"The contribution of this port to the path cost of paths towards the spanning tree root which include this port. 802.1D-1990 recommends that the default value of this parameter be in inverse proportion to the speed of the attached LAN."
(dot1dStpPortPathCost)
dot1dStpPortPathCost
"The unique Bridge Identifier of the Bridge recorded as the Root in the Configuration BPDUs transmitted by the Designated Bridge for the segment to which the port is attached."
(dot1dStpPortDesignatedRoot)
dot1dStpPortDesignatedRoot
"The Bridge Identifier of the bridge which this port considers to be the Designated Bridge for this port's segment."
(dot1dStpPortDesignatedBridge)
dot1dStpPortDesignatedBridge
(dot1dStpPortDesignatedPort)
dot1dStpPortDesignatedPort
"The Port Identifier of the port on the Designated Bridge for this port's segment."
Returns the mapping of (dot1dStpPortDesignatedPort) to the interface index (iid).
Returns the mapping of (dot1dStpPortState) to the interface index (iid).
Returns the mapping of (dot1dStpPort) to the interface index (iid).
Returns the mapping of (dot1dStpPortDesignatedBridge) to the interface index (iid).
dot1qPortVlanTable
The PVID, the VLAN ID assigned to untagged frames or Priority-Tagged frames received on this port.
(dot1qPvid)
dot1qPvid
Either admitAll or admitOnlyVlanTagged. This is a good spot to find trunk ports.
admitAll
admitOnlyVlanTagged
(dot1qPortAcceptableFrameTypes)
dot1qPortAcceptableFrameTypes
When this is true the device will discard incoming frames for VLANs which do not include this Port in its Member set. When false, the port will accept all incoming frames.
true
false
(dot1qPortIngressFiltering)
dot1qPortIngressFiltering
dot1qVlanCurrentTable
The set of ports which are assigned to the egress list for this VLAN.
(dot1qVlanCurrentEgressPorts)
dot1qVlanCurrentEgressPorts
The set of ports which should transmit egress packets for this VLAN as untagged.
(dot1qVlanCurrentUntaggedPorts)
dot1qVlanCurrentUntaggedPorts
Status of the VLAN, other, permanent, or dynamicGvrp.
(dot1qVlanStatus)
dot1qVlanStatus
Human-entered name for vlans.
(dot1qVlanStaticName)
dot1qVlanStaticName
(dot1qVlanStaticEgressPorts)
dot1qVlanStaticEgressPorts
The set of ports which are prohibited from being included in the egress list for this VLAN.
(dot1qVlanForbiddenEgressPorts)
dot1qVlanForbiddenEgressPorts
(dot1qVlanStaticUntaggedPorts)
dot1qVlanStaticUntaggedPorts
active !
active
(dot1qVlanStaticRowStatus)
dot1qVlanStaticRowStatus
dot1qFdbTable
(dot1qTpFdbAddress)
dot1qTpFdbAddress
(dot1qTpFdbPort)
dot1qTpFdbPort
Returns reference to hash of forwarding table entries VLAN ID
(dot1qTpFdbStatus)
dot1qTpFdbStatus
These are methods that provide SNMP set functionality for overridden methods or provide a simpler interface to complex set operations. See "SETTING DATA VIA SNMP" in SNMP::Info for general information on set operations.
Currently unsupported. Throws an error and returns.
An alias for set_i_vlan.
set_i_vlan
To install SNMP::Info, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SNMP::Info
CPAN shell
perl -MCPAN -e shell install SNMP::Info
For more information on module installation, please visit the detailed CPAN module installation guide.