NAME
SNMP::Info::Bridge - SNMP Interface to SNMP data available through the BRIDGE-MIB (RFC1493)
AUTHOR
Max Baker
SYNOPSIS
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";
}
# Spanning trees: read the list in the default context and keep it, then
# read each tree's ports in the contexts that serve it. enter_context()
# is the helper in "SNMP Contexts" in SNMP::Info.
my $community = $bridge->snmp_comm();
my $trees = $bridge->stp_trees() || {};
foreach my $key (sort keys %$trees) {
my %ports;
foreach my $context (@{ $trees->{$key}{contexts} }) {
enter_context($bridge, $context, $community) or next;
%ports = (%ports, %{ $bridge->stp_tree_ports($key) || {} });
}
$bridge->update();
foreach my $iid (sort keys %ports) {
printf "%s %s: %s\n", $key, $interfaces->{$iid},
$ports{$iid}{state} // 'no state';
}
}
DESCRIPTION
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.
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(...);
Inherited Classes
None.
Required MIBs
GLOBALS
These are methods that return scalar values from SNMP
- $bridge->b_mac()
-
Returns the MAC Address of the root bridge port
(
dot1dBaseBridgeAddress) - $bridge->b_ports()
-
Returns the number of ports in device
(
dot1dBaseNumPorts) - $bridge->b_type()
-
Returns the type of bridging this bridge can perform, transparent and/or source route.
(
dot1dBaseType) - $bridge->stp_ver()
-
Returns what version of STP the device is running.
(
dot1dStpProtocolSpecification) - $bridge->stp_time()
-
Returns time since last topology change detected. (100ths/second)
(
dot1dStpTimeSinceTopologyChange) - $bridge->stp_root()
-
Returns root of STP.
(
dot1dStpDesignatedRoot) - $bridge->qb_vlans_max()
-
Maximum number of VLANS supported on this device.
(
dot1qMaxSupportedVlans) - $bridge->qb_vlans()
-
Current number of VLANs that are configured in this device.
(
dot1qNumVlans) - $bridge->qb_next_vlan_index()
-
The next available value for
dot1qVlanIndexof a local VLAN entry indot1qVlanStaticTable(
dot1qNextFreeLocalVlanIndex)
TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash.
- $bridge->i_vlan()
-
Returns a mapping between
ifIndexand the PVID or default VLAN. - $vtp->i_untagged()
-
An alias for
i_vlan. - $bridge->i_vlan_membership()
-
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"; } - $bridge->i_vlan_membership_untagged()
-
Returns reference to hash of arrays: key =
ifIndex, value = array of VLAN IDs. These are the VLANs which are members of the untagged egress list for the port. - $bridge->qb_i_vlan_t()
-
Returns reference to hash: key =
dot1dBasePort, value = either 'trunk' for tagged ports or the VLAN ID. - $bridge->qb_fdb_index()
-
Returns reference to hash: key = FDB ID, value = VLAN ID.
An FDB ID shared by several VLANs (shared VLAN learning) maps to
undef. - $bridge->v_index()
-
Returns VLAN IDs
Forwarding Table (dot1dTpFdbEntry)
Some devices serve this table once per VLAN, each in its own SNMP context. Check with "context_kinds" in SNMP::Info.
- $bridge->fw_mac()
-
Returns reference to hash of forwarding table MAC Addresses
(
dot1dTpFdbAddress) - $bridge->fw_port()
-
Returns reference to hash of forwarding table entries port interface identifier (iid)
(
dot1dTpFdbPort) - $bridge->fw_status()
-
Returns reference to hash of forwarding table entries status
(
dot1dTpFdbStatus)
Bridge Port Table (dot1dBasePortEntry)
- $bridge->bp_index()
-
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
(
dot1dBasePortIfIndex) - $bridge->bp_port()
-
Returns reference to hash of bridge port table entries for a port which (potentially) has the same value of
dot1dBasePortIfIndexas another port on the same bridge, this object contains the name of an object instance unique to this port.(
dot1dBasePortCircuit)
Spanning Tree Instance Globals
These are not part of a table, but return a hash reference to ease API compatibility with MST and PVST implementations indexed by a spanning tree instance id.
- $bridge->stp_i_time()
-
Returns time since last topology change detected. (100ths/second)
(
dot1dStpTimeSinceTopologyChange) - $bridge->stp_i_time()
-
Returns the total number of topology changes detected.
(
dot1dStpTopChanges) - $bridge->stp_i_root()
-
Returns root of STP.
(
dot1dStpDesignatedRoot) - $bridge->stp_i_root_port()
-
Returns the port number of the port that offers the lowest cost path to the root bridge.
(
dot1dStpRootPort) - $bridge->stp_i_priority()
-
Returns the port number of the port that offers the lowest cost path to the root bridge.
(
dot1dStpPriority)
Spanning Tree Protocol Table (dot1dStpPortTable)
Descriptions are straight from BRIDGE-MIB.my
- $bridge->stp_p_id()
-
"The port number of the port for which this entry contains Spanning Tree Protocol management information."
(
dot1dStpPort) - $bridge->stp_p_priority()
-
"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) - $bridge->stp_p_enable()
-
"The enabled/disabled status of the port."
(
dot1dStpPortEnable) - $bridge->stp_p_state()
-
"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)."disabled(1) blocking(2) listening(3) learning(4) forwarding(5) broken(6)(
dot1dStpPortState) - $bridge->stp_p_cost()
-
"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) - $bridge->stp_p_root()
-
"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) - $bridge->stp_p_bridge()
-
"The Bridge Identifier of the bridge which this port considers to be the Designated Bridge for this port's segment."
(
dot1dStpPortDesignatedBridge) - $bridge->stp_p_port()
-
(
dot1dStpPortDesignatedPort)"The Port Identifier of the port on the Designated Bridge for this port's segment."
- $bridge->i_stp_port()
-
Returns the mapping of (
dot1dStpPortDesignatedPort) to the interface index (iid). - $bridge->i_stp_state()
-
Returns the mapping of (
dot1dStpPortState) to the interface index (iid): the port state in the device's default spanning tree.BRIDGE-MIBindexes spanning tree ports by port number alone, with no instance or VLAN. On a device running more than one tree (MSTP instances, a tree per VLAN, or vendor STP domains) this is the one tree the agent exposes in the polled context, not the port's state in every VLAN. A class whose platform exposes a different tree says so in its own documentation. See "Spanning Tree Trees" for every tree the device runs. - $bridge->i_stp_id()
-
Returns the mapping of (
dot1dStpPort) to the interface index (iid). - $bridge->i_stp_bridge()
-
Returns the mapping of (
dot1dStpPortDesignatedBridge) to the interface index (iid).
Spanning Tree Trees
These methods report each spanning tree a device runs, and its ports' state, role, designated bridge and designated port, one tree at a time. Every record names its tree, so a row read out of context still says which tree it describes. Read the tree list in the default context and keep it: update() clears the cache on every context switch. Where trees are served in other contexts, see "SNMP Contexts" in SNMP::Info.
This class reports the BRIDGE-MIB tree as the common tree, the one tree under RSTP and the CIST under MSTP, with its protocol unknown. Classes that read a vendor's protocol and trees override these methods.
A class that can read which protocol a device runs also defines hasSTP(), hasRSTP(), hasMSTP(), hasPVST(), hasRapidPVST() or hasVSTP(), each true when the device runs that protocol, read from an object that names the protocol and never from a table having rows. As with has_topo() in SNMP::Info, test can() before calling one.
- $bridge->stp_protocols()
-
Returns a reference to an array of the spanning tree protocols the device runs, or nothing when no tree was read:
stp,rstp,mstp,pvst(PVST+),rapid-pvst(Rapid-PVST+),vstp(Juniper VLAN Spanning Tree, one tree per VLAN in its own context) ordot1d.dot1dmeans aBRIDGE-MIBtree is served but no object says which protocol it is. Nothing does not mean the device runs no spanning tree: checkstp_trees_complete(). - $bridge->stp_trees()
-
Returns reference to hash of tree records, keyed by tree key (
cist.0). Each record holdstypeandid;protocol, undef where the device does not say;measured, true only where the platform's data was checked against the device's CLI;ports_complete, false when port rows were dropped;contexts, the contexts that serve the tree, in order, each as "snmp_context" in SNMP::Info describes it (kindnonemeans the default context); read the tree's ports in any one of them, and union the rows where several are listed;bridge, the device's own bridge ID; androot, the designated root. Bridge IDs are hashes ofpriority,sys_id_ext,macandraw, the served value; the device's ownrawis built fromdot1dStpPriorityanddot1dBaseBridgeAddress.Returns nothing, with
error()set, when the session is in a non-default context, since only the default context serves the whole list. - $bridge->stp_trees_complete()
-
Returns 1 when the tree list holds every tree the device runs, 0 when trees may exist that were not read (including a device whose class does not read its trees), and nothing when the device serves no tree. Vendor classes that read their own trees return 0, not nothing, when no tree was read.
- $bridge->stp_vlan_map()
-
Returns reference to hash mapping each VLAN id to the key of the tree that carries it, as the device serves the map, or nothing where it serves none. This class serves none: one
BRIDGE-MIBtree carries every VLAN. - $bridge->stp_tree_ports($tree_key)
-
Returns reference to hash of port records for the tree
$tree_key, keyed by interface index (iid), read in the session's current context. Each record holdstree_typeandtree_id,state,enabled(1 when the device runs spanning tree on the port, 0 when it does not, undef where not served),role(one ofdisabled,root,designated,alternate,backup,boundaryormaster, undef where not served or not known),role_raw(the role as served, undef where not served),designated_bridge(a bridge ID as above) anddesignated_port(a hash ofpriority,portandraw). A port whose designated bridge is another bridge connects to that bridge's designated port.Returns nothing, with
error()set, for a key not instp_trees().
Q-BRIDGE Port VLAN Table (dot1qPortVlanTable)
- $bridge->qb_i_vlan()
-
The PVID, the VLAN ID assigned to untagged frames or Priority-Tagged frames received on this port.
(
dot1qPvid) - $bridge->qb_i_vlan_type()
-
Either
admitAlloradmitOnlyVlanTagged. This is a good spot to find trunk ports.(
dot1qPortAcceptableFrameTypes) - $bridge->qb_i_vlan_in_flt()
-
When this is
truethe device will discard incoming frames for VLANs which do not include this Port in its Member set. Whenfalse, the port will accept all incoming frames.(
dot1qPortIngressFiltering)
Q-BRIDGE VLAN Current Table (dot1qVlanCurrentTable)
- $bridge->qb_cv_egress()
-
The set of ports which are assigned to the egress list for this VLAN.
(
dot1qVlanCurrentEgressPorts) - $bridge->qb_cv_untagged()
-
The set of ports which should transmit egress packets for this VLAN as untagged.
(
dot1qVlanCurrentUntaggedPorts) - $bridge->qb_cv_stat()
-
Status of the VLAN, other, permanent, or dynamicGvrp.
(
dot1qVlanStatus)
Q-BRIDGE VLAN Static Table (dot1qVlanStaticTable)
- $bridge->qb_v_name()
-
Human-entered name for vlans.
(
dot1qVlanStaticName) - $bridge->qb_v_egress()
-
The set of ports which are assigned to the egress list for this VLAN.
(
dot1qVlanStaticEgressPorts) - $bridge->qb_v_fbdn_egress()
-
The set of ports which are prohibited from being included in the egress list for this VLAN.
(
dot1qVlanForbiddenEgressPorts) - $bridge->qb_v_untagged()
-
The set of ports which should transmit egress packets for this VLAN as untagged.
(
dot1qVlanStaticUntaggedPorts) - $bridge->qb_v_stat()
-
active!(
dot1qVlanStaticRowStatus)
Q-BRIDGE Filtering Database Table (dot1qFdbTable)
- $bridge->qb_fw_mac()
-
Returns reference to hash of forwarding table MAC Addresses
(
dot1qTpFdbAddress) - $bridge->qb_fw_port()
-
Returns reference to hash of forwarding table entries port interface identifier (iid)
(
dot1qTpFdbPort) - $bridge->qb_fw_vlan()
-
Returns reference to hash of forwarding table entries VLAN ID
Entries whose FDB ID is shared by several VLANs have an
undefVLAN ID. Entries whose FDB ID has no mapping use the FDB ID as the VLAN ID. - $bridge->qb_fw_status()
-
Returns reference to hash of forwarding table entries status
(
dot1qTpFdbStatus)
SET METHODS
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.
- $bridge->set_i_vlan(vlan, ifIndex)
-
Currently unsupported. Throws an error and returns.
- $bridge->set_i_untagged(vlan, ifIndex)
-
An alias for
set_i_vlan. - $bridge->set_i_pvid(pvid, ifIndex)
-
Currently unsupported. Throws an error and returns.
- $bridge->set_add_i_vlan_tagged(vlan, ifIndex)
-
Currently unsupported. Throws an error and returns.
- $bridge->set_remove_i_vlan_tagged(vlan, ifIndex)
-
Currently unsupported. Throws an error and returns.