NAME

SNMP::Info::Layer2::TPLink - SNMP Interface to TP-Link Layer2 devices

AUTHORS

Dmitry Sergienko <dmitry.sergienko@gmail.com> and Eric Miller

based on work by the Netdisco Developer Team

SYNOPSIS

# Let SNMP::Info determine the correct subclass for you.
my $tplink = new SNMP::Info(
                         AutoSpecify => 1,
                         Debug       => 1,
                         DestHost    => 'myswitch',
                         Community   => 'public',
                         Version     => 2
                       )
 or die "Can't connect to DestHost.\n";

my $class = $tplink->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";

DESCRIPTION

Provides abstraction to the configuration information obtainable from a TP-Link JetStream or Omada switch through SNMP. TP-Link private MIBs supply system information, VLANs, PoE, spanning tree, LLDP neighbors and the dynamic address table where the standard MIBs are absent or incomplete.

Inherited Classes

SNMP::Info::EtherLike
SNMP::Info::Layer2

Required MIBs

Inherited MIBs

See "Required MIBs" in SNMP::Info::EtherLike for its MIB requirements.

See "Required MIBs" in SNMP::Info::Layer2 for its MIB requirements.

GLOBALS

These are methods that return scalar value from SNMP

Returns 'TP-Link'

Returns 'tplink'

Returns the software version from tp_sysinfo_swver. When that is absent or empty, returns the first dotted number found in sysDescr.

Returns the first non-blank of tp_sysinfo_hwver (the short model with hardware version, e.g. T1600G-28TS 3.0), tp_sysinfo_descr, and sysDescr, with surrounding space removed.

Returns the serial number from tp_sysinfo_serial, or undef when it is absent or blank.

Returns the base MAC address from b_mac. When that is absent, returns tp_sysinfo_mac in upper case with colon separators.

Returns the TP-Link system description, which holds the product name.

(tpSysInfoDescription)

Returns the administratively assigned host name.

(tpSysInfoHostName)

Returns the hardware version of the product.

(tpSysInfoHwVersion)

Returns the software version of the product.

(tpSysInfoSwVersion)

Returns the system MAC address as text, for example 74-DA-88-68-2A-D2.

(tpSysInfoMacAddr)

Returns the serial number. netdisco-mibs names this object tpSysInfoUpTime, so it is polled by number (netdisco/netdisco-mibs#281).

(tpSysInfoSerialNum, .1.3.6.1.4.1.11863.6.1.1.8.0)

Returns the maximum power the PoE switch supplies, in watts.

(tpSystemPowerLimit)

Returns the real time PoE power consumption, in watts.

(tpSystemPowerConsumption)

Returns the real time remaining PoE power, in watts.

(tpSystemPowerRemain)

Returns the internal power supply status as the device reports it. netdisco-mibs lacks TPLINK-POWERSUPPLYUNIT-MIB, so it is polled by number (netdisco/netdisco-mibs#281).

(powerSupplyUnitInternalPower, .1.3.6.1.4.1.11863.6.88.1.1.3.0)

Returns the external power supply status as the device reports it. netdisco-mibs lacks TPLINK-POWERSUPPLYUNIT-MIB, so it is polled by number (netdisco/netdisco-mibs#281).

(powerSupplyUnitExternalPower, .1.3.6.1.4.1.11863.6.88.1.1.4.0)

Overrides

Returns true when "hasLLDP" in SNMP::Info::LLDP is true, or when the TP-Link neighbor table (tp_lldp_rem_id) has rows. Otherwise returns false.

Returns the spanning tree mode: stp, rstp or mstp.

(tpStpMode)

Returns the time of the last topology change as text.

(tpStpLastTopologyChangeTime)

Returns the CIST root bridge.

(tpStpCISTRoot)

Returns the root port.

(tpStpRootPort)

Returns the bridge priority in the CIST.

(tpStpCistPriority)

Returns reference to a hash keyed by VLAN ID. Values are the VLAN IDs. Declared as a global, but it walks the TP-Link VLAN table column in place of the Q-BRIDGE VLAN index.

(TPLINK-DOT1Q-VLAN-MIB::dot1qVlanId)

Returns reference to a hash keyed by VLAN ID. Values are the VLAN descriptions. Declared as a global, but it walks the TP-Link VLAN table column in place of the Q-BRIDGE VLAN name.

(TPLINK-DOT1Q-VLAN-MIB::dot1qVlanDescription)

Global Methods imported from SNMP::Info::EtherLike

See "GLOBALS" in SNMP::Info::EtherLike for details.

Global Methods imported from SNMP::Info::Layer2

See "GLOBALS" in SNMP::Info::Layer2 for details.

TABLE METHODS

These are methods that return tables of information in the form of a reference to a hash.

Overrides

Returns reference to hash. Port name per ifIndex: i_alias when not blank, else ifName. When i_alias has no rows, tp_port_config_descr supplies the alias instead.

Returns reference to hash. Duplex per ifIndex. Uses el_duplex (EtherLike, full or half, other states omitted) when it returns any rows, otherwise parses tp_lldp_oper_mau (unknown when the string has no duplex).

Returns reference to hash. Configured duplex per port: half, full or auto.

(tpPortConfigDuplex)

Returns reference to hash. Configured speed per port, for example speed-1Gigabps or auto.

(tpPortConfigSpeed)

Returns reference to hash of forwarding table entries port interface identifier (iid). Values come from qb_fw_port (Q-BRIDGE or the TP-Link dynamic table) or else BRIDGE-MIB. Port 0 (not learned) is dropped. A port number resolves to the single u/s/number interface (ambiguous on a stack), else an existing ifIndex, else bp_index. Unresolved values stay as reported.

Returns reference to hash of Q-BRIDGE forwarding table ports, keyed vlan.mac. Uses dot1qTpFdbPort when present, otherwise builds it from tpl2BridgeManageDynPort (index mac.vlan). A u/s/p value resolves through the interface port map, a port number through the single u/s/number interface, then bp_index. Unresolved values stay as reported.

Returns reference to hash. PVID per ifIndex from tp_vlan_port_pvid. When that column is empty, the VLAN a port is untagged in, for ports untagged in exactly one VLAN.

Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs (sorted, no repeats) from the tagged and untagged port lists. Tokens the parser does not know, such as Tunnel1, are skipped. Q-BRIDGE is not polled.

Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs from the untagged port lists only.

Returns reference to hash. PVID per ifIndex. netdisco-mibs names column 2 vlanPortType with enumerated labels, so the device may return trunk for VLAN 1; munge_tp_pvid maps the label back. It is polled by number (netdisco/netdisco-mibs#281).

(vlanPortPvid, .1.3.6.1.4.1.11863.6.14.1.1.1.1.2)

Returns reference to hash. Tagged member port list per VLAN ID, as text such as 1/0/15-18,LAG1.

(vlanTagPortMemberAdd)

Returns reference to hash. Untagged member port list per VLAN ID, as text.

(vlanUntagPortMemberAdd)

Power Over Ethernet Port Table

These methods emulate the POWER-ETHERNET-MIB Power Source Entity (PSE) Port Table pethPsePortTable methods using the TPLINK-POWER-OVER-ETHERNET-MIB PoE Port Configuration Table tpPoePortConfigTable. Entries are keyed unit.port with unit 1; ports without a matching interface are omitted.

Returns reference to hash. Maps unit.port to ifIndex for every port in tp_peth_port_admin that has an interface.

Administrative status: is this port permitted to deliver power? true or false, from tp_peth_port_admin.

Current status, from tp_peth_port_status: on is deliveringPower; off and turning-on are searching; overload, short, voltage-high, voltage-low, hardware-fault and overtemperature are fault; anything else is otherFault. A port with tp_peth_port_admin disable is disabled.

Device class as the device reports it, for example class3, from tp_peth_port_class.

The power, in milliwatts, that the port is delivering, from tp_peth_port_power.

The PoE power budget, in watts: {1 => $watts} from tp_power_limit, else an empty hash.

The PoE module status: {1 => 'on'} when tp_power_limit is reported, else an empty hash.

Returns reference to hash. PoE enabled per port number: disable or enable.

(tpPoePortStatus)

Returns reference to hash. PoE power state per port number, for example on, off or overload.

(tpPoePowerStatus)

Returns reference to hash. PoE class per port number.

(tpPoeClass)

Returns reference to hash. Real time power per port number, in units of 0.1 W.

(tpPoePower)

LLDP Neighbor Information

The neighbor source is decided once per device: LLDP-MIB when it has remote rows, in which case these methods defer to SNMP::Info::LLDP, otherwise the TPLINK-LLDPINFO-MIB lldpNeighborInfoTable, keyed ifIndex.remIdx.

Returns reference to hash. Local ifIndex per neighbor. With TP-Link neighbor data, the first component of the ifIndex.remIdx index. With LLDP-MIB neighbors, the local port number in the index is mapped through lldpLocPortId to the interface whose ifDescr matches exactly; a port with no exact match keeps the result of the inherited lldp_if.

Returns reference to hash. With LLDP-MIB neighbors, the lldpRemManAddrTable rows keyed by the lldpRemTable index. Rows indexed without lldpRemTimeMark (localPort.remIndex.subtype.len.addr), as some Omada firmware returns them, take the index of the neighbor with the same localPort.remIndex and the newest lldpRemTimeMark; rows matching no neighbor are omitted. Otherwise the column as read.

(lldpRemManAddrIfSubtype)

Returns reference to hash. Remote IPv4 management address per neighbor from tp_lldp_rman. ::a.b.c.d is returned as a.b.c.d; :: and IPv6 are omitted.

Returns reference to hash. Remote IPv6 management address per neighbor from tp_lldp_rman, as reported. :: and ::a.b.c.d are omitted.

Returns reference to hash. Remote port per neighbor: tp_lldp_rem_pid, else tp_lldp_rem_desc.

Returns reference to hash. Remote chassis id per neighbor from tp_lldp_rem_id, as reported.

Returns reference to hash. Remote platform per neighbor: tp_lldp_rem_sysdesc, else tp_lldp_rem_sysname.

Returns reference to hash of arrays. Remote capabilities per neighbor as LLDP-MIB names such as bridge and router, parsed from the tp_lldp_rem_cap_spt text. Unknown words are dropped.

Returns reference to hash. Remote chassis id as text, for example 48:A9:8A:C1:AC:58.

(lldpNeighborChassisId)

Returns reference to hash. Remote port id (column 6). Column 1, lldpNeighborPortId, is the local port.

(lldpNeighborPortIdDescr)

Returns reference to hash. Remote port description.

(lldpNeighborPortDescr)

Returns reference to hash. Remote system name.

(lldpNeighborDeviceName)

Returns reference to hash. Remote system description.

(lldpNeighborDeviceDescr)

Returns reference to hash. Remote capabilities as text, for example Bridge Router.

(lldpNeighborCapAvailable)

Returns reference to hash. Remote management address as text, for example ::169.254.2.131.

(lldpNeighborManageIpAddr)

Returns reference to hash. Local operational MAU per ifIndex, for example speed(1000M)/duplex(Full). Used by i_duplex when EtherLike is absent.

(lldpLocalOperMau)

Spanning Tree Port Table

These methods map the TPLINK-SPANNING-TREE-MIB objects onto the SNMP::Info::Bridge spanning tree methods.

Returns reference to hash. CIST root bridge.

(tpStpCISTRoot)

Returns reference to hash. Time of the last topology change.

(tpStpLastTopologyChangeTime)

Returns reference to hash. Root port.

(tpStpRootPort)

Returns reference to hash. Bridge priority in the CIST.

(tpStpCistPriority)

Returns reference to hash. Port number of the switch.

(tpStpPortNumber)

Returns reference to hash. Port priority.

(tpStpPortPriority)

Returns reference to hash. Port state, for example blocking or forwarding.

(tpStpPortStatus)

Returns reference to hash. Internal path cost of the port.

(tpStpPortInPathCost)

Returns reference to hash. Port role, for example root or designated.

(tpStpPortRole)

Returns reference to hash. Edge port setting: disable or enable.

(tpStpEdgePortStatus)

Returns reference to hash. Edge port status, read from the same object as is_edgeport_admin.

(tpStpEdgePortStatus)

Port Configuration and Dynamic Address Tables

Returns reference to hash. Port description, used by i_name when ifAlias has no rows.

(tpPortConfigDescription)

Returns reference to hash. Dynamic MAC address, indexed mac.vlan.

(tpl2BridgeManageDynMac)

Returns reference to hash. VLAN ID of the dynamic MAC address.

(tpl2BridgeManageDynVlanId)

Returns reference to hash. Port of the dynamic MAC address, as a u/s/p name or a port number. Used by qb_fw_port when Q-BRIDGE is absent.

(tpl2BridgeManageDynPort)

Table Methods imported from SNMP::Info::EtherLike

See "TABLE METHODS" in SNMP::Info::EtherLike for details.

Table Methods imported from SNMP::Info::Layer2

See "TABLE METHODS" in SNMP::Info::Layer2 for details.

Data Munging Callback Subroutines

Converts tenths of a watt to watts. Undef and zero return 0.

Maps the vlanPortType labels access, trunk and general back to 0, 1 and 2; other values are returned unchanged.