SNMP::...Bridge(3pm)

okay bestie, welcome to the SNMP::Info::Bridge manual page πŸ’– it’s from User Contributed Perl Documentation, section 3pm. this is part one of two, so don’t wander off β€” there’s more coming.

πŸŽ€ NAME πŸŽ€

SNMP::Info::Bridge β€” the SNMP Interface to SNMP data available through the BRIDGE-MIB (RFC1493). yes, it’s giving network-gremlin energy and we’re obsessed. slay ✨

✨ AUTHOR ✨

Max Baker. that’s the whole author list, periodt. πŸ‘‘


🌈 SYNOPSIS 🌈

here’s the code, copied exactly because we do not mess with the facts:

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";
}

πŸ’– DESCRIPTION πŸ’–

so BRIDGE-MIB is used by most Layer 2 devices, and it holds info like the MAC Forwarding Table and Spanning Tree Protocol info. iconic behavior, honestly. πŸ¦‹

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. like, do not, bestie, fr fr. πŸ›‘

For debugging you can call new() directly as you would in SNMP::Info

my $bridge = new SNMP::Info::Bridge(...);

🧬 Inherited Classes 🧬

None. like, absolutely none, no cap. 🫢

πŸ“š Required MIBs πŸ“š

  • BRIDGE-MIB
  • Q-BRIDGE-MIB
  • RSTP-MIB

πŸ‘‘ GLOBALS πŸ‘‘

These are methods that return scalar values from SNMP β€” so they’re the little single-value serves, okay? πŸ’…βœ¨

  • $bridge->b_mac() β€” Returns the MAC Address of the root bridge port. MIB object: ("dot1dBaseBridgeAddress") πŸ’–
  • $bridge->b_ports() β€” Returns the number of ports in device. MIB object: ("dot1dBaseNumPorts") πŸ”₯
  • $bridge->b_type() β€” Returns the type of bridging this bridge can perform, transparent and/or source route. MIB object: ("dot1dBaseType") 🌈
  • $bridge->stp_ver() β€” Returns what version of STP the device is running. MIB object: ("dot1dStpProtocolSpecification") πŸŽ€
  • $bridge->stp_time() β€” Returns time since last topology change detected. (100ths/second) MIB object: ("dot1dStpTimeSinceTopologyChange") ⏳
  • $bridge->stp_root() β€” Returns root of STP. MIB object: ("dot1dStpDesignatedRoot") πŸ‘‘
  • $bridge->qb_vlans_max() β€” Maximum number of VLANS supported on this device. MIB object: ("dot1qMaxSupportedVlans") πŸ“
  • $bridge->qb_vlans() β€” Current number of VLANs that are configured in this device. MIB object: ("dot1qNumVlans") 🧚
  • $bridge->qb_next_vlan_index() β€” The next available value for "dot1qVlanIndex" of a local VLAN entry in "dot1qVlanStaticTable". MIB object: ("dot1qNextFreeLocalVlanIndex") πŸ’œ

πŸ’– TABLE METHODS πŸ’–

okay so these are the methods that just hand you whole tables, and they do it in the form of a reference to a hash. table szn besties πŸ“

  • $bridge->i_vlan() β€” maps ifIndex ↔ the PVID (or the default VLAN). giving you the receipts on which port lives in which VLAN.
  • $vtp->i_untagged() β€” an alias for i_vlan. same energy, different name. slay.
  • $bridge->i_vlan_membership() β€” returns a reference to a hash of arrays: the key is ifIndex, and the value is an array of VLAN IDs. these are the VLANs that are members of the egress list for that 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() β€” same shape, reference to a hash of arrays: key = ifIndex, value = array of VLAN IDs. but these are the VLANs on the untagged egress list for the port. the chill ones. πŸ¦‹
  • $bridge->qb_i_vlan_t() β€” returns a reference to a hash: key = dot1dBasePort, value = either 'trunk' for tagged ports, or the VLAN ID. trunk detection era πŸ’…
  • $bridge->qb_fdb_index() β€” returns a reference to a hash: key = FDB ID, value = VLAN ID. the crosswalk between the two.
  • $bridge->v_index() β€” returns VLAN IDs. short, sweet, iconic.

🌈 Forwarding Table (dot1dTpFdbEntry)

  • $bridge->fw_mac() β€” returns a reference to a hash of forwarding table MAC Addresses

(dot1dTpFdbAddress)

  • $bridge->fw_port() β€” returns a reference to a hash of forwarding table entries port interface identifier (iid)

(dot1dTpFdbPort)

  • $bridge->fw_status() β€” returns a reference to a hash of forwarding table entries status

(dot1dTpFdbStatus)

🌸 Bridge Port Table (dot1dBasePortEntry)

  • $bridge->bp_index() β€” returns a reference to a hash of bridge port table entries, mapped back to the interface identifier (iid)

(dot1dBasePortIfIndex)

  • $bridge->bp_port() β€” returns a reference to a hash of bridge port table entries for a port which (potentially) has the same value of dot1dBasePortIfIndex as another port on the same bridge. in that case, this object contains the name of an object instance unique to this port. lowkey the "which one tho" problem, solved.

(dot1dBasePortCircuit)

πŸ”₯ Spanning Tree Instance Globals

these ones are not part of a table, but they still return a hash reference β€” purely to keep the API compatible with MST and PVST implementations that get indexed by a spanning tree instance id. compatibility queen πŸŽ€

  • $bridge->stp_i_time() β€” returns the time since the last topology change was detected. (100ths/second)

(dot1dStpTimeSinceTopologyChange)

  • $bridge->stp_i_time() β€” returns the total number of topology changes detected. yep, it's listed again under the same name and fr fr we're keeping it exactly as written, no cap πŸ™ˆ

(dot1dStpTopChanges)

  • $bridge->stp_i_root() β€” returns the 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. the shortest-route girlie πŸ’…

(dot1dStpRootPort)

  • $bridge->stp_i_priority() β€” returns the port number of the port that offers the lowest cost path to the root bridge. (literally the same sentence as above, and we are not editing the source, bestie)

(dot1dStpPriority)

✨ Spanning Tree Protocol Table (dot1dStpPortTable)

heads up: these descriptions are straight from BRIDGE-MIB.my. verbatim, untouched, we don't gatekeep the original prose. 🫢

  • $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_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).
  • $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).

πŸ’œ Q-BRIDGE Port VLAN Table (dot1qPortVlanTable)

  • $bridge->qb_i_vlan() β€” the PVID: the VLAN ID that's assigned to untagged frames or Priority-Tagged frames received on this port.

(dot1qPvid)

  • $bridge->qb_i_vlan_type() β€” either "admitAll" or "admitOnlyVlanTagged". this is a good spot to find your trunk ports, bestie β€” go look here first. πŸ‘€

(dot1qPortAcceptableFrameTypes)

  • $bridge->qb_i_vlan_in_flt() β€” when this is "true", the device discards incoming frames for VLANs that don't include this Port in their Member set. when it's "false", the port accepts all incoming frames. the vibe check, but for frames. 🧚

(dot1qPortIngressFiltering)

🌟 Q-BRIDGE VLAN Current Table (dot1qVlanCurrentTable)

  • $bridge->qb_cv_egress() β€” the set of ports assigned to the egress list for this VLAN.

(dot1qVlanCurrentEgressPorts)

  • $bridge->qb_cv_untagged() β€” the set of ports that 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() β€” the human-entered name for vlans. yes, an actual person typed it. respect. ✍️

(dot1qVlanStaticName)

  • $bridge->qb_v_egress() β€” the set of ports assigned to the egress list for this VLAN.

(dot1qVlanStaticEgressPorts)

  • $bridge->qb_v_fbdn_egress() β€” the set of ports that are prohibited from being included in the egress list for this VLAN. the banned list, periodt.

(dot1qVlanForbiddenEgressPorts)

  • $bridge->qb_v_untagged() β€” the set of ports that 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 a reference to a hash of forwarding table MAC Addresses

(dot1qTpFdbAddress)

  • $bridge->qb_fw_port() β€” returns a reference to a hash of forwarding table entries port interface identifier (iid)

(dot1qTpFdbPort)

  • $bridge->qb_fw_vlan() β€” returns a reference to a hash of forwarding table entries VLAN ID
  • $bridge->qb_fw_status() β€” returns a reference to a hash of forwarding table entries status

(dot1qTpFdbStatus)


πŸ’… SET METHODS πŸ’…

okay so these are the methods that give you SNMP set functionality β€” either for overridden methods, or a simpler interface to set operations that are, frankly, a whole lot. for the general info on set operations, go read "SETTING DATA VIA SNMP" in SNMP::Info. iykyk.

ngl bestie, this whole section is currently unsupported. every single one throws an error and returns. that's not me being dramatic, that's just what it says. 😭
  • $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. so, same energy. same error. 🫠
  • $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.

and that's the whole page, bestie β€” you made it to the end and you ate πŸ’–βœ¨ this beauty was cooked up around perl v5.40.1, dated 2026-02-28, and it lives at SNMP::...Bridge(3pm) in the User Contributed Perl Documentation collection. go forth and snmp. πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from