Compare commits

..

1 Commits

Author SHA1 Message Date
cvs2svn
ea7eb9c71f This commit was manufactured by cvs2svn to create tag 'ver_0_3'.
Sprout from master 2003-03-06 21:56:22 UTC Max Baker 'ver_03'
Delete:
    t/prereq.t
2003-03-06 21:56:23 +00:00
106 changed files with 4198 additions and 43424 deletions

View File

@@ -1,8 +1,3 @@
All code from version 0.7 on
Copyright (c) 2003-2009 Max Baker and SNMP::Info Developers
All rights reserved.
Original Code
Copyright (c) 2002,2003 Regents of the University of California
All rights reserved.

386
ChangeLog
View File

@@ -1,388 +1,17 @@
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
version 2.06 (2011-09-28)
[NEW FEATURES]
* Support for PacketFront devices in new class L3::PacketFront
* Support for Mikrotik devices in new class L3::Mikrotik
* Support for HP VirtualConnect switches in new class L2::HPVC
* Support for ADSL-LINE-MIB in new class AdslLine
[ENHANCEMENTS]
* POD clarification on i_speed() munging by Info.pm
* Added i_stack_status method that can be used for finding the parent
interface for e.g. ADSL interface speed determination
[BUG FIXES]
* [3344843] Fix returning serial() and os_ver() for web-managable HP
switches, introduced by HP/HP4000 class split, reported by J R Binks
* [2809033] Put L2-only Cisco blade switches in L3::C6500
* [3408506] Fix uninitialized value in IPv6 when neighbor state is
incomplete (Michael Borgelt)
version 2.05 (2011-06-23)
+ Fix broken function call in L2::Aironet
+ Promote L2::Aruba to L3::Aruba, as Aruba devices can be L3 entities and
provide L3 information.
version 2.04 (2011-03-31)
+ Support for older HP switch models moved to new L2::HP4000 class
+ Fix VLAN changing in L2::HP and L2::HP4000 classes
* Updated model lists in HP classes
+ [2980782] Added L3::CiscoFWSM for Cisco Firewall Services Modules
(Brian De Wolf)
+ Added L3::Pf for FreeBSD PFSense Firewalls (max)
* Added specific functions for neighbor mgmt addresses to CDP class
* Implemented os_bin() method in CiscoStats
+ [2980787] Fix for C1900 bp_index not containing interfaces.
(Brian De Wolf)
+ [2599795] Added vendor_i_type() method to HP and HP4000 clases
+ [2688801] Minor modification for obscure Proxim/Orinoco device
(jrbinks)
+ [3051443] Add PoE measured power per port to Cisco, Extrme and HP
classes (jeroenvi)
* Minor tweaks to support devices without sysServices
* Added Cisco CBS3xxx blade switches to L3::C6500
* Fix for FWSMs not being detected properly. Special thanks goes to
Jukka Pirhonen for pointing it out. (Brian De Wolf)
+ Added support for IPv6 to physical address mapping
* Added ME340x to L3::C3550
* Added new ProCurve models to HP class
* Fixed i_speed_raw not returning raw values (Alexander Hartmaier)
version 2.01 (06/12/09)
+ Added CiscoStpExtensions Class (Carlos Vicente)
+ Added Layer3::Arista (fenner)
+ [2020353] Added L3::Altiga for Cisco (Altiga) VPN3000 Concentrators
(Jeroen van Ingen)
* Fixed RFC1213-MIB vs IF-MIB collision in ifOperStatus
* Updated test_class.pl for better debug info and relative path
* Add cisco vendor detection by OID in Layer3.pm (Sam Stickland)
* Fix CaSe of EtherLike-MIB in EtherLike.pm (Alexander Hartmaier)
* Added Cisco FWSM to L3::Cisco
* Added s222_rp to L3::C6500
* Added CIGESM to L2::C2900
* Added Airespace WLC to L2::Airespace
* Updated POD and DeviceMatrix quite a bit
* Added ENTITY-MIB to CiscoStats for better model handling above
* Fix networkaddress handling in LLDP-MIB
* Added CiscoConfig to L2::Aironet, L3::C3550 classes
* Better SSID capabilities for L2::Aironet
* Fix CDP vs LLDP in c_id() for HP Class
* test_class.pl improvements
version 2.00 (08/01/08)
+ Support for Alcatel-Lucent OmniSwitch via L3::AlcatelLucent
+ Support for Alcatel-Lucent Service Router via L3::Timetra
+ Support for Alcatel-Lucent OmniAccess via L2::Aruba
* Silence warnings in MAU due to uninitialized variables
version 1.09 (07/22/08) - Beta/developer release
+ Added support for HP ProCurve Foundry OEM switches, such as the 9300
series, in new class L3::HP9300 (contributions from Douglas McKeown and
Ivan Auger)
+ Added support for CISCO-PAE-MIB in CiscoPortSecurity (Kesy)
+ Support for D-Link devices through L3::Dell
+ Support for Linksys SRW2048 through L3::Dell
+ Support for IBM BladeCenter 4-Port GB Ethernet Switch Module through
L3::Dell (Alex Kramarov)
+ Support for newer Nortel Alteon switches and Nortel BladeCenter Switch
Modules in L3::AlteonAD
+ Support for Cisco 1250 series through L2::Aironet
+ Updates to fan, power supply, and serial number methods in
L2::HP (Jeroen van Ingen)
+ Use Cisco Client Association MIBs for Aironet client reporting
via fw_mac
+ Support VLANs on Aironet
+ Get the proper radio MAC address from aironet in MBSS mode
+ Additional wireless statistics from Aironet
+ Add support to specify MIB to resolve leaf names conflicts in
%GLOBALS and %FUNCS.
+ Added munge_port_list() and modify_port_list() methods to assist in
working with PortList objects.
+ Added set_multi() method to enable a SNMP set command on several new
values in one request. Required for complex set operations
on some agents.
+ Infrastructure for SNMPv3 support:
+ Save the SecName passed into the constructor
+ Create an update() function, which replaces the underlying
SNMP session using different parameters.
+ Return the SecName instead of community from snmp_comm() when using
SNMPv3.
* L2::HP now isa Layer3 instead of Layer2 to support arpnip
(Dudley Freeman)
* Silence warnings from Cisco devices which don't return values for
extended VLAN range (1024-4096)
* Documentation coverage, spelling, and syntax updates
* set_i_pvid(), set_i_vlan(), set_add_i_vlan_tagged(),
set_remove_i_vlan_tagged() removed from Bridge and HP classes due to
incompatibility across devices.
version 1.07 (11/26/07) - Beta/developer release
version 1.05 (11/25/07) - CVS only. No official release
+ Added support for LLDP in new class LLDP (contributions from Bernhard
Augenstein)
+ Added device specific support for LLDP in L2::HP, L2::Baystack,
L3::Enterasys and L3::Foundry
+ Added support for Enterasys devices as new class L3::Enterasys
+ Added support for Dell PowerConnect switches as new class L3::Dell
+ Added basic support for generic routers running Microsoft Windows OS
as new class L3::Microsoft (begemot)
+ Added basic support for Sun routers as new class L3::Sun (begemot)
+ Added basic support for Juniper NetScreen devices as new class
L3::Netscreen (Kent Hamilton)
+ Added support for Cyclades terminal servers as new class L1::Cyclades
+ Added support for Cisco (Airespace) wireless controllers as new class
L2::Airespace
+ Added support for Nortel Ethernet Routing Switch 2500 series and
Business Ethernet Switches (David Sieb<65>rger)
+ Update of L3::Foundry to support all Foundry devices including newer
switches. Depreciate L2::Foundry.
+ Added generic device type detection using IANA assigned enterpise
number extracted from sysObjectID
+ Added ifDiscards and other missing entries from IF-MIB::ifEntry (Greg King)
+ Added CGESM devices to L2::C2900 class (Alexander Hartmaier)
+ Added support for dual speed 10/100 hubs and i_speed() in L1::Bayhub
+ Added i_ssidlist(), i_ssidbcast(), and i_80211channel() methods to
L2::Aruba, Airespace, and L2::NAP222x classes
+ New class IEEE802dot11 class for generic standards based wireless AP
support to include i_ssidlist()and i_80211channel() methods.
+ L2::Orinoco inherits from new IEEE802dot11 for i_ssidlist()and
i_80211channel() support.
+ Added new VLAN methods i_pvid(), i_vlan_membership(), set_i_pvid(),
set_i_vlan(), set_add_i_vlan_tagged(), set_remove_i_vlan_tagged() to
Bridge, CiscoVTP, Extreme, HP, and RapidCity classes.
+ Added set_i_speed_admin() method to RapidCity class,
+ Added set_i_duplex_admin() method to RapidCity class,
+ Added OSPF Neighbor Tables, SF Patch 1577918 to Layer 3 (Andrew Herrick)
+ Added CiscoConfig class, SF Patch 1555001 (Justin Hunter)
+ Enable load_ methods for %GLOBALS and MIB Leaf node names.
+ Enable dynamic methods in AUTOLOAD with MIB Leaf node names for loaded
MIBs without definition in %FUNCS or %GLOBALS. Single instance mib leafs
will be treated as a GLOBAL and returna scalar while mib leafs which
reside in a table will be treated as a FUNC and return a reference to a
hash.
+ Enable load_ methods for %GLOBALS and MIB Leaf node names.
+ Add loop detect option and code for getnext table column walks.
+ Add Layer3::NetSNMP for Net-SNMP-based hosts, part of
SF patch 1557529 (Bradley Baetz).
+ Add EIGRP Neighbor Tables to L3::Cisco SF Patch 1577927 (Andrew Herrick)
+ Additions to CiscoQOS and CiscoStats (Alexander Hartmaier)
+ Emulate ENTITY-MIB Physical Table methods for devices which don't
have ENTITY-MIB support in Airespace, Bayhub, Baystack, BayRS,
NortelStack, and Passport classes.
+ Enable use of MIB Leaf node names in SNMP sets.
+ Add POWER-ETHERNET-MIB and CISCO-POWER-ETHERNET-EXT-MIB support.
* Fix for bug where an SNMP error in any operation would cause subsequent
table get operations to fail while using the same session, originally
identified by Nicolai Petri.
* Enable single instance partial table fetches (Alexander Hartmaier)
* Enable partial table fetches in overriden table methods (Justin Hunter)
* Allow partial table fetches with load_ methods.
* Fixed vlan trunk port handling bug in L2:HP (Michael Robbert)
* Correct bp_port() definition in Bridge class (Reported by Nicolai Petri)
* Remove port security definitions from CiscoStack and move into new class
CiscoPortSecurity. Needed to support devices such a L3::C4000 which
support CISCO-PORT-SECURITY-MIB, but not CISCO-STACK-MIB.
(Reported by Prakash RudraRaju)
* Correct port numbering for Nortel 8110, 1100, 1150 in L3:Passport
(Reported by David Pinkoski)
* Documentation updates
* Translate OIDs returned by Entity MIB e_type
* Modify inheritance to use Cisco classes before generic classes
* Create e_index method in ENTITY-MIB to facilitate emulation methods in
other classes as entPhysicalIndex is not-accessible.
* Only return MAC from munge_mac() if it actually is a MAC. Fix for
netdisco where device would not be inserted in DB due to malformed MAC.
* Enable SUPER class calls to find autoloaded methods (Bernhard Augenstein)
* Clear attribute cache on sucessful SNMP set.
* Improve accuracy of operational and administrative duplex reporting on
devices using CiscoStack.
* All i_type() methods now use standard IANAifType values.
* Report bridge groups (VLANs) in L2::C1900.
* Turn on bulkwalk for C6500. Users with buggy OS versions can turn
it off when creating the object.
* c_ip() now attempts to return only IPV4 addresses, use c_addr() for all
address types.
version 1.04 (07/08/06)
+ Added C1130 and C1240 to L2::Aironet (Ralf Gross)
+ Added detection for Cisco 2960, 2940, 3400 w/ MetroBase
+ Added generic L2::Cisco Class
* Corrected detection for Cisco Supervisor Engine 2 and 32 (IOS).
* Fixed warnings in CiscoStack
* Updated ProCurve HP device detection for newer firmwares
version 1.03 (04/14/06) - Beta/developer release
* Use ipNetToMedia table instead of atTable for ARP
* Remove CiscoStack from Layer3::C4000
* Fixed bug in MAU class when polling devices without MAU-MIB support
version 1.01 (04/08/06) - Beta/developer release
+ Change version numbers to X.XX format. Odd releases are beta
or developer only releases. Even are official releases.
version 1.0 (04/07/06) - CVS only. No official release
+ Added Interface FlowControl status to CiscoStack (Nicolai Petri)
+ Added CiscoImage class (Matthew Tuttle)
+ Added C1200 and C350 IOS devices to L2::Aironet (Matthew Tuttle)
+ Added support for Foundry IronWare and gave L3::Foundry CPR
+ Added support for Foundry EdgeIrons as new class L2::Foundry
+ Added BulkWalk and BulkRepeaters options to new()
+ Added DebugSNMP option to new()
+ Added CISCO-ENTITY-VENDORTYPE-OID-MIB,CISCO-PRODUCTS-MIB,CISCO-STACK-MIB
to CiscoStats.pm for model()
+ Check for bulkwalk_no() method
+ Added Entity.pm to L3 and L2 classes per N. Petri's suggestion.
+ Added support for Passport/Accelar 1100 and 1200 series in L3::Passport
+ Added support for Passport/Accelar 8100 series in L3::Passport
+ Added support for Passport 1600 series as new class, L3::N1600
+ Added support for Extreme Alpine and Summit switches as new class
L3:Extreme (Mike Hunter and Eric Miller)
+ Added support for Aruba wireless switches (Eric Miller and Brian Chow)
+ Added support for Nortel 2700 series (Airespace) wireless switches
+ Added support for Synoptics hubs as new class L1:S3000
+ Added Cisco QOS and RTT classes (Alexander Hartmaier)
+ Added BGP Peer Table to L3 class (Carlos Vicente)
+ Added ipforwarding status to Info base class (Carlos Vicente)
+ Added STP port state to Bridge class (Alexander Barthel)
+ Added L3 support (arpnip) to Baystack class for routing capable switches
+ Added set_i_duplex_admin() and set_i_speed_admin() to C2900 class
(Justin Hunter)
+ Added set_i_duplex_admin() and set_i_speed_admin() to CiscoStack class
+ CDP added to Aironet class
+ Added Juniper class
+ Added support for Catalyst 4000 and 4500, get admin. duplex
and speed properly
+ Added i_speed_high(), which i_speed() uses if needed to support
interfaces >4Gbps
* More error checking in _load_attr() around bulkwalk code
* Minor warning fix in L3::Aironet::os_ver()
* Abstracted remaining Cisco stuff from L3 to L3::Cisco
* Removed all Cisco stuff from L2
* Expanded Entity.pm to cover the whole ENTITY-MIB and improved docs.
* changed all refs to $DEBUG to $self->debug() for reentrant code
* [ 1111284 ] Parameters not being set with AutoSpecify - fixed.
* Turned off BULKWALK for C1900 and C6500 classes.
* Added exception handling for V2 ENDOFMIBVIEW
* Fix in SONMP when topology not enabled
* Fix in L3::Passport root_ip()
* Fix in L3::Passport bp_index() some devices not returning complete index.
* Enable set_i_up_admin() in Bayhub
* Recognize new Nortel model names in Baystack and Passport classes
* Orinoco class should now recognize more models
* Cleanup model recognition in Baystack class, recognize more models
* Modify Catalyst class to use CISCO-STACK-MIB for brige port index mapping
some devices having problems returning complete index from BRIDGE-MIB
* Check root ip for reachability before assignment
* HP class should recognize more models
* Fix in HP class for models not returning full bp_index
* [ 1436103 ] L2::Aironet devices weren't getting their model
translated properly
verison 0.9 (11/15/04)
+ ** Added full Nortel/Bay/BayStack support
by new developer Eric Miller.
L2::Bay now depricated.
+ Added Alteon Ace support (Eric Miller)
+ Added Nortel Cotivity support (Eric Miller)
+ Added Nortel BayRS support (Eric Miller)
+ Added Nortel Centillion support (Eric Miller)
+ Added Nortel AP 222x support (Eric Miller)
+ Added Orinco AP support (Eric Miller)
+ Added i_lastchange() per suggestion of Nicolai Petri
+ Added BULKWALK patch by Bradley Baetz - This should
greatly speed up requests on SNMPv2c devices.
+ Added MibDirs option to new() to allow specifying non-system MIB
directories.
* Added C3560s to the C3550 class. Thanks to Nicolai.
* Fixed Bug where older Cisco's would append nulls to certain
CDP information. Would come up a 'DBD::Pg parser' error in Netdisco
* Changed so a failed _global() call is cached so it won't retry
an error over and over again if the same global is used.
* Added check in _set() to see if data came from sub or FUNCS/GLOBALS
Fails if came from sub.
version 0.8 (03/21/04)
+ Added Q-BRIDGE-MIB support to SNMP::Info::Bridge
+ Added Aironet AP4800 to Layer3::Aironet class
+ Added C3500XL devices to the Layer2::C2900 class
+ Added Cisco 3750 (37xxstack) to Layer3::C6500 class
+ Added Cisco Catalyst 4000 to Layer3::C6500 class
+ Added Cisco Catalyst 2970 to Layer3::C6500 Class
* Made Cisco Commuinty string indexing a boolean method for clarification
* Added VLAN info for HP devices using Q-BRIDGE-MIB
* Fixed warning about uninitialized value in CiscoStats line 92
* Added for more serial# checking for L2 and L3
* Fixed warning in Layer2::Bay about non numeric port line 199
Contributions from Dmitry Sergienko:
+ Added Cisco Aironet BR500 and AP1200 to L2::Aironet Class
* Fixed the Port name alias for Catalyst 2900 devices
+ Added Support For ZyXEL DSLAMs and Allied Telesys Switches
version 0.7 (08/14/03)
* Added Class for Catalyst 6500 Series - Layer3::C6500
* Added CiscoVTP support to 3550,2900, and Catalyst classes
* Extracted VLAN stuff from Layer2::Catalyst to SNMP::Info::CiscoVTP
* Extracted CISCO-STACK-MIB from Layer2::Catalyst to SNMP::Info::CiscoStack
* Added 2950's to the Layer2::C2900 class
* Added 3548's and 350x's to the Layer3::C3550 class
* Broke out 3550's into separate device types (3550-24, 3550-48)
* Added T1,dual T1, and T3 , ATM over OC-12 ... to the SPEED_MAP
* Fixed speed map -- OC-1 -> OC-3
* Fixed Bug where Catalyst Switch running IOS would report CatOS as os()
version 0.6 (06/18/03)
* Minor Bug Fix. SNMP::Info::Layer2::Bay and SNMP::Info::Layer2::C1900
didn't return 1 and failed to load on some versions of Perl.
version 0.5 (06/10/03)
* Added ability to get paritial tables. For example to get the
IP routing table for 128.114.* you can do
$ipr = $dev->ipr_dest('128.114');
* Added IP Routing Table entries from RFC1213 to SNMP::Info
* minor bug fixes
version 0.4 (04/29/03)
* BIG CHANGE ! Internal Data structure has changed.
* Added clear_cache() method
* Added NO_SUCH support for snmpget (TABLE) calls to get SNMP MIB II data
from SNMP Version 1 devices.
* Methods load_all() and all() have changed their return value. Sorry but
the API had to change.
* New object methods snmp_comm(), snmp_ver(), store(), class(), nosuch()
to make it more OO happy.
* Globals are now cached
* Added new argument 'AutoSpecify' to new() to auto-connect with subclass
detected in device_type()
* New method specify() returns a new subclass object
* Subclasses are automatically loaded when specify or autospecify is used!
* Added methods for Interface statistics (ifInOctets ...)
* Added methods for Memory and CPU statistics
* Added SNMP::Info::Entity, moved out of L2-HP
* Added SNMP::Info::Layer2::Aironet
SNMP::Info - Perl5 OO Interface to Network Devices and SNMP MIBs
ChangeLog $Id$
version 0.3 (03/06/03)
* Fixed HP model() warning
* Added error checking for responses of NOSUCHOBJECT and NOSUCHINSTANCE
in _global and _load_attr
* Added error checking for responses of NOSUCHOBJECT and NOSUCHINSTANCE in _global
and _load_attr
* Added more debugging
* Added info and munging for c_capabilities in SNMP::Info::CD
Thanks to Martin Lorensen <martin /at- lorensen.dk>
Thanks to Martin Lorensen <martin@lorensen.dk>
* Removed requirement for SNMP in the Makefile.PL and moved it to t/prereq.t
so that the Module will install via CPAN without trying to install the old
4.2.0 version of SNMP on CPAN. Will now fail in the test phase.
Thanks again to Martin Lorensen <martin /at- lorensen.dk>
Thanks again to Martin Lorensen <martin@lorensen.dk>
* Moved tests from test.pl to t/*
version 0.2 (02/19/03)
@@ -392,8 +21,7 @@ version 0.2 (02/19/03)
* Added Spanning Tree Protocol (STP) methods to SNMP::Info::Bridge
* Removed HP Specific MIBS in SNMP::Info::Layer2 and cleaned up model()
* Added poke for Bay 450 Switches
* Mapped HP Part Numbers to model numbers J4812A => 2512 in
SNMP::Info::Layer2::HP
* Mapped HP Part Numbers to model numbers J4812A => 2512 in SNMP::Info::Layer2::HP
version 0.1 (12/30/02)
* Initial Release

29
DEVELOP
View File

@@ -1,29 +0,0 @@
SNMP::Info Developer Guidelines
Coding Guidelines:
- tab-width of 4, no tab characters
- keep POD documentation up-to-date
- always update ChangeLog before committing
- always update DeviceMatrix.txt before committing
- check-in required mibs to netdisco-mibs and release new package if needed
Release and Testing Instructions:
- Please see misc/RELEASE in Netdisco
( http://netdisco.cvs.sourceforge.net/viewvc/netdisco/misc/RELEASE?view=markup )
and follow all testing and release guidelines
FAQ:
- Do I have to update the version number and timestamp in modified files before committing?
-> No. These are RCS tags that are automatically updated by CVS when you commit
- Should I add changes at the top of the ChangeLog?
-> Yes. The changelog is created one commit at a time. If there isn't a
section for the current version, then add one at the top and put your
changes after. You can leave the date field for the release empty ().
- What should I change the $VERSION to?
-> If you are the first person to get to a file after a release, update it
to either release++ or "release++ dash cvs".
Example: File is marked 2.01, change it to 2.02-cvs with your new changes.
Example: File is marked 2.02-cvs, no change until packaging for release when the -cvs is removed.
TODO: Is there still an odd/even scheme as introduced by Eric?

View File

@@ -1,865 +0,0 @@
# SNMP Device Compatibility Matrix
# SNMP::Info - (C) 2004 Max Baker
# This file is meant to detail the cababilities
# of network devices to supply data via SNMP.
# $Id$
#
# Airespace (pre-Cisco)
#
device-vendor: Airespace
cdp:no
arpnip: no
macsuck: yes
portmac: yes
duplex: both
vlan: yes
modules: yes
class: Layer2::Airespace
device-family: Airespace Wireless Controllers
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
note: Device will only communicate with SNMP version configured in the controller.
device: 3500, 4101, 4102
#
# Alcatel-Lucent
#
device-vendor: Alcatel-Lucent
device-family: L3
class: Layer3::AlcatelLucent
device: All
device-family: Timetra
class: Layer3::Timetra
device: All
device-family: AOS
class: Layer3::Aruba
device: All
#
# Allied
#
device-vendor: Allied Telesyn
cdp:no
class: Layer1::Allied
ver: 1
arpnip: no
macsuck: no
duplex: no
device-family: Allied Hubs
device: AT-3624T
device-family: AT-8000 Switches
class: Layer2::Allied
ver: 2
macsuck: yes
device: All
#
# Altiga
#
device-vendor: Altiga
class: Layer3::Altiga
note: See Cisco/Altiga
#
# Arista
#
device-vendor: Arista
class: Layer3::Arista
device-family: All
device: All
#
# Aruba
#
device-vendor: Aruba
arpnip: yes
macsuck: yes
portmac: yes
duplex: no
class: Layer3::Aruba
device-family: Aruba Wireless Controllers
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
device: 5000
device: 6000
#
# Asante
#
device-vendor: Asante
class: Layer1::Asante
ver: 1
arpnip: no
macsuck: no
duplex: no
device-family: Asante Hubs
device: 1012
#
# Bay
#
device-vendor: Bay
note: See Nortel
#
# CISCO
#
device-vendor: Cisco
cdp: yes
ver: 2
modules: yes
device-family: Aironet
note: IOS and Aironet OS versions
class: Layer3::Aironet
device: AIRAP1100, AP1200, C1100, C1130, C1240
note: IOS based device
class: Layer2::Aironet
device: BR500
note: Aironet based device
device: AP350, AP340, CAP350, CAP340, 1200, AP4800
note: Aironet based device
device-family: Altiga
class: Layer3::Altiga
device: VPN3000
note: The Cisco 3000 device can return duplicate interface names, while Netdisco expects unique interface names. To ensure unique device names I append numbers only when an interface name would not be unique without one. Interfaces with unique names keep their ifDescr name.
device-family: 1000
duplex: no
ver: 1
class: Layer3::Cisco
device: 1003
device-family: 1700
class: Layer3::Cisco
device: 1710
duplex: link
device-family: 2500
duplex: no
macsuck: yes
arpnip: yes
ver: 1
class: Layer3::Cisco
device: 2501,2503,2511,2514
device: AS2509RJ,AS2511RJ
device-family: 2600
duplex: link
arpnip: yes
macsuck: yes
class: Layer3::Cisco
device:2610, 2610XM, 2611, 2620, 2620XM, 2621, 2621XM, 2651XM, 2691
device-family: 2800
duplex: link
arpnip: yes
macsuck: yes
class: Layer3::Cisco
device: 2811,2821,2851
device-family: 3600
class: Layer3::Cisco
device: 3620
device: 3640
duplex: no
device-family:7200
class: Layer3::Cisco
device:all
#note: Unconfirmed problem : "When scanning my network with netdisco I would find that my 7200 series router running Cisco IOS Software Release 12.2(1) would reboot when scanning for CDP neighbours, to solve the issue I upgraded to Cisco IOS Software Release Version 12.2(37)"
device-family: 7500
class: Layer3::Cisco
device: 7507
duplex: no
note: !Duplex settings are falsely reported in ancient IOS versions
device-family: AS5000
duplex: no
class: Layer3::Cisco
device: AS5300
#
# Cisco - Catalyst
#
device-family: Catalyst 1900
note: !Upgrade older (pre 9.0) versions of CatOS
note: !CatOS ver 9.00.03 through 9.00.06 have problems when trunking. Upgrade to 9.00.07 or higher.
ver: 1
duplex: both
vlan: write
class: Layer2::C1900
device: wsc1900c, wsc1900
device-family: Catalyst 2900
note: IOS
macsuck: vlan
duplex: write
vlan: write
class: Layer2::C2900
portmac: yes
note: !Pre IOS 11.2 (8) SA3 - PortMAC shows up in CAM table.
device: 2912MfXL, 2924CXL, 2924CXLv
device: 2908xl
note: !Pre IOS 11.2 (8.6) some features (duplex...) aren't present.
device: 2924MXL
ver: 1
device-family: Catalyst 2940
note: IOS
macsuck: vlan
duplex: write
vlan: write
class: Layer2::C2900
portmac: yes
device: 2940-8TT
device-family: Catalyst 2950
note: IOS
macsuck: vlan
duplex: write
vlan: write
class: Layer2::C2900
portmac: yes
device: 2950-t24
device-family: Catalyst 2970
macsuck:vlan
duplex: write
vlan: write
note: Acts just like IOS Catalyst 6500 series
class: Layer3::C6500
device: 2960, 2970G-24T-E
device-family: Catalyst 3500 XL
portmac: yes
macsuck: vlan
duplex: write
vlan: write
note: L2 only IOS devices - Just like Catalyst 2900 series from SNMP
note: IOS Version 12.0(5)XP is buggy and doesn't do VLAN Community indexing correctly.
class: Layer2::C2900
device: 3508GXL, 3524XL, 3548XL
device-family: Catalyst 3550
macsuck: vlan
duplex: write
vlan: write
class: Layer3::C3550
note: Run IOS
note: Has VLANs that don't accept SNMP connections. Don't know if they are standard (by name or number).
note: Uses CISCO-STACK-MIB like Catalyst 5000 series for serial,duplex,type but not name
note: Comes in flavors that support L2, L3 or combo.
device: 3550-12T
device: 3400 w/ MetroBase Image
device: 3550, 3560, 3550-24, 3550-48
note: L2/L3 Switch
arpnip: yes
macsuck: vlan
device-family: Catalyst 3750
class: Layer3::C6500
device: 3750
device-family: Catalyst Blade Switch 3xxx
macsuck: vlan
class: Layer3::C6500
note: Cisco Blade switches for Dell, FSC, HP and IBM blade system chassis. Limited testing done.
device-family: Catalyst 4000
duplex: write
macsuck: vlan
vlan: write
class: Layer2::Catalyst
note: Comes in IOS and CatOS versions like the 6k series.
note: !Reported problems with SNMP taking up all the CPU on older SW. Requests take significantly longer.
note: !IOS Version 12.1.8a reported not to respond to BRIDGE-MIB calls.
device: wsc4003, wsc4006, wsc4503, wsc4506
device: wsc4912g
note: Dedicated 12 port gig-e switch
device: 4006
duplex: both
class: Layer3::C4000
note: !Has serious slowdown/timeout problems with SNMP
note: !IOS Software Release 12.2(20)EW or higher required for duplex support
device: 4503, 4506, 4507, 4510
duplex: both
class: Layer3::C4000
note: !Has serious slowdown/timeout problems with SNMP
note: !IOS Software Release 12.2(20)EW or higher required for duplex support
device-family: Catalyst 5000
duplex: write
vlan: write
class: Layer2::Catalyst
device: wsc2926
note: !Can give false information over SNMP at times.
device: wsc2948g, wsc2980g, wsc5500, wsc5505, wsc5509
device: wsc5000
note: !Has nasty tendency to not give you all SNMP data ,flaky for some older Catalyst versions.
device: wsx5302
arpnip: yes
class: Layer3
note: Router blade that runs IOS
device-family: Catalyst 6500
macsuck:vlan
duplex: write
vlan: write
class: Layer3::C6500
note: Runs in two possible modes, native (IOS) and hybrid (IOS with CatOS on top).
note: Switch running Hybrid has WS-C in description field and loves L2::Catalyst class
note: Native Mode (IOS) versions seem to have SNMP problems with L2 data.
note: !Problem with IOS 12.2.17d-SXB ... upgrade to -SXB1 or higher.
note: !Sup720-3B and NativeIOS 12.2 (17d)SXB10 may report 127.0.0.51 as CDP neighbor address.
device: 6503, 6509, sp72033, s3223, s32p3, s222
note: Native mode (IOS) reports L2+L3
device: wsc6509
duplex: write
class: Layer2::Catalyst
note: Hybrid Mode (Catalyst) reports L2 only
device: 6kMsfc
class: Layer3
duplex: no
vlan: no
note: IOS portion of Hybrid mode. VLAN and other L3 Services.
device: 6kMsfc2
class: Layer3
duplex: no
vlan: no
note: IOS portion of Hybrid mode. VLAN and other L3 Services.
device-family: Voice Gateway
class: Layer3
duplex: no
device: VG200
device-family: Wireless Controllers
class: Layer2::Airespace
cdp:no
arpnip: no
macsuck: yes
portmac: yes
duplex: both
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
note: Device will only communicate with SNMP version configured in the controller.
device: 2006, 4112, 4124, 4136, 4402, 4404
device-family: Firewall
class: Layer3::Cisco
device: PIX Security Appliance
device: Adaptive Security Applicance
device: Firewall Services Modules (FWSM)
note: !Arpnip only available for 4.x software releases.
class: Layer3::CiscoFWSM
arpnip: yes
#
# Cyclades
#
device-vendor: Cyclades
class: Layer1::Cyclades
device-family: All
device: All
#
# Dell
#
device-vendor: Dell
arpnip: no
macsuck: yes
duplex: both
vlan: yes
cdp: no
modules: yes
class: Layer3::Dell
device-family: Dell PowerConnect 6000 Series
arpnip: yes
device: 6024F, 6224, 6248
device-family: Dell PowerConnect 5000 Series
device: 5324
device-family: Dell PowerConnect 3000 Series
device: 3348, 3448P, 3424, 3424P
device-family: IBM BladeCenter Ethernet Switch
device: All
device-family: Linksys 2048
device: All
#
# Enterasys
#
device-vendor: Enterasys Networks
arpnip: yes
macsuck: yes
duplex: both
vlan: yes
cdp: yes
modules: yes
class: Layer3::Enterasys
device-family: SuperStack C-Series
device: C3G124-24, C3G124-48, C2G124-24, C2G124-48
device-family: Matrix
device: Matrix N-Series DFE
#
# Extreme
#
device-vendor: Extreme Networks
arpnip: yes
macsuck: yes
duplex: both
vlan: yes
cdp: no
modules: yes
class: Layer3::Extreme
device-family: Alpine and Summit
device: Alpine 3808
device: Summit 7i, 48si
#
# FreeBSD
#
device-vendor: FreeBSD
device-famly: Pf
class: Layer3::Pf
arpnip: yes
cdp: no
note: LLDP support might be available. See note in Layer3::Pf
#
# Foundry
#
device-vendor: Foundry Networks
vlan: yes
modules: no
device-family: FastIron
class: Layer3::Foundry
ver: 1
note: Support very limited
device: FastIron 4802
device-family: EdgeIron
ver: 2
class: Layer3::Foundry
cdp: yes
duplex: yes
macsuck: yes
device: EdgeIron 24G
note: Bug where spanning tree stuff loops forever when polled by SNMP.
device-family: IronWare
class: Layer3::Foundry
ver: 2
cdp: yes
note: FDP enabled.
duplex: yes
macsuck: yes
arpnip: yes
device: FWSX424
device: ServerIronGT
device: FLS624, FLS648
#
# HP
#
device-vendor: HP
note: HP Devices are very widely supported.
ver: 2
modules: yes
device-family: HP ProCurve (old)
class: Layer2::HP4000
duplex: both
macsuck: yes
arpnip: no
cdp: yes
vlan: write
note: devices in this class only have CDP support
note: VLAN info in HP-VLAN MIB
device: 1600M,2400,2424M,4000,8000
duplex: link
note: duplex issues?
device-family: HP ProCurve (recent)
class: Layer2::HP
duplex: both
macsuck: yes
arpnip: no
cdp: yes
vlan: write
note: old firmware versions only have CDP support, more recent have LLDP
note: VLAN info in Q-BRIDGE-MIB
device: 2312,2324,2512,2524
ver: 1
device: 2510,2600,2610,2800,2810,2900,2910al
device: 3124,3324XL,3400cl,3500,3500yl
device: 4100GL,4200vl,5300XL,5400yy,5400zl
device: 6108,6200yl,6400cl,6410cl,6600,6600ml,8200zl
#
# Juniper
#
device-vendor: Juniper
arpnip: yes
device-family: M-series router
class: Layer3::Juniper
device: All
device-family: NetScreen
class: Layer3::Netscreen
device: All
#
# Linksys
#
device-vendor: Linksys
device-family: Generic L2 Device
class: Layer2
device: Some
device-family: Generic L3 Device
class: Layer3
device: Some
device-family: 2048
class: Layer3::Dell
device: All
#
# Microsoft
#
device-vendor: Microsoft
device-family: Windows
class: Layer3::Microsoft
device: Windows Router
#
# Netgear
#
device-vendor: NetGear
device-family: Switches
class: Layer2::Netgear
device: All
#
# NetScreen
#
device-vendor: NetScreen
note: See Juniper
#
# Net-SNMP
#
device-vendor: Net-SNMP
class: Layer3
ver: 2
device-family: Linux
note: net-snmp 4.x agent and 5.x agent.
device: Linux routers
device-family: BSD
device: BSD routers
#
# NORTEL
#
device-vendor: Nortel
macsuck: yes
cdp: proprietary
note: SONMP Discovery Protocol Supported
device-family: BayStack Hub
duplex: both
ver: 1
modules: yes
class: Layer1::Bayhub
note: Uses proprietary MIBs to provide MAC to port mapping.
note: !Requires Advanced or Advanced Analyzer NMM
device: 102
device: System 5000
device-family: Ethernet Switch/Baystack Switch
macsuck: yes
duplex: both
vlan: write
modules: yes
class: Layer2::Baystack
device: 303, 304, 350, 380, 410, 420, 425, 460, 470
device: 450
note: !Some versions > 4.X in stacked configuration have SNMP timeout issues.
note: Labels full duplex as 20Mbit connection.
device: Business Policy Switch (BPS)
device-family: Ethernet Routing Switch/Baystack Switch
arpnip: yes
duplex: write
vlan: write
modules: yes
class: Layer2::Baystack
device: 3510
device: 2526,2550
device: 4524,4526,4548,4550
device: 5510,5520,5530
device-family: Business Ethernet Switch
arpnip: yes
duplex: write
vlan: write
modules: yes
class: Layer2::Baystack
device: 50,110,120,210,220,1010,1020
device-family: Centillion
duplex: both
vlan: yes
class: Layer2::Centillion
note: !Must be on version 4.x or 5.x (VLAN based) software.
device: 5000BH, 5005BH
device: C50,C100
device-family: AP222x
duplex: both
modules: no
class: Layer2::NAP222x
note: !Upgrade to version 1.3 or higher.
note: Sends out topology packets if enabled but does not build neighbor table.
device: AP-2220, AP-2221
device-family: Alteon AD
arpnip: yes
duplex: both
cdp: no
vlan: yes
modules: no
class: Layer3::AlteonAD
note: !Some versions have issues with continuous SNMP polling. Upgrade to 10.0.30.7 or higher.
device: AD2,AD3,AD4
device: 180,183,184
device-family: Multiprotocol Router/BayRS
arpnip: yes
portmac: yes
duplex: both
cdp: no
vlan: yes
modules: yes
class: Layer3::BayRS
device: AN,ARN,ASN,BLN,BCN
device: 2430,5430
device-family: VPN Router/Contivity
arpnip: yes
macsuck: no
portmac: yes
duplex: no
cdp: no
modules: yes
class: Layer3::Contivity
device: 100,400,600
device: 1000,1010,1050
device: 1500,1600,1700,1740,1750
device: 2500,2600,2700
device: 4500,4600,5000
device-family: Ethernet Routing Switch/Passport/Accelar LAN
arpnip: yes
macsuck: yes
portmac: yes
duplex: write
cdp: proprietary
vlan: write
modules: yes
class: Layer3::Passport
note: !8600 Code versions < 3.2 vlan based mac-suck and are unsupported. Upgrade code.
note: !8600 3.2 code versions < 3.2.2.2 have Bridge MIB loop. Upgrade code.
device: 8603,8606,8610, 8610co, 8106, 8110
device: 1050,1100,1150,1200
device-family: Ethernet Routing Switch/Passport 1600 (Software < 2.1)
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
cdp: proprietary
vlan: write
class: Layer3::N1600
device: 1612,1624,1648
device-family: Ethernet Routing Switch/Passport 1600 (Software >= 2.1)
arpnip: yes
macsuck: yes
portmac: yes
duplex: write
cdp: proprietary
vlan: write
class: Layer3::Passport
device: 1612,1624,1648
device-family: Synoptics
macsuck: yes
duplex: both
cdp: proprietary
ver: 1
class: Layer1::S3000
note: Uses proprietary MIBs to provide MAC to port mapping.
note: !Requires Advanced or Advanced Analyzer NMM
device: 281X
device: System 3000
device-family: Wireless Switch 2270
arpnip: no
macsuck: yes
portmac: yes
duplex: both
cdp: proprietary
modules: yes
class: Layer2::N2270
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
device: 2270
#
# Proxim
#
device-vendor: Proxim
macsuck: yes
duplex: no
cdp: no
class: Layer2::Orinoco
device-family: Orinoco
device: AP-1000,AP-2000,AP-4000
device: WavePOINT-II
#
# Sun
#
device-vendor: Sun
class: Layer3::Sun
device-family: Sun routers
device: Sun routers
#
# Synoptics
#
device-vendor: Synoptics
note: See Nortel
#
# Zyxel
#
device-vendor: Zyxel
class: Layer2::ZyXEL_DSLAM
note: Doesn't report sysServices (layers)
device-family: Zyxel DSLAM
device:AAM10008-61, AAM1008-63

3655
Info.pm

File diff suppressed because it is too large Load Diff

View File

@@ -1,172 +0,0 @@
# SNMP::Info::AdslLine
#
# Copyright (c) 2009 Alexander Hartmaier
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::AdslLine;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::AdslLine::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::AdslLine::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'ADSL-LINE-MIB' => 'adslLineType' );
%GLOBALS = ();
%FUNCS = (
# ADSL-LINE-MIB::adslAtucChanTable
'adsl_atuc_interleave_delay' => 'adslAtucChanInterleaveDelay',
'adsl_atuc_curr_tx_rate' => 'adslAtucChanCurrTxRate',
'adsl_atuc_prev_tx_rate' => 'adslAtucChanPrevTxRate',
'adsl_atuc_crc_block_len' => 'adslAtucChanCrcBlockLength',
# ADSL-LINE-MIB::adslAturChanTable
'adsl_atur_interleave_delay' => 'adslAturChanInterleaveDelay',
'adsl_atur_curr_tx_rate' => 'adslAturChanCurrTxRate',
'adsl_atur_prev_tx_rate' => 'adslAturChanPrevTxRate',
'adsl_atur_crc_block_len' => 'adslAturChanCrcBlockLength',
);
%MUNGE = ();
1;
__END__
=head1 NAME
SNMP::Info::AdslLine - SNMP Interface to the ADSL-LINE-MIB
=head1 AUTHOR
Alexander Hartmaier
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $info = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $info->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::AdslLine is a subclass of SNMP::Info that provides
information about the adsl interfaces of a device.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<ADSL-LINE-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
=item none
=back
=head1 TABLE METHODS
=head2 ATUC channel table (C<adslAtucChanTable>)
This table provides one row for each ATUC channel.
ADSL channel interfaces are those ifEntries where ifType
is equal to adslInterleave(124) or adslFast(125).
=over
=item $info->adsl_atuc_interleave_delay()
(C<adslAtucChanInterleaveDelay>)
=item $info->adsl_atuc_curr_tx_rate()
(C<adslAtucChanCurrTxRate>)
=item $info->adsl_atuc_prev_tx_rate()
(C<adslAtucChanPrevTxRate>)
=item $info->adsl_atuc_crc_block_len()
(C<adslAtucChanCrcBlockLength>)
=back
=head2 ATUR channel table (C<adslAturChanTable>)
This table provides one row for each ATUR channel.
ADSL channel interfaces are those ifEntries where ifType
is equal to adslInterleave(124) or adslFast(125).
=over
=item $info->adsl_atur_interleave_delay()
(C<adslAturChanInterleaveDelay>)
=item $info->adsl_atur_curr_tx_rate()
(C<adslAturChanCurrTxRate>)
=item $info->adsl_atur_prev_tx_rate()
(C<adslAturChanPrevTxRate>)
=item $info->adsl_atur_crc_block_len()
(C<adslAturChanCrcBlockLength>)
=back
=cut

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,237 +1,149 @@
# SNMP::Info::CDP
# $Id$
#
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
# All rights reserved.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CDP;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use Carp;
@SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CDP::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
$VERSION = '2.06';
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MIBS_V1 %MUNGE $INIT/;
# Debug
$DEBUG=0;
$SNMP::debugging=$DEBUG;
# Five data structures required by SNMP::Info
%MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' );
$INIT = 0;
%MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' );
%MIBS_V1 = ( 'CISCO-CDP-MIB-V1SMI' => 'cdpGlobalRun' );
# Notice we dont inherit the default GLOBALS and FUNCS
# only the default MUNGE.
%GLOBALS = (
'cdp_run' => 'cdpGlobalRun',
'cdp_interval' => 'cdpGlobalMessageInterval',
'cdp_holdtime' => 'cdpGlobalHoldTime',
'cdp_id' => 'cdpGlobalDeviceId',
);
'cdp_run' => 'cdpGlobalRun',
'cdp_interval' => 'cdpGlobalMessageInterval',
'cdp_holdtime' => 'cdpGlobalHoldTime',
'cdp_id' => 'cdpGlobalDeviceId',
);
%FUNCS = (
'c_index' => 'cdpCacheIfIndex',
'c_proto' => 'cdpCacheAddressType',
'c_addr' => 'cdpCacheAddress',
'c_ver' => 'cdpCacheVersion',
'c_id' => 'cdpCacheDeviceId',
'c_port' => 'cdpCacheDevicePort',
'c_platform' => 'cdpCachePlatform',
'c_capabilities' => 'cdpCacheCapabilities',
'c_domain' => 'cdpCacheVTPMgmtDomain',
'c_vlan' => 'cdpCacheNativeVLAN',
'c_duplex' => 'cdpCacheDuplex',
'c_power' => 'cdpCachePowerConsumption',
'c_pri_mgmt_type'=> 'cdpCachePrimaryMgmtAddrType',
'c_pri_mgmt_addr'=> 'cdpCachePrimaryMgmtAddr',
'c_sec_mgmt_type'=> 'cdpCacheSecondaryMgmtAddrType',
'c_sec_mgmt_addr'=> 'cdpCacheSecondaryMgmtAddr',
);
%FUNCS = (
'c_if' => 'cdpCacheIfIndex',
'c_proto' => 'cdpCacheAddressType',
'c_ip' => 'cdpCacheAddress',
'c_ver' => 'cdpCacheVersion',
'c_id' => 'cdpCacheDeviceId',
'c_port' => 'cdpCacheDevicePort',
'c_platform' => 'cdpCachePlatform',
'c_capabilities' => 'cdpCacheCapabilities',
'c_domain' => 'cdpCacheVTPMgmtDomain',
'c_vlan' => 'cdpCacheNativeVLAN',
'c_duplex' => 'cdpCacheDuplex'
);
%MUNGE = (
'c_capabilities' => \&SNMP::Info::munge_caps,
'c_platform' => \&SNMP::Info::munge_null,
'c_domain' => \&SNMP::Info::munge_null,
'c_port' => \&SNMP::Info::munge_null,
'c_id' => \&SNMP::Info::munge_null,
'c_ver' => \&SNMP::Info::munge_null,
'c_ip' => \&SNMP::Info::munge_ip,
'c_power' => \&munge_power,
'c_capabilities' => \&munge_caps,
'c_ip' => \&SNMP::Info::munge_ip
);
);
sub munge_power {
my $power = shift;
my $decimal = substr( $power, -3 );
$power =~ s/$decimal$/\.$decimal/;
return $power;
sub munge_caps {
my $caps = shift;
return undef unless defined $caps;
my $bits = substr(unpack("B*",$caps),-7);
return $bits;
}
sub hasCDP {
my $cdp = shift;
my $ver = $cdp->{_version};
# SNMP v1 clients dont have the globals
if ( defined $ver and $ver == 1 ) {
if (defined $ver and $ver == 1){
my $c_ip = $cdp->c_ip();
# See if anything in cdp cache, if so we have cdp
return 1 if ( defined $c_ip and scalar( keys %$c_ip ) );
return;
return 1 if (defined $c_ip and scalar(keys %$c_ip)) ;
return undef;
}
return $cdp->cdp_run();
}
sub c_if {
my $cdp = shift;
# See if by some miracle Cisco implemented the cdpCacheIfIndex entry
my $c_index = $cdp->c_index();
return $c_index if defined $c_index;
# Nope, didn't think so. Now we fake it.
my $c_ip = $cdp->c_ip();
unless ( defined $c_ip ) {
$cdp->error_throw(
"SNMP::Info::CDP:c_if() - Device doesn't have cdp_ip() data. Can't fake cdp_index()"
);
return;
}
my %c_if;
foreach my $key ( keys %$c_ip ) {
next unless defined $key;
my $iid = $key;
# Truncate .1 from cdp cache entry
$iid =~ s/\.\d+$//;
$c_if{$key} = $iid;
}
return \%c_if;
}
sub c_ip {
my $cdp = shift;
my $partial = shift;
my $c_addr = $cdp->c_addr($partial) || {};
my $c_proto = $cdp->c_proto($partial) || {};
my %c_ip;
foreach my $key ( keys %$c_addr ) {
my $addr = $c_addr->{$key};
my $proto = $c_proto->{$key};
next unless defined $addr;
next if ( defined $proto and $proto ne 'ip' );
my $ip = join( '.', unpack( 'C4', $addr ) );
$c_ip{$key} = $ip;
}
return \%c_ip;
}
1;
__END__
=head1 NAME
SNMP::Info::CDP - SNMP Interface to Cisco Discovery Protocol (CDP) using SNMP
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
my $cdp = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
my $class = $cdp->class();
print " Using device sub class : $class\n";
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
# Print out a map of device ports with CDP neighbors:
my $interfaces = $cdp->interfaces();
my $c_if = $cdp->c_if();
my $c_ip = $cdp->c_ip();
my $c_port = $cdp->c_port();
foreach my $cdp_key (keys %$c_ip){
my $iid = $c_if->{$cdp_key};
my $port = $interfaces->{$iid};
my $neighbor = $c_ip->{$cdp_key};
my $neighbor_port = $c_port->{$cdp_key};
print "Port : $port connected to $neighbor / $neighbor_port\n";
}
SNMP::Info::CDP - Perl5 Interface to Cisco Discovery Protocol (CDP) using SNMP
=head1 DESCRIPTION
SNMP::Info::CDP is a subclass of SNMP::Info that provides an object oriented
interface to CDP information through SNMP.
CDP is a Layer 2 protocol that supplies topology information of devices that
also speak CDP, mostly switches and routers. CDP is implemented in Cisco and
some HP devices.
CDP is a Layer 2 protocol that supplies topology information of devices that also speak CDP,
mostly switches and routers.
Create or use a device subclass that inherits this class. Do not use
directly.
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $info = new SNMP::Info ( DestHost => 'router',
Community => 'public'
);
my $type = $info->device_type();
my $cdp = new $type ( DestHost => 'router',
Community => 'public);
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
@neighbor_ips = values( %{$cdp->c_ip()} );
See L<SNMP::Info> for all inherited methods.
=head2 Your Device May Vary
Each device implements a subset of the global and cache entries.
Check the return value to see if that data is held by the device.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<CISCO-CDP-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=head1 CDP GLOBAL VALUES
=over
@@ -243,43 +155,72 @@ Accounts for SNMP version 1 devices which may have CDP but not cdp_run()
=item $cdp->cdp_run()
Is CDP enabled on this device? Note that a lot of Cisco devices that
implement CDP don't implement this value. @#%$!
Is CDP enabled on this device?
(C<cdpGlobalRun>)
(B<cdpGlobalRun>)
=item $cdp->cdp_interval()
Interval in seconds at which CDP messages are generated.
(C<cdpGlobalMessageInterval>)
(B<cdpGlobalMessageInterval>)
=item $cdp->cdp_holdtime()
Time in seconds that CDP messages are kept.
(C<cdpGlobalHoldTime>)
(B<cdpGlobalHoldTime>)
=item $cdp->cdp_id()
Returns CDP device ID.
This is the device id broadcast via CDP to other devices, and is what is
retrieved from remote devices with $cdp->id().
This is the device id broadcast via CDP to other devices, and is what is retrieved from remote devices with $cdp->id().
(C<cdpGlobalDeviceId>)
(B<cdpGlobalDeviceId>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 CDP CACHE ENTRIES
=head1 CDP CACHE ENTRIES
=over
=item $cdp->c_proto()
Returns remote address type received. Usually IP.
(B<cdpCacheAddressType>)
=item $cdp->c_ip()
Returns remote IP address
(B<cdpCacheAddress>)
=item $cdp->c_ver()
Returns remote hardware version
(B<cdpCacheVersion>)
=item $cdp->c_id()
Returns remote device id string
(B<cdpCacheDeviceId>)
=item $cdp->c_port()
Returns remote port ID
(B<cdpDevicePort>)
=item $cdp->c_platform()
Returns remote platform id
(B<cdpCachePlatform>)
=item $cdp->c_capabilities()
Returns Device Functional Capabilities. Results are munged into an ascii
@@ -294,148 +235,41 @@ From L<http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#1884
=item (0x40) - Provides level 1 functionality.
=item (0x20) - The bridge or switch does not forward IGMP Report packets on
non router ports.
=item (0x20) - The bridge or switch does not forward IGMP Report packets on nonrouter ports.
=item (0x10) - Sends and receives packets for at least one network layer
protocol. If the device is routing the protocol, this bit should not be set.
=item (0x10) - Sends and receives packets for at least one network layer protocol. If the device is routing the protocol, this bit should not be set.
=item (0x08) - Performs level 2 switching. The difference between this bit
and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This
device is assumed to be deployed in a physical loop-free topology.
=item (0x08) - Performs level 2 switching. The difference between this bit and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This device is assumed to be deployed in a physical loop-free topology.
=item (0x04) - Performs level 2 source-route bridging. A source-route bridge
would set both this bit and bit 0x02.
=item (0x04) - Performs level 2 source-route bridging. A source-route bridge would set both this bit and bit 0x02.
=item (0x02) - Performs level 2 transparent bridging.
=item (0x01) - Performs level 3 routing for at least one network layer
protocol.
=item (0x01) - Performs level 3 routing for at least one network layer protocol.
=back
Thanks to Martin Lorensen C<martin -at- lorensen.dk> for a pointer to this
information.
Thanks to Martin Lorensen C<martin -at- lorensen.dk> for a pointer to this information.
(C<cdpCacheCapabilities>)
(B<cdpCacheCapabilities>)
=item $cdp->c_domain()
Returns remote VTP Management Domain as defined in
C<CISCO-VTP-MIB::managementDomainName>
Returns remote VTP Management Domain as defined in CISCO-VTP-MIB::managementDomainName
(C<cdpCacheVTPMgmtDomain>)
=item $cdp->c_duplex()
Returns the port duplex status from remote devices.
(C<cdpCacheDuplex>)
=item $cdp->c_id()
Returns remote device id string
(C<cdpCacheDeviceId>)
=item $cdp->c_if()
Returns the mapping to the SNMP Interface Table.
Note that a lot devices don't implement $cdp->c_index(), So if it isn't
around, we fake it.
In order to map the cdp table entry back to the interfaces() entry, we
truncate the last number off of it :
# it exists, yay.
my $c_index = $device->c_index();
return $c_index if defined $c_index;
# if not, let's fake it
my $c_ip = $device->c_ip();
my %c_if
foreach my $key (keys %$c_ip){
$iid = $key;
## Truncate off .1 from cdp response
$iid =~ s/\.\d+$//;
$c_if{$key} = $iid;
}
return \%c_if;
=item $cdp->c_index()
Returns the mapping to the SNMP2 Interface table for CDP Cache Entries.
Most devices don't implement this, so you probably want to use $cdp->c_if()
instead.
See c_if() entry.
(C<cdpCacheIfIndex>)
=item $cdp->c_ip()
If $cdp->c_proto() is supported, returns remote IPV4 address only. Otherwise
it will return all addresses.
(C<cdpCacheAddress>)
=item $cdp->c_addr()
Returns remote address
(C<cdpCacheAddress>)
=item $cdp->c_platform()
Returns remote platform id
(C<cdpCachePlatform>)
=item $cdp->c_port()
Returns remote port ID
(C<cdpDevicePort>)
=item $cdp->c_proto()
Returns remote address type received. Usually IP.
(C<cdpCacheAddressType>)
=item $cdp->c_ver()
Returns remote hardware version
(C<cdpCacheVersion>)
(B<cdpCacheVTPMgmtDomain>)
=item $cdp->c_vlan()
Returns the remote interface native VLAN.
(C<cdpCacheNativeVLAN>)
(B<cdpCacheNativeVLAN>)
=item $cdp->c_power()
=item $cdp->c_duplex()
Returns the amount of power consumed by remote device in milliwatts munged
for decimal placement.
Returns the port duplex status from remote devices.
(C<cdpCachePowerConsumption>)
=back
=head1 Data Munging Callback Subroutines
=over
=item $cdp->munge_power()
Inserts a decimal at the proper location.
(B<cdpCacheDuplex>)
=back

View File

@@ -1,473 +0,0 @@
# SNMP::Info::CiscoConfig
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoConfig;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoConfig::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoConfig::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
'CISCO-CONFIG-COPY-MIB' => 'ccCopyTable',
'CISCO-FLASH-MIB' => 'ciscoFlashCopyTable',
'OLD-CISCO-SYS-MIB' => 'writeMem',
);
%GLOBALS = (
# OLD-CISCO-SYS-MIB
'old_write_mem' => 'writeMem',
'old_write_net' => 'writeNet',
);
%FUNCS = (
# CISCO-COPY-CONFIG-MIB::ccCopyTable
'config_protocol' => 'ccCopyProtocol',
'config_source_type' => 'ccCopySourceFileType',
'config_dest_type' => 'ccCopyDestFileType',
'config_server_addr' => 'ccCopyServerAddress',
'config_filename' => 'ccCopyFileName',
'config_username' => 'ccCopyUserName',
'config_password' => 'ccCopyUserPassword',
'config_notify_complete' => 'ccCopyNotificationOnCompletion',
'config_copy_state' => 'ccCopyState',
'config_copy_start_time' => 'ccCopyTimeStarted',
'config_copy_complete_time' => 'ccCopyTimeCompleted',
'config_fail_cause' => 'ccCopyFailCause',
'config_row_status' => 'ccCopyEntryRowStatus',
# CISCO-FLASH-MIB::ciscoFlashCopyTable
'flash_copy_cmd' => 'ciscoFlashCopyCommand',
'flash_copy_protocol' => 'ciscoFlashCopyProtocol',
'flash_copy_address' => 'ciscoFlashCopyServerAddress',
'flash_copy_source' => 'ciscoFlashCopySourceName',
'flash_copy_dest' => 'ciscoFlashCopyDestinationName',
'flash_copy_row_status' => 'ciscoFlashCopyEntryStatus',
);
%MUNGE = ();
sub copy_run_tftp {
my $ciscoconfig = shift;
my ( $tftphost, $tftpfile ) = @_;
srand( time() ^ ( $$ + ( $$ << 15 ) ) );
my $rand = int( rand( 1 << 24 ) );
print "Saving running config to $tftphost as $tftpfile\n"
if $ciscoconfig->debug();
#Try new method first fall back to old method
if ( $ciscoconfig->set_config_protocol( 1, $rand ) ) {
print "Using new method, row iid: $rand\n" if $ciscoconfig->debug();
#Check each set, delete created row if any fail
unless ( $ciscoconfig->set_config_source_type( 4, $rand ) ) {
$ciscoconfig->error_throw("Setting source type failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Setting source type failed and failed to delete row $rand"
);
}
return;
}
unless ( $ciscoconfig->set_config_dest_type( 1, $rand ) ) {
$ciscoconfig->error_throw("Setting destination type failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Setting dest type failed and failed to delete row $rand"
);
}
return;
}
unless ( $ciscoconfig->set_config_server_addr( $tftphost, $rand ) ) {
$ciscoconfig->error_throw("Setting tftp server failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Setting tftp server failed and failed to delete row $rand"
);
}
return;
}
unless ( $ciscoconfig->set_config_filename( $tftpfile, $rand ) ) {
$ciscoconfig->error_throw("Setting file name failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Setting file name failed and failed to delete row $rand"
);
}
return;
}
unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) {
$ciscoconfig->error_throw("Initiating transfer failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Initiating transfer failed and failed to delete row $rand"
);
}
return;
}
my $status = 0;
my $timer = 0;
# Hard-coded timeout of approximately 5 minutes, we can wrap this in an
# option later if needed
my $timeout = 300;
while ( $status !~ /successful|failed/ ) {
my $t = $ciscoconfig->config_copy_state($rand);
$status = $t->{$rand};
last if $status =~ /successful|failed/;
$timer += 1;
if ( $timer >= $timeout ) {
$status = 'failed';
last;
}
sleep 1;
}
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug();
}
if ( $status eq 'successful' ) {
print "Save operation successful\n" if $ciscoconfig->debug();
return 1;
}
if ( $status eq 'failed' ) {
$ciscoconfig->error_throw("Save operation failed");
return;
}
}
print "Using old method\n" if $ciscoconfig->debug();
unless ( $ciscoconfig->set_old_write_net( $tftpfile, $tftphost ) ) {
$ciscoconfig->error_throw("Save operation failed");
return;
}
return 1;
}
sub copy_run_start {
my $ciscoconfig = shift;
srand( time() ^ ( $$ + ( $$ << 15 ) ) );
my $rand = int( rand( 1 << 24 ) );
print "Saving running config to memory\n" if $ciscoconfig->debug();
if ( $ciscoconfig->set_config_source_type( 4, $rand ) ) {
print "Using new method, row iid: $rand\n" if $ciscoconfig->debug();
#Check each set, delete created row if any fail
unless ( $ciscoconfig->set_config_dest_type( 3, $rand ) ) {
$ciscoconfig->error_throw("Setting dest type failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Setting dest type failed and failed to delete row $rand"
);
}
return;
}
unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) {
$ciscoconfig->error_throw("Initiating save failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw(
"Initiating save failed and failed to delete row $rand");
}
return;
}
my $status = 0;
my $timer = 0;
# Hard-coded timeout of approximately 5 minutes, we can wrap this in an
# option later if needed
my $timeout = 300;
while ( $status !~ /successful|failed/ ) {
my $t = $ciscoconfig->config_copy_state($rand);
$status = $t->{$rand};
last if $status =~ /successful|failed/;
$timer += 1;
if ( $timer >= $timeout ) {
$status = 'failed';
last;
}
sleep 1;
}
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug();
}
if ( $status eq 'successful' ) {
print "Save operation successful\n" if $ciscoconfig->debug();
return 1;
}
if ( $status eq 'failed' ) {
$ciscoconfig->error_throw("Save operation failed");
return;
}
}
print "Using old method\n" if $ciscoconfig->debug();
unless ( $ciscoconfig->set_old_write_mem(1) ) {
$ciscoconfig->error_throw("Save operation failed");
return;
}
return 1;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoConfig - SNMP Interface to Cisco Configuration Files
=head1 AUTHOR
Justin Hunter, Eric Miller
=head1 SYNOPSIS
my $ciscoconfig = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ciscoconfig->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoConfig is a subclass of SNMP::Info that provides an interface
to F<CISCO-CONFIG-COPY-MIB>, F<CISCO-FLASH-MIB>, and F<OLD-CISCO-SYS-MIB>.
These MIBs facilitate the writing of configuration files.
Use or create a subclass of SNMP::Info that inherits this one.
Do not use directly.
=head2 Inherited Classes
=over
None.
=back
=head2 Required MIBs
=over
=item F<CISCO-CONFIG-COPY-MIB>
=item F<CISCO-FLASH-MIB>
=item F<OLD-CISCO-SYS-MIB>
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $ciscoconfig->old_write_mem()
(C<writeMem>)
=item $ciscoconfig->old_write_net()
(C<writeNet>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=back
=head2 Config Copy Request Table (C<ccCopyTable>)
=over
=item $ciscoconfig->config_protocol()
(C<ccCopyProtocol>)
=item $ciscoconfig->config_source_type()
(C<ccCopySourceFileType>)
=item $ciscoconfig->config_dest_type()
(C<ccCopyDestFileType>)
=item $ciscoconfig->config_server_addr()
(C<ccCopyServerAddress>)
=item $ciscoconfig->config_filename()
(C<ccCopyFileName>)
=item $ciscoconfig->config_username()
(C<ccCopyUserName>)
=item $ciscoconfig->config_password()
(C<ccCopyUserPassword>)
=item $ciscoconfig->config_notify_complete()
(C<ccCopyNotificationOnCompletion>)
=item $ciscoconfig->config_copy_state()
(C<ccCopyState>)
=item $ciscoconfig->config_copy_start_time()
(C<ccCopyTimeStarted>)
=item $ciscoconfig->config_copy_complete_time()
(C<ccCopyTimeCompleted>)
=item $ciscoconfig->config_fail_cause()
(C<ccCopyFailCause>)
=item $ciscoconfig->config_row_status()
(C<ccCopyEntryRowStatus>)
=back
=head2 Flash Copy Table (C<ciscoFlashCopyTable>)
Table of Flash copy operation entries.
=over
=item $ciscoconfig->flash_copy_cmd()
(C<ciscoFlashCopyCommand>)
=item $ciscoconfig->flash_copy_protocol()
(C<ciscoFlashCopyProtocol>)
=item $ciscoconfig->flash_copy_address()
(C<ciscoFlashCopyServerAddress>)
=item $ciscoconfig->flash_copy_source()
(C<ciscoFlashCopySourceName>)
=item $ciscoconfig->flash_copy_dest()
(C<ciscoFlashCopyDestinationName>)
=item $ciscoconfig->flash_copy_row_status()
(C<ciscoFlashCopyEntryStatus>)
=back
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over
=item $ciscoconfig->copy_run_tftp (tftpserver, tftpfilename )
Store the running configuration on a TFTP server. Equivalent to the CLI
commands "copy running-config tftp" or "write net".
This method attempts to use newer "copy running-config tftp" procedure first
and then the older "write net" procedure if that fails. The newer procedure
is supported Cisco devices with the F<CISCO-CONFIG-COPY-MIB> available, Cisco
IOS software release 12.0 or on some devices as early as release 11.2P. The
older procedure has been depreciated by Cisco and is utilized only to support
devices running older code revisions.
Example:
$ciscoconfig->copy_run_tftp('1.2.3.4', 'myconfig')
or die Couldn't save config. ",$ciscoconfig->error(1);
=item $ciscoconfig->copy_run_start()
Copy the running configuration to the start up configuration. Equivalent to
the CLI command C<"copy running-config startup-config"> or C<"write mem">.
This method attempts to use newer C<"copy running-config startup-config">
procedure first and then the older C<"write mem"> procedure if that fails.
The newer procedure is supported Cisco devices with the
F<CISCO-CONFIG-COPY-MIB> available, Cisco IOS software release 12.0 or on
some devices as early as release 11.2P. The older procedure has been
depreciated by Cisco and is utilized only to support devices running older
code revisions.
Example:
$ciscoconfig->copy_run_start()
or die "Couldn't save config. ",$ciscoconfig->error(1);
=back
=cut

View File

@@ -1,115 +0,0 @@
# $Id$
#
# Copyright (c) 2005 Matt Tuttle
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoImage;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoImage::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'CISCO-IMAGE-MIB' => 'ciscoImageString', );
%GLOBALS = ();
%FUNCS = ( 'ci_images' => 'ciscoImageString', );
%MUNGE = ();
1;
__END__
=head1 NAME
SNMP::Info::CiscoImage - SNMP Interface to image strings for Cisco Devices
=head1 AUTHOR
Matt Tuttle (C<mtuttle@americanhebrewacademy.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $ci = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ci->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoImage is a subclass of SNMP::Info that provides access to
image strings embedded in an image running on Cisco Devices.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<CISCO-IMAGE-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
None.
=head1 TABLE METHODS
=over
=item $ci->ci_images()
Returns the table of image strings.
C<ciscoImageString>
=back
=cut

View File

@@ -1,388 +0,0 @@
# SNMP::Info::CiscoPortSecurity
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoPortSecurity;
use strict;
use Exporter;
@SNMP::Info::CiscoPortSecurity::ISA = qw/Exporter/;
@SNMP::Info::CiscoPortSecurity::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PAECAPABILITIES/;
$VERSION = '2.06';
%MIBS = (
'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB',
'CISCO-PAE-MIB' => 'ciscoPaeMIB',
'IEEE8021-PAE-MIB' => 'dot1xAuthLastEapolFrameSource',
);
%GLOBALS = (
# CISCO-PORT-SECURITY-MIB
'cps_clear' => 'cpsGlobalClearSecureMacAddresses',
'cps_notify' => 'cpsGlobalSNMPNotifControl',
'cps_rate' => 'cpsGlobalSNMPNotifRate',
'cps_enable' => 'cpsGlobalPortSecurityEnable',
'cps_mac_count' => 'cpsGlobalTotalSecureAddress',
'cps_mac_max' => 'cpsGlobalMaxSecureAddress',
);
%FUNCS = (
# CISCO-PORT-SECURITY-MIB::cpsIfConfigTable
'cps_i_limit_val' => 'cpsIfInvalidSrcRateLimitValue',
'cps_i_limit' => 'cpsIfInvalidSrcRateLimitEnable',
'cps_i_sticky' => 'cpsIfStickyEnable',
'cps_i_clear_type' => 'cpsIfClearSecureMacAddresses',
'cps_i_shutdown' => 'cpsIfShutdownTimeout',
'cps_i_flood' => 'cpsIfUnicastFloodingEnable',
'cps_i_clear' => 'cpsIfClearSecureAddresses',
'cps_i_mac' => 'cpsIfSecureLastMacAddress',
'cps_i_count' => 'cpsIfViolationCount',
'cps_i_action' => 'cpsIfViolationAction',
'cps_i_mac_static' => 'cpsIfStaticMacAddrAgingEnable',
'cps_i_mac_type' => 'cpsIfSecureMacAddrAgingType',
'cps_i_mac_age' => 'cpsIfSecureMacAddrAgingTime',
'cps_i_mac_count' => 'cpsIfCurrentSecureMacAddrCount',
'cps_i_mac_max' => 'cpsIfMaxSecureMacAddr',
'cps_i_status' => 'cpsIfPortSecurityStatus',
'cps_i_enable' => 'cpsIfPortSecurityEnable',
# CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
'cps_i_v_mac_count' => 'cpsIfVlanCurSecureMacAddrCount',
'cps_i_v_mac_max' => 'cpsIfVlanMaxSecureMacAddr',
'cps_i_v' => 'cpsIfVlanIndex',
# CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
'cps_i_v_mac_status' => 'cpsIfVlanSecureMacAddrRowStatus',
'cps_i_v_mac_age' => 'cpsIfVlanSecureMacAddrRemainAge',
'cps_i_v_mac_type' => 'cpsIfVlanSecureMacAddrType',
'cps_i_v_vlan' => 'cpsIfVlanSecureVlanIndex',
'cps_i_v_mac' => 'cpsIfVlanSecureMacAddress',
# CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
'cps_m_status' => 'cpsSecureMacAddrRowStatus',
'cps_m_age' => 'cpsSecureMacAddrRemainingAge',
'cps_m_type' => 'cpsSecureMacAddrType',
'cps_m_mac' => 'cpsSecureMacAddress',
# IEEE8021-PAE-MIB::dot1xPaePortEntry
'pae_i_capabilities' => 'dot1xPaePortCapabilities',
'pae_i_last_eapol_frame_source' => 'dot1xAuthLastEapolFrameSource',
);
%MUNGE = (
'cps_i_mac' => \&SNMP::Info::munge_mac,
'cps_m_mac' => \&SNMP::Info::munge_mac,
'cps_i_v_mac' => \&SNMP::Info::munge_mac,
'pae_i_last_eapol_frame_source' => \&SNMP::Info::munge_mac,
'pae_i_capabilities' => \&munge_pae_capabilities,
);
%PAECAPABILITIES = (
0 => 'dot1xPaePortAuthCapable',
1 => 'dot1xPaePortSuppCapable'
);
sub munge_pae_capabilities {
my $bits = shift;
return unless defined $bits;
my @vals
= map( $PAECAPABILITIES{$_}, sprintf( "%x", unpack( 'b*', $bits ) ) );
return join( ' ', @vals );
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoPortSecurity - SNMP Interface to data from
F<CISCO-PORT-SECURITY-MIB> and F<CISCO-PAE-MIB>
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $cps = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $cps->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoPortSecurity is a subclass of SNMP::Info that provides
an interface to the F<CISCO-PORT-SECURITY-MIB> and F<CISCO-PAE-MIB>. These
MIBs are used across the Catalyst family under CatOS and IOS.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<CISCO-PORT-SECURITY-MIB>
=item F<CISCO-PAE-MIB>
=item F<IEEE8021-PAE-MIB>
=back
=head1 GLOBALS
These are methods that return scalar values from SNMP
=over
=back
=head2 F<CISCO-PORT-SECURITY-MIB> globals
=over
=item $cps->cps_clear()
(C<cpsGlobalClearSecureMacAddresses>)
=item $cps->cps_notify()
(C<cpsGlobalSNMPNotifControl>)
=item $cps->cps_rate()
(C<cpsGlobalSNMPNotifRate>)
=item $cps->cps_enable()
(C<cpsGlobalPortSecurityEnable>)
=item $cps->cps_mac_count()
(C<cpsGlobalTotalSecureAddress>)
=item $cps->cps_mac_max()
(C<cpsGlobalMaxSecureAddress>)
=back
=head1 TABLE METHODS
=head2 C<CISCO-PORT-SECURITY-MIB> - Interface Config Table
=over
=item $cps->cps_i_limit_val()
(C<cpsIfInvalidSrcRateLimitValue>)
=item $cps->cps_i_limit()
(C<cpsIfInvalidSrcRateLimitEnable>)
=item $cps->cps_i_sticky()
(C<cpsIfStickyEnable>)
=item $cps->cps_i_clear_type()
(C<cpsIfClearSecureMacAddresses>)
=item $cps->cps_i_shutdown()
(C<cpsIfShutdownTimeout>)
=item $cps->cps_i_flood()
(C<cpsIfUnicastFloodingEnable>)
=item $cps->cps_i_clear()
(C<cpsIfClearSecureAddresses>)
=item $cps->cps_i_mac()
(C<cpsIfSecureLastMacAddress>)
=item $cps->cps_i_count()
(C<cpsIfViolationCount>)
=item $cps->cps_i_action()
(C<cpsIfViolationAction>)
=item $cps->cps_i_mac_static()
(C<cpsIfStaticMacAddrAgingEnable>)
=item $cps->cps_i_mac_type()
(C<cpsIfSecureMacAddrAgingType>)
=item $cps->cps_i_mac_age()
(C<cpsIfSecureMacAddrAgingTime>)
=item $cps->cps_i_mac_count()
(C<cpsIfCurrentSecureMacAddrCount>)
=item $cps->cps_i_mac_max()
(C<cpsIfMaxSecureMacAddr>)
=item $cps->cps_i_status()
(C<cpsIfPortSecurityStatus>)
=item $cps->cps_i_enable()
(C<cpsIfPortSecurityEnable>)
=back
=head2 C<CISCO-PORT-SECURITY-MIB::cpsIfVlanTable>
=over
=item $cps->cps_i_v_mac_count()
(C<cpsIfVlanCurSecureMacAddrCount>)
=item $cps->cps_i_v_mac_max()
(C<cpsIfVlanMaxSecureMacAddr>)
=item $cps->cps_i_v()
(C<cpsIfVlanIndex>)
=back
=head2 C<CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable>
=over
=item $cps->cps_i_v_mac_status()
(C<cpsIfVlanSecureMacAddrRowStatus>)
=item $cps->cps_i_v_mac_age()
(C<cpsIfVlanSecureMacAddrRemainAge>)
=item $cps->cps_i_v_mac_type()
(C<cpsIfVlanSecureMacAddrType>)
=item $cps->cps_i_v_vlan()
(C<cpsIfVlanSecureVlanIndex>)
=item $cps->cps_i_v_mac()
(C<cpsIfVlanSecureMacAddress>)
=back
=head2 C<CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable>
=over
=item $cps->cps_m_status()
(C<cpsSecureMacAddrRowStatus>)
=item $cps->cps_m_age()
(C<cpsSecureMacAddrRemainingAge>)
=item $cps->cps_m_type()
(C<cpsSecureMacAddrType>)
=item $cps->cps_m_mac()
(C<cpsSecureMacAddress>)
=back
=head2 C<IEEE8021-PAE-MIB::dot1xPaePortEntry>
=over
=item $cps->pae_i_capabilities()
C<dot1xPaePortCapabilities>
Indicates the PAE functionality that this Port supports
and that may be managed through this MIB munged to return either
C<'dot1xPaePortAuthCapable'> or C<'dot1xPaePortSuppCapable'>.
=item $cps->pae_i_last_eapol_frame_source()
C<dot1xAuthLastEapolFrameSource>
The source MAC address carried in the most recently received EAPOL frame.
=back
=head1 Data Munging Callback Subroutines
=over
=item $cps->munge_pae_capabilities()
Return either C<'dot1xPaePortAuthCapable'> or C<'dot1xPaePortSuppCapable'>
based upon bit value.
=back
=cut

View File

@@ -1,193 +0,0 @@
# SNMP::Info::CiscoPower
# $Id$
#
# Copyright (c) 2008 Bill Fenner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoPower;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoPower::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoPower::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex',
'CISCO-CDP-MIB' => 'cdpCachePowerConsumption' );
%GLOBALS = ();
%FUNCS = (
'cpeth_ent_phy' => 'cpeExtPsePortEntPhyIndex',
'peth_port_power' => 'cpeExtPsePortPwrConsumption',
);
%MUNGE = ();
# Cisco overcame the limitation of the module.port index of the
# pethPsePortTable by adding another mapping table, which maps
# a pethPsePortTable row to an entPhysicalTable index, which can
# then be mapped to ifIndex.
sub peth_port_ifindex {
my $cpeth = shift;
my $partial = shift;
my $ent_phy = $cpeth->cpeth_ent_phy($partial);
my $e_port = $cpeth->e_port();
my $peth_port_ifindex = {};
foreach my $i ( keys %$ent_phy ) {
if ( $e_port->{ $ent_phy->{$i} } ) {
$peth_port_ifindex->{$i} = $e_port->{ $ent_phy->{$i} };
}
}
return $peth_port_ifindex;
}
# peth_port_neg_power uses the same index as the other peth_port_* tables.
# However, cdpCachePowerConsumption uses <ifIndex>.<neighbor>.
# Therefore, we have to invert peth_port_ifindex, to get to
# the index that is expected and the rest of the code can re-invert it.
sub peth_port_neg_power {
my $cpeth = shift;
my $partial = shift;
# Ignoring partial, since it's not easy to implement properly.
my $index = $cpeth->peth_port_ifindex();
my %inverse_index;
foreach my $i ( keys %$index ) {
$inverse_index{ $index->{$i} } = $i;
}
my $neg_power = $cpeth->cdpCachePowerConsumption();
my $peth_port_neg_power = {};
foreach my $i ( keys %$neg_power ) {
my( $ifIndex, $nbrIndex ) = split( /\./, $i );
if ( defined( $inverse_index{ $ifIndex } ) ) {
$peth_port_neg_power->{ $inverse_index{ $ifIndex } } = $neg_power->{ $i };
}
}
return $peth_port_neg_power;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoPower - SNMP Interface to data stored in
F<CISCO-POWER-ETHERNET-EXT-MIB>.
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $poe = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $poe->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
The Info::PowerEthernet class needs a per-device helper function to
properly map the C<pethPsePortTable> to C<ifIndex> values. This class
provides that helper, using F<CISCO-POWER-ETHERNET-EXT-MIB>.
It does not define any helpers for the extra values that this MIB
contains.
Create or use a device subclass that inherit this class. Do not use directly.
For debugging purposes you can call this class directly as you would
SNMP::Info
my $poe = new SNMP::Info::CiscoPower (...);
=head2 Inherited Classes
none.
Note that it requires that the device inherits from Info::Entity.
=head2 Required MIBs
=over
=item F<CISCO-POWER-ETHERNET-EXT-MIB>
=back
=head1 GLOBALS
none.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Power Port Table
=over
=item $poe->peth_port_ifindex()
Maps the C<pethPsePortTable> to C<ifIndex> by way of the F<ENTITY-MIB>.
=item $poe->peth_port_power()
Power supplied by PoE ports, in milliwatts
("cpeExtPsePortPwrConsumption")
=back
=head2 CDP Port table
=over
=item $poe->peth_port_neg_power()
Power negotiated using CDP, in milliwats
("cdpCachePowerConsumption")
=back
=cut

View File

@@ -1,218 +0,0 @@
# SNMP::Info::CiscoQOS
# $Id$
#
# Copyright (c) 2005 Alexander Hartmaier
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoQOS;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoQOS::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoQOS::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex', );
%GLOBALS = ();
%FUNCS = (
# CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable
'qos_i_index' => 'cbQosIfIndex',
'qos_i_type' => 'cbQosIfType',
'qos_pol_direction' => 'cbQosPolicyDirection',
# CISCO-CLASS-BASED-QOS-MIB::cbQosObjectsTable
'qos_obj_conf_index' => 'cbQosConfigIndex',
'qos_obj_type' => 'cbQosObjectsType',
'qos_obj_parent' => 'cbQosParentObjectsIndex',
# CISCO-CLASS-BASED-QOS-MIB::cbQosCMCfgTable
'qos_cm_name' => 'cbQosCMName',
'qos_cm_desc' => 'cbQosCMDesc',
'qos_cm_info' => 'cbQosCMInfo',
# CISCO-CLASS-BASED-QOS-MIB::cbQosCMStatsTable
'qos_octet_pre' => 'cbQosCMPrePolicyByte',
'qos_octet_post' => 'cbQosCMPostPolicyByte',
# CISCO-CLASS-BASED-QOS-MIB::cbQosQueueingCfgTable
'qos_queueingcfg_bw' => 'cbQosQueueingCfgBandwidth',
'qos_queueingcfg_bw_units' => 'cbQosQueueingCfgBandwidthUnits',
);
%MUNGE = ();
1;
__END__
=head1 NAME
SNMP::Info::CiscoQOS - SNMP Interface to Cisco's Quality of Service MIBs
=head1 AUTHOR
Alexander Hartmaier
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $qos = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $qos->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoQOS is a subclass of SNMP::Info that provides
information about a cisco device's QoS config.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<CISCO-CLASS-BASED-QOS-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
=item none
=back
=head1 TABLE METHODS
=head2 Service Policy Table (C<cbQosServicePolicyTable>)
This table describes the interfaces/media types and the policy map that are
attached to it.
=over
=item $qos->qos_i_index()
(C<cbQosIfIndex>)
=item $qos->qos_i_type()
(C<cbQosIfType>)
=item $qos->qos_pol_direction()
(C<cbQosPolicyDirection>)
=back
=head2 Class Map Objects Table (C<cbQosObjectsTable>)
=over
=item $qos->qos_obj_index()
(C<cbQosConfigIndex>)
=item $qos->qos_obj_type()
(C<cbQosObjectsType>)
=item $qos->qos_obj_parent()
(C<cbQosParentObjectsIndex>)
=back
=head2 Class Map Configuration Table (C<cbQosCMCfgTable>)
=over
=item $qos->qos_cm_name()
(C<cbQosCMName>)
=item $qos->qos_cm_desc()
(C<cbQosCMDesc>)
=item $qos->qos_cm_info()
(C<cbQosCMInfo>)
=back
=head2 Class Map Stats Table (C<cbQosCMStatsTable>)
=over
=item $qos->qos_octet_pre()
(C<cbQosCMPrePolicyByte>)
=item $qos->qos_octet_post()
(C<cbQosCMPostPolicyByte>)
=back
=head2 Queueing Configuration Table (C<cbQosQueueingCfgTable>)
=over
=item $qos->qos_queueingcfg_bw()
(C<cbQosQueueingCfgBandwidth>)
=item $qos->qos_queueingcfg_bw_units()
(C<cbQosQueueingCfgBandwidthUnits>)
=back
=cut

View File

@@ -1,138 +0,0 @@
# SNMP::Info::CiscoRTT
# $Id$
#
# Copyright (c) 2005 Alexander Hartmaier
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoRTT;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoRTT::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoRTT::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner', );
%GLOBALS = ();
%FUNCS = (
# CISCO-RTTMON-MIB
'rtt_desc' => 'rttMonCtrlAdminOwner',
'rtt_last' => 'rttMonLatestRttOperCompletionTime',
);
%MUNGE = ();
1;
__END__
=head1 NAME
SNMP::Info::CiscoRTT - SNMP Interface to Cisco's Round Trip Time MIBs
=head1 AUTHOR
Alexander Hartmaier
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $rtt = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $rtt->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoRTT is a subclass of SNMP::Info that provides
information about a cisco device's RTT values.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<CISCO-RTTMON-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
None
=back
=head1 TABLE METHODS
=head2 Overall Control Group Table
This table is from C<CISCO-RTTMAN-MIB::rttMonCtrlAdminTable>
=over
=item $rtt->rtt_desc()
(C<rttMonCtrlAdminOwner>)
=back
=head2 Overall Control Group Table
This table is from C<CISCO-RTTMON-MIB::rttMonCtrl>
=over
=item $rtt->rtt_last()
(C<rttMonLatestRttOperCompletionTime>)
=back
=cut

View File

@@ -1,637 +0,0 @@
# SNMP::Info::CiscoStack
# $Id$
#
# Copyright (c) 2008 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoStack;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoStack::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT/;
$VERSION = '2.06';
%MIBS = ( 'CISCO-STACK-MIB' => 'ciscoStackMIB', );
%GLOBALS = (
'sysip' => 'sysIpAddr',
'netmask' => 'sysNetMask',
'broadcast' => 'sysBroadcast',
'serial1' => 'chassisSerialNumber',
'serial2' => 'chassisSerialNumberString',
'model1' => 'chassisModel',
'ps1_type' => 'chassisPs1Type',
'ps1_status' => 'chassisPs1Status',
'ps2_type' => 'chassisPs2Type',
'ps2_status' => 'chassisPs2Status',
'slots' => 'chassisNumSlots',
'fan' => 'chassisFanStatus',
);
%FUNCS = (
# CISCO-STACK-MIB::moduleEntry
# These are blades in a catalyst device
'm_type' => 'moduleType',
'm_model' => 'moduleModel',
'm_serial' => 'moduleSerialNumber',
'm_status' => 'moduleStatus',
'm_name' => 'moduleName',
'm_ports' => 'moduleNumPorts',
'm_ports_status' => 'modulePortStatus',
'm_hwver' => 'moduleHwVersion',
'm_fwver' => 'moduleFwVersion',
'm_swver' => 'moduleSwVersion',
# Router Blades :
'm_ip' => 'moduleIPAddress',
'm_sub1' => 'moduleSubType',
'm_sub2' => 'moduleSubType2',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
'p_rx_flow_control' => 'portOperRxFlowControl',
'p_tx_flow_control' => 'portOperTxFlowControl',
'p_rx_flow_control_admin' => 'portAdminRxFlowControl',
'p_tx_flow_control_admin' => 'portAdminTxFlowControl',
'p_oidx' => 'portCrossIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
);
%MUNGE = (
'm_ports_status' => \&munge_port_status,
'p_duplex_admin' => \&SNMP::Info::munge_bits,
);
%PORTSTAT = (
1 => 'other',
2 => 'ok',
3 => 'minorFault',
4 => 'majorFault'
);
# Changes binary byte describing each port into ascii, and returns
# an ascii list separated by spaces.
sub munge_port_status {
my $status = shift;
my @vals = map( $PORTSTAT{$_}, unpack( 'C*', $status ) );
return join( ' ', @vals );
}
sub serial {
my $stack = shift;
my $serial1 = $stack->serial1();
my $serial2 = $stack->serial2();
return $serial1 if defined $serial1;
return $serial2 if defined $serial2;
return;
}
# Rules for older CatOS devices using CiscoStack
#
# You can configure Ethernet and Fast Ethernet interfaces to either full
# duplex or half duplex.
#
# You cannot configure the duplex mode on Gigabit Ethernet ports (they are
# always in full-duplex mode).
#
# If you set the port speed to auto, duplex mode is automatically set to auto.
#
# For operational duplex if portCpbDuplex is all zeros the port is a gigabit
# port and duplex is always full. If the port is not operational and auto
# return value will be undef since we don't know the operational status.
#
# Newer devices use ETHERLIKE-MIB to report operational duplex, this will be
# checked in the device class.
sub i_duplex {
my $stack = shift;
my $partial = shift;
my $p_port = $stack->p_port() || {};
my $p_duplex = $stack->p_duplex() || {};
my $p_duplex_cap = $stack->p_duplex_admin() || {};
my $i_duplex = {};
foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port};
next unless defined $iid;
next if ( defined $partial and $iid !~ /^$partial$/ );
# Test for gigabit
if ( $p_duplex_cap->{$port} && $p_duplex_cap->{$port} == 0 ) {
$i_duplex->{$iid} = 'full';
}
# Auto is not a valid operational state
elsif ( $p_duplex->{$port} eq 'auto' ) {
next;
}
else {
$i_duplex->{$iid} = $p_duplex->{$port};
}
}
return $i_duplex;
}
# For administrative duplex if portCpbDuplex is all zeros the port is a gigabit
# port and duplex is always full. If portAdminSpeed is set to auto then the
# duplex will be auto, otherwise use portDuplex.
sub i_duplex_admin {
my $stack = shift;
my $partial = shift;
my $p_port = $stack->p_port() || {};
my $p_duplex = $stack->p_duplex() || {};
my $p_duplex_cap = $stack->p_duplex_admin() || {};
my $p_speed = $stack->p_speed() || {};
my $i_duplex_admin = {};
foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port};
next unless defined $iid;
next if ( defined $partial and $iid !~ /^$partial$/ );
# Test for gigabit
if ( $p_duplex_cap->{$port} && $p_duplex_cap->{$port} == 1 ) {
$i_duplex_admin->{$iid} = 'full';
}
# Check admin speed for auto
elsif ( $p_speed->{$port} =~ /auto/ ) {
$i_duplex_admin->{$iid} = 'auto';
}
else {
$i_duplex_admin->{$iid} = $p_duplex->{$port};
}
}
return $i_duplex_admin;
}
sub i_speed_admin {
my $stack = shift;
my $partial = shift;
my %i_speed_admin;
my $p_port = $stack->p_port() || {};
my %mapping = reverse %$p_port;
my $p_speed = $stack->p_speed( $mapping{$partial} );
my %speeds = (
'autoDetect' => 'auto',
'autoDetect10100' => 'auto',
's10000000' => '10 Mbps',
's100000000' => '100 Mbps',
's1000000000' => '1.0 Gbps',
's10G' => '10 Gbps',
);
%i_speed_admin
= map { $p_port->{$_} => $speeds{ $p_speed->{$_} } } keys %$p_port;
return \%i_speed_admin;
}
sub set_i_speed_admin {
# map speeds to those the switch will understand
my %speeds = qw/auto 1 10 10000000 100 100000000 1000 1000000000/;
my $stack = shift;
my ( $speed, $iid ) = @_;
my $p_port = $stack->p_port() || {};
my %reverse_p_port = reverse %$p_port;
$speed = lc($speed);
return 0 unless defined $speeds{$speed};
$iid = $reverse_p_port{$iid};
return $stack->set_p_speed( $speeds{$speed}, $iid );
}
sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/;
my $stack = shift;
my ( $duplex, $iid ) = @_;
if ( $duplex eq 'auto' ) {
$stack->error_throw(
"Software doesn't support setting auto duplex with
set_i_duplex_admin() you must use
set_i_speed_admin() and set both speed and duplex
to auto"
);
return 0;
}
my $p_port = $stack->p_port() || {};
my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex};
$iid = $reverse_p_port{$iid};
return $stack->set_p_duplex( $duplexes{$duplex}, $iid );
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoStack - SNMP Interface to data from F<CISCO-STACK-MIB> and
F<CISCO-PORT-SECURITY-MIB>
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $ciscostats = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ciscostats->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoStack is a subclass of SNMP::Info that provides
an interface to the C<CISCO-STACK-MIB>. This MIB is used across
the Catalyst family under CatOS and IOS.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<CISCO-STACK-MIB>
=back
=head1 GLOBALS
=over
=item $stack->broadcast()
(C<sysBroadcast>)
=item $stack->fan()
(C<chassisFanStatus>)
=item $stack->model()
(C<chassisModel>)
=item $stack->netmask()
(C<sysNetMask>)
=item $stack->ps1_type()
(C<chassisPs1Type>)
=item $stack->ps2_type()
(C<chassisPs2Type>)
=item $stack->ps1_status()
(C<chassisPs1Status>)
=item $stack->ps2_status()
(C<chassisPs2Status>)
=item $stack->serial()
(C<chassisSerialNumberString>) or (C<chassisSerialNumber>)
=item $stack->slots()
(C<chassisNumSlots>)
=back
=head1 TABLE METHODS
=head2 Interface Tables
=over
=item $stack->i_physical()
Returns a map to IID for ports that are physical ports, not vlans, etc.
=item $stack->i_type()
Crosses p_port() with p_type() and returns the results.
Overrides with C<ifType> if p_type() isn't available.
=item $stack->i_duplex()
Returns reference to hash of iid to current link duplex setting.
First checks for fixed gigabit ports which are always full duplex. Next, if
the port is not operational and reported port duplex (C<portDuplex>) is auto
then the operational duplex can not be determined. Otherwise it uses the
reported port duplex (C<portDuplex>).
=item $stack->i_duplex_admin()
Returns reference to hash of iid to administrative duplex setting.
First checks for fixed gigabit ports which are always full duplex. Next checks
the port administrative speed (C<portAdminSpeed>) which if set to
autonegotiate then the duplex will also autonegotiate, otherwise it uses the
reported port duplex (C<portDuplex>).
=item $stack->i_speed_admin()
Returns reference to hash of iid to administrative speed setting.
C<portAdminSpeed>
=item $stack->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port C<ifIndex>
Speed choices are 'auto', '10', '100', '1000'
Crosses $stack->p_port() with $stack->p_duplex() to
utilize port C<ifIndex>.
Example:
my %if_map = reverse %{$stack->interfaces()};
$stack->set_i_speed_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port speed. ",$stack->error(1);
=item $stack->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port C<ifIndex>
Speed choices are 'auto', 'half', 'full'
Crosses $stack->p_port() with $stack->p_duplex() to
utilize port C<ifIndex>.
Example:
my %if_map = reverse %{$stack->interfaces()};
$stack->set_i_duplex_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port duplex. ",$stack->error(1);
=back
=head2 Module table
This table holds configuration information for each of the blades installed in
the Catalyst device.
=over
=item $stack->m_type()
(C<moduleType>)
=item $stack->m_model()
(C<moduleModel>)
=item $stack->m_serial()
(C<moduleSerialNumber>)
=item $stack->m_status()
(C<moduleStatus>)
=item $stack->m_name()
(C<moduleName>)
=item $stack->m_ports()
(C<moduleNumPorts>)
=item $stack->m_ports_status()
Returns a list of space separated status strings for the ports.
To see the status of port 4 :
@ports_status = split(' ', $stack->m_ports_status() );
$port4 = $ports_status[3];
(C<modulePortStatus>)
=item $stack->m_ports_hwver()
(C<moduleHwVersion>)
=item $stack->m_ports_fwver()
(C<moduleFwVersion>)
=item $stack->m_ports_swver()
(C<moduleSwVersion>)
=item $stack->m_ports_ip()
(C<moduleIPAddress>)
=item $stack->m_ports_sub1()
(C<moduleSubType>)
=item $stack->m_ports_sub2()
(C<moduleSubType2>)
=back
=head2 Modules - Router Blades
=over
=item $stack->m_ip()
(C<moduleIPAddress>)
=item $stack->m_sub1()
(C<moduleSubType>)
=item $stack->m_sub2()
(C<moduleSubType2>)
=back
=head2 Port Entry Table (C<CISCO-STACK-MIB::portTable>)
=over
=item $stack->p_name()
(C<portName>)
=item $stack->p_type()
(C<portType>)
=item $stack->p_status()
(C<portOperStatus>)
=item $stack->p_status2()
(C<portAdditionalStatus>)
=item $stack->p_speed()
(C<portAdminSpeed>)
=item $stack->p_duplex()
(C<portDuplex>)
=item $stack->p_port()
(C<portIfIndex>)
=item $stack->p_rx_flow_control()
Can be either C<on> C<off> or C<disagree>
"Indicates the receive flow control operational status of the port. If the
port could not agree with the far end on a link protocol, its operational
status will be disagree(3)."
C<portOperRxFlowControl>
=item $stack->p_tx_flow_control()
Can be either C<on> C<off> or C<disagree>
"Indicates the transmit flow control operational status of the port. If the
port could not agree with the far end on a link protocol, its operational
status will be disagree(3)."
C<portOperTxFlowControl>
=item $stack->p_rx_flow_control_admin()
Can be either C<on> C<off> or C<desired>
"Indicates the receive flow control administrative status set on the port. If
the status is set to on(1), the port will require the far end to send flow
control. If the status is set to off(2), the port will not allow far end to
send flow control. If the status is set to desired(3), the port will allow
the far end to send the flow control."
C<portAdminRxFlowControl>
=item $stack->p_tx_flow_control_admin()
Can be either C<on> C<off> or C<desired>
"Indicates the transmit flow control administrative status set on the port.
If the status is set to on(1), the port will send flow control to the far end. If
the status is set to off(2), the port will not send flow control to the far
end. If the status is set to desired(3), the port will send flow control to
the far end if the far end supports it."
C<portAdminTxFlowControl>
=back
=head2 Port Capability Table (C<CISCO-STACK-MIB::portCpbTable>)
=over
=item $stack->p_speed_admin()
(C<portCpbSpeed>)
=item $stack->p_duplex_admin()
(C<portCpbDuplex>)
=back
=head1 Data Munging Callback Subroutines
=over
=item $stack->munge_port_status()
Munges binary byte describing each port into ascii, and returns an ascii
list separated by spaces.
=back
=cut

View File

@@ -1,543 +0,0 @@
# SNMP::Info::CiscoStats
# $Id$
#
# Changes since Version 0.7 Copyright (c) 2008-2009 Max Baker and SNMP::Info Developers
# All rights reserved.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoStats;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoStats::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
'SNMPv2-MIB' => 'sysDescr',
'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec',
'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed',
'OLD-CISCO-SYSTEM-MIB' => 'writeMem',
'CISCO-PRODUCTS-MIB' => 'sysName',
'ENTITY-MIB' => 'entPhysicalSoftwareRev',
# some older catalysts live here
'CISCO-STACK-MIB' => 'wsc1900sysID',
'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis',
'CISCO-FLASH-MIB' => 'ciscoFlashDeviceSize',
);
%GLOBALS = (
'description' => 'sysDescr',
'ent_physical_software_rev' => 'entPhysicalSoftwareRev.1',
# We will use the numeric OID's so that we don't require people
# to install v1 MIBs, which can conflict.
# OLD-CISCO-CPU-MIB:avgBusyPer
'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0',
'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0',
'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0',
# CISCO-PROCESS-MIB
'cat_cpu' => 'cpmCPUTotal5sec.9',
'cat_cpu_1min' => 'cpmCPUTotal1min.9',
'cat_cpu_5min' => 'cpmCPUTotal5min.9',
# OLD-CISCO-SYSTEM-MIB
'write_mem' => 'writeMem',
'rom_id' => 'romId',
);
%FUNCS = (
# CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolTable
'cisco_mem_free' => 'ciscoMemoryPoolFree',
'cisco_mem_used' => 'ciscoMemoryPoolUsed',
# CISCO-FLASH-MIB::ciscoFlashDeviceTable
'cisco_flash_size' => 'ciscoFlashDeviceSize',
);
%MUNGE = ();
sub vendor {
return 'cisco';
}
sub os {
my $l2 = shift;
my $descr = $l2->description() || '';
# order here matters - there are Catalysts that run IOS and have catalyst
# in their description field.
return 'ios' if ( $descr =~ /IOS/ );
return 'catalyst' if ( $descr =~ /catalyst/i );
return 'css' if ( $descr =~ /Content Switch SW/ );
return 'css-sca' if ( $descr =~ /Cisco Systems Inc CSS-SCA-/ );
return 'pix' if ( $descr =~ /Cisco PIX Security Appliance/ );
return 'asa' if ( $descr =~ /Cisco Adaptive Security Appliance/ );
if ( $descr =~ /Application Control Engine Service Module/ ) {
# Only the admin context implements the entity MIB
return 'ace-admin' if defined $l2->ent_physical_software_rev();
return 'ace-context';
}
# Pre-version 3 FWSMs
return 'fwsm' if ( $descr =~ /Cisco Secure FWSM Firewall/ );
# Version 3+ FWSMs (currently untested against version 4)
if ( $descr =~ /Firewall Services Module/ ) {
my $model = $l2->model();
if ( defined $model && $model eq "WsSvcFwm1sc" ) {
# Only the admin context implements the entity MIB
return 'fwsm-admin' if defined $l2->ent_physical_software_rev();
return 'fwsm-context';
}
# Non context mode FWSM
return 'fwsm';
}
return;
}
sub os_ver {
my $l2 = shift;
my $os = $l2->os();
my $descr = $l2->description();
# Older Catalysts
if ( defined $os
and $os eq 'catalyst'
and defined $descr
and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/ )
{
return $1;
}
if ( defined $os
and $os eq 'css'
and defined $descr
and $descr =~ m/Content Switch SW Version ([0-9\.\(\)]+) with SNMPv1\/v2c Agent/ )
{
return $1;
}
if ( defined $os
and $os eq 'css-sca'
and defined $descr
and $descr =~ m/Cisco Systems Inc CSS-SCA-2FE-K9, ([0-9\.\(\)]+) Release / )
{
return $1;
}
if ( defined $os
and $os eq 'pix'
and defined $descr
and $descr =~ m/Cisco PIX Security Appliance Version ([0-9\.\(\)]+)/ )
{
return $1;
}
if ( defined $os
and $os eq 'asa'
and defined $descr
and $descr =~ m/Cisco Adaptive Security Appliance Version ([0-9\.\(\)]+)/ )
{
return $1;
}
if ( defined $os
and $os =~ /^ace/ )
{
return $l2->ent_physical_software_rev();
}
if ( defined $os
and $os =~ /^fwsm/
and defined $descr
and $descr =~ m/Version (\d+\.\d+(\(\d+\)){0,1})/ )
{
return $1;
}
# Newer Catalysts and IOS devices
if ( defined $descr
and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ )
{
return $1;
}
return;
}
sub os_bin {
my $self = shift;
my $rom_id = $self->rom_id();
if ($rom_id =~ m/Version ([^,]+),/) {
return $1;
}
return;
}
sub cpu {
my $self = shift;
my $ios_cpu = $self->ios_cpu();
return $ios_cpu if defined $ios_cpu;
my $cat_cpu = $self->cat_cpu();
return $cat_cpu;
}
sub cpu_1min {
my $self = shift;
my $ios_cpu_1min = $self->ios_cpu_1min();
return $ios_cpu_1min if defined $ios_cpu_1min;
my $cat_cpu_1min = $self->cat_cpu_1min();
return $cat_cpu_1min;
}
sub cpu_5min {
my $self = shift;
my $ios_cpu_5min = $self->ios_cpu_5min();
return $ios_cpu_5min if defined $ios_cpu_5min;
my $cat_cpu_5min = $self->cat_cpu_5min();
return $cat_cpu_5min;
}
sub mem_free {
my $self = shift;
my $mem_free;
my $cisco_mem_free = $self->cisco_mem_free() || {};
foreach my $mem_free_val ( values %$cisco_mem_free ) {
$mem_free += $mem_free_val;
}
return $mem_free;
}
sub mem_used {
my $self = shift;
my $mem_used;
my $cisco_mem_used = $self->cisco_mem_used() || {};
foreach my $mem_used_val ( values %$cisco_mem_used ) {
$mem_used += $mem_used_val;
}
return $mem_used;
}
sub mem_total {
my $self = shift;
my $mem_total;
my $cisco_mem_free = $self->cisco_mem_free() || {};
my $cisco_mem_used = $self->cisco_mem_used() || {};
foreach my $mem_entry ( keys %$cisco_mem_free ) {
my $mem_free = $cisco_mem_free->{$mem_entry} || 0;
my $mem_used = $cisco_mem_used->{$mem_entry} || 0;
$mem_total += ( $mem_free + $mem_used );
}
return $mem_total;
}
sub flashmem_total {
my $self = shift;
my $flashmem_total;
my $flash_sizes = $self->cisco_flash_size;
foreach my $flash_index ( keys %$flash_sizes ) {
$flashmem_total += $flash_sizes->{$flash_index};
}
return $flashmem_total;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco
Devices
=head1 AUTHOR
Eric Miller, Max Baker, Sam Stickland
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $ciscostats = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ciscostats->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoStats is a subclass of SNMP::Info that provides cpu, memory,
os and version information about Cisco Devices.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<CISCO-PRODUCTS-MIB>
=item F<CISCO-PROCESS-MIB>
=item F<CISCO-MEMORY-POOL-MIB>
=item F<SNMPv2-MIB>
=item F<OLD-CISCO-SYSTEM-MIB>
=item F<CISCO-STACK-MIB>
=item F<CISCO-ENTITY-VENDORTYPE-OID-MIB>
=item F<CISCO-FLASH-MIB>
=item F<ENTITY-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
=item $ciscostats->cpu()
Returns ios_cpu() or cat_cpu(), whichever is available.
=item $ciscostats->cpu_1min()
Returns ios_cpu_1min() or cat_cpu1min(), whichever is available.
=item $ciscostats->cpu_5min()
Returns ios_cpu_5min() or cat_cpu5min(), whichever is available.
=item $ciscostats->mem_total()
Returns mem_free() + mem_used()
=item $ciscostats->vendor()
'cisco'
=item $ciscostats->os()
Tries to parse if device is running IOS or CatOS from description()
Available values :
=over
=item pix
Cisco PIX
=item asa
Cisco ASA
=item fwsm
Single-mode FWSM
=item fwsm-admin
Admin context of multi-context FWSM
=item fwsm-context
Standard context of multi-context FWSM
=item ace-admin
Admin context of ACE module
=item ace-context
Standard context of ACE module (NB: No OS version detection
is available, but will be the same as it's 'ace admin')
=item css
Cisco Content Switch
=item css-sca
Cisco Content Switch Secure Content Acceleration
=back
=item $ciscostats->os_ver()
Tries to parse device operating system version from description()
=item $ciscostats->os_bin()
Tries to parse ROMMON version from rom_id() string
=item $ciscostats->ios_cpu()
Current CPU usage in percent.
C<1.3.6.1.4.1.9.2.1.56.0> =
C<OLD-CISCO-CPU-MIB:avgBusyPer>
=item $ciscostats->ios_cpu_1min()
Average CPU Usage in percent over the last minute.
C<1.3.6.1.4.1.9.2.1.57.0>
=item $ciscostats->ios_cpu_5min()
Average CPU Usage in percent over the last 5 minutes.
C<1.3.6.1.4.1.9.2.1.58.0>
=item $ciscostats->cat_cpu()
Current CPU usage in percent.
C<CISCO-PROCESS-MIB::cpmCPUTotal5sec.9>
=item $ciscostats->cat_cpu_1min()
Average CPU Usage in percent over the last minute.
C<CISCO-PROCESS-MIB::cpmCPUTotal1min.9>
=item $ciscostats->cat_cpu_5min()
Average CPU Usage in percent over the last 5 minutes.
C<CISCO-PROCESS-MIB::cpmCPUTotal5min.9>
=item $ciscostats->mem_free()
Main DRAM free of the device in bytes.
C<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree>
=item $ciscostats->mem_used()
Main DRAM used of the device in bytes.
C<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed>
=item $ciscostats->mem_total()
Main DRAM of the device in bytes.
C<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree> +
C<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed>
=item $ciscostats->flashmem_total()
Flash memory of the device in bytes.
C<CISCO-FLASH-MIB::ciscoFlashDeviceSize>
=back
=head1 TABLE METHODS
=head2 Cisco Memory Pool Table (C<ciscoMemoryPoolTable>)
=over
=item $ciscostats->cisco_mem_free()
The number of bytes from the memory pool that are currently unused on the
managed device.
(C<ciscoMemoryPoolFree>)
=item $ciscostats->cisco_mem_used()
The number of bytes from the memory pool that are currently in use by
applications on the managed device.
(C<ciscoMemoryPoolUsed>)
=back
=head2 Cisco Flash Device Table (C<ciscoFlashDeviceTable>)
=over
=item $ciscostats->cisco_flash_size()
Total size of the Flash device. For a removable device, the size will be
zero if the device has been removed.
(C<ciscoFlashDeviceSize>)
=back
=cut

View File

@@ -1,353 +0,0 @@
# SNMP::Info::CiscoStpExtensions
#
# Copyright (c)2009 Carlos Vicente
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the author nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoStpExtensions;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/;
$VERSION = '2.06';
@SNMP::Info::CiscoStpExtensions::ISA = qw/SNMP::Info::Bridge SNMP::Info Exporter/;
@SNMP::Info::CiscoStpExtensions::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::Bridge::MIBS,
'CISCO-STP-EXTENSIONS-MIB' => 'stpxSpanningTreeType',
);
%GLOBALS = (
%SNMP::Info::Bridge::GLOBALS,
'stpx_mst_config_digest' => 'stpxSMSTConfigDigest',
'stpx_mst_region_name' => 'stpxMSTRegionName',
'stpx_mst_region_rev' => 'stpxSMSTRegionRevision',
'stpx_stp_type' => 'stpxSpanningTreeType',
'stpx_bpduguard_enable' => 'stpxFastStartBpduGuardEnable',
'stpx_bpdufilter_enable' => 'stpxFastStartBpduFilterEnable',
);
%FUNCS = (
%SNMP::Info::Bridge::FUNCS,
'stpx_rootguard_enabled' => 'stpxRootGuardConfigEnabled',
'stpx_loopguard_enabled' => 'stpxLoopGuardConfigEnabled',
'stpx_port_bpduguard_mode' => 'stpxFastStartPortBpduGuardMode',
'stpx_port_bpdufilter_mode' => 'stpxFastStartPortBpduFilterMode',
'stpx_smst_root' => 'stpxSMSTInstanceCISTRegionalRoot',
'stpx_smst_vlans_mapped_1k2k' => 'stpxSMSTInstanceVlansMapped1k2k',
'stpx_smst_vlans_mapped_3k4k' => 'stpxSMSTInstanceVlansMapped3k4k',
);
%MUNGE = (
%SNMP::Info::Bridge::MUNGE,
'stpx_mst_config_digest' => \&SNMP::Info::CiscoStpExtensions::oct2str,
);
# Report version of STP via standard method
sub stp_ver {
my $self = shift;
my $stp_ver = $self->SUPER::stp_ver();
if ( $stp_ver eq 'unknown' ){
if ( defined $self->stpx_stp_type() ){
$stp_ver = $self->stpx_stp_type();
}
}
return $stp_ver;
}
sub mst_config_digest {
my $self = shift;
return $self->stpx_mst_config_digest;
}
sub mst_region_name {
my $self = shift;
return $self->stpx_mst_region_name;
}
sub mst_region_rev {
my $self = shift;
return $self->stpx_mst_region_rev;
}
sub mst_vlan2instance {
my $self = shift;
# Get MST vlan-to-instance mapping
my $m1k2k = $self->stpx_smst_vlans_mapped_1k2k;
my $m3k4k = $self->stpx_smst_vlans_mapped_3k4k;
# Get list of VLANs
my $vlan_membership = $self->i_vlan_membership;
my @vlans;
foreach my $iid ( keys %$vlan_membership ){
if ( my $vm = $vlan_membership->{$iid} ){
foreach my $vid ( @$vm ){
push @vlans, $vid;
}
}
}
my %res;
foreach my $vlan ( @vlans ){
if ( $vlan < 2048 ){
foreach my $inst ( keys %$m1k2k ){
my $list = $m1k2k->{$inst};
my $vlanlist = [split(//, unpack("B*", $list))];
if ( @$vlanlist[$vlan] ){
$res{$vlan} = $inst;
last;
}
}
}else{
foreach my $inst ( keys %$m3k4k ){
my $list = $m3k4k->{$inst};
my $vlanlist = [split(//, unpack("B*", $list))];
if ( @$vlanlist[$vlan-2048] ){
$res{$vlan} = $inst;
last;
}
}
}
}
return \%res;
}
sub i_rootguard_enabled {
my $self = shift;
my $partial = shift;
my $rg_enabled = $self->stpx_rootguard_enabled();
my $bp_index = $self->bp_index($partial);
my %res;
foreach my $index ( keys %$rg_enabled ){
my $enabled = $rg_enabled->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $enabled;
$res{$iid} = $enabled;
}
return \%res;
}
sub i_loopguard_enabled {
my $self = shift;
my $partial = shift;
my $lg_enabled = $self->stpx_loopguard_enabled();
my $bp_index = $self->bp_index($partial);
my %res;
foreach my $index ( keys %$lg_enabled ){
my $enabled = $lg_enabled->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $enabled;
$res{$iid} = $enabled;
}
return \%res;
}
sub i_bpduguard_enabled {
my $self = shift;
my $partial = shift;
my $bpdugm_default = $self->stpx_bpduguard_enable();
my $bp_index = $self->bp_index($partial);
my $bpdugm = $self->stpx_port_bpduguard_mode();
my %res;
foreach my $index ( keys %$bpdugm ){
my $mode = $bpdugm->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $mode;
if ( $mode eq 'default' ){
$res{$iid} = $bpdugm_default;
}else{
$res{$iid} = $mode;
}
}
return \%res;
}
sub i_bpdufilter_enabled {
my $self = shift;
my $partial = shift;
my $bpdufm_default = $self->stpx_bpdufilter_enable();
my $bp_index = $self->bp_index($partial);
my $bpdufm = $self->stpx_port_bpdufilter_mode();
my %res;
foreach my $index ( keys %$bpdufm ){
my $mode = $bpdufm->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $mode;
if ( $mode eq 'default' ){
$res{$iid} = $bpdufm_default;
}else{
$res{$iid} = $mode;
}
}
return \%res;
}
sub oct2str {
my ($v) = @_;
return sprintf('%s', unpack('H*', $v));
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoStpExtensions - SNMP Interface to C<CISCO-STP-EXTENSIONS-MIB>
=head1 AUTHOR
Carlos Vicente
=head1 SYNOPSIS
=head1 DESCRIPTION
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 $stpx = new SNMP::Info::CiscoStpExtensions(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
=item $stpx->stp_ver()
Returns the particular STP version running on this device.
Meant to override SNMP::Info::Brigde::stp_ver()
Values: C<pvstPlus>, C<mistp>, C<mistpPvstPlus>, C<mst>, C<rapidPvstPlus>
(C<stpxSpanningTreeType>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $stpx->mst_config_digest()
Returns the Multiple Spanning Tree (MST) configuration digest
(C<stpxSMSTConfigDigest>)
=item $stpx->mst_region_name()
Returns the Multiple Spanning Tree (MST) region name
(C<stpxMSTRegionName>)
=item $stpx->mst_region_rev()
Returns the Multiple Spanning Tree (MST) region name
(C<stpxSMSTRegionRevision>)
=item $stpx->mst_vlan2instance()
Returns the mapping of vlan to MST instance in the form of a hash reference
with key = VLAN id, value = STP instance
=item $stpx->i_rootguard_enabled()
Returns 1 or 0 depending on whether C<RootGuard> is enabled on a given port.
Format is a hash reference with key = C<ifIndex>, value = [1|0]
(C<stpxRootGuardConfigEnabled>)
=item $stpx->i_loopguard_enabled()
Returns 1 or 0 depending on whether C<LoopGuard> is enabled on a given port.
Format is a hash reference with key = C<ifIndex>, value = [1|0]
(C<stpxLoopGuardConfigEnabled>)
=item $stpx->i_bpduguard_enabled()
Returns 1 or 0 depending on whether C<BpduGuard> is enabled on a given port.
Format is a hash reference with key = C<ifIndex>, value = [1|0]
(C<stpxFastStartPortBpduGuardMode>)
=item $stpx->i_bpdufilter_enabled()
Returns 1 or 0 depending on whether C<BpduFilter> is enabled on a given port.
Format is a hash reference with key = C<ifIndex>, value = [1|0]
(C<stpxFastStartBpduFilterEnable>)
=back
=head1 MUNGES
=over
=item oct2str()
Unpacks H* into a string
=back
=cut

View File

@@ -1,859 +0,0 @@
# SNMP::Info::CiscoVTP
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoVTP;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoVTP::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
'CISCO-VTP-MIB' => 'vtpVlanName',
'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry',
'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex',
);
%GLOBALS = (
'vtp_version' => 'vtpVersion',
'vtp_maxstore' => 'vtpMaxVlanStorage',
'vtp_notify' => 'vtpNotificationsEnabled',
'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled',
'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled',
'vtp_trunk_set_serial' => 'vlanTrunkPortSetSerialNo',
);
%FUNCS = (
# CISCO-VTP-MIB::managementDomainTable
'vtp_d_index' => 'managementDomainIndex',
'vtp_d_name' => 'managementDomainName',
'vtp_d_mode' => 'managementDomainLocalMode',
'vtp_d_rev' => 'managementDomainConfigRevNumber',
'vtp_d_updater' => 'managementDomainLastUpdater',
'vtp_d_last' => 'managementDomainLastChange',
'vtp_d_status' => 'managementDomainRowStatus',
'vtp_d_tftp' => 'managementDomainTftpServer',
'vtp_d_tftp_path' => 'managementDomainTftpPathname',
'vtp_d_pruning' => 'managementDomainPruningState',
'vtp_d_ver' => 'managementDomainVersionInUse',
# CISCO-VTP-MIB::vtpVlanTable
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
'v_said' => 'vtpVlanDot10Said',
'v_ring' => 'vtpVlanRingNumber',
'v_bridge' => 'vtpVlanBridgeNumber',
'v_stp' => 'vtpVlanStpType',
'v_parent' => 'vtpVlanParentVlan',
'v_trans1' => 'vtpVlanTranslationalVlan1',
'v_trans2' => 'vtpVlanTranslationalVlan2',
'v_btype' => 'vtpVlanBridgeType',
'v_hop_are' => 'vtpVlanAreHopCount',
'v_hop_ste' => 'vtpVlanSteHopCount',
'v_crf' => 'vtpVlanIsCRFBackup',
'v_type_ext' => 'vtpVlanTypeExt',
'v_if' => 'vtpVlanIfIndex',
# CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable
'i_vlan_type' => 'vmVlanType',
'i_vlan2' => 'vmVlan',
'i_vlan_stat' => 'vmPortStatus',
'i_vlan_1' => 'vmVlans',
'i_vlan_2' => 'vmVlans2k',
'i_vlan_3' => 'vmVlans3k',
'i_vlan_4' => 'vmVlans4k',
# CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable
'i_voice_vlan' => 'vmVoiceVlanId',
# CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB
'v_cvi_if' => 'cviRoutedVlanIfIndex',
# CISCO-VTP-MIB::vlanTrunkPortTable
'vtp_trunk_mgmt_dom' => 'vlanTrunkPortManagementDomain',
'vtp_trunk_encaps_t' => 'vlanTrunkPortEncapsulationType',
'vtp_trunk_vlans' => 'vlanTrunkPortVlansEnabled',
'vtp_trunk_vlans_2k' => 'vlanTrunkPortVlansEnabled2k',
'vtp_trunk_vlans_3k' => 'vlanTrunkPortVlansEnabled3k',
'vtp_trunk_vlans_4k' => 'vlanTrunkPortVlansEnabled4k',
'vtp_trunk_native' => 'vlanTrunkPortNativeVlan',
'i_pvid' => 'vlanTrunkPortNativeVlan',
'vtp_trunk_rstat' => 'vlanTrunkPortRowStatus',
'vtp_trunk_dyn' => 'vlanTrunkPortDynamicState',
'vtp_trunk_dyn_stat' => 'vlanTrunkPortDynamicStatus',
'vtp_trunk_vtp' => 'vlanTrunkPortVtpEnabled',
'vtp_trunk_encaps' => 'vlanTrunkPortEncapsulationOperType',
# TODO Add these tables if someone wants them..
# vtpEditControlTable
# vtpVlanEditTable
# vtpStatsTable
);
%MUNGE = ();
sub v_index {
my $vtp = shift;
my $partial = shift;
my $v_name = $vtp->v_name($partial);
my %v_index;
foreach my $idx ( keys %$v_name ) {
my ( $mgmtdomain, $vlan ) = split( /\./, $idx );
$v_index{$idx} = $vlan;
}
return \%v_index;
}
sub i_vlan {
my $vtp = shift;
my $partial = shift;
my $port_vlan = $vtp->vtp_trunk_native($partial) || {};
my $i_vlan = $vtp->i_vlan2($partial) || {};
my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {};
my %i_vlans;
# Get access ports
foreach my $port ( keys %$i_vlan ) {
my $vlan = $i_vlan->{$port};
next unless defined $vlan;
$i_vlans{$port} = $vlan;
}
# Get trunk ports
foreach my $port ( keys %$port_vlan ) {
my $vlan = $port_vlan->{$port};
next unless defined $vlan;
my $stat = $trunk_dyn_stat->{$port};
if ( defined $stat and $stat =~ /^trunking/ ) {
$i_vlans{$port} = $vlan;
}
}
# Check in CISCO-VLAN-IFTABLE-RELATION-MIB
# Is this only for Aironet??? If so, it needs
# to be removed from this class
my $v_cvi_if = $vtp->v_cvi_if();
if ( defined $v_cvi_if ) {
# Translate vlan.physical_interface -> iid
# to iid -> vlan
foreach my $i ( keys %$v_cvi_if ) {
my ( $vlan, $phys ) = split( /\./, $i );
my $iid = $v_cvi_if->{$i};
$i_vlans{$iid} = $vlan;
}
}
return \%i_vlans;
}
sub i_vlan_membership {
my $vtp = shift;
my $partial = shift;
my $ports_vlans = $vtp->vtp_trunk_vlans($partial) || {};
my $ports_vlans_2k = $vtp->vtp_trunk_vlans_2k($partial) || {};
my $ports_vlans_3k = $vtp->vtp_trunk_vlans_3k($partial) || {};
my $ports_vlans_4k = $vtp->vtp_trunk_vlans_4k($partial) || {};
my $vtp_vlans = $vtp->v_state();
my $i_vlan = $vtp->i_vlan2($partial) || {};
my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {};
my $i_vlan_membership = {};
# Get access ports
foreach my $port ( keys %$i_vlan ) {
my $vlan = $i_vlan->{$port};
next unless defined $vlan;
my $stat = $trunk_dyn_stat->{$port};
if ( defined $stat and $stat =~ /notTrunking/ ) {
push( @{ $i_vlan_membership->{$port} }, $vlan );
}
}
# Get trunk ports
my %oper_vlans;
foreach my $iid ( keys %$vtp_vlans ) {
my $vlan = 0;
my $vtp_dom = 0;
my $state = $vtp_vlans->{$iid};
next unless defined $state;
next if $state !~ /operational/;
if ( $iid =~ /(\d+)\.(\d+)/ ) {
$vtp_dom = $1;
$vlan = $2;
}
$oper_vlans{$vlan}++;
}
foreach my $port ( keys %$ports_vlans ) {
my $stat = $trunk_dyn_stat->{$port};
if ( defined $stat and $stat =~ /^trunking/ ) {
my $k = 0;
my $list1 = $ports_vlans->{$port} || '0';
my $list2 = $ports_vlans_2k->{$port} || '0';
my $list3 = $ports_vlans_3k->{$port} || '0';
my $list4 = $ports_vlans_4k->{$port} || '0';
foreach my $list ( "$list1", "$list2", "$list3", "$list4" ) {
my $offset = 1024 * $k++;
next unless $list;
my $vlanlist = [ split( //, unpack( "B*", $list ) ) ];
foreach my $vlan ( keys %oper_vlans ) {
push( @{ $i_vlan_membership->{$port} }, $vlan )
if ( @$vlanlist[ $vlan - $offset ] );
}
}
}
}
return $i_vlan_membership;
}
sub set_i_pvid {
my $vtp = shift;
my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
my $native_vlan = $vtp->vtp_trunk_native($ifindex);
if ( defined $native_vlan ) {
print
"Changing native VLAN from $native_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n"
if $vtp->debug();
my $rv = $vtp->set_vtp_trunk_native( $vlan_id, $ifindex );
unless ($rv) {
$vtp->error_throw(
"Unable to change native VLAN to $vlan_id on IfIndex: $ifindex"
);
return;
}
return $rv;
}
$vtp->error_throw("Can't find ifIndex: $ifindex - Is it a trunk port?");
return;
}
sub set_i_vlan {
my $vtp = shift;
my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
my $i_vlan = $vtp->i_vlan2($ifindex);
if ( defined $i_vlan ) {
print
"Changing VLAN from $i_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n"
if $vtp->debug();
my $rv = $vtp->set_i_vlan2( $vlan_id, $ifindex );
unless ($rv) {
$vtp->error_throw(
"Unable to change VLAN to $vlan_id on IfIndex: $ifindex");
return;
}
return $rv;
}
$vtp->error_throw("Can't find ifIndex: $ifindex - Is it an access port?");
return;
}
sub set_add_i_vlan_tagged {
my $vtp = shift;
my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
print "Adding VLAN: $vlan_id to ifIndex: $ifindex\n" if $vtp->debug();
my $trunk_serial = $vtp->load_vtp_trunk_set_serial();
my $trunk_members = $vtp->vtp_trunk_vlans($ifindex);
unless ( defined $trunk_members ) {
$vtp->error_throw(
"Can't find ifIndex: $ifindex - Is it a trunk port?");
return;
}
my @member_list = split( //, unpack( "B*", $trunk_members->{$ifindex} ) );
print "Original vlan list for ifIndex: $ifindex: @member_list \n"
if $vtp->debug();
$member_list[$vlan_id] = '1';
print "Modified vlan list for ifIndex: $ifindex: @member_list \n"
if $vtp->debug();
my $new_list = pack( "B*", join( '', @member_list ) );
#Add VLAN to member list
my $list_rv = $vtp->set_vtp_trunk_vlans( $new_list, $ifindex );
unless ($list_rv) {
$vtp->error_throw(
"Unable to add VLAN: $vlan_id to ifIndex: $ifindex member list");
return;
}
#Make sure no other SNMP manager was making modifications at the same time.
my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial);
unless ($serial_rv) {
$vtp->error_throw(
"Unable to increment trunk set serial number - check configuration!"
);
return;
}
return 1;
}
sub set_remove_i_vlan_tagged {
my $vtp = shift;
my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
print "Removing VLAN: $vlan_id from ifIndex: $ifindex\n" if $vtp->debug();
my $trunk_serial = $vtp->load_vtp_trunk_set_serial();
my $trunk_members = $vtp->vtp_trunk_vlans($ifindex);
unless ( defined $trunk_members ) {
$vtp->error_throw(
"Can't find ifIndex: $ifindex - Is it a trunk port?");
return;
}
my @member_list = split( //, unpack( "B*", $trunk_members->{$ifindex} ) );
print "Original vlan list for ifIndex: $ifindex: @member_list \n"
if $vtp->debug();
$member_list[$vlan_id] = '0';
print "Modified vlan list for ifIndex: $ifindex: @member_list \n"
if $vtp->debug();
my $new_list = pack( "B*", join( '', @member_list ) );
#Remove VLAN to member list
my $list_rv = $vtp->set_vtp_trunk_vlans( $new_list, $ifindex );
unless ($list_rv) {
$vtp->error_throw(
"Error: Unable to remove VLAN: $vlan_id from ifIndex: $ifindex member list"
);
return;
}
#Make sure no other manager was making modifications at the same time.
my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial);
unless ($serial_rv) {
$vtp->error_throw(
"Error: Unable to increment trunk set serial number - check configuration!"
);
return;
}
return 1;
}
#
# These are internal methods and are not documented. Do not use directly.
#
sub _validate_vlan_param {
my $vtp = shift;
my ( $vlan_id, $ifindex ) = @_;
# VID and ifIndex should both be numeric
unless (defined $vlan_id
and defined $ifindex
and $vlan_id =~ /^\d+$/
and $ifindex =~ /^\d+$/ )
{
$vtp->error_throw("Invalid parameter");
return;
}
# Check that ifIndex exists on device
my $index = $vtp->interfaces($ifindex);
unless ( exists $index->{$ifindex} ) {
$vtp->error_throw("ifIndex $ifindex does not exist");
return;
}
#Check that VLAN exists on device
my $vtp_vlans = $vtp->v_state();
my $vlan_exists = 0;
foreach my $iid ( keys %$vtp_vlans ) {
my $vlan = 0;
my $vtp_dom = 0;
my $state = $vtp_vlans->{$iid};
next unless defined $state;
next if $state !~ /operational/;
if ( $iid =~ /(\d+)\.(\d+)/ ) {
$vtp_dom = $1;
$vlan = $2;
}
$vlan_exists = 1 if ( $vlan_id eq $vlan );
}
unless ($vlan_exists) {
$vtp->error_throw(
"VLAN $vlan_id does not exist or is not operational");
return;
}
return 1;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoVTP - SNMP Interface to Cisco's VLAN Management MIBs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $vtp = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $vtp->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoVTP is a subclass of SNMP::Info that provides
information about a Cisco device's VLAN and VTP Domain membership.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<CISCO-VTP-MIB>
=item F<CISCO-VLAN-MEMBERSHIP-MIB>
=item F<CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
=item $vtp->vtp_version()
(C<vtpVersion>)
=item $vtp->vtp_maxstore()
(C<vtpMaxVlanStorage>)
=item $vtp->vtp_notify()
(C<vtpNotificationsEnabled>)
=item $vtp->vtp_notify_create()
(C<vtpVlanCreatedNotifEnabled>)
=item $vtp->vtp_notify_delete()
(C<vtpVlanDeletedNotifEnabled>)
=item $vtp->vtp_trunk_set_serial()
(C<vlanTrunkPortSetSerialNo>)
=back
=head1 TABLE METHODS
Your device will only implement a subset of these methods.
=over
=item $vtp->i_vlan()
Returns a mapping between C<ifIndex> and assigned VLAN ID for access ports
and the default VLAN ID for trunk ports.
=item $vtp->i_vlan_membership()
Returns reference to hash of arrays: key = C<ifIndex>, value = array of VLAN
IDs. These are the VLANs which are members of enabled VLAN list for the port.
Example:
my $interfaces = $vtp->interfaces();
my $vlans = $vtp->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";
}
=back
=head2 VLAN Table (C<CISCO-VTP-MIB::vtpVlanTable>)
See L<ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html>
for a good treaty of how to connect to the VLANs
=over
=item $vtp->v_index()
(C<vtpVlanIndex>)
=item $vtp->v_state()
(C<vtpVlanState>)
=item $vtp->v_type()
(C<vtpVlanType>)
=item $vtp->v_name()
(C<vtpVlanName>)
=item $vtp->v_mtu()
(C<vtpVlanMtu>)
=item $vtp->v_said()
(C<vtpVlanDot10Said>)
=item $vtp->v_ring()
(C<vtpVlanRingNumber>)
=item $vtp->v_bridge()
(C<vtpVlanBridgeNumber>)
=item $vtp->v_stp()
(C<vtpVlanStpType>)
=item $vtp->v_parent()
(C<vtpVlanParentVlan>)
=item $vtp->v_trans1()
(C<vtpVlanTranslationalVlan1>)
=item $vtp->v_trans2()
(C<vtpVlanTranslationalVlan2>)
=item $vtp->v_btype()
(C<vtpVlanBridgeType>)
=item $vtp->v_hop_are()
(C<vtpVlanAreHopCount>)
=item $vtp->v_hop_ste()
(C<vtpVlanSteHopCount>)
=item $vtp->v_crf()
(C<vtpVlanIsCRFBackup>)
=item $vtp->v_type_ext()
(C<vtpVlanTypeExt>)
=item $vtp->v_if()
(C<vtpVlanIfIndex>)
=back
=head2 VLAN Membership Table (C<CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable>)
=over
=item $vtp->i_vlan_type()
Static, Dynamic, or multiVlan.
(C<vmVlanType>)
=item $vtp->i_vlan2()
The VLAN that an access port is assigned to.
(C<vmVlan>)
=item $vtp->i_vlan_stat()
Inactive, active, shutdown.
(C<vmPortStatus>)
=item $vtp->i_vlan_1()
Each bit represents a VLAN. This is 0 through 1023
(C<vmVlans>)
=item $vtp->i_vlan_2()
Each bit represents a VLAN. This is 1024 through 2047
(C<vmVlans2k>)
=item $vtp->i_vlan_3()
Each bit represents a VLAN. This is 2048 through 3071
(C<vmVlans3k>)
=item $vtp->i_vlan_4()
Each bit represents a VLAN. This is 3072 through 4095
(C<vmVlans4k>)
=back
=head2 VLAN Membership Voice VLAN Table
(C<CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable>)
=over
=item $vtp->i_voice_vlan()
(C<vmVoiceVlanId>)
=back
=head2 Management Domain Table (C<CISCO-VTP-MIB::managementDomainTable>)
=over
=item $vtp->vtp_d_index()
(C<managementDomainIndex>)
=item $vtp->vtp_d_name()
(C<managementDomainName>)
=item $vtp->vtp_d_mode()
(C<managementDomainLocalMode>)
=item $vtp->vtp_d_rev()
(C<managementDomainConfigRevNumber>)
=item $vtp->vtp_d_updater()
(C<managementDomainLastUpdater>)
=item $vtp->vtp_d_last()
(C<managementDomainLastChange>)
=item $vtp->vtp_d_status()
(C<managementDomainRowStatus>)
=item $vtp->vtp_d_tftp()
(C<managementDomainTftpServer>)
=item $vtp->vtp_d_tftp_path()
(C<managementDomainTftpPathname>)
=item $vtp->vtp_d_pruning()
(C<managementDomainPruningState>)
=item $vtp->vtp_d_ver()
(C<managementDomainVersionInUse>)
=back
=head2 VLAN Trunk Port Table (C<CISCO-VTP-MIB::vlanTrunkPortTable>)
=over
=item $vtp->vtp_trunk_mgmt_dom()
(C<vlanTrunkPortManagementDomain>)
=item $vtp->vtp_trunk_encaps_t()
(C<vlanTrunkPortEncapsulationType>)
=item $vtp->vtp_trunk_vlans()
(C<vlanTrunkPortVlansEnabled>)
=item $vtp->vtp_trunk_vlans_2k()
(C<vlanTrunkPortVlansEnabled2k>)
=item $vtp->vtp_trunk_vlans_3k()
(C<vlanTrunkPortVlansEnabled3k>)
=item $vtp->vtp_trunk_vlans_4k()
(C<vlanTrunkPortVlansEnabled4k>)
=item $vtp->vtp_trunk_native()
(C<vlanTrunkPortNativeVlan>)
=item $vtp->i_pvid()
(C<vlanTrunkPortNativeVlan>)
=item $vtp->vtp_trunk_rstat()
(C<vlanTrunkPortRowStatus>)
=item $vtp->vtp_trunk_dyn()
(C<vlanTrunkPortDynamicState>)
=item $vtp->vtp_trunk_dyn_stat()
(C<vlanTrunkPortDynamicStatus>)
=item $vtp->vtp_trunk_vtp()
(C<vlanTrunkPortVtpEnabled>)
=item $vtp->vtp_trunk_encaps()
(C<vlanTrunkPortEncapsulationOperType>)
=back
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over
=item $vtp->set_i_vlan ( vlan, ifIndex )
Changes an access (untagged) port VLAN, must be supplied with the numeric
VLAN ID and port C<ifIndex>. This method should only be used on end station
(non-trunk) ports.
Example:
my %if_map = reverse %{$vtp->interfaces()};
$vtp->set_i_vlan('2', $if_map{'FastEthernet0/1'})
or die "Couldn't change port VLAN. ",$vtp->error(1);
=item $vtp->set_i_pvid ( pvid, ifIndex )
Sets port default VLAN, must be supplied with the numeric VLAN ID and
port C<ifIndex>. This method should only be used on trunk ports.
Example:
my %if_map = reverse %{$vtp->interfaces()};
$vtp->set_i_pvid('2', $if_map{'FastEthernet0/1'})
or die "Couldn't change port default VLAN. ",$vtp->error(1);
=item $vtp->set_add_i_vlan_tagged ( vlan, ifIndex )
Adds the VLAN to the enabled VLANs list of the port, must be supplied with the
numeric VLAN ID and port C<ifIndex>.
Example:
my %if_map = reverse %{$vtp->interfaces()};
$vtp->set_add_i_vlan_tagged('2', $if_map{'FastEthernet0/1'})
or die "Couldn't add port to egress list. ",$vtp->error(1);
=item $vtp->set_remove_i_vlan_tagged ( vlan, ifIndex )
Removes the VLAN from the enabled VLANs list of the port, must be supplied
with the numeric VLAN ID and port C<ifIndex>.
Example:
my %if_map = reverse %{$vtp->interfaces()};
$vtp->set_remove_i_vlan_tagged('2', $if_map{'FastEthernet0/1'})
or die "Couldn't add port to egress list. ",$vtp->error(1);
=back
=cut

View File

@@ -1,282 +0,0 @@
# SNMP::Info::Entity
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Entity;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::Entity::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Entity::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum' );
%GLOBALS = ();
%FUNCS = (
'e_alias' => 'entPhysicalAlias',
'e_class' => 'entPhysicalClass',
'e_descr' => 'entPhysicalDescr',
'e_fwver' => 'entPhysicalFirmwareRev',
'e_fru' => 'entPhysicalIsFRU',
'e_hwver' => 'entPhysicalHardwareRev',
'e_id' => 'entPhysicalAssetID',
'e_map' => 'entAliasMappingIdentifier',
'e_model' => 'entPhysicalModelName',
'e_name' => 'entPhysicalName',
'e_parent' => 'entPhysicalContainedIn',
'e_pos' => 'entPhysicalParentRelPos',
'e_serial' => 'entPhysicalSerialNum',
'e_swver' => 'entPhysicalSoftwareRev',
'e_type' => 'entPhysicalVendorType',
'e_vendor' => 'entPhysicalMfgName',
);
%MUNGE = ( 'e_type' => \&SNMP::Info::munge_e_type, );
# entPhysicalIndex is not-accessible. Create to facilitate emulation methods
# in other classes
sub e_index {
my $entity = shift;
my $partial = shift;
# Force use of MIB leaf to avoid inheritance issues in psuedo classes
my $e_descr = $entity->entPhysicalDescr($partial);
return unless ($e_descr);
my %e_index;
foreach my $iid ( keys %$e_descr ) {
$e_index{$iid} = $iid;
}
return \%e_index;
}
sub e_port {
my $entity = shift;
my $partial = shift;
my $e_map = $entity->e_map($partial);
my %e_port;
foreach my $e_id ( keys %$e_map ) {
my $id = $e_id;
$id =~ s/\.0$//;
my $iid = $e_map->{$e_id};
$iid =~ s/.*\.//;
$e_port{$id} = $iid;
}
return \%e_port;
}
1;
__END__
=head1 NAME
SNMP::Info::Entity - SNMP Interface to data stored in F<ENTITY-MIB>. RFC 2737
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $entity = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $entity->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
F<ENTITY-MIB> is used by Layer 2 devices from HP, Aironet, Foundry, Cisco,
and more.
See RFC 2737 for full details.
Create or use a device subclass that inherit this class. Do not use directly.
For debugging purposes you can call this class directly as you would
SNMP::Info
my $entity = new SNMP::Info::Entity (...);
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<ENTITY-MIB>
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
none.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Entity Table
=over
=item $entity->e_index()
Index
(C<entPhysicalIndex>)
=item $entity->e_alias()
Human entered, not usually used.
(C<entPhysicalAlias>)
=item $entity->e_class()
Stack, Module, Container, Port ...
(C<entPhysicalClass>)
=item $entity->e_descr()
Human Friendly
(C<entPhysicalClass>)
=item $entity->e_fwver()
(C<entPhysicalFirmwareRev>)
=item $entity->e_fru()
BOOLEAN. Field Replaceable unit?
(C<entPhysicalFRU>)
=item $entity->e_hwver()
(C<entPhysicalHardwareRev>)
=item $entity->e_id()
This is human entered and not normally used.
(C<entPhysicalAssetID>)
=item $entity->e_map()
See MIB.
(C<entAliasMappingIdentifier>)
=item $entity->e_model()
Model Name of Entity.
(C<entPhysicalModelName>)
=item $entity->e_name()
More computer friendly name of entity. Parse me.
(C<entPhysicalName>)
=item $entity->e_parent()
0 if root.
(C<entPhysicalContainedIn>)
=item $entity->e_port()
Maps Entity Table entries to the Interface Table (C<IfTable>) using
$entity->e_map()
=item $entity->e_pos()
The relative position among all entities sharing the same parent.
(C<entPhysicalParentRelPos>)
=item $entity->e_serial()
(C<entPhysicalSerialNum>)
=item $entity->e_swver()
(C<entPhysicalSoftwareRev>)
=item $entity->e_type()
This is an OID, which gets munged into the object name if the right
MIB is loaded.
(C<entPhysicalVendorType>)
=item $entity->e_vendor()
Vendor of Module.
(C<entPhysicalMfgName>)
=back
=cut

View File

@@ -1,86 +1,62 @@
# SNMP::Info::EtherLike
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::EtherLike;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::EtherLike::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
$INIT = 0;
%MIBS = ( 'EtherLike-MIB' => 'etherMIB' );
# Same info in both rfc1398 and this?
%MIBS = ('ETHERLIKE-MIB' => 'etherMIB' );
%GLOBALS = ();
%FUNCS = (
# EtherLike StatsTable
'el_index' => 'dot3StatsIndex',
'el_duplex' => 'dot3StatsDuplexStatus',
);
# EtherLike StatsTable
'el_chipset' => 'dot3StatsEtherChipSet',
'el_coll_excess' => 'dot3StatsExcessiveCollisions',
'el_coll_late' => 'dot3StatsLateCollisions',
'el_coll_mult' => 'dot3StatsMultipleCollisionFrames',
'el_coll_single' => 'dot3StatsSingleCollisionFrames',
'el_duplex' => 'dot3StatsDuplexStatus',
'el_error_alignment' => 'dot3StatsAlignmentErrors',
'el_error_fcs' => 'dot3StatsFCSErrors',
'el_error_cs' => 'dot3StatsCarrierSenseErrors',
'el_error_frame' => 'dot3StatsFrameTooLongs',
'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors',
'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors',
'el_error_sqe' => 'dot3StatsSQETestErrors',
'el_error_symbol' => 'dot3StatsSymbolErrors',
'el_index' => 'dot3StatsIndex',
'el_xmit_defer' => 'dot3StatsDeferredTransmissions',
# Ethernet-like Collision Statistics Group
'el_coll_count' => 'dot3CollCount',
'el_coll_freq' => 'dot3CollFrequencies'
);
%MUNGE = ( %SNMP::Info::MUNGE, 'el_duplex' => \&munge_el_duplex, );
sub munge_el_duplex {
my $duplex = shift;
return unless defined $duplex;
$duplex =~ s/Duplex$//;
return $duplex;
}
%MUNGE = ( %SNMP::Info::MUNGE );
1;
__END__
@@ -88,80 +64,54 @@ __END__
=head1 NAME
SNMP::Info::EtherLike - SNMP Interface to SNMP F<ETHERLIKE-MIB> RFC 1398
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
my $el = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
my $class = $cdp->class();
print " Using device sub class : $class\n";
# Find the duplex setting for a port on a device that implements
# ETHERLIKE-MIB
my $interfaces = $el->interfaces();
my $el_index = $el->el_index();
my $el_duplex = $el->el_duplex();
foreach my $el_port (keys %$el_duplex){
my $duplex = $el_duplex->{$el_port};
my $iid = $el_index->{$el_port};
my $port = $interfaces->{$iid};
print "PORT:$port set to duplex:$duplex\n";
}
SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB
=head1 DESCRIPTION
SNMP::Info::EtherLike is a subclass of SNMP::Info that supplies
access to the F<ETHERLIKE-MIB> used by some Layer 3 Devices such as
Cisco routers.
access to the ETHERLIKE-MIB used by some Layer 3 Devices such as Cisco routers.
See RFC 1398 for more details.
Use SNMP::Info directly, or create a subclass that inherits this one.
Use or create a subclass of SNMP::Info that inherits this one. Do not use
directly.
=head1 AUTHOR
=head2 Inherited Classes
Max Baker (C<max@warped.org>)
None.
=head1 SYNOPSIS
=head2 Required MIBs
my $el = new SNMP::Info::EtherLike(DestHost => 'myrouter',
Community => 'public');
my $el_decoder = $el->el_index();
my $el_duplex = $el->el_duplex();
=head1 CREATING AN OBJECT
=over
=item F<ETHERLIKE-MIB>
=item new SNMP::Info::EtherLike()
Arguments passed to new() are passed on to SNMP::Session::new()
my $el = new SNMP::Info::EtherLike(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $el;
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
These are methods that return scalar values from SNMP
=over
=item None
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 ETHERLIKE STATS TABLE (C<dot3StatsTable>)
=head1 ETHERLIKE STATS TABLE (dot3StatsTable)
=over
@@ -169,87 +119,13 @@ to a hash.
Returns reference to hash. Indexes Stats Table to the interface index (iid).
(C<dot3StatsIndex>)
(B<dot3StatsIndex>)
=item $el->el_duplex()
Returns reference to hash. Indexes Stats Table to Duplex Status of port.
(C<dot3StatsDuplexStatus>)
=item $el->el_chipset()
(C<dot3StatsEtherChipSet>)
=item $el->el_coll_excess()
(C<dot3StatsExcessiveCollisions>)
=item $el->el_coll_late()
(C<dot3StatsLateCollisions>)
=item $el->el_coll_mult()
(C<dot3StatsMultipleCollisionFrames>)
=item $el->el_coll_single()
(C<dot3StatsSingleCollisionFrames>)
=item $el->el_error_alignment()
(C<dot3StatsAlignmentErrors>)
=item $el->el_error_fcs()
(C<dot3StatsFCSErrors>)
=item $el->el_error_cs()
(C<dot3StatsCarrierSenseErrors>)
=item $el->el_error_frame()
(C<dot3StatsFrameTooLongs>)
=item $el->el_error_mac_rec()
(C<dot3StatsInternalMacReceiveErrors>)
=item $el->el_error_mac_xmit()
(C<dot3StatsInternalMacTransmitErrors>)
=item $el->el_error_sqe()
(C<dot3StatsSQETestErrors>)
=item $el->el_error_symbol()
(C<dot3StatsSymbolErrors>)
=item $el->el_xmit_defer()
(C<dot3StatsDeferredTransmissions>)
=item $el->el_coll_count()
(C<dot3CollCount>)
=item $el->el_coll_freq()
(C<dot3CollFrequencies>)
=back
=head1 Data Munging Callback Subroutines
=over
=item $el->munge_el_duplex()
Removes 'Duplex' from the end of a string.
(B<dot3StatsDuplexStatus>)
=back

View File

@@ -1,432 +0,0 @@
# SNMP::Info::FDP
# $Id$
#
# Copyright (c) 2008 Bruce Rodger, Max Baker
# All rights reserved.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::FDP;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::FDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::FDP::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' );
%GLOBALS = (
# CDP-Compatibility
'cdp_interval' => 'snFdpGlobalMessageInterval',
'cdp_holdtime' => 'snFdpGlobalHoldTime',
'cdp_id' => 'snFdpGlobalDeviceId',
#
'fdp_run' => 'snFdpGlobalRun',
'fdp_interval' => 'snFdpGlobalMessageInterval',
'fdp_holdtime' => 'snFdpGlobalHoldTime',
'fdp_id' => 'snFdpGlobalDeviceId',
);
%FUNCS = (
'c_index' => 'snFdpCacheIfIndex',
'c_proto' => 'snFdpCacheAddressType',
'c_ip' => 'snFdpCacheAddress',
'c_ver' => 'snFdpCacheVersion',
'c_id' => 'snFdpCacheDeviceId',
'c_port' => 'snFdpCacheDevicePort',
'c_platform' => 'snFdpCachePlatform',
'c_capabilities' => 'snFdpCacheCapabilities',
'c_domain' => 'snFdpCacheVTPMgmtDomain',
'c_vlan' => 'snFdpCacheNativeVLAN',
'c_duplex' => 'snFdpCacheDuplex',
);
%MUNGE = (
'c_capabilities' => \&SNMP::Info::munge_caps,
'c_ip' => \&SNMP::Info::munge_ip
);
sub cdp_run {
my $fdp = shift;
my $fdp_run = $fdp->fdp_run();
# if fdp_run isn't implemented on device, assume FDP is on
return $fdp_run if defined $fdp_run;
return 1;
}
sub hasFDP {
my $fdp = shift;
my $ver = $fdp->{_version};
#my $ver = $fdp->fdp_ver;
# SNMP v1 clients dont have the globals
if ( defined $ver and $ver == 1 ) {
my $fdp_ip = $fdp->fdp_ip();
# See if anything in fdp cache, if so we have fdp
return 1 if ( defined $fdp_ip and scalar( keys %$fdp_ip ) );
return;
}
return $fdp->fdp_run();
}
sub c_if {
my $fdp = shift;
# See if by some miracle Cisco implemented the fdpCacheIfIndex entry
my $fdp_index = $fdp->fdp_index();
return $fdp_index if defined $fdp_index;
# Nope, didn't think so. Now we fake it.
my $fdp_ip = $fdp->c_ip();
unless ( defined $fdp_ip ) {
$fdp->error_throw(
"SNMP::Info::FDP:fdp_if() - Device doesn't have fdp_ip() data. Can't fake fdp_index()"
);
return;
}
my %fdp_if;
foreach my $key ( keys %$fdp_ip ) {
next unless defined $key;
my $iid = $key;
# Truncate .1 from fdp cache entry
$iid =~ s/\.\d+$//;
$fdp_if{$key} = $iid;
}
return \%fdp_if;
}
1;
__END__
=head1 NAME
SNMP::Info::FDP - SNMP Interface to Foundry Discovery Protocol (FDP) using
SNMP
=head1 AUTHOR
Bruce Rodger, Max Baker
=head1 SYNOPSIS
my $fdp = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
my $class = $fdp->class();
print " Using device sub class : $class\n";
$hasfdp = $fdp->hasFDP() ? 'yes' : 'no';
# Print out a map of device ports with FDP neighbors:
my $interfaces = $fdp->interfaces();
my $fdp_if = $fdp->fdp_if();
my $fdp_ip = $fdp->fdp_ip();
my $fdp_port = $fdp->fdp_port();
foreach my $fdp_key (keys %$fdp_ip){
my $iid = $fdp_if->{$fdp_key};
my $port = $interfaces->{$iid};
my $neighbor = $fdp_ip->{$fdp_key};
my $neighbor_port = $fdp_port->{$fdp_key};
print "Port : $port connected to $neighbor / $neighbor_port\n";
}
=head1 DESCRIPTION
SNMP::Info::FDP is a subclass of SNMP::Info that provides an object oriented
interface to FDP information through SNMP.
FDP is a Layer 2 protocol that supplies topology information of
devices that also speak FDP, mostly switches and routers. It has
similar functionality to Cisco's CDP, and the SNMP interface is
virtually identical. FDP is implemented in Foundry devices, including
the Bigiron and Fastiron range.
Create or use a device subclass that inherits this class. Do not use
directly.
Each device implements a subset of the global and cache entries.
Check the return value to see if that data is held by the device.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<FOUNDRY-SN-SWITCH-GROUP-MIB>
Needs a reasonably recent MIB. Works OK with B2R07604A.mib, but doesn't
work with B2R07600C.
=back
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
=item $fdp->hasFDP()
Is FDP is active in this device?
Accounts for SNMP version 1 devices which may have FDP but not fdp_run()
=item $fdp->fdp_run()
Is FDP enabled on this device?
(C<fdpGlobalRun>)
=item $fdp->fdp_interval()
Interval in seconds at which FDP messages are generated.
(C<fdpGlobalMessageInterval>)
=item $fdp->fdp_holdtime()
Time in seconds that FDP messages are kept.
(C<fdpGlobalHoldTime>)
=item $fdp->fdp_id()
Returns FDP device ID.
This is the device id broadcast via FDP to other devices, and is what is
retrieved from remote devices with $fdp->id().
(C<fdpGlobalDeviceId>)
=back
=head2 Overrides
CDP compatibility
=over
=item $fdp->c_interval()
Interval in seconds at which FDP messages are generated.
(C<fdpGlobalMessageInterval>)
=item $fdp->c_holdtime()
Time in seconds that FDP messages are kept.
(C<fdpGlobalHoldTime>)
=item $fdp->c_id()
Returns FDP device ID.
This is the device id broadcast via FDP to other devices, and is what is
retrieved from remote devices with $fdp->id().
(C<fdpGlobalDeviceId>)
=item $cdp->cdp_run()
Is FDP enabled on this device?
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
CDP compatibility
=over
=item $fdp->c_capabilities()
Returns Device Functional Capabilities. Results are munged into an ascii
binary string, 7 digits long, MSB. Each digit represents a bit from the
table below.
From L<http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#18843>:
(Bit) - Description
=over
=item (0x40) - Provides level 1 functionality.
=item (0x20) - The bridge or switch does not forward IGMP Report packets on
non router ports.
=item (0x10) - Sends and receives packets for at least one network layer
protocol. If the device is routing the protocol, this bit should not be set.
=item (0x08) - Performs level 2 switching. The difference between this bit
and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This
device is assumed to be deployed in a physical loop-free topology.
=item (0x04) - Performs level 2 source-route bridging. A source-route bridge
would set both this bit and bit 0x02.
=item (0x02) - Performs level 2 transparent bridging.
=item (0x01) - Performs level 3 routing for at least one network layer
protocol.
=back
Thanks to Martin Lorensen C<martin -at- lorensen.dk> for a pointer to
this information.
(C<fdpCacheCapabilities>)
=item $fdp->c_domain()
The CDP version of this returns remote VTP Management Domain as defined
in C<CISCO-VTP-MIB::managementDomainName>
(C<fdpCacheVTPMgmtDomain>)
=item $fdp->c_duplex()
Returns the port duplex status from remote devices.
(C<fdpCacheDuplex>)
=item $fdp->c_id()
Returns remote device id string
(C<fdpCacheDeviceId>)
=item $fdp->c_if()
Returns the mapping to the SNMP Interface Table.
Note that a lot devices don't implement $fdp->fdp_index(), So if it isn't
around, we fake it.
In order to map the fdp table entry back to the interfaces() entry, we
truncate the last number off of it :
# it exists, yay.
my $fdp_index = $device->fdp_index();
return $fdp_index if defined $fdp_index;
# if not, let's fake it
my $fdp_ip = $device->fdp_ip();
my %fdp_if
foreach my $key (keys %$fdp_ip){
$iid = $key;
## Truncate off .1 from fdp response
$iid =~ s/\.\d+$//;
$fdp_if{$key} = $iid;
}
return \%fdp_if;
=item $fdp->c_index()
Returns the mapping to the SNMP2 Interface table for FDP Cache Entries.
Most devices don't implement this, so you probably want to use $fdp->fdp_if()
instead.
See fdp_if() entry.
(C<fdpCacheIfIndex>)
=item $fdp->c_ip()
Returns remote IP address
(C<fdpCacheAddress>)
=item $fdp->c_platform()
Returns remote platform id
(C<fdpCachePlatform>)
=item $fdp->c_port()
Returns remote port ID
(C<fdpDevicePort>)
=item $fdp->c_proto()
Returns remote address type received. Usually IP.
(C<fdpCacheAddressType>)
=item $fdp->c_ver()
Returns remote hardware version
(C<fdpCacheVersion>)
=item $fdp->c_vlan()
Returns the remote interface native VLAN.
(C<fdpCacheNativeVLAN>)
=back
=cut

View File

@@ -1,407 +0,0 @@
# SNMP::Info::IEEE802dot11
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::IEEE802dot11;
use strict;
use Exporter;
@SNMP::Info::IEEE802dot11::ISA = qw/Exporter/;
@SNMP::Info::IEEE802dot11::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'IEEE802dot11-MIB' => 'dot11DesiredSSID', );
%GLOBALS = ();
%FUNCS = (
# dot11PhyOFDMTable
'dot11_cur_freq' => 'dot11CurrentFrequency',
# dot11PhyDSSSTable
'dot11_cur_ch' => 'dot11CurrentChannel',
# dot11PhyOperationTable
'dot11_phy_type' => 'dot11PHYType',
'dot11_reg_dom' => 'dot11CurrentRegDomain',
# dot11ResourceInfoTable
'dot11_prod_ver' => 'dot11manufacturerProductVersion',
'dot11_prod_name' => 'dot11manufacturerProductName',
'dot11_man_name' => 'dot11manufacturerName',
# dot11OperationTable
'dot11_mac' => 'dot11MACAddress',
# dot11StationConfigTable
'dot11_bss_type' => 'dot11DesiredBSSType',
'i_ssidlist' => 'dot11DesiredSSID',
'dot11_pwr_mode' => 'dot11PowerManagementMode',
'dot11_sta_id' => 'dot11StationID',
# dot11PhyTxPowerTable
'dot11_cur_tx_pwr' => 'dot11CurrentTxPowerLevel',
'dot11_tx_pwr_level_1' => 'dot11TxPowerLevel1',
'dot11_tx_pwr_level_2' => 'dot11TxPowerLevel2',
'dot11_tx_pwr_level_3' => 'dot11TxPowerLevel3',
'dot11_tx_pwr_level_4' => 'dot11TxPowerLevel4',
'dot11_tx_pwr_level_5' => 'dot11TxPowerLevel5',
'dot11_tx_pwr_level_6' => 'dot11TxPowerLevel6',
'dot11_tx_pwr_level_7' => 'dot11TxPowerLevel7',
'dot11_tx_pwr_level_8' => 'dot11TxPowerLevel8',
);
%MUNGE = (
'dot11_mac' => \&SNMP::Info::munge_mac,
'dot11_sta_id' => \&SNMP::Info::munge_mac,
);
sub vendor {
my $dot11 = shift;
my $names = $dot11->dot11_man_name();
foreach my $iid ( keys %$names ) {
my $vendor = $names->{$iid};
next unless defined $vendor;
if ( $vendor =~ /^(\S+)/ ) {
return lc($1);
}
}
return;
}
sub model {
my $dot11 = shift;
my $names = $dot11->dot11_prod_name();
foreach my $iid ( keys %$names ) {
my $prod = $names->{$iid};
next unless defined $prod;
return lc($prod);
}
return;
}
sub os_ver {
my $dot11 = shift;
my $versions = $dot11->dot11_prod_ver();
foreach my $iid ( keys %$versions ) {
my $ver = $versions->{$iid};
next unless defined $ver;
if ( $ver =~ /([\d\.]+)/ ) {
return $1;
}
}
return;
}
sub i_80211channel {
my $dot11 = shift;
my $phy_type = $dot11->dot11_phy_type() || {};
my $cur_freq = $dot11->dot11_cur_freq() || {};
my $cur_ch = $dot11->dot11_cur_ch() || {};
my %i_80211channel;
foreach my $iid ( keys %$phy_type ) {
my $type = $phy_type->{$iid};
next unless defined $type;
if ( $type =~ /dsss/ ) {
my $ch = $cur_ch->{$iid};
next unless defined $ch;
$i_80211channel{$iid} = $ch;
}
elsif ( $type =~ /ofdm/ ) {
my $ch = $cur_freq->{$iid};
next unless defined $ch;
$i_80211channel{$iid} = $ch;
}
else {
next;
}
}
return \%i_80211channel;
}
sub dot11_cur_tx_pwr_mw {
my $dot11 = shift;
my $partial = shift;
my $cur = $dot11->dot11_cur_tx_pwr($partial);
my $dot11_cur_tx_pwr_mw = {};
foreach my $idx ( keys %$cur ) {
my $pwr = $cur->{$idx};
if ( $pwr >= 1 && $pwr <= 8 ) {
# ToDo - Look at string eval
my $mw
= eval "\$dot11->dot11_tx_pwr_level_$pwr(\$idx)"; ## no critic
$dot11_cur_tx_pwr_mw->{$idx} = $mw->{$idx};
}
else {
next;
}
}
return $dot11_cur_tx_pwr_mw;
}
1;
__END__
=head1 NAME
SNMP::Info::IEEE802dot11 - SNMP Interface to data from F<IEEE802dot11-MIB>
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
my $dot11 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $dot11->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
SNMP::Info::IEEE802dot11 is a subclass of SNMP::Info that provides an
interface to F<IEEE802dot11-MIB>. This MIB is used in standards based
802.11 wireless devices.
Use or create a subclass of SNMP::Info that inherits this one.
Do not use directly.
=head2 Inherited Classes
=over
None.
=back
=head2 Required MIBs
=over
=item F<IEEE802dot11-MIB>
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $dot11->vendor()
Tries to discover the vendor from dot11_man_name() - returns lower case
of the first word in the first instance found.
=item $dot11->model()
Tries to discover the model from dot11_prod_name() - returns lower case
of the first instance found.
=item $dot11->os_ver()
Tries to discover the operating system version from dot11_prod_ver() - returns
string of numeric and decimals in the first instance found.
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $dot11->i_ssidlist()
Returns reference to hash. SSID's recognized by the radio interface.
(C<dot11DesiredSSID>)
=item $dot11->i_80211channel()
Returns reference to hash. Current operating frequency channel of the radio
interface.
=item $dot11->dot11_cur_tx_pwr_mw()
Returns reference to hash. Current transmit power, in milliwatts, of the
radio interface.
=back
=head2 Dot11 Phy OFDM Table (C<dot11PhyOFDMTable>)
=over
=item $dot11->dot11_cur_freq()
(C<dot11CurrentFrequency>)
=back
=head2 Dot11 Phy DSSS Table (C<dot11PhyDSSSTable>)
=over
=item $dot11->dot11_cur_ch()
(C<dot11CurrentChannel>)
=back
=head2 Dot11 Phy Operation Table (C<dot11PhyOperationTable>)
=over
=item $dot11->dot11_phy_type()
(C<dot11PHYType>)
=item $dot11->dot11_reg_dom()
(C<dot11CurrentRegDomain>)
=back
=head2 Dot11 Resource Information Table (C<dot11ResourceInfoTable>)
=over
=item $dot11->dot11_prod_ver()
(C<dot11manufacturerProductVersion>)
=item $dot11->dot11_prod_name()
(C<dot11manufacturerProductName>)
=item $dot11->dot11_man_name()
(C<dot11manufacturerName>)
=back
=head2 Dot11 Operation Table (C<dot11OperationTable>)
=over
=item $dot11->dot11_mac()
(C<dot11MACAddress>)
=back
=head2 Dot11 Station Configuration Table (C<dot11StationConfigTable>)
=over
=item $dot11->dot11_bss_type()
(C<dot11DesiredBSSType>)
=item $dot11->dot11_pwr_mode()
(C<dot11PowerManagementMode>)
=item $dot11->dot11_sta_id()
(C<dot11StationID>)
=back
=head2 Dot11 Transmission Power Table (C<dot11PhyTxPowerTable>)
=over
=item $dot11->dot11_cur_tx_pwr()
(C<dot11CurrentTxPowerLevel>)
=item $dot11->dot11_tx_pwr_level_1()
(C<dot11TxPowerLevel1>)
=item $dot11->dot11_tx_pwr_level_2()
(C<dot11TxPowerLevel2>)
=item $dot11->dot11_tx_pwr_level_3()
(C<dot11TxPowerLevel3>)
=item $dot11->dot11_tx_pwr_level_4()
(C<dot11TxPowerLevel4>)
=item $dot11->dot11_tx_pwr_level_5()
(C<dot11TxPowerLevel5>)
=item $dot11->dot11_tx_pwr_level_6()
(C<dot11TxPowerLevel6>)
=item $dot11->dot11_tx_pwr_level_7()
(C<dot11TxPowerLevel7>)
=item $dot11->dot11_tx_pwr_level_8()
(C<dot11TxPowerLevel8>)
=back
=cut

View File

@@ -1,475 +0,0 @@
# SNMP::Info::IPv6
#
# Copyright (c) 2010 Jeroen van Ingen and Carlos Vicente
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::IPv6;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::IPv6::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::IPv6::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE $METHOD/;
use constant {
IPMIB => 1,
CISCO => 2,
IPV6MIB => 3,
};
$VERSION = '2.06';
%MIBS = (
'IP-MIB' => 'ipv6InterfaceTableLastChange',
'IPV6-MIB' => 'ipv6IfTableLastChange',
'CISCO-IETF-IP-MIB' => 'cInetNetToMediaNetAddress',
);
%GLOBALS = ();
%FUNCS = (
'ip_n2p_phys_addr' => 'ipNetToPhysicalPhysAddress', # IP-MIB
'c_inet_phys_addr' => 'cInetNetToMediaPhysAddress', # CISCO-IETF-IP-MIB
'i6_n2p_phys_addr' => 'ipv6NetToMediaNetAddress', # IPV6-MIB
'ip_n2p_phys_type' => 'ipNetToPhysicalType', # IP-MIB
'c_inet_phys_type' => 'cInetNetToMediaType', # CISCO-IETF-IP-MIB
'i6_n2p_phys_type' => 'ipv6NetToMediaType', # IPV6-MIB
'ip_n2p_phys_state' => 'ipNetToPhysicalState', # IP-MIB
'c_inet_phys_state' => 'cInetNetToMediaState', # CISCO-IETF-IP-MIB
'i6_n2p_phys_state' => 'ipv6NetToMediaState', # IPV6-MIB
'ip_pfx_origin' => 'ipAddressPrefixOrigin', # IP-MIB
'c_pfx_origin' => 'cIpAddressPfxOrigin', # CISCO-IETF-IP-MIB
'ip_addr6_pfx' => 'ipAddressPrefix', # IP-MIB
'c_addr6_pfx' => 'cIpAddressPrefix', # CISCO-IETF-IP-MIB
'ip_addr6_index' => 'ipAddressIfIndex', # IP-MIBw
'c_addr6_index' => 'cIpAddressIfIndex', # CISCO-IETF-IP-MIB
'ip_addr6_type' => 'ipAddressType', # IP-MIB
'c_addr6_type' => 'cIpAddressType', # CISCO-IETF-IP-MIB
);
%MUNGE = (
'ip_n2p_phys_addr' => \&SNMP::Info::munge_mac,
'c_inet_phys_addr' => \&munge_physaddr,
'i6_n2p_phys_addr' => \&SNMP::Info::munge_mac,
);
sub ipv6_n2p_mac {
my $info = shift;
my $return;
my $phys_addr = &_test_methods( $info, {
ip_n2p_phys_addr => IPMIB,
c_inet_phys_addr => CISCO,
i6_n2p_phys_addr => IPV6MIB,
});
return unless defined $phys_addr;
foreach my $row (keys %$phys_addr) {
if ($row =~ /^(\d+)\.(\d+)\.(\d+)\.([\d\.]+)$/) {
my $ifindex = $1; my $addrtype = $2; my $addrsize = $3; my $v6addr = $4;
if ($info::METHOD == IPV6MIB) {
# IPV6-MIB doesn't include the addrtype in the index;
# also, address syntax is IPv6Address (fixed 16 bytes) and not InetAddress (length field followed by address bytes)
$v6addr = join('.', $addrtype, $addrsize, $v6addr);
$addrtype = 2;
}
if (($addrtype == 2) && (defined $phys_addr->{$row})) { # IPv6
$return->{$row} = substr($phys_addr->{$row}, 0, 17);
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_n2p_addr {
my $info = shift;
my $return;
my $net_addr = &_test_methods( $info, {
ip_n2p_phys_addr => IPMIB,
c_inet_phys_addr => CISCO,
i6_n2p_phys_addr => IPV6MIB,
});
return unless defined $net_addr;
foreach my $row (keys %$net_addr) {
if ($row =~ /^(\d+)\.(\d+)\.(\d+)\.([\d\.]+)$/) {
my $ifindex = $1; my $addrtype = $2; my $addrsize = $3; my $v6addr = $4;
if ($info::METHOD == IPV6MIB) {
# IPV6-MIB doesn't include the addrtype in the index;
# also, address syntax is IPv6Address (fixed 16 bytes) and not InetAddress (length field followed by address bytes)
$v6addr = join('.', $addrtype, $addrsize, $v6addr);
$addrtype = 2;
}
if ($addrtype == 2) { # IPv6
my $v6_packed = pack("C*", split(/\./, $v6addr));
$v6addr = join(':', map { sprintf("%04x", $_) } unpack("n*", $v6_packed) );
$return->{$row} = $v6addr;
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_n2p_if {
my $info = shift;
my $return;
my $phys_addr = &_test_methods( $info, {
ip_n2p_phys_addr => IPMIB,
c_inet_phys_addr => CISCO,
i6_n2p_phys_addr => IPV6MIB,
});
return unless defined $phys_addr;
foreach my $row (keys %$phys_addr) {
if ($row =~ /^(\d+)\.(\d+)\.(\d+)\.([\d\.]+)$/) {
my $ifindex = $1; my $addrtype = $2; my $addrsize = $3; my $v6addr = $4;
if ($info::METHOD == IPV6MIB) {
# IPV6-MIB doesn't include the addrtype in the index;
# also, address syntax is IPv6Address (fixed 16 bytes) and not InetAddress (length field followed by address bytes)
$v6addr = join('.', $addrtype, $addrsize, $v6addr);
$addrtype = 2;
}
if ($addrtype == 2) { # IPv6
$return->{$row} = $ifindex;
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_n2p_type {
my $info = shift;
my $return;
my $phys_type = &_test_methods( $info, {
ip_n2p_phys_type => IPMIB,
c_inet_phys_type => CISCO,
i6_n2p_phys_type => IPV6MIB,
});
return unless defined $phys_type;
foreach my $row (keys %$phys_type) {
if ($row =~ /^(\d+)\.(\d+)\.(\d+)\.([\d\.]+)$/) {
my $ifindex = $1; my $addrtype = $2; my $addrsize = $3; my $v6addr = $4;
if ($info::METHOD == IPV6MIB) {
# IPV6-MIB doesn't include the addrtype in the index;
# also, address syntax is IPv6Address (fixed 16 bytes) and not InetAddress (length field followed by address bytes)
$v6addr = join('.', $addrtype, $addrsize, $v6addr);
$addrtype = 2;
}
if ($addrtype == 2) { # IPv6
$return->{$row} = $phys_type->{$row};
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_n2p_state {
my $info = shift;
my $return;
my $phys_state = &_test_methods( $info, {
ip_n2p_phys_state => IPMIB,
c_inet_phys_state => CISCO,
i6_n2p_phys_state => IPV6MIB,
});
return unless defined $phys_state;
foreach my $row (keys %$phys_state) {
if ($row =~ /^(\d+)\.(\d+)\.(\d+)\.([\d\.]+)$/) {
my $ifindex = $1; my $addrtype = $2; my $addrsize = $3; my $v6addr = $4;
if ($info::METHOD == IPV6MIB) {
# IPV6-MIB doesn't include the addrtype in the index;
# also, address syntax is IPv6Address (fixed 16 bytes) and not InetAddress (length field followed by address bytes)
$v6addr = join('.', $addrtype, $addrsize, $v6addr);
$addrtype = 2;
}
if ($addrtype == 2) { # IPv6
$return->{$row} = $phys_state->{$row};
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_index {
my $info = shift;
my $return;
my $ipv6_index = &_test_methods( $info, {
ip_addr6_index => IPMIB,
c_addr6_index => CISCO,
});
return unless defined $ipv6_index;
foreach my $row (keys %$ipv6_index){
if ($row =~ /^(\d+)\.([\d\.]+)$/) {
my $addrtype = $1; my $v6addr = $2;
if ($addrtype == 2) { # IPv6
$return->{$row} = $ipv6_index->{$row};
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_type {
my $info = shift;
my $return;
my $ipv6_type = &_test_methods( $info, {
ip_addr6_type => IPMIB,
c_addr6_type => CISCO,
});
return unless defined $ipv6_type;
foreach my $row (keys %$ipv6_type){
if ($row =~ /^(\d+)\.([\d\.]+)$/) {
my $addrtype = $1; my $v6addr = $2;
if ($addrtype == 2) { # IPv6
$return->{$row} = $ipv6_type->{$row};
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_pfx_origin {
my $info = shift;
my $return;
my $ipv6_pfx_origin = &_test_methods( $info, {
ip_pfx_origin => IPMIB,
c_pfx_origin => CISCO,
});
return unless defined $ipv6_pfx_origin;
foreach my $row (keys %$ipv6_pfx_origin){
if ($row =~ /^(\d+)\.(\d+)\.([\d\.]+)\.(\d+)$/) {
my $ifindex = $1; my $type = $2; my $pfx = $3; my $len = $4;
if ($type == 2) { # IPv6
$return->{$row} = $ipv6_pfx_origin->{$row};
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub ipv6_addr_prefix {
my $info = shift;
my $return;
my $ipv6_addr_prefix = &_test_methods( $info, {
ip_addr6_pfx => IPMIB,
c_addr6_pfx => CISCO,
});
return unless defined $ipv6_addr_prefix;
foreach my $row (keys %$ipv6_addr_prefix){
if ($row =~ /^(\d+)\.[\d\.]+$/) {
my $type = $1;
if ($type == 2) { # IPv6
# Remove the OID part from the value
my $val = $ipv6_addr_prefix->{$row};
if ( $val =~ /^.+?((?:\d+\.){19}\d+)$/ ){
$val = $1;
$return->{$row} = $val;
}
}
}
}
printf("%s: data comes from %s.\n", &_my_sub_name, $info->_method_used() ) if $info->debug();
return $return;
}
sub _method_used {
my $info = shift;
my $return = 'none of the MIBs';
if (defined $info::METHOD) {
if ($info::METHOD eq IPMIB) {
$return = 'IP-MIB';
} elsif ($info::METHOD eq IPV6MIB) {
$return = 'IPV6-MIB';
} elsif ($info::METHOD eq CISCO) {
$return = 'CISCO-IETF-IP-MIB';
}
}
return $return;
}
sub _test_methods {
my $info = shift;
my $test = shift;
my $return = {};
foreach my $method (sort {$test->{$a} <=> $test->{$b}} keys %$test) {
$return = $info->$method || {};
if (scalar keys %$return) {
$info::METHOD = $test->{$method};
last;
}
}
return $return;
}
sub _my_sub_name {
my @callinfo = caller(1);
return $callinfo[3];
}
sub munge_physaddr {
my $addr = shift;
return unless defined $addr;
return unless length $addr;
$addr = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $addr ) );
return $addr;
}
1;
__END__
=head1 NAME
SNMP::Info::IPv6 - SNMP Interface for obtaining IPv6 addresses and IPv6
address mappings
=head1 AUTHOR
Jeroen van Ingen and Carlos Vicente
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $info = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $info->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
The SNMP::Info::IPv6 class implements functions to for mapping IPv6 addresses
to MAC addresses, interfaces and more. It will use data from the IP-MIB, IPV6-MIB
or the CISCO-IETF-IP-MIB, whichever is supported by the device.
This class is inherited by Info::Layer3 to provide IPv6 node tracking across
device classes.
For debugging purposes you can call this class directly as you would
SNMP::Info
my $info = new SNMP::Info::IPv6 (...);
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<IP-MIB>
=item F<IPV6-MIB>
=item F<CISCO-IETF-IP-MIB>
=back
=head1 GLOBALS
none.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Internet Address Table
=over
=item $info->ipv6_n2p_addr()
=item $info->ipv6_n2p_if()
=item $info->ipv6_n2p_mac()
=item $info->ipv6_n2p_state()
=item $info->ipv6_n2p_type()
=item $info->ipv6_index()
Maps an IPv6 address to an interface C<ifIndex>
=item $info->ipv6_type()
Maps an IPv6 address to its type (unicast, anycast, etc.)
=item $info->ipv6_pfx_origin()
Maps an IPv6 prefix with its origin (manual, well-known, dhcp, etc.)
=item $info->ipv6_addr_prefix()
Maps IPv6 addresses with their prefixes
=back
=head2 Internet Address Translation Table
=over
=item $info->c_inet_phys_address()
Maps an address of type C<cInetNetToMediaNetAddressType> on interface C<ifIndex> to a physical address.
=back
=head1 MUNGES
=over
=item munge_physaddr()
Takes an octet stream (HEX-STRING) and returns a colon separated ASCII hex
string.
=back
=cut

View File

@@ -1,512 +0,0 @@
# SNMP::Info::LLDP
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::LLDP;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::LLDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::LLDP::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
'LLDP-MIB' => 'lldpLocSysCapEnabled',
'LLDP-EXT-DOT1-MIB' => 'lldpXdot1MIB',
'LLDP-EXT-DOT3-MIB' => 'lldpXdot3MIB',
);
%GLOBALS = (
'lldp_sysname' => 'lldpLocSysName',
'lldp_sysdesc' => 'lldpLocSysDesc',
'lldp_sys_cap' => 'lldpLocSysCapEnabled',
);
%FUNCS = (
# LLDP-MIB::lldpLocManAddrTable
'lldp_lman_addr' => 'lldpLocManAddrIfId',
# LLDP-MIB::lldpRemTable
'lldp_rem_id_type' => 'lldpRemChassisIdSubtype',
'lldp_rem_id' => 'lldpRemChassisId',
'lldp_rem_pid_type' => 'lldpRemPortIdSubtype',
'lldp_rem_pid' => 'lldpRemPortId',
'lldp_rem_desc' => 'lldpRemPortDesc',
'lldp_rem_sysname' => 'lldpRemSysName',
'lldp_rem_sysdesc' => 'lldpRemSysDesc',
'lldp_rem_sys_cap' => 'lldpRemSysCapEnabled',
# LLDP-MIB::lldpRemManAddrTable
'lldp_rman_addr' => 'lldpRemManAddrIfSubtype',
);
%MUNGE = (
'lldp_sysdesc' => \&SNMP::Info::munge_null,
'lldp_sysname' => \&SNMP::Info::munge_null,
'lldp_rem_sysname' => \&SNMP::Info::munge_null,
'lldp_rem_sysdesc' => \&SNMP::Info::munge_null,
'lldp_rem_port_desc' => \&SNMP::Info::munge_null,
'lldp_sys_cap' => \&SNMP::Info::munge_bits,
'lldp_rem_sys_cap' => \&SNMP::Info::munge_bits,
);
sub hasLLDP {
my $lldp = shift;
# We may be have LLDP, but nothing in lldpRemoteSystemsData Tables
# so we could be running LLDP but not return any useful information
my $lldp_cap = $lldp->lldp_sys_cap();
return 1 if defined $lldp_cap;
return;
}
sub lldp_if {
my $lldp = shift;
my $partial = shift;
my $addr = $lldp->lldp_rem_pid($partial) || {};
my %lldp_if;
foreach my $key ( keys %$addr ) {
my @aOID = split( '\.', $key );
my $port = $aOID[1];
$lldp_if{$key} = $port;
}
return \%lldp_if;
}
sub lldp_ip {
my $lldp = shift;
my $partial = shift;
my $rman_addr = $lldp->lldp_rman_addr($partial) || {};
my %lldp_ip;
foreach my $key ( keys %$rman_addr ) {
my ( $index, $proto, $addr ) = _lldp_addr_index($key);
next unless defined $index;
next unless $proto == 1;
$lldp_ip{$index} = $addr;
}
return \%lldp_ip;
}
sub lldp_addr {
my $lldp = shift;
my $partial = shift;
my $rman_addr = $lldp->lldp_rman_addr($partial) || {};
my %lldp_ip;
foreach my $key ( keys %$rman_addr ) {
my ( $index, $proto, $addr ) = _lldp_addr_index($key);
next unless defined $index;
$lldp_ip{$index} = $addr;
}
return \%lldp_ip;
}
sub lldp_port {
my $lldp = shift;
my $partial = shift;
my $pdesc = $lldp->lldp_rem_desc($partial) || {};
my $pid = $lldp->lldp_rem_pid($partial) || {};
my $ptype = $lldp->lldp_rem_pid_type($partial) || {};
my %lldp_port;
foreach my $key ( sort keys %$pid ) {
my $port = $pdesc->{$key};
unless ($port) {
$port = $pid->{$key};
next unless $port;
my $type = $ptype->{$key};
next unless $type;
# May need to format other types in the future, i.e. Network address
if ( $type =~ /mac/ ) {
$port = join( ':',
map { sprintf "%02x", $_ } unpack( 'C*', $port ) );
}
}
# Nortel lldpRemPortDesc doesn't match ifDescr, but we can still
# figure out slot.port based upon lldpRemPortDesc
if ( $port =~ /^(Unit\s+(\d+)\s+)?Port\s+(\d+)$/ ) {
$port = defined $1 ? "$2.$3" : "$3";
}
$lldp_port{$key} = $port;
}
return \%lldp_port;
}
sub lldp_id {
my $lldp = shift;
my $partial = shift;
my $ch_type = $lldp->lldp_rem_id_type($partial) || {};
my $ch = $lldp->lldp_rem_id($partial) || {};
my %lldp_id;
foreach my $key ( keys %$ch ) {
my $id = $ch->{$key};
next unless $id;
my $type = $ch_type->{$key};
next unless $type;
# May need to format other types in the future
if ( $type =~ /mac/ ) {
$id = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $id ) );
}elsif ($type eq 'networkAddress'){
if ( length(unpack('H*', $id)) == 10 ){
# IP address (first octet is sign, I guess)
my @octets = (map { sprintf "%02x",$_ } unpack('C*', $id))[1..4];
$id = join '.', map { hex($_) } @octets;
}
}
$lldp_id{$key} = $id;
}
return \%lldp_id;
}
#sub root_ip {
# my $lldp = shift;
#
# my $man_addr = $lldp->lldp_lman_addr() || {};
#
# foreach my $key (keys %$man_addr) {
# my @oids = split(/\./, $key);
# my $proto = shift(@oids);
# my $length = shift(@oids);
# # IPv4
# if ($proto == 1) {
# my $addr = join('.',@oids);
# return $addr if (defined $addr and $lldp->snmp_connect_ip($addr));
# }
# }
# return;
#}
# Break up the lldpRemManAddrTable INDEX into common index, protocol,
# and address.
sub _lldp_addr_index {
my $idx = shift;
my @oids = split( /\./, $idx );
my $index = join( '.', splice( @oids, 0, 3 ) );
my $proto = shift(@oids);
my $length = shift(@oids);
# IPv4
if ( $proto == 1 ) {
return ( $index, $proto, join( '.', @oids ) );
}
# MAC
elsif ( $proto == 6 ) {
return ( $index, $proto,
join( ':', map { sprintf "%02x", $_ } @oids ) );
}
# TODO - Need to handle other protocols, i.e. IPv6
else {
return;
}
}
1;
__END__
=head1 NAME
SNMP::Info::LLDP - SNMP Interface to the Link Layer Discovery Protocol (LLDP)
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
my $lldp = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
my $class = $lldp->class();
print " Using device sub class : $class\n";
$haslldp = $lldp->hasLLDP() ? 'yes' : 'no';
# Print out a map of device ports with LLDP neighbors:
my $interfaces = $lldp->interfaces();
my $lldp_if = $lldp->lldp_if();
my $lldp_ip = $lldp->lldp_ip();
my $lldp_port = $lldp->lldp_port();
foreach my $lldp_key (keys %$lldp_ip){
my $iid = $lldp_if->{$lldp_key};
my $port = $interfaces->{$iid};
my $neighbor = $lldp_ip->{$lldp_key};
my $neighbor_port = $lldp_port->{$lldp_key};
print "Port : $port connected to $neighbor / $neighbor_port\n";
}
=head1 DESCRIPTION
SNMP::Info::LLDP is a subclass of SNMP::Info that provides an object oriented
interface to LLDP information through SNMP.
LLDP is a Layer 2 protocol that allows a network device to advertise its
identity and capabilities on the local network providing topology information.
The protocol is defined in the IEEE standard 802.1AB.
Create or use a device subclass that inherits this class. Do not use
directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<LLDP-MIB>
=item F<LLDP-EXT-DOT1-MIB>
=item F<LLDP-EXT-DOT3-MIB>
=back
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
=item $lldp->hasLLDP()
Is LLDP is active in this device?
Note: LLDP may be active, but nothing in C<lldpRemoteSystemsData> Tables so
the device would not return any useful topology information.
=item $lldp->lldp_sysname()
The string value used to identify the system name of the local system. If the
local agent supports IETF RFC 3418, C<lldpLocSysName> object should have the
same value of C<sysName> object.
Nulls are removed before the value is returned.
(C<lldpLocSysName>)
=item $lldp->lldp_sysdesc()
The string value used to identify the system description of the local system.
If the local agent supports IETF RFC 3418, C<lldpLocSysDesc> object should
have the same value of C<sysDesc> object.
Nulls are removed before the value is returned.
(C<lldpLocSysDesc>)
=item $lldp->lldp_sys_cap()
Returns which system capabilities are enabled on the local system. Results
are munged into an ascii binary string, LSB. Each digit represents a bit
from the table below:
=over
=item Bit 'other(0)' indicates that the system has capabilities other than
those listed below.
=item Bit 'repeater(1)' indicates that the system has repeater capability.
=item Bit 'bridge(2)' indicates that the system has bridge capability.
=item Bit 'wlanAccessPoint(3)' indicates that the system has WLAN access
point capability.
=item Bit 'router(4)' indicates that the system has router capability.
=item Bit 'telephone(5)' indicates that the system has telephone capability.
=item Bit 'docsisCableDevice(6)' indicates that the system has DOCSIS Cable
Device capability (IETF RFC 2669 & 2670).
=item Bit 'stationOnly(7)' indicates that the system has only station
capability and nothing else."
=back
(C<lldpLocSysCapEnabled>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $lldp->lldp_id()
Returns the string value used to identify the chassis component associated
with the remote system.
(C<lldpRemChassisId>)
=item $lldp->lldp_if()
Returns the mapping to the SNMP Interface Table.
=item $lldp->lldp_ip()
Returns remote IPv4 address. Returns for all other address types, use
lldp_addr if you want any return address type.
=item $lldp->lldp_addr()
Returns remote address. Type may be any IANA Address Family Number.
Currently only returns IPv4 or MAC addresses.
=item $lldp->lldp_port()
Returns remote port ID
=back
=head2 LLDP Remote Table (C<lldpRemTable>)
=over
=item $lldp->lldp_rem_id_type()
Returns the type of encoding used to identify the chassis associated with
the remote system.
(C<lldpRemChassisIdSubtype>)
=item $lldp->lldp_rem_id()
Returns the string value used to identify the chassis component associated
with the remote system.
(C<lldpRemChassisId>)
=item $lldp->lldp_rem_pid_type()
Returns the type of port identifier encoding used in the associated
C<lldpRemPortId> object.
(C<lldpRemPortIdSubtype>)
=item $lldp->lldp_rem_pid()
Returns the string value used to identify the port component associated with
the remote system.
(C<lldpRemPortId>)
=item $lldp->lldp_rem_desc()
Returns the string value used to identify the description of the given port
associated with the remote system.
Nulls are removed before the value is returned.
(C<lldpRemPortDesc>)
=item $lldp->lldp_rem_sysname()
Returns the string value used to identify the system name of the remote
system.
Nulls are removed before the value is returned.
(C<lldpRemSysName>)
=item $lldp->lldp_rem_sysdesc()
Returns the string value used to identify the system description of the
remote system.
Nulls are removed before the value is returned.
(C<lldpRemSysDesc>)
=item $lldp->lldp_rem_sys_cap()
Returns which system capabilities are enabled on the local system. Results
are munged into an ascii binary string, LSB. Each digit
represents a bit from the table below:
=over
=item Bit 'other(0)' indicates that the system has capabilities other than
those listed below.
=item Bit 'repeater(1)' indicates that the system has repeater capability.
=item Bit 'bridge(2)' indicates that the system has bridge capability.
=item Bit 'wlanAccessPoint(3)' indicates that the system has WLAN access
point capability.
=item Bit 'router(4)' indicates that the system has router capability.
=item Bit 'telephone(5)' indicates that the system has telephone capability.
=item Bit 'docsisCableDevice(6)' indicates that the system has DOCSIS Cable
Device capability (IETF RFC 2669 & 2670).
=item Bit 'stationOnly(7)' indicates that the system has only station
capability and nothing else."
=back
(C<lldpRemSysCapEnabled>)
=back
=cut

View File

@@ -1,73 +1,79 @@
# SNMP::Info::Layer1 - SNMP Interface to Layer1 Devices
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# SNMP::Info::Layer1 - SNMP Interface to Layer1 Devices
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Layer1::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = ( %SNMP::Info::MIBS, 'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex' );
%MIBS = ( %SNMP::Info::MIBS,
'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex'
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
'ports_managed' => 'ifNumber',
'rptr_slots' => 'rptrGroupCapacity',
'slots' => 'rptrGroupCapacity'
);
%SNMP::Info::GLOBALS,
'ports_managed' => 'ifNumber',
'rptr_slots' => 'rptrGroupCapacity',
'slots' => 'rptrGroupCapacity'
);
%FUNCS = (
%SNMP::Info::FUNCS,
'rptr_ports' => 'rptrGroupPortCapacity',
'rptr_port' => 'rptrPortIndex',
'rptr_slot' => 'rptrPortGroupIndex',
'rptr_up_admin' => 'rptrPortAdminStatus',
'rptr_up' => 'rptrPortOperStatus',
'rptr_last_src' => 'rptrAddrTrackNewLastSrcAddress',
);
%FUNCS = (
%SNMP::Info::FUNCS,
'i_up2' => 'ifOperStatus',
'i_up_admin2' => 'ifAdminStatus',
'rptr_ports' => 'rptrGroupPortCapacity',
'rptr_port' => 'rptrPortIndex',
'rptr_slot' => 'rptrPortGroupIndex',
'rptr_up_admin' => 'rptrPortAdminStatus',
'rptr_up' => 'rptrPortOperStatus',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
'rptr_last_src' => \&SNMP::Info::munge_mac,
);
# Inherit all the built in munging
%SNMP::Info::MUNGE,
);
# Method OverRides
@@ -75,23 +81,23 @@ $VERSION = '2.06';
sub ports {
my $l1 = shift;
my $ports = $l1->ports_managed();
my $rptr_ports = $l1->rptr_ports();
my $ports = $l1->ports_managed();
my $rptr_ports = $l1->rptr_ports();
foreach my $group ( keys %$rptr_ports ) {
$ports += $rptr_ports->{$group};
foreach my $group (keys %$rptr_ports){
$ports += $rptr_ports->{$group};
}
return $ports;
}
# $l1->model() - Looks at sysObjectID which gives the oid of the system
# name, contained in a propriatry MIB.
# name, contained in a propriatry MIB.
sub model {
my $l1 = shift;
my $id = $l1->id();
my $l1 = shift;
my $id = $l1->id();
my $model = &SNMP::translateObj($id);
# HP
$model =~ s/^hpswitch//i;
@@ -102,167 +108,118 @@ sub model {
}
sub vendor {
my $l1 = shift;
my $l1 = shift;
my $descr = $l1->description();
return 'hp' if ( $descr =~ /hp/i );
return 'cisco' if ( $descr =~ /(catalyst|cisco|ios)/i );
return 'allied' if ( $descr =~ /allied/i );
return 'asante' if ( $descr =~ /asante/i );
return 'unknown';
return 'hp' if ($descr =~ /hp/i);
return 'cisco' if ($descr =~ /(catalyst|cisco|ios)/i);
return 'allied' if ($descr =~ /allied/i);
return 'asante' if ($descr =~ /asante/i);
}
# By Default we'll use the description field
sub interfaces {
my $l1 = shift;
my $partial = shift;
my $l1 = shift;
my $interfaces = $l1->i_index();
my $rptr_port = $l1->rptr_port();
my $interfaces = $l1->i_index($partial) || {};
my $rptr_port = $l1->rptr_port($partial) || {};
foreach my $port ( keys %$rptr_port ) {
foreach my $port (keys %$rptr_port){
$interfaces->{$port} = $port;
}
return $interfaces;
}
sub i_up_admin {
my $l1 = shift;
my $partial = shift;
my $l1 = shift;
my $i_up_admin = $l1->SUPER::i_up_admin($partial) || {};
my $rptr_up_admin = $l1->rptr_up_admin($partial) || {};
my $i_up_admin = $l1->i_up_admin2();
my $rptr_up_admin = $l1->rptr_up_admin();
foreach my $key ( keys %$rptr_up_admin ) {
foreach my $key (keys %$rptr_up_admin){
my $up = $rptr_up_admin->{$key};
$i_up_admin->{$key} = 'up' if $up =~ /enabled/;
$i_up_admin->{$key} = 'down' if $up =~ /disabled/;
$i_up_admin->{$key} = 'up' if $up =~ /enabled/;
$i_up_admin->{$key} = 'down' if $up =~ /disabled/;
}
return $i_up_admin;
}
sub i_up {
my $l1 = shift;
my $partial = shift;
my $l1 = shift;
my $i_up = $l1->i_up2();
my $rptr_up = $l1->rptr_up();
my $i_up = $l1->SUPER::i_up($partial) || {};
my $rptr_up = $l1->rptr_up($partial) || {};
foreach my $key ( keys %$rptr_up ) {
foreach my $key (keys %$rptr_up){
my $up = $rptr_up->{$key};
$i_up->{$key} = 'up' if $up =~ /operational/;
$i_up->{$key} = 'up' if $up =~ /operational/;
}
return $i_up;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1 - SNMP Interface to network devices serving Layer1 only.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $l1 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $l1->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
my $interfaces = $l1->interfaces();
my $i_up = $l1->i_up();
my $i_speed = $l1->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
SNMP::Info::Layer1 - Perl5 Interface to Layer1 network devices.
=head1 DESCRIPTION
This class is usually used as a superclass for more specific device classes
listed under SNMP::Info::Layer1::* Please read all docs under SNMP::Info
first.
Provides abstraction to the configuration information obtainable from a
Layer1 device through SNMP. Information is stored in a number of MIBs.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
Inherits from:
my $l1 = new SNMP::Info::Layer1(...);
SNMP::Info
=head2 Inherited Classes
MIBS:
MIBS listed in SNMP::Info
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $l1 = new SNMP::Info::Layer1(DestHost => 'mybridge' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info
=item new SNMP::Info::Layer1()
Arguments passed to new() are passed on to SNMP::Session::new()
my $l1 = new SNMP::Info::Layer1(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $l1;
=back
=head2 Required MIBs
=over
=item F<SNMP-REPEATER-MIB>
=back
MIBs required for L<SNMP::Info/"Required MIBs">
See L<SNMP::Info/"Required MIBs"> for its MIB requirements.
F<SNMP-REPEATER-MIB> needs to be extracted from
ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $l1->vendor()
Trys to discover the vendor from $l1->model() and $l1->vendor()
=item $l1->ports_managed()
Gets the number of ports under the interface mib
(C<ifNumber>)
=back
=head2 Overrides
=over
=item $l1->model()
Cross references $l1->id() with product IDs.
For HP devices, removes C<'hpswitch'> from the name
For Cisco devices, removes C<'sysid'> from the name
=item $l1->vendor()
Tries to discover the vendor from $l1->model() and $l1->vendor()
(B<ifNumber>)
=item $l1->ports()
@@ -272,18 +229,11 @@ Adds the values from rptr_ports() and ports_managed()
Number of 'groups' in the Repeater MIB
(C<rptrGroupCapacity>)
(B<rptrGroupCapacity>)
=back
=head2 Global Methods imported from SNMP::Info
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -291,16 +241,10 @@ to a hash.
=item $l1->interfaces()
Returns reference to the map between IID and physical Port.
=item $l1->i_up()
Returns reference to map of IIDs to link status.
=item $l1->i_up_admin()
Returns reference to map of IIDs to administrative link status.
=back
=head2 Repeater MIB
@@ -311,36 +255,28 @@ Returns reference to map of IIDs to administrative link status.
Number of ports in each group.
(C<rptrGroupPortCapacity>)
(B<rptrGroupPortCapacity>)
=item $l1->rptr_port()
Port number in Group
(C<rptrPortIndex>)
(B<rptrPortIndex>)
=item $l1->rptr_slot()
Group (slot) Number for given port.
(C<rptrPortGroupIndex>)
(B<rptrPortGroupIndex>)
=item $l1->rptr_up_admin()
(C<rptrPortAdminStatus>)
(B<rptrPortAdminStatus>)
=item $l1->rptr_up()
(C<rptrPortOperStatus>)
=item $l1->rptr_last_src()
(C<rptrAddrTrackNewLastSrcAddress>)
(B<rptrPortOperStatus>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=cut

View File

@@ -1,117 +1,107 @@
# SNMP::Info::Layer1::Allied
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Allied;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer1;
@SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Allied::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, 'root_ip' => 'actualIPAddr', );
%GLOBALS = (
%SNMP::Info::Layer1::GLOBALS,
'root_ip' => 'actualIPAddr',
);
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
'ati_p_name' => 'portName',
'ati_up' => 'linkTestLED',
);
%FUNCS = (%SNMP::Info::Layer1::FUNCS,
'i_name2' => 'ifName',
'ati_p_name' => 'portName',
'ati_up' => 'linkTestLED',
);
%MIBS = ( %SNMP::Info::Layer1::MIBS, 'ATI-MIB' => 'atiPortGroupIndex' );
%MIBS = (
%SNMP::Info::Layer1::MIBS,
'ATI-MIB' => 'atiPortGroupIndex'
);
%MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
%MUNGE = (%SNMP::Info::Layer1::MUNGE,
);
sub vendor {
return 'allied';
}
sub os {
return 'allied';
}
sub os_ver {
my $allied = shift;
my $descr = $allied->description();
if ( $descr =~ m/version (\d+\.\d+)/ ) {
return $1;
}
}
sub model {
my $allied = shift;
my $desc = $allied->description();
if ( $desc =~ /(AT-\d{4}\S{1}?)/ ) {
if ($desc =~ /(AT-\d{4}\S{1}?)/){
return $1;
}
return;
return undef;
}
sub i_name {
my $allied = shift;
my $partial = shift;
sub i_name{
my $allied = shift;
my $i_name = $allied->orig_i_name($partial) || {};
my $ati_p_name = $allied->ati_p_name($partial) || {};
my $i_name = $allied->i_name2();
foreach my $port ( keys %$ati_p_name ) {
my $ati_p_name = $allied->ati_p_name();
foreach my $port (keys %$ati_p_name){
my $name = $ati_p_name->{$port};
$i_name->{$port} = $name if ( defined $name and $name !~ /^\s*$/ );
$i_name->{$port} = $name if (defined $name and $name !~ /^\s*$/);
}
return $i_name;
}
sub i_up {
my $allied = shift;
my $partial = shift;
my $allied = shift;
my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial );
my $ati_up = $allied->ati_up($partial) || {};
my $i_up = SNMP::Info::Layer1::i_up($allied);
my $ati_up = $allied->ati_up();
foreach my $port ( keys %$ati_up ) {
foreach my $port (keys %$ati_up){
my $up = $ati_up->{$port};
$i_up->{$port} = 'down' if $up eq 'linktesterror';
$i_up->{$port} = 'up' if $up eq 'nolinktesterror';
$i_up->{$port} = 'up' if $up eq 'nolinktesterror';
}
return $i_up;
}
1;
@@ -121,88 +111,70 @@ __END__
SNMP::Info::Layer1::Allied - SNMP Interface to old Allied Hubs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $allied = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myhub',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $allied->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Allied device through SNMP. See inherited classes' documentation for
inherited methods.
=head2 Inherited Classes
Inherits from:
SNMP::Info::Layer1
Required MIBs:
ATI-MIB - Download for your device from http://www.allied-telesyn.com/allied/support/
MIBs listed in SNMP::Info::Layer1
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $allied = new SNMP::Info::Layer1::Allied(DestHost => 'mycat1900' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::Layer1
=item new SNMP::Info::Layer1::Allied()
Arguments passed to new() are passed on to SNMP::Session::new()
my $allied = new SNMP::Info::Layer1::Allied(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $allied;
=back
=head2 Required MIBs
=over
=item F<ATI-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $allied->vendor()
Returns 'allied' :)
=item $allied->os()
Returns 'allied'
=item $allied->os_ver()
Culls Version from description()
=item $allied->root_ip()
Returns IP Address of Managed Hub.
(C<actualIpAddr>)
(B<actualIpAddr>)
=item $allied->model()
Tries to cull out C<AT-nnnnX> out of the description field.
Trys to cull out AT-nnnnX out of the description field.
=back
=head2 Global Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE METHODS
=head1 TABLE ENTRIES
=head2 Overrides
@@ -225,16 +197,12 @@ the values of ati_up() to 'up' and 'down'.
=item $allied->ati_p_name()
(C<portName>)
(B<portName>)
=item $allied->ati_up()
(C<linkTestLED>)
(B<linkTestLED>)
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -1,91 +1,85 @@
# SNMP::Info::Layer1::Asante
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Asante;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer1;
@SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Asante::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, );
%GLOBALS = (
%SNMP::Info::Layer1::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
'asante_port' => 'ePortIndex',
'asante_group' => 'ePortGrpIndex',
'i_type' => 'ePortStateType',
'asante_up' => 'ePortStateLinkStatus',
);
%FUNCS = (%SNMP::Info::Layer1::FUNCS,
'i_speed2' => 'ifSpeed',
'i_mac2' => 'ifPhysAddress',
'i_descr2' => 'ifDescr',
'i_name2' => 'ifName',
'asante_port' => 'ePortIndex',
'asante_group' => 'ePortGrpIndex',
'i_type' => 'ePortStateType',
'asante_up' => 'ePortStateLinkStatus',
);
%MIBS = ( %SNMP::Info::Layer1::MIBS, 'ASANTE-HUB1012-MIB' => 'asante' );
%MIBS = (
%SNMP::Info::Layer1::MIBS,
'ASANTE-HUB1012-MIB' => 'asante'
);
%MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
%MUNGE = (%SNMP::Info::Layer1::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'i_speed2' => \&SNMP::Info::munge_speed,
);
sub interfaces {
my $asante = shift;
my $partial = shift;
my $asante = shift;
my $rptr_port = $asante->rptr_port($partial) || {};
my $rptr_port = $asante->rptr_port();
my %interfaces;
foreach my $port ( keys %$rptr_port ) {
foreach my $port (keys %$rptr_port){
$interfaces{$port} = $port;
}
return \%interfaces;
}
sub os {
return 'asante';
}
sub os_ver {
my $asante = shift;
my $descr = $asante->description();
if ( $descr =~ /software v(\d+\.\d+)/ ) {
return $1;
}
}
sub vendor {
return 'asante';
}
@@ -93,33 +87,31 @@ sub vendor {
sub model {
my $asante = shift;
my $id = $asante->id();
my $id = $asante->id();
my $model = &SNMP::translateObj($id);
return $model;
}
sub i_up {
my $asante = shift;
my $partial = shift;
my $asante = shift;
my $asante_up = $asante->asante_up($partial) || {};
my $asante_up = $asante->asante_up();
my $i_up = {};
foreach my $port ( keys %$asante_up ) {
foreach my $port (keys %$asante_up){
my $up = $asante_up->{$port};
$i_up->{$port} = 'down' if $up =~ /on/;
$i_up->{$port} = 'up' if $up =~ /off/;
$i_up->{$port} = 'up' if $up =~ /off/;
}
return $i_up;
}
sub i_speed {
my $asante = shift;
my $partial = shift;
my $asante = shift;
my $i_speed = $asante->orig_i_speed($partial) || {};
my $i_speed = $asante->i_speed2();
my %i_speed;
@@ -129,10 +121,9 @@ sub i_speed {
}
sub i_mac {
my $asante = shift;
my $partial = shift;
my $asante = shift;
my $i_mac = $asante->orig_i_mac($partial) || {};
my $i_mac = $asante->i_mac2();
my %i_mac;
@@ -142,14 +133,13 @@ sub i_mac {
}
sub i_description {
return;
return undef;
}
sub i_name {
my $asante = shift;
my $partial = shift;
my $asante = shift;
my $i_name = $asante->orig_i_descr($partial) || {};
my $i_name = $asante->i_descr2();
my %i_name;
@@ -157,107 +147,82 @@ sub i_name {
return \%i_name;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::Asante - SNMP Interface to old Asante 1012 Hubs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $asante = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $asante->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Asante device through SNMP.
Asante device through SNMP. See inherited classes' documentation for
inherited methods.
=head2 Inherited Classes
Inherits from:
SNMP::Info::Layer1
Required MIBs:
ASANTE-HUB1012-MIB - Download from http://www.mibdepot.com
MIBs listed in SNMP::Info::Layer1
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $asante = new SNMP::Info::Layer1::Asante(DestHost => 'mycat1900' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::Layer1
=item new SNMP::Info::Layer1::Asante()
Arguments passed to new() are passed on to SNMP::Session::new()
my $asante = new SNMP::Info::Layer1::Asante(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $asante;
=back
=head2 Required MIBs
=over
=item F<ASANTE-HUB1012-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
=head2 Overrides
=over
=item $asante->os()
Returns 'asante'
=item $asante->os_ver()
Culls software version from description()
=item $asante->vendor()
Returns 'asante' :)
=item $asante->root_ip()
Returns IP Address of Managed Hub.
(B<actualIpAddr>)
=item $asante->model()
Cross references $asante->id() to the F<ASANTE-HUB1012-MIB> and returns
the results.
Trys to cull out AT-nnnnX out of the description field.
=back
=head2 Global Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE METHODS
=head1 TABLE ENTRIES
=head2 Overrides
=over
=item $asante->interfaces()
Returns reference to the map between IID and physical Port.
=item $asante->i_description()
Description of the interface.
=item $asante->i_mac()
MAC address of the interface. Note this is just the MAC of the port, not
anything connected to it.
=item $asante->i_name()
Returns reference to map of IIDs to human-set port name.
@@ -265,11 +230,7 @@ Returns reference to map of IIDs to human-set port name.
=item $asante->i_up()
Returns reference to map of IIDs to link status. Changes
the values of asante_up() to 'up' and 'down'.
=item $asante->i_speed()
Speed of the link, human format.
the values of ati_up() to 'up' and 'down'.
=back
@@ -279,16 +240,12 @@ Speed of the link, human format.
=item $asante->ati_p_name()
(C<portName>)
(B<portName>)
=item $asante->ati_up()
(C<linkTestLED>)
(B<linkTestLED>)
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -1,729 +0,0 @@
# SNMP::Info::Layer1::Bayhub
# $Id$
#
# Copyright (c) 2008 Eric Miller, Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Bayhub;
use strict;
use Exporter;
use SNMP::Info::SONMP;
use SNMP::Info::NortelStack;
use SNMP::Info::Layer2;
@SNMP::Info::Layer1::Bayhub::ISA
= qw/SNMP::Info::SONMP SNMP::Info::NortelStack SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer1::Bayhub::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS,
'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable',
'S5-COMMON-STATS-MIB' => 's5CmStat',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::SONMP::FUNCS,
# S5-ETHERNET-COMMON-MIB::s5EnPortTable
'bayhub_pb_index' => 's5EnPortBrdIndx',
'bayhub_pp_index' => 's5EnPortIndx',
'bayhub_up_admin' => 's5EnPortPartStatus',
'bayhub_up' => 's5EnPortLinkStatus',
# S5-ETHERNET-COMMON-MIB::s5EnPortExtTable
'bayhub_p_speed' => 's5EnPortExtActiveSpeed',
'bayhub_p_cap' => 's5EnPortExtHwCapability',
'bayhub_p_adv' => 's5EnPortExtAutoNegAdv',
# S5-COMMON-STATS-MIB::s5CmSNodeTable
'bayhub_nb_index' => 's5CmSNodeBrdIndx',
'bayhub_np_index' => 's5CmSNodePortIndx',
'fw_mac' => 's5CmSNodeMacAddr',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
sub layers {
return '00000011';
}
sub os {
return 'bay_hub';
}
sub vendor {
return 'nortel';
}
sub model {
my $bayhub = shift;
my $id = $bayhub->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^sreg-//i;
return 'Baystack Hub' if ( $model =~ /BayStack/ );
return '5000' if ( $model =~ /5000/ );
return '5005' if ( $model =~ /5005/ );
return $model;
}
# Hubs do not support ifMIB requirements for get MAC
# and port status
sub i_index {
my $bayhub = shift;
my $partial = shift;
my $b_index = $bayhub->bayhub_pb_index($partial) || {};
my $p_index = $bayhub->bayhub_pp_index($partial) || {};
my $model = $bayhub->model() || 'Baystack Hub';
my %i_index;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
if ( $model eq 'Baystack Hub' ) {
my $comidx = $board;
if ( !( $comidx % 5 ) ) {
$board = ( $board / 5 );
}
elsif ( $comidx =~ /[16]$/ ) {
$board = int( $board / 5 );
$port = 25;
}
elsif ( $comidx =~ /[27]$/ ) {
$board = int( $board / 5 );
$port = 26;
}
}
my $index = ( $board * 256 ) + $port;
$i_index{$iid} = $index;
}
return \%i_index;
}
# Partials don't really help in this class, but implemented
# for consistency
sub interfaces {
my $bayhub = shift;
my $partial = shift;
my $i_index = $bayhub->i_index() || {};
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# Index numbers are deterministic slot * 256 + port
my $port = $index % 256;
my $slot = int( $index / 256 );
my $slotport = "$slot.$port";
$if{$index} = $slotport;
}
return \%if;
}
sub i_duplex {
my $bayhub = shift;
my $partial = shift;
my $port_index = $bayhub->i_index() || {};
my %i_duplex;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $duplex = 'half';
$i_duplex{$index} = $duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $bayhub = shift;
my $partial = shift;
my $port_index = $bayhub->i_index() || {};
my %i_duplex_admin;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $duplex = 'half';
$i_duplex_admin{$index} = $duplex;
}
return \%i_duplex_admin;
}
sub i_speed {
my $bayhub = shift;
my $partial = shift;
my $port_index = $bayhub->i_index() || {};
my $port_speed = $bayhub->bayhub_p_speed() || {};
my %i_speed;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $speed = $port_speed->{$iid} || '10 Mbps';
$speed = '10 Mbps' if $speed =~ /bps10M/i;
$speed = '100 Mbps' if $speed =~ /bps100M/i;
$i_speed{$index} = $speed;
}
return \%i_speed;
}
sub i_up {
my $bayhub = shift;
my $partial = shift;
my $port_index = $bayhub->i_index() || {};
my $link_stat = $bayhub->bayhub_up() || {};
my %i_up;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$link_stat = 'up' if $link_stat =~ /on/i;
$link_stat = 'down' if $link_stat =~ /off/i;
$i_up{$index} = $link_stat;
}
return \%i_up;
}
sub i_up_admin {
my $bayhub = shift;
my $partial = shift;
my $i_index = $bayhub->i_index() || {};
my $link_stat = $bayhub->bayhub_up_admin() || {};
my %i_up_admin;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$i_up_admin{$index} = $link_stat;
}
return \%i_up_admin;
}
sub set_i_up_admin {
# map setting to those the hub will understand
my %setting = qw/up 2 down 3/;
my $bayhub = shift;
my ( $setting, $iid ) = @_;
my $i_index = $bayhub->i_index() || {};
my %reverse_i_index = reverse %$i_index;
$setting = lc($setting);
return 0 unless defined $setting{$setting};
$iid = $reverse_i_index{$iid};
return $bayhub->set_bayhub_up_admin( $setting{$setting}, $iid );
}
# Hubs do not support the standard Bridge MIB
sub bp_index {
my $bayhub = shift;
my $partial = shift;
my $b_index = $bayhub->bayhub_nb_index() || {};
my $p_index = $bayhub->bayhub_np_index() || {};
my $model = $bayhub->model() || 'Baystack Hub';
my %bp_index;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
if ( $model eq 'Baystack Hub' ) {
my $comidx = $board;
if ( !( $comidx % 5 ) ) {
$board = ( $board / 5 );
}
elsif ( $comidx =~ /[16]$/ ) {
$board = int( $board / 5 );
$port = 25;
}
elsif ( $comidx =~ /[27]$/ ) {
$board = int( $board / 5 );
$port = 26;
}
}
my $index = ( $board * 256 ) + $port;
next if ( defined $partial and $index !~ /^$partial$/ );
$bp_index{$index} = $index;
}
return \%bp_index;
}
sub fw_port {
my $bayhub = shift;
my $partial = shift;
my $b_index = $bayhub->bayhub_nb_index($partial) || {};
my $p_index = $bayhub->bayhub_np_index($partial) || {};
my $model = $bayhub->model() || 'Baystack Hub';
my %fw_port;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
if ( $model eq 'Baystack Hub' ) {
my $comidx = $board;
if ( !( $comidx % 5 ) ) {
$board = ( $board / 5 );
}
elsif ( $comidx =~ /[16]$/ ) {
$board = int( $board / 5 );
$port = 25;
}
elsif ( $comidx =~ /[27]$/ ) {
$board = int( $board / 5 );
$port = 26;
}
}
my $index = ( $board * 256 ) + $port;
$fw_port{$iid} = $index;
}
return \%fw_port;
}
sub index_factor {
return 256;
}
sub slot_offset {
return 0;
}
# Devices do not support ENTITY-MIB use proprietary methods.
sub e_index {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_index($partial);
}
sub e_class {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_class($partial);
}
sub e_descr {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_descr($partial);
}
sub e_name {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_name($partial);
}
sub e_fwver {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_fwver($partial);
}
sub e_hwver {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_hwver($partial);
}
sub e_parent {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_parent($partial);
}
sub e_pos {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_pos($partial);
}
sub e_serial {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_serial($partial);
}
sub e_swver {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_swver($partial);
}
sub e_type {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_type($partial);
}
sub e_vendor {
my $stack = shift;
my $partial = shift;
return $stack->ns_e_vendor($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::Bayhub - SNMP Interface to Bay / Nortel Hubs
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $bayhub = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $bayhub->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bay hub device through SNMP. Also provides device MAC to port mapping through
the proprietary MIB.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $bayhub = new SNMP::Info::Layer1::Bayhub(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::NortelStack
=item SNMP::Info::SONMP
=back
=head2 Required MIBs
=over
=item F<S5-ETHERNET-COMMON-MIB>
=item F<S5-COMMON-STATS-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::NortelStack/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::SONMP/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $bayhub->vendor()
Returns 'nortel'
=item $bayhub->os()
Returns 'bay_hub'
=item $bayhub->model()
Cross references $bayhub->id() to the F<SYNOPTICS-MIB> and returns
the results.
Removes either Baystack Hub, 5000, or 5005 depending on the model.
=back
=head2 Overrides
=over
=item $bayhub->layers()
Returns 00000011. Class emulates Layer 2 functionality through proprietary
MIBs.
=item $bayhub->index_factor()
Required by SNMP::Info::SONMP. Number representing the number of ports
reserved per slot within the device MIB. Returns 256.
=item $bayhub->slot_offset()
Required by SNMP::Info::SONMP. Offset if slot numbering does not
start at 0. Returns 0.
=back
=head2 Globals imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::NortelStack
See L<SNMP::Info::NortelStack/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $bayhub->i_index()
Returns reference to map of IIDs to Interface index.
Since hubs do not support C<ifIndex>, the interface index is created using the
formula (board * 256 + port).
=item $bayhub->interfaces()
Returns reference to map of IIDs to physical ports.
=item $bayhub->i_duplex()
Returns half, hubs do not support full duplex.
=item $bayhub->i_duplex_admin()
Returns half, hubs do not support full duplex.
=item $bayhub->i_speed()
Returns interface speed.
=item $bayhub->i_up()
Returns (C<s5EnPortLinkStatus>) for each port. Translates on/off to up/down.
=item $bayhub->i_up_admin()
Returns (C<s5EnPortPartStatus>) for each port.
=item $bayhub->set_i_up_admin(state, ifIndex)
Sets port state, must be supplied with state and port C<ifIndex>
State choices are 'up' or 'down'
Example:
my %if_map = reverse %{$bayhub->interfaces()};
$bayhub->set_i_up_admin('down', $if_map{'1.1'})
or die "Couldn't change port state. ",$bayhub->error(1);
=item $bayhub->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $bayhub->fw_port()
Returns reference to map of IIDs of the C<S5-COMMON-STATS-MIB::s5CmSNodeTable>
to the Interface index.
=item $bayhub->fw_mac()
(C<s5CmSNodeMacAddr>)
=back
=head2 Pseudo F<ENTITY-MIB> Information
These devices do not support F<ENTITY-MIB>. These methods emulate Physical
Table methods using F<S5-CHASSIS-MIB>. See
L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
=over
=item $bayhub->e_index()
Returns ns_e_index().
=item $bayhub->e_class()
Returns ns_e_class().
=item $bayhub->e_descr()
Returns ns_e_descr().
=item $bayhub->e_name()
Returns ns_e_name().
=item $bayhub->e_fwver()
Returns ns_e_fwver().
=item $bayhub->e_hwver()
Returns ns_e_hwver().
=item $bayhub->e_parent()
Returns ns_e_parent().
=item $bayhub->e_pos()
Returns ns_e_pos().
=item $bayhub->e_serial()
Returns ns_e_serial().
=item $bayhub->e_swver()
Returns ns_e_swver().
=item $bayhub->e_type()
Returns ns_e_type().
=item $bayhub->e_vendor()
Returns ns_e_vendor().
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::NortelStack
See L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,444 +0,0 @@
# SNMP::Info::Layer1::Cyclades
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Cyclades;
use strict;
use Exporter;
use SNMP::Info::Layer1;
@SNMP::Info::Layer1::Cyclades::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Cyclades::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer1::MIBS,
'CYCLADES-ACS-SYS-MIB' => 'cyACSversion',
'CYCLADES-ACS-CONF-MIB' => 'cyEthIPaddr',
'CYCLADES-ACS-INFO-MIB' => 'cyISPortTty',
);
%GLOBALS = (
# CYCLADES-ACS-SYS-MIB
%SNMP::Info::Layer1::GLOBALS,
'os_ver' => 'cyACSversion',
'cy_model' => 'cyACSpname',
'serial' => 'cyACSDevId',
'root_ip' => 'cyEthIPaddr',
'ps1_status' => 'cyACSPw1',
'ps2_status' => 'cyACSPw2',
);
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
# CYCLADES-ACS-INFO-MIB::cyInfoSerialTable
'cy_port_tty' => 'cyISPortTty',
'cy_port_name' => 'cyISPortName',
'cy_port_speed' => 'cyISPortSpeed',
'cy_port_cd' => 'cyISPortSigCD',
# CYCLADES-ACS-CONF-MIB::cySerialPortTable
'cy_port_socket' => 'cySPortSocketPort',
);
%MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
# These devices don't have a FDB and we probably don't want to poll for ARP
# cache so turn off reported L2/L3.
sub layers {
return '01000001';
}
sub os {
return 'cyclades';
}
sub vendor {
return 'cyclades';
}
sub model {
my $cyclades = shift;
my $model = $cyclades->cy_model();
return unless defined $model;
return lc($model);
}
# Extend interface methods to include serial ports
#
# Partials don't really help in this class, but implemented
# for consistency
sub i_index {
my $cyclades = shift;
my $partial = shift;
my $orig_index = $cyclades->orig_i_index($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my %i_index;
foreach my $iid ( keys %$orig_index ) {
my $index = $orig_index->{$iid};
next unless defined $index;
$i_index{$iid} = $index;
}
# Use alternative labeling system for the serial port, listening socket
# to avoid conflicts with ifIndex.
foreach my $iid ( keys %$cy_index ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
$i_index{$index} = $index;
}
return \%i_index;
}
sub interfaces {
my $cyclades = shift;
my $partial = shift;
my $i_descr = $cyclades->orig_i_description($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_tty = $cyclades->cy_port_tty() || {};
my %if;
foreach my $iid ( keys %$i_descr ) {
my $descr = $i_descr->{$iid};
next unless defined $descr;
$if{$iid} = $descr;
}
foreach my $iid ( keys %$cy_p_tty ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $name = $cy_p_tty->{$iid};
next unless defined $name;
$if{$index} = $name;
}
return \%if;
}
sub i_speed {
my $cyclades = shift;
my $partial = shift;
my $i_speed = $cyclades->orig_i_speed($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_speed = $cyclades->cy_port_speed() || {};
my %i_speed;
foreach my $iid ( keys %$i_speed ) {
my $speed = $i_speed->{$iid};
next unless defined $speed;
$i_speed{$iid} = $speed;
}
foreach my $iid ( keys %$cy_p_speed ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $speed = $cy_p_speed->{$iid};
next unless defined $speed;
$i_speed{$index} = $speed;
}
return \%i_speed;
}
sub i_up {
my $cyclades = shift;
my $partial = shift;
my $i_up = $cyclades->orig_i_up($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_up = $cyclades->cy_port_cd() || {};
my %i_up;
foreach my $iid ( keys %$i_up ) {
my $up = $i_up->{$iid};
next unless defined $up;
$i_up{$iid} = $up;
}
foreach my $iid ( keys %$cy_p_up ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $up = $cy_p_up->{$iid};
next unless defined $up;
$i_up{$index} = $up;
}
return \%i_up;
}
sub i_description {
my $cyclades = shift;
my $partial = shift;
my $i_desc = $cyclades->orig_i_description($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_desc = $cyclades->cy_port_name() || {};
my %descr;
foreach my $iid ( keys %$i_desc ) {
my $desc = $i_desc->{$iid};
next unless defined $desc;
$descr{$iid} = $desc;
}
foreach my $iid ( keys %$cy_p_desc ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $desc = $cy_p_desc->{$iid};
next unless defined $desc;
$descr{$index} = $desc;
}
return \%descr;
}
sub i_name {
my $cyclades = shift;
my $partial = shift;
my $i_name = $cyclades->orig_i_name($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_desc = $cyclades->cy_port_name() || {};
my %i_name;
foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid};
next unless defined $name;
$i_name{$iid} = $name;
}
foreach my $iid ( keys %$cy_p_desc ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $name = $cy_p_desc->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
return \%i_name;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::Cyclades - SNMP Interface to Cyclades terminal servers
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $cyclades = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $cyclades->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Cyclades device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $cyclades = new SNMP::Info::Layer1::Cyclades(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer1
=back
=head2 Required MIBs
=over
=item F<CYCLADES-ACS-SYS-MIB>
=item F<CYCLADES-ACS-CONF-MIB>
=item F<CYCLADES-ACS-INFO-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $cyclades->os_ver()
(C<cyACSversion>)
=item $cyclades->serial()
(C<cyACSDevId>)
=item $cyclades->root_ip()
(C<cyEthIPaddr>)
=item $cyclades->ps1_status()
(C<cyACSPw1>)
=item $cyclades->ps2_status()
(C<cyACSPw2>)
=back
=head2 Overrides
=over
=item $cyclades->layers()
Returns 01000001. These devices don't have a FDB and we probably don't want
to poll for an ARP cache so turn off reported Layer 2 and Layer 3.
=item $cyclades->vendor()
Returns 'cyclades'
=item $cyclades->os()
Returns 'cyclades'
=item $cyclades->model()
Returns lower case (C<cyACSpname>)
=back
=head2 Globals imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $cyclades->i_index()
Returns reference to map of IIDs to Interface index.
Extended to include serial ports. Serial ports are indexed with the
alternative labeling system for the serial port, the listening socket port
C<cySPortSocketPort> to avoid conflicts with C<ifIndex>.
=item $cyclades->interfaces()
Returns reference to map of IIDs to physical ports. Extended to include
serial ports, C<cyISPortTty>.
=item $cyclades->i_speed()
Returns interface speed. Extended to include serial ports, C<cyISPortSpeed>.
=item $cyclades->i_up()
Returns link status for each port. Extended to include serial ports,
C<cyISPortSigCD>.
=item $cyclades->i_description()
Returns description of each port. Extended to include serial ports,
C<cyISPortName>.
=item $cyclades->i_name()
Returns name of each port. Extended to include serial ports, C<cyISPortName>.
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -1,548 +0,0 @@
# SNMP::Info::Layer1::S3000
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::S3000;
use strict;
use Exporter;
use SNMP::Info::Layer2;
@SNMP::Info::Layer1::S3000::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer1::S3000::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable',
'SYNOPTICS-COMMON-MIB' => 's3AgentType',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
# From SYNOPTICS-COMMON-MIB
'os_bin' => 's3AgentFwVer',
's3000_major_ver' => 's3AgentSwMajorVer',
's3000_minor_ver' => 's3AgentSwMinorVer',
's3000_maint_ver' => 's3AgentSwMaintVer',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
# SYNOPTICS-ETHERNET-MIB::s3EnetPortTable
's3000_pb_index' => 's3EnetPortBoardIndex',
's3000_pp_index' => 's3EnetPortIndex',
's3000_up_admin' => 's3EnetPortPartStatus',
's3000_up' => 's3EnetPortLinkStatus',
# SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable
's3000_nb_index' => 's3EnetShowNodesSlotIndex',
's3000_np_index' => 's3EnetShowNodesPortIndex',
'fw_mac' => 's3EnetShowNodesMacAddress',
# SYNOPTICS-ETHERNET-MIB::s3EnetTopNmmTable
's3000_topo_port' => 's3EnetTopNmmPort',
's3000_topo_mac' => 's3EnetTopNmmMacAddr',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, 's3000_topo_mac' => \&SNMP::Info::munge_mac
);
sub layers {
return '00000011';
}
sub os {
return 'synoptics';
}
sub vendor {
return 'nortel';
}
sub model {
my $s3000 = shift;
my $id = $s3000->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^s3reg-//i;
return $1 if ( $model =~ /((\d+){3}[\dX])/ );
return $model;
}
sub os_ver {
my $s3000 = shift;
my $major_ver = $s3000->s3000_major_ver() || 0;
my $minor_ver = $s3000->s3000_minor_ver() || 0;
my $maint_ver = $s3000->s3000_maint_ver() || 0;
my $ver = "$major_ver.$minor_ver.$maint_ver";
return $ver;
}
sub mac {
my $s3000 = shift;
my $topo_port = $s3000->s3000_topo_port();
my $topo_mac = $s3000->s3000_topo_mac();
foreach my $entry ( keys %$topo_port ) {
my $port = $topo_port->{$entry};
next unless $port == 0;
my $mac = $topo_mac->{$entry};
return $mac;
}
# Topology turned off, not supported.
return;
}
# Hubs do not support ifMIB requirements for get MAC
# and port status
sub i_index {
my $s3000 = shift;
my $partial = shift;
my $b_index = $s3000->s3000_pb_index($partial) || {};
my $p_index = $s3000->s3000_pp_index($partial) || {};
my %i_index;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
# We need to make up an index for multiple board instances.
my $index = ( $board * 256 ) + $port;
$i_index{$iid} = $index;
}
return \%i_index;
}
# Partials don't really help in this class, but implemented
# for consistency
sub interfaces {
my $s3000 = shift;
my $partial = shift;
my $i_index = $s3000->i_index() || {};
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# Index numbers are deterministic slot * 256 + port - see i_index()
my $port = $index % 256;
my $slot = int( $index / 256 );
my $slotport = "$slot.$port";
$if{$index} = $slotport;
}
return \%if;
}
sub i_duplex {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my %i_duplex;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# Hubs only function half duplex
my $duplex = 'half';
$i_duplex{$index} = $duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my %i_duplex_admin;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# Hubs only function half duplex
my $duplex = 'half';
$i_duplex_admin{$index} = $duplex;
}
return \%i_duplex_admin;
}
sub i_speed {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my %i_speed;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# These hubs only support 10 Mbs
my $speed = '10000000';
$i_speed{$index} = $speed;
}
return \%i_speed;
}
sub i_up {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my $link_stat = $s3000->s3000_up() || {};
my %i_up;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$link_stat = 'up' if $link_stat =~ /on/i;
$link_stat = 'down' if $link_stat =~ /off/i;
$i_up{$index} = $link_stat;
}
return \%i_up;
}
sub i_up_admin {
my $s3000 = shift;
my $partial = shift;
my $i_index = $s3000->i_index() || {};
my $link_stat = $s3000->s3000_up_admin() || {};
my %i_up_admin;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$i_up_admin{$index} = $link_stat;
}
return \%i_up_admin;
}
sub set_i_up_admin {
# map setting to those the hub will understand
my %setting = qw/up 2 down 3/;
my $s3000 = shift;
my ( $setting, $iid ) = @_;
my $i_index = $s3000->i_index() || {};
my %reverse_i_index = reverse %$i_index;
$setting = lc($setting);
return 0 unless defined $setting{$setting};
$iid = $reverse_i_index{$iid};
return $s3000->set_s3000_up_admin( $setting{$setting}, $iid );
}
# Hubs do not support the standard Bridge MIB
sub bp_index {
my $s3000 = shift;
my $partial = shift;
my $b_index = $s3000->s3000_nb_index() || {};
my $p_index = $s3000->s3000_np_index() || {};
my $model = $s3000->model();
my %bp_index;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
my $index = ( $board * 256 ) + $port;
next if ( defined $partial and $index !~ /^$partial$/ );
$bp_index{$index} = $index;
}
return \%bp_index;
}
sub fw_port {
my $s3000 = shift;
my $partial = shift;
my $b_index = $s3000->s3000_nb_index($partial) || {};
my $p_index = $s3000->s3000_np_index($partial) || {};
my $model = $s3000->model();
my %fw_port;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
my $index = ( $board * 256 ) + $port;
$fw_port{$iid} = $index;
}
return \%fw_port;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::S3000 - SNMP Interface to Synoptics / Nortel Hubs
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $s3000 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $s3000->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bay hub device through SNMP. Also provides device MAC to port mapping through
the proprietary MIB.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $s3000 = new SNMP::Info::Layer1::S3000(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<SYNOPTICS-COMMON-MIB>
=item F<SYNOPTICS-ETHERNET-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $s3000->vendor()
Returns 'nortel'
=item $s3000->os()
Returns 'synoptics'
=item $s3000->model()
Cross references $s3000->id() to the F<SYNOPTICS-MIB> and returns
the results.
Removes C<sreg-> from the model name and returns only the numeric model
identifier.
=item $stack->os_ver()
Returns the software version specified as major.minor.maint.
(C<s3AgentSwMajorVer>).(C<s3AgentSwMinorVer>).(C<s3AgentSwMaintVer>)
=item $stack->os_bin()
Returns the firmware version. (C<s3AgentFwVer>)
=item $s3000->mac()
Returns MAC of the advertised IP address of the device.
=back
=head2 Overrides
=over
=item $s3000->layers()
Returns 00000011. Class emulates Layer 2 functionality through proprietary
MIBs.
=back
=head2 Globals imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $s3000->i_index()
Returns reference to map of IIDs to Interface index.
Since hubs do not support C<ifIndex>, the interface index is created using the
formula (board * 256 + port). This is required to support devices with more
than one module.
=item $s3000->interfaces()
Returns reference to map of IIDs to physical ports.
=item $s3000->i_duplex()
Returns half, hubs do not support full duplex.
=item $s3000->i_duplex_admin()
Returns half, hubs do not support full duplex.
=item $s3000->i_speed()
Returns 10000000. The hubs only support 10 Mbs Ethernet.
=item $s3000->i_up()
Returns (C<s3EnetPortLinkStatus>) for each port. Translates on/off to
up/down.
=item $s3000->i_up_admin()
Returns (C<s3EnetPortPartStatus>) for each port.
=item $s3000->set_i_up_admin(state, ifIndex)
Sets port state, must be supplied with state and port C<ifIndex>
State choices are 'up' or 'down'
Example:
my %if_map = reverse %{$s3000->interfaces()};
$s3000->set_i_up_admin('down', $if_map{'1.1'})
or die "Couldn't change port state. ",$s3000->error(1);
=item $s3000->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $s3000->fw_port()
Returns reference to map of IIDs of the
C<SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable> to the Interface index.
=item $s3000->fw_mac()
(C<s3EnetShowNodesMacAddress>)
=item $s3000->s3000_topo_port()
Returns reference to hash. Key: Table entry, Value:Port Number
(interface iid)
(C<s3EnetTopNmmPort>)
=item $s3000->s3000_topo_mac()
(C<s3EnetTopNmmMacAddr>)
Returns reference to hash. Key: Table entry, Value:Remote MAC address
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,89 +1,91 @@
# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices
# $Id$
#
# Copyright (c) 2008 Max Baker -- All changes from Version 0.7 on
# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::Entity;
use SNMP::Info::PowerEthernet;
use SNMP::Info::CDP;
@SNMP::Info::Layer2::ISA
= qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity SNMP::Info::PowerEthernet Exporter/;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::Entity::MIBS, %SNMP::Info::PowerEthernet::MIBS,
);
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::CDP::MIBS,
'CISCO-PRODUCTS-MIB' => 'sysName',
'CISCO-STACK-MIB' => 'wsc1900sysID',
# 'HP-ICF-OID' => 'hpSwitch4000',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::PowerEthernet::GLOBALS,
'serial1' =>
'.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
);
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Entity::FUNCS, %SNMP::Info::PowerEthernet::FUNCS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::CDP::FUNCS,
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE,
);
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::CDP::MUNGE,
);
# Method OverRides
# $l2->model() - Looks at sysObjectID which gives the oid of the system
# name, contained in a propriatry MIB.
# name, contained in a propriatry MIB.
sub model {
my $l2 = shift;
my $id = $l2->id();
my $model = &SNMP::translateObj($id) || $id || '';
my $l2 = shift;
my $id = $l2->id();
my $model = &SNMP::translateObj($id);
# HP
$model =~ s/^hpswitch//i;
@@ -96,71 +98,61 @@ sub model {
}
sub vendor {
my $l2 = shift;
my $l2 = shift;
my $model = $l2->model();
my $descr = $l2->description();
if ( $model =~ /hp/i or $descr =~ /\bhp\b/i ) {
if ($model =~ /hp/i or $descr =~ /hp/i) {
return 'hp';
}
if ( $model =~ /catalyst/i or $descr =~ /(catalyst|cisco)/i ) {
if ($model =~ /catalyst/i or $descr =~ /(catalyst|cisco)/i) {
return 'cisco';
}
}
sub serial {
sub i_ignore {
my $l2 = shift;
my $serial1 = $l2->serial1();
my $e_descr = $l2->e_descr() || {};
my $e_serial = $l2->e_serial() || {};
my $serial2 = $e_serial->{1} || undef;
my $chassis = $e_descr->{1} || undef;
# precedence
# serial2,chassis parse,serial1
return $serial2 if ( defined $serial2 and $serial2 !~ /^\s*$/ );
return $1
if ( defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i );
return $serial1 if ( defined $serial1 and $serial1 !~ /^\s*$/ );
return;
}
sub i_ignore {
my $l2 = shift;
my $partial = shift;
my $i_type = $l2->i_type($partial) || {};
my $i_type = $l2->i_type();
my %i_ignore = ();
foreach my $if ( keys %$i_type ) {
foreach my $if (keys %$i_type){
my $type = $i_type->{$if};
$i_ignore{$if}++
if $type =~ /(loopback|other|cpu)/i;
$i_ignore{$if}++
if $type =~ /(loopback|propvirtual|other|cpu)/i;
}
return \%i_ignore;
}
}
# By Default we'll use the description field
sub interfaces {
my $l2 = shift;
my $partial = shift;
my $l2 = shift;
my $interfaces = $l2->i_index();
my $i_descr = $l2->i_description();
my $i_name = $l2->i_name();
my $interfaces = $l2->i_index($partial) || {};
my $i_descr = $l2->i_description($partial) || {};
# Replace the Index with the ifDescr field.
foreach my $iid ( keys %$i_descr ) {
my %if;
foreach my $iid (keys %$interfaces){
my $port = $i_descr->{$iid};
my $name = $i_name->{$iid};
$port = $name if (defined $name and $name !~ /^\s*$/);
next unless defined $port;
$interfaces->{$iid} = $port;
# Cisco 1900 has a space in some of its port descr.
# get rid of any weird characters
$port =~ s/[^\d\/,()\w]+//gi;
# Translate Cisco 2926,etc. from 1/5 to 1.5
$port =~ s/\//\./ if ($port =~ /^\d+\/\d+$/);
$if{$iid} = $port;
}
return $interfaces;
return \%if
}
1;
@@ -168,119 +160,79 @@ __END__
=head1 NAME
SNMP::Info::Layer2 - SNMP Interface to network devices serving Layer2 only.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $l2 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $l2->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
my $interfaces = $l2->interfaces();
my $i_up = $l2->i_up();
my $i_speed = $l2->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
SNMP::Info::Layer2 - Perl5 Interface to Layer2 network devices.
=head1 DESCRIPTION
This class is usually used as a superclass for more specific device classes
listed under SNMP::Info::Layer2::* Please read all docs under SNMP::Info
first.
Provides abstraction to the configuration information obtainable from a
Layer2 device through SNMP. Information is stored in a number of MIBs.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
See super classes for descriptions of other available methods.
my $l2 = new SNMP::Info::Layer2(...);
Inherits from:
=head2 Inherited Classes
SNMP::Info
SNMP::Info::Bridge
SNMP::Info::CDP
MIBS:
CISCO-PRODUCTS-MIB - Needed for ID of Cisco Products
CISCO-STACK-MIB - Needed for ID of Cisco Products
##HP-ICF-OID - Needed for ID of HP Products
MIBS listed in SNMP::Info::Bridge and SNMP::Info::CDP
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
HP MIBs can be found at http://www.hp.com/rnd/software
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $l2 = new SNMP::Info::Layer2(DestHost => 'mybridge' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info
=item new SNMP::Info::Layer2()
=item SNMP::Info::Bridge
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::Entity
my $l2 = new SNMP::Info::Layer2(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $l2;
=back
=head2 Required MIBs
=over
=item Inherited Classes
MIBs required by the inherited classes listed above.
=back
MIBs can be found in netdisco-mibs package.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $l2->model()
Cross references $l2->id() with product IDs in the
Cisco MIBs.
Cisco and HP specific MIBs.
For HP devices, removes C<'hpswitch'> from the name
For HP devices, removes 'hpswitch' from the name
For Cisco devices, removes c<'sysid'> from the name
For Cisco devices, removes 'sysid' from the name
=item $l2->vendor()
Tries to discover the vendor from $l2->model() and $l2->description()
=item $l2->serial()
Returns serial number if available through SNMP
Trys to discover the vendor from $l2->model() and $l2->vendor()
=back
=head2 Globals imported from SNMP::Info
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -288,29 +240,16 @@ to a hash.
=item $l2->interfaces()
Creates a map between the interface identifier (iid) and the physical port
name.
Creates a map between the interface identifier (iid) and the physical port name.
Defaults to C<ifDescr> but checks and overrides with C<ifName>
Defaults to B<ifDescr> but checks and overrides with B<ifName>
=item $l2->i_ignore()
Returns reference to hash. Increments value of IID if port is to be ignored.
Ignores ports with C<ifType> of loopback, propvirtual, other, and cpu
Ignores ports with B<ifType> of loopback,propvirtual,other, and cpu
=back
=head2 Table Methods imported from SNMP::Info
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=cut

View File

@@ -1,269 +0,0 @@
# SNMP::Info::Layer2::Airespace
# $Id$
#
# Copyright (c) 2008 Eric Miller
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Airespace;
use strict;
use Exporter;
use SNMP::Info::Bridge;
use SNMP::Info::CDP;
use SNMP::Info::Airespace;
@SNMP::Info::Layer2::Airespace::ISA
= qw/SNMP::Info::Airespace SNMP::Info::CDP SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer2::Airespace::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::Airespace::MIBS,
'AIRESPACE-SWITCHING-MIB' => 'agentInterfaceVlanId',
'CISCO-LWAPP-DOT11-CLIENT-MIB' => 'cldcClientCurrentTxRateSet',
);
%GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::Airespace::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::Airespace::FUNCS,
# This needs to be cleaned up, but for now we pretend to
# have the CISCO-DOT11-MIB for signal strengths, etc.
'cd11_sigstrength' => 'bsnMobileStationRSSI', # kinda
'cd11_sigqual' => 'bsnMobileStationSnr', # kinda
'cd11_rxbyte' => 'bsnMobileStationBytesReceived',
'cd11_txbyte' => 'bsnMobileStationBytesSent',
'cd11_rxpkt' => 'bsnMobileStationPacketsReceived',
'cd11_txpkt' => 'bsnMobileStationPacketsSent',
'cd11_txrate' => 'cldcClientCurrentTxRateSet',
'cd11_rateset' => 'cldcClientDataRateSet',
);
%MUNGE = (
%SNMP::Info::MUNGE, %SNMP::Info::Bridge::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::Airespace::MUNGE,
'cd11_rxpkt' => \&munge_64bits,
'cd11_txpkt' => \&munge_64bits,
'cd11_txrate' => \&munge_cd11_txrate,
'cd11_rateset' => \&munge_cd11_rateset,
);
sub os {
return 'cisco';
}
sub vendor {
return 'cisco';
}
sub model {
my $airespace = shift;
my $model = $airespace->airespace_model();
return unless defined $model;
return $model;
}
# vlan:
# AIRESPACE-SWITCHING-MIB::agentInterfaceVlanId
sub cd11_mac {
my $airespace = shift;
my $cd11_sigstrength = $airespace->cd11_sigstrength();
my $ret = {};
foreach my $idx ( keys %$cd11_sigstrength ) {
my $mac = join( ":", map { sprintf "%02x", $_ } split /\./, $idx );
$ret->{$idx} = $mac
}
return $ret;
}
sub munge_cd11_txrate {
my $rate = shift;
if ( $rate ) {
return [ $rate * 1.0 ];
} else {
return [ 0.0 ];
}
}
sub munge_cd11_rateset {
my $rates = shift;
return [ map { $_ * 1.0 } split /,/, $rates ];
}
sub munge_64bits {
# The controller sometimes hands off a ridiculous value for packets.
# Just truncate it to 32 bits.
my $value = shift;
return $value & 0xffffffff;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Airespace - SNMP Interface to Cisco (Airespace) Wireless
Controllers
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $airespace = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $airespace->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from
Cisco (Airespace) Wireless Controllers through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $airespace = new SNMP::Info::Layer2::Airespace(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Airespace
=item SNMP::Info::CDP
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::Airespace/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $airespace->vendor()
Returns 'cisco'
=item $airespace->os()
Returns 'cisco'
=item $airespace->model()
(C<agentInventoryMachineModel>)
=back
=head2 Global Methods imported from SNMP::Info::Airespace
See documentation in L<SNMP::Info::Airespace/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item cd11_mac()
=back
=head2 Overrides
=head2 Table Methods imported from SNMP::Info::Airespace
See documentation in L<SNMP::Info::Airespace/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head1 MUNGES
=over
=item munge_64bits()
=item munge_cd11_rateset()
=item munge_cd11_txrate()
=back
=cut

View File

@@ -1,650 +0,0 @@
# SNMP::Info::Layer2::Aironet
# $Id$
#
# Copyright (c) 2008-2009 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Aironet;
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::Entity;
use SNMP::Info::EtherLike;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoConfig;
use SNMP::Info::CDP;
use SNMP::Info::IEEE802dot11;
@SNMP::Info::Layer2::Aironet::ISA
= qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike
SNMP::Info::CiscoStats SNMP::Info::CiscoConfig SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::Aironet::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%GLOBALS = (
%SNMP::Info::IEEE802dot11::GLOBALS,
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'serial' => 'entPhysicalSerialNum.1',
'descr' => 'sysDescr'
);
%FUNCS = (
%SNMP::Info::IEEE802dot11::FUNCS,
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::Entity::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CDP::FUNCS,
'i_80211channel' => 'cd11IfPhyDsssCurrentChannel',
'c_dot11subif' => 'cDot11ClientSubIfIndex',
'cd11_rateset' => 'cDot11ClientDataRateSet',
'cd11_txrate' => 'cDot11ClientCurrentTxRateSet',
'cd11_uptime' => 'cDot11ClientUpTime',
'cd11_sigstrength' => 'cDot11ClientSignalStrength',
'cd11_sigqual' => 'cDot11ClientSigQuality',
'cd11_rxpkt' => 'cDot11ClientPacketsReceived',
'cd11_txpkt' => 'cDot11ClientPacketsSent',
'cd11_rxbyte' => 'cDot11ClientBytesReceived',
'cd11_txbyte' => 'cDot11ClientBytesSent',
'mbss_mac_addr' => 'cdot11MbssidIfMacAddress',
);
%MIBS = (
%SNMP::Info::IEEE802dot11::MIBS,
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::Entity::MIBS,
%SNMP::Info::EtherLike::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CDP::MIBS,
'CISCO-DOT11-IF-MIB' => 'cd11IfAuxSsid',
'CISCO-DOT11-ASSOCIATION-MIB' => 'cDot11ClientSubIfIndex',
'CISCO-DOT11-SSID-SECURITY-MIB' => 'cdot11SecVlanNameId',
'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex',
);
%MUNGE = (
%SNMP::Info::IEEE802dot11::MUNGE,
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CDP::MUNGE,
'cd11_txrate' => \&munge_cd11_txrate,
'cd11_rateset' => \&munge_cd11_txrate,
'mbss_mac_addr' => \&SNMP::Info::munge_mac,
);
# Use 802.11 power level without putting IEEE802dot11 in @ISA
*SNMP::Info::Layer2::Aironet::dot11_cur_tx_pwr_mw
= \&SNMP::Info::IEEE802dot11::dot11_cur_tx_pwr_mw;
sub vendor {
# Sorry, but it's true.
return 'cisco';
}
sub interfaces {
my $aironet = shift;
my $partial = shift;
my $i_description = $aironet->i_description($partial);
return $i_description;
}
# Tag on e_descr.1
sub description {
my $aironet = shift;
my $descr = $aironet->descr();
my $e_descr = $aironet->e_descr();
$descr = "$e_descr->{1} $descr" if defined $e_descr->{1};
return $descr;
}
# Fetch duplex from EtherLike
sub i_duplex {
my $aironet = shift;
my $partial = shift;
my $el_duplex = $aironet->el_duplex($partial);
my %i_duplex;
foreach my $d ( keys %$el_duplex ) {
my $val = $el_duplex->{$d};
next unless defined $val;
$i_duplex{$d} = 'full' if $val =~ /full/i;
$i_duplex{$d} = 'half' if $val =~ /half/i;
}
return \%i_duplex;
}
#
# IOS 12.3 introduces the cDot11ClientSubIfIndex in the
# cDot11ClientConfigInfoTable, which supplies the ifIndex
# of the VLAN Subinterface if one exists, or of the primary
# interface if there are not subinterfaces. 12.2 used the
# Q-BRIDGE-MIB dot1qTpFdbTable but that was removed in 12.3.
sub _aironet_special {
my $aironet = shift;
my $os_ver = $aironet->os_ver();
if ( defined($os_ver)
&& $os_ver =~ /^(\d+)\.(\d+)(\D|$)/
&& ( ( $1 == 12 && $2 >= 3 ) || $1 > 12 ) )
{
return 1;
}
}
#
# INDEX { ifIndex, cd11IfAuxSsid, cDot11ClientAddress }
sub _aironet_breakout_dot11idx {
my $oid = shift;
my @parts = split( /\./, $oid );
my $ifindex = shift(@parts);
my $ssidlen = shift(@parts);
my $ssid = pack( "C*", splice( @parts, 0, $ssidlen ) );
my $mac = join( ":", map { sprintf "%02x", $_ } @parts );
return ( $ifindex, $ssid, $mac );
}
sub fw_mac {
my $aironet = shift;
return $aironet->qb_fw_mac() unless _aironet_special($aironet);
my $c_dot11subif = $aironet->c_dot11subif();
my $fw_mac = {};
foreach my $i ( keys %$c_dot11subif ) {
my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i);
$fw_mac->{$i} = $mac;
}
return $fw_mac;
}
sub fw_port {
my $aironet = shift;
return $aironet->qb_fw_port() unless _aironet_special($aironet);
my $c_dot11subif = $aironet->c_dot11subif();
my $fw_port = {};
foreach my $i ( keys %$c_dot11subif ) {
my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i);
$fw_port->{$i} = $c_dot11subif->{$i} || $ifindex;
}
return $fw_port;
}
sub bp_index {
my $aironet = shift;
return $aironet->orig_bp_index() unless _aironet_special($aironet);
my $c_dot11subif = $aironet->c_dot11subif();
my $bp_index = {};
foreach my $i ( keys %$c_dot11subif ) {
my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i);
my ($i) = $c_dot11subif->{$i} || $ifindex;
$bp_index->{$i} = $i;
}
return $bp_index;
}
###
#
# VLAN support
#
sub v_name {
my $aironet = shift;
my $v_name = {};
my $vlan_nameid = $aironet->cdot11SecVlanNameId();
foreach my $i ( keys %$vlan_nameid ) {
my @parts = split( /\./, $i );
my $namelen = shift(@parts);
my $name = pack( "C*", @parts );
$v_name->{$i} = $name;
}
return $v_name;
}
sub v_index {
my $aironet = shift;
return $aironet->cdot11SecVlanNameId();
}
sub i_vlan {
my $aironet = shift;
my $i_vlan = {};
my $idxmap = $aironet->cviRoutedVlanIfIndex();
foreach my $i ( keys %$idxmap ) {
my @parts = split( /\./, $i );
$i_vlan->{ $idxmap->{$i} } = $parts[0];
}
return $i_vlan;
}
# The MIB reports in units of half a megabit, e.g.,
# 5.5Mbps is reported as 11.
sub munge_cd11_txrate {
my $txrates = shift;
my @units = unpack( "C*", $txrates );
my @rates = map {
my $unit = $_;
$unit *= 0.5;
} @units;
return \@rates;
}
# cd11 INDEX
sub cd11_port {
my $aironet = shift;
my $cd11_sigstrength = $aironet->cd11_sigstrength();
my $interfaces = $aironet->interfaces();
my %ret;
foreach ( keys %$cd11_sigstrength ) {
my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_);
$ret{$_} = $interfaces->{$ifindex};
}
return \%ret;
}
sub cd11_ssid {
my $aironet = shift;
my $cd11_sigstrength = $aironet->cd11_sigstrength();
my %ret;
foreach ( keys %$cd11_sigstrength ) {
my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_);
$ret{$_} = $ssid;
}
return \%ret;
}
sub cd11_mac {
my $aironet = shift;
my $cd11_sigstrength = $aironet->cd11_sigstrength();
my %ret;
foreach ( keys %$cd11_sigstrength ) {
my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_);
$ret{$_} = $mac;
}
return \%ret;
}
# Map VLAN N on interface I to its actual ifIndex.
sub _vlan_map_n_stack {
my $aironet = shift;
my $vlan_idx = $aironet->cviRoutedVlanIfIndex();
my $vlan_map = {};
foreach my $idx ( keys %$vlan_idx ) {
my ( $vlan, $num ) = split( /\./, $idx );
$vlan_map->{$vlan}->{$num} = $vlan_idx->{$idx};
}
return $vlan_map;
}
# When using MBSS, the ifTable reports the
# base MAC address, but the actual association is
# with a different MAC address for MBSS.
# This convoluted path seems to be necessary
# to get the right overrides.
sub i_mac {
my $aironet = shift;
# no partial is possible due to the levels
# of indirection.
# Start with the ifPhysAddress, and override
my $mbss_mac = $aironet->orig_i_mac();
my $mbss_mac_addr = $aironet->mbss_mac_addr();
my $ssid_vlan = $aironet->cdot11SecAuxSsidVlan();
my $vlan_map = $aironet->cviRoutedVlanIfIndex();
my $ifstack = $aironet->ifStackStatus();
my $vlan_list = {};
foreach my $idx ( keys %$vlan_map ) {
my ( $vlan, $num ) = split( /\./, $idx );
push( @{ $vlan_list->{$vlan} }, $vlan_map->{$idx} );
}
my $stack = {};
foreach my $idx ( keys %$ifstack ) {
my ( $upper, $lower ) = split( /\./, $idx );
$stack->{$upper}->{$lower} = $ifstack->{$idx};
}
# mbss_mac_addr index is (radio, ssid).
# ssid_vlan maps ssid->vlan.
# vlan_map maps vlan->[list of interfaces]
# ifstack allows us to pick the right interface
foreach my $idx ( keys %$mbss_mac_addr ) {
my ( $interface, @ssid ) = split( /\./, $idx );
my $vlan = $ssid_vlan->{ join( ".", scalar(@ssid), @ssid ) };
next unless defined($vlan);
foreach my $vlanif ( @{ $vlan_list->{$vlan} } ) {
if ( defined( $stack->{$vlanif}->{$interface} ) ) {
$mbss_mac->{$vlanif} = $mbss_mac_addr->{$idx};
}
}
}
return $mbss_mac;
}
sub i_ssidlist {
my $aironet = shift;
# no partial is possible due to the levels
# of indirection.
my $ssid_row = $aironet->cdot11SecInterfSsidRowStatus();
my $ssid_vlan = $aironet->cdot11SecAuxSsidVlan();
if ( !defined($ssid_row) || !defined($ssid_vlan) ) {
return $aironet->cd11IfAuxSsid();
}
my $ssidlist = {};
my $if_ssidcount = {};
my $vlan_map = $aironet->_vlan_map_n_stack();
foreach my $idx ( keys %$ssid_row ) {
next unless $ssid_row->{$idx} eq 'active';
# ssid_row index is radio.ssid
my ( $interface, $ssid ) = split( /\./, $idx, 2 );
my ( $len, @ssidt ) = split( /\./, $ssid );
my $mappedintf = $vlan_map->{ $ssid_vlan->{$ssid} }->{$interface};
next unless $mappedintf;
if ( !$if_ssidcount->{$mappedintf} ) {
$if_ssidcount->{$mappedintf} = 1;
}
my $ssidlist_idx
= sprintf( "%s.%d", $mappedintf, $if_ssidcount->{$mappedintf} );
$ssidlist->{$ssidlist_idx} = pack( "C*", @ssidt );
$if_ssidcount->{$mappedintf}++;
}
return $ssidlist;
}
sub i_ssidbcast {
my $aironet = shift;
my $partial = shift;
my $mbss_bcast = $aironet->cdot11SecAuxSsidMbssidBroadcast();
if ( !defined($mbss_bcast) ) {
return $aironet->cd11IfAuxSsidBroadcastSsid($partial);
}
my $map = {};
foreach my $key ( keys %$mbss_bcast ) {
my (@idx) = split( /\./, $key );
my $len = shift(@idx);
$map->{ pack( "C*", @idx ) } = $mbss_bcast->{$key};
}
# This needs to return the same indexes as i_ssidlist.
# mbss_bcast maps ssid -> broadcasting
# so we just replace the i_ssidlist values with the mbss_bcast ones.
my $i_ssidlist = $aironet->i_ssidlist();
my $i_ssidbcast = {};
foreach my $key ( keys %$i_ssidlist ) {
$i_ssidbcast->{$key} = $map->{ $i_ssidlist->{$key} };
}
return $i_ssidbcast;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Aironet - SNMP Interface to Cisco Aironet devices running
IOS.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $aironet = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $aironet->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides interface to SNMP Data available on newer Aironet devices running
Cisco IOS.
Note there are two classes for Aironet devices :
=over
=item SNMP::Info::Layer3::Aironet
This class is for devices running Aironet software (older)
=item SNMP::Info::Layer2::Aironet
This class is for devices running Cisco IOS software (newer)
=back
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $aironet = new SNMP::Info::Layer2::Aironet(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::Entity
=item SNMP::Info::EtherLike
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoConfig
=back
=head2 Required MIBs
=over
=item Inherited Classes
MIBs required by the inherited classes listed above.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $aironet->discription()
Adds info from method e_descr() from SNMP::Info::Entity
=item $aironet->vendor()
Returns 'cisco'
=item $aironet->description()
System description
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::EtherLike
See documentation in L<SNMP::Info::EtherLike/"GLOBALS"> for details.
=head1 TABLE METHODS
=over
=item $aironet->cd11_port()
Returns radio interfaces.
=item $aironet->cd11_mac()
Returns radio interface MAC addresses.
=item $aironet->cd11_ssid()
Returns radio interface ssid.
=item $aironet->dot11_cur_tx_pwr_mw()
Current transmit power, in milliwatts, of the radio interface.
=back
=head2 Overrides
=over
=item $aironet->interfaces()
Uses the i_description() field.
=item $aironet->i_mac()
MAC address of the interface. Note this is just the MAC of the port, not
anything connected to it.
=item $aironet->i_duplex()
Crosses information from SNMP::Info::EtherLike to get duplex info for
interfaces.
=item $aironet->bp_index()
Returns reference to hash of bridge port table entries map back to interface
identifier (iid)
=item $aironet->fw_mac()
Returns reference to hash of forwarding table MAC Addresses
=item $aironet->fw_port()
Returns reference to hash of forwarding table entries port interface
identifier (iid)
=item $aironet->i_vlan()
Returns a mapping between C<ifIndex> and the PVID or default VLAN.
=item $aironet->v_index()
Returns VLAN IDs
=item $aironet->v_name()
Returns VLAN names
=item $aironet->i_ssidlist()
Returns a list of SSIDs associated with interfaces. This function
is C<MBSSID> aware, so when using C<MBSSID> can map SSIDs to the sub-interface
to which they belong.
=item $aironet->i_ssidbcast()
With the same keys as i_ssidlist, returns whether the given SSID is
being broadcast.
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::EtherLike
See documentation in L<SNMP::Info::EtherLike/"TABLE METHODS"> for details.
=head1 Data Munging Callback Subroutines
=over
=item $aironet->munge_cd11_txrate()
Converts units of half a megabit to human readable string.
=back
=cut

View File

@@ -1,240 +0,0 @@
# SNMP::Info::Layer2::Allied
# $Id$
#
# Copyright (c) 2008 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Allied;
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::Layer1;
@SNMP::Info::Layer2::Allied::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Allied::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS );
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
'ip_adresses' => 'atNetAddress',
'ip_mac' => 'atPhysAddress',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'AtiSwitch-MIB' => 'atiswitchProductType',
'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking',
);
%MUNGE = ( %SNMP::Info::Layer2::MUNGE, );
sub vendor {
return 'allied';
}
sub os {
return 'allied';
}
sub os_ver {
my $allied = shift;
my $descr = $allied->description();
if ( $descr =~ m/version (\d+\.\d+)/ ) {
return $1;
}
}
sub model {
my $allied = shift;
my $desc = $allied->description();
if ( $desc =~ /(AT-80\d{2}\S*)/ ) {
return $1;
}
return;
}
sub root_ip {
my $allied = shift;
my $ip_hash = $allied->ip_addresses();
my $found_ip;
foreach my $ip ( values %{$ip_hash} ) {
$found_ip = SNMP::Info::munge_ip($ip) if ( defined $ip );
last; # this is only one IP address
}
return $found_ip;
}
sub mac {
my $allied = shift;
my $mac_hash = $allied->ip_mac();
my $found_mac;
foreach my $mac ( values %{$mac_hash} ) {
$found_mac = SNMP::Info::munge_mac($mac);
last; # this is only one MAC address
}
return $found_mac;
}
sub i_up {
my $allied = shift;
my $partial = shift;
my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial );
foreach my $port ( keys %$i_up ) {
my $up = $i_up->{$port};
$i_up->{$port} = 'down' if $up eq 'linktesterror';
$i_up->{$port} = 'up' if $up eq 'nolinktesterror';
}
return $i_up;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Allied - SNMP Interface to Allied Telesyn switches
=head1 AUTHOR
Max Baker, Dmitry Sergienko <dmitry@trifle.net>
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $allied = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myhub',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $allied->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Allied device through SNMP. See inherited classes' documentation for
inherited methods.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<AtiSwitch-MIB>
=item F<AtiStackInfo-MIB>
Download for your device from ftp://ftp.allied-telesyn.com/pub/switches/mibs/
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $allied->vendor()
Returns 'allied' :)
=item $allied->os()
Returns 'allied'
=item $allied->os_ver()
Culls Version from description()
=item $allied->root_ip()
Returns IP Address of Managed Device.
(C<actualIpAddr>)
=item $allied->model()
Tries to cull out C<AT-nnnnX> out of the description field.
=item $allied->mac()
Returns device MAC.
=back
=head2 Globals imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
=head2 Overrides
=over
=item $allied->i_up()
Returns reference to map of IIDs to link status. Changes
the values of ati_up() to 'up' and 'down'.
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,137 +1,92 @@
# SNMP::Info::Layer2::Bay
# $Id$
# This module depricated. See Layer2::BayStack
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Bay;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Bay::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
'cdp_id' => 's5EnMsTopIpAddr',
'cdp_run' => 's5EnMsTopStatus',
);
%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS,
'cdp_id' => 's5EnMsTopIpAddr',
'cdp_run' => 's5EnMsTopStatus',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
'imac2' => 'ifPhysAddress',
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
'imac2' => 'ifPhysAddress',
# S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable
'bay_topo_slot' => 's5EnMsTopNmmSlot',
'bay_topo_port' => 's5EnMsTopNmmPort',
'bay_topo_ip' => 's5EnMsTopNmmIpAddr',
'bay_topo_seg' => 's5EnMsTopNmmSegId',
'bay_topo_mac' => 's5EnMsTopNmmMacAddr',
'bay_topo_platform' => 's5EnMsTopNmmChassisType',
'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
# S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable
'bay_topo_slot' => 's5EnMsTopNmmSlot',
'bay_topo_port' => 's5EnMsTopNmmPort',
'bay_topo_ip' => 's5EnMsTopNmmIpAddr',
'bay_topo_seg' => 's5EnMsTopNmmSegId',
'bay_topo_mac' => 's5EnMsTopNmmMacAddr',
'bay_topo_platform' => 's5EnMsTopNmmChassisType',
'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'SYNOPTICS-ROOT-MIB' => 'synoptics',
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop'
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'SYNOPTICS-ROOT-MIB' => 'synoptics',
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop'
);
delete $MIBS{'CISCO-CDP-MIB'};
# 450's report full duplex as speed = 20mbps?!
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
%MUNGE = ( %SNMP::Info::Layer2::MUNGE, 'i_mac2' => \&SNMP::Info::munge_mac, );
sub os {
return 'bay';
}
sub os_ver {
my $bay = shift;
my $descr = $bay->description();
return unless defined $descr;
# 303 / 304
if ( $descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/ ) {
return $1;
}
# 450
if ( $descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/ ) {
return $1;
}
return;
}
sub os_bin {
my $bay = shift;
my $descr = $bay->description();
return unless defined $descr;
# 303 / 304
if ( $descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/ ) {
return $1;
}
# 450
if ( $descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/ ) {
return $1;
}
return;
}
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac ,
);
sub vendor {
# or nortel, or synopsis?
return 'bay';
}
sub i_ignore {
my $bay = shift;
my $bay = shift;
my $descr = $bay->description();
my $i_type = $bay->i_type();
my %i_ignore;
foreach my $if ( keys %$i_type ) {
my $type = $i_type->{$if};
foreach my $if (keys %$i_type){
my $type = $i_type->{$if};
$i_ignore{$if}++ if $type =~ /(loopback|propvirtual|cpu)/i;
}
@@ -139,50 +94,48 @@ sub i_ignore {
}
sub interfaces {
my $bay = shift;
my $bay = shift;
my $i_index = $bay->i_index();
return $i_index;
}
sub i_mac {
my $bay = shift;
sub i_mac {
my $bay = shift;
my $i_mac = $bay->i_mac2();
# Bay 303's with a hw rev < 2.11.4.5 report the mac as all zeros
foreach my $iid ( keys %$i_mac ) {
foreach my $iid (keys %$i_mac){
my $mac = $i_mac->{$iid};
delete $i_mac->{$iid} if $mac eq '00:00:00:00:00:00';
}
return $i_mac;
}
sub model {
my $bay = shift;
my $id = $bay->id();
return unless defined $id;
my $id = $bay->id();
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^sreg-//i;
my $descr = $bay->description();
return '303' if ( $descr =~ /\D303\D/ );
return '304' if ( $descr =~ /\D304\D/ );
return '450' if ( $model =~ /BayStack450/ );
return '303' if ($descr =~ /\D303\D/);
return '304' if ($descr =~ /\D304\D/);
return '450' if ($model =~ /BayStack450/);
return $model;
}
# Hack in some CDP type stuff
sub c_if {
my $bay = shift;
my $bay = shift;
my $bay_topo_port = $bay->bay_topo_port();
my %c_if;
foreach my $entry ( keys %$bay_topo_port ) {
foreach my $entry (keys %$bay_topo_port){
my $port = $bay_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
$c_if{"$port.1"} = $port;
}
@@ -190,30 +143,28 @@ sub c_if {
}
sub c_ip {
my $bay = shift;
my $bay = shift;
my $bay_topo_ip = $bay->bay_topo_ip();
my $bay_topo_port = $bay->bay_topo_port();
my $ip = $bay->cdp_ip();
my $ip = $bay->cdp_ip();
# Count the number of devices seen on each port.
# more than one device seen means connected to a non-bay
# device, but other bay devices are squawking further away.
my %ip_port;
foreach my $entry ( keys %$bay_topo_ip ) {
foreach my $entry (keys %$bay_topo_ip){
my $port = $bay_topo_port->{$entry};
next unless defined $port;
next if ( $port =~ /^[\d\.]+$/ and $port == 0 );
my $ip = $bay_topo_ip->{$entry};
push( @{ $ip_port{$port} }, $ip );
next if $port == 0;
my $ip = $bay_topo_ip->{$entry};
push(@{$ip_port{$port}},$ip);
}
my %c_ip;
foreach my $port ( keys %ip_port ) {
foreach my $port (keys %ip_port){
my $ips = $ip_port{$port};
if ( scalar @$ips == 1 ) {
if (scalar @$ips == 1) {
$c_ip{"$port.1"} = $ips->[0];
}
else {
} else {
$c_ip{"$port.1"} = $ips;
}
}
@@ -222,24 +173,23 @@ sub c_ip {
}
sub c_port {
my $bay = shift;
my $bay = shift;
my $bay_topo_port = $bay->bay_topo_port();
my $bay_topo_seg = $bay->bay_topo_seg();
my $bay_topo_seg = $bay->bay_topo_seg();
my %c_port;
foreach my $entry ( keys %$bay_topo_seg ) {
foreach my $entry (keys %$bay_topo_seg){
my $port = $bay_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
# For fake remotes (multiple IPs for a c_ip), use first found
next if defined $c_port{"$port.1"};
my $seg = $bay_topo_seg->{$entry};
my $seg = $bay_topo_seg->{$entry};
# Segment id is (256 * remote slot_num) + (remote_port)
my $remote_port = $seg % 256;
$c_port{"$port.1"} = $remote_port;
}
@@ -247,19 +197,20 @@ sub c_port {
}
sub c_platform {
my $bay = shift;
my $bay = shift;
my $bay_topo_port = $bay->bay_topo_port();
my $bay_topo_platform = $bay->bay_topo_platform();
my %c_platform;
foreach my $entry ( keys %$bay_topo_platform ) {
my $port = $bay_topo_port->{$entry} || 0;
foreach my $entry (keys %$bay_topo_platform){
my $port = $bay_topo_port->{$entry};
next if $port == 0;
# For fake remotes (multiple IPs for a c_ip), use first found
next if defined $c_platform{"$port.1"};
my $platform = $bay_topo_platform->{$entry};
my $platform = $bay_topo_platform->{$entry};
$c_platform{"$port.1"} = $platform;
}
@@ -267,57 +218,68 @@ sub c_platform {
return \%c_platform;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network BayStack Switches
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
This module is Deprecated. Please use Layer2::BayStack instead.
SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network Switches
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bay device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
Inherits from
my $bay = new SNMP::Info::Layer2::Bay(...);
SNMP::Info::Layer2
=head2 Inherited Classes
Required MIBs:
SYNOPTICS-ROOT-MIB
S5-ETH-MULTISEG-TOPOLOGY-MIB
MIBS listed in SNMP::Info::Layer2
Bay MIBs can be found on the CD that came with your product.
Or, if you still have a service contract they can be downloaded at
www.nortelnetworks.com
They have also been seen at : http://www.inotech.com/mibs/vendor/baynetworks/synoptics/synoptics.asp
Or http://www.oidview.com/mibs/detail.html under Synoptics.
You will need at least the two listed above, and probably a few more.
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $bay = new SNMP::Info::Layer2::Bay(DestHost => 'mybayswitch' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::Layer2
=item new SNMP::Info::Layer2::Bay()
=back
Arguments passed to new() are passed on to SNMP::Session::new()
=head2 Required MIBs
=over
=item F<SYNOPTICS-ROOT-MIB>
=item F<S5-ETH-MULTISEG-TOPOLOGY-MIB>
=item Inherited classes
MIBs required by L<SNMP::Info::Layer2/"Required MIBs"> and its superclasses.
my $bay = new SNMP::Info::Layer2::Bay(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $bay;
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $bay->vendor()
@@ -326,46 +288,27 @@ Returns 'bay' :)
=item $bay->model()
Cross references $bay->id() to the F<SYNOPTICS-MIB> and returns
Cross references $bay->id() to the SYNOPTICS-MIB and returns
the results. 303s and 304s have the same ID, so we have a hack
to return depending on which it is.
Removes C<sreg-> from the model name
=item $baystack->os()
Returns 'bay'.
=item $bay->os_ver()
Returns the os version extracted from C<sysDescr>.
=item $bay->os_bin()
Returns the firmware version extracted from C<sysDescr>.
Removes sreg- from the model name
=item $bay->cdp_id()
Returns the IP that the device is sending out for its Nmm topology info.
(C<s5EnMsTopIpAddr>)
(B<s5EnMsTopIpAddr>)
=item $bay->cdp_run()
Returns if the F<S5-ETH-MULTISEG-TOPOLOGY> info is on for this device.
Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
(C<s5EnMsTopStatus>)
(B<s5EnMsTopStatus>)
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -375,17 +318,17 @@ to a hash.
Returns reference to map of IIDs to physical ports.
Currently simply returns the C<ifIndex>
Currently simply returns the B<ifIndex>
=item $bay->i_ignore()
Returns reference to hash of IIDs to ignore.
Simply calls the SNMP::Info::Layer2::i_ignore() for this.
Simply calls the SNMP::Info::Layer2::i_ignore() fn for this.
=item $bay->i_mac()
Returns the C<ifPhysAddress> table entries.
Returns the B<ifPhysAddress> table entries.
Removes all entries matching '00:00:00:00:00:00' -- Certain
older revisions of Bay 303 and 304 firmware report all zeros
@@ -393,7 +336,7 @@ for each port mac.
=back
=head2 Pseudo CDP information
=head2 Psuedo CDP information
All entries with port=0 are local and ignored.
@@ -401,31 +344,21 @@ All entries with port=0 are local and ignored.
=item $bay->c_if()
Returns reference to hash. Key: port.1 Value: port (iid)
Returns referenece to hash. Key: port.1 Value: port (iid)
=item $bay->c_ip()
Returns reference to hash. Key: port.1
Returns referenece to hash. Key: port.1
The value of each hash entry can either be a scalar or an array.
A scalar value is most likely a direct neighbor to that port.
It is possible that there is a non-bay device in between this device and the
remote device.
It is possible that there is a non-bay device in between this device and the remote device.
An array value represents a list of seen devices. The only time you will get
an array of neighbors, is if there is a non-bay device in between two or more
devices.
An array value represents a list of seen devices. The only time you will get an array
of nieghbors, is if there is a non-bay device in between two or more devices.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $bay->c_port()
Returns reference to hash. Key: IID, Value: Remote port (interfaces)
=item $bay->c_platform()
Returns reference to hash. Key: IID, Value: Remote device type
=item $bay->port()
Returns reference to hash. Key: port.1 Value: port
@@ -436,7 +369,7 @@ Returns reference to hash. Key: port.1 Value: Remote Device Type
=back
=head2 Layer2 Topology info (C<s5EnMsTopNmmTable>)
=head2 Layer2 Topology info (s5EnMsTopNmmTable)
=over
@@ -444,29 +377,28 @@ Returns reference to hash. Key: port.1 Value: Remote Device Type
Returns reference to hash. Key: Table entry, Value:slot number
(C<s5EnMsTopNmmSlot>)
(B<s5EnMsTopNmmSlot>)
=item $bay->bay_topo_port()
Returns reference to hash. Key: Table entry, Value:Port Number
(interface iid)
Returns reference to hash. Key: Table entry, Value:Port Number (interface iid)
(C<s5EnMsTopNmmPort>)
(B<s5EnMsTopNmmPort>)
=item $bay->bay_topo_ip()
Returns reference to hash. Key: Table entry, Value:Remote IP address of entry
(C<s5EnMsTopNmmIpAddr>)
(B<s5EnMsTopNmmIpAddr>)
=item $bay->bay_topo_seg()
Returns reference to hash. Key: Table entry, Value:Remote Segment ID
(C<s5EnMsTopNmmSegId>)
(B<s5EnMsTopNmmSegId>)
=item $bay->bay_topo_mac
(C<s5EnMsTopNmmMacAddr>)
(B<s5EnMsTopNmmMacAddr>)
Returns reference to hash. Key: Table entry, Value:Remote MAC address
@@ -474,19 +406,14 @@ Returns reference to hash. Key: Table entry, Value:Remote MAC address
Returns reference to hash. Key: Table entry, Value:Remote Device Type
(C<s5EnMsTopNmmChassisType>)
(B<s5EnMsTopNmmChassisType>)
=item $bay->bay_topo_localseg
Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg()
is local
Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg() is local
(C<s5EnMsTopNmmLocalSeg>)
(B<s5EnMsTopNmmLocalSeg>)
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,769 +0,0 @@
# SNMP::Info::Layer2::Baystack
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Baystack;
use strict;
use Exporter;
use SNMP::Info::SONMP;
use SNMP::Info::NortelStack;
use SNMP::Info::RapidCity;
use SNMP::Info::LLDP;
use SNMP::Info::Layer3;
@SNMP::Info::Layer2::Baystack::ISA
= qw/SNMP::Info::SONMP SNMP::Info::NortelStack
SNMP::Info::RapidCity SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer2::Baystack::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::LLDP::MIBS,
%SNMP::Info::RapidCity::MIBS, %SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::RapidCity::GLOBALS, %SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::LLDP::FUNCS,
%SNMP::Info::RapidCity::FUNCS, %SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::SONMP::FUNCS,
);
# 450's report full duplex as speed = 20mbps?!
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
$SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps';
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
%SNMP::Info::RapidCity::MUNGE, %SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
sub os {
my $baystack = shift;
my $descr = $baystack->description();
my $model = $baystack->model();
if ( ( defined $descr and $descr =~ /Business Ethernet Switch.*SW:v/i ) )
{
return 'bes';
}
if (
(
(defined $model and $model =~ /(420|425|BPS)/ )
and
(defined $descr and $descr =~ m/SW:v[1-2]/i )
)
or
(
(defined $model and $model =~ /(410|450|380)/ )
)
)
{
return 'baystack';
}
return 'boss';
}
sub os_bin {
my $baystack = shift;
my $descr = $baystack->description();
return unless defined $descr;
# 303 / 304
if ( $descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/ ) {
return $1;
}
# 450
if ( $descr =~ m/FW:V(\d+\.\d+)/ ) {
return $1;
}
if ( $descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i ) {
return $1;
}
return;
}
sub vendor {
return 'nortel';
}
sub model {
my $baystack = shift;
my $id = $baystack->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
my $descr = $baystack->description();
return '303' if ( defined $descr and $descr =~ /\D303\D/ );
return '304' if ( defined $descr and $descr =~ /\D304\D/ );
return 'BPS' if ( $model =~ /BPS2000/i );
return $2
if ( $model
=~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)-?(\d+)/ );
return $model;
}
sub interfaces {
my $baystack = shift;
my $partial = shift;
my $i_index = $baystack->i_index($partial) || {};
my $index_factor = $baystack->index_factor();
my $slot_offset = $baystack->slot_offset();
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
# Ignore cascade ports
next if $index > 513;
my $port = ( $index % $index_factor );
my $slot = ( int( $index / $index_factor ) ) + $slot_offset;
my $slotport = "$slot.$port";
$if{$iid} = $slotport;
}
return \%if;
}
sub i_mac {
my $baystack = shift;
my $partial = shift;
my $i_mac = $baystack->orig_i_mac($partial) || {};
my %i_mac;
# Baystack 303's with a hw rev < 2.11.4.5 report the mac as all zeros
foreach my $iid ( keys %$i_mac ) {
my $mac = $i_mac->{$iid};
next unless defined $mac;
next if $mac eq '00:00:00:00:00:00';
$i_mac{$iid} = $mac;
}
return \%i_mac;
}
sub i_name {
my $baystack = shift;
my $partial = shift;
my $i_index = $baystack->i_index($partial) || {};
my $i_alias = $baystack->i_alias($partial) || {};
my $i_name2 = $baystack->orig_i_name($partial) || {};
my %i_name;
foreach my $iid ( keys %$i_name2 ) {
my $name = $i_name2->{$iid};
my $alias = $i_alias->{$iid};
$i_name{$iid}
= ( defined $alias and $alias !~ /^\s*$/ )
? $alias
: $name;
}
return \%i_name;
}
sub index_factor {
my $baystack = shift;
my $model = $baystack->model();
my $os = $baystack->os();
my $os_ver = $baystack->os_ver();
my $op_mode = $baystack->ns_op_mode();
$op_mode = 'pure' unless defined $op_mode;
if ( $os_ver =~ m/^(\d+)\./ ) {
$os_ver = $1;
} else {
$os_ver = 1;
}
my $index_factor = 32;
$index_factor = 64
if ( ( defined $model and $model =~ /(470)/ )
or ( $os =~ m/(boss|bes)/ ) and ( $op_mode eq 'pure' ) );
$index_factor = 128
if ( ( defined $model and $model =~ /(5[56]\d\d)/ )
and ( $os_ver >= 6 ) );
return $index_factor;
}
# Use SONMP and/or LLDP
sub hasCDP {
my $baystack = shift;
return $baystack->hasLLDP() || $baystack->SUPER::hasCDP();
}
sub c_ip {
my $baystack = shift;
my $partial = shift;
my $cdp = $baystack->SUPER::c_ip($partial) || {};
my $lldp = $baystack->lldp_ip($partial) || {};
my %c_ip;
foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
return \%c_ip;
}
sub c_if {
my $baystack = shift;
my $partial = shift;
my $lldp = $baystack->lldp_if($partial) || {};
my $cdp = $baystack->SUPER::c_if($partial) || {};
my %c_if;
foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
return \%c_if;
}
sub c_port {
my $baystack = shift;
my $partial = shift;
my $lldp = $baystack->lldp_port($partial) || {};
my $cdp = $baystack->SUPER::c_port($partial) || {};
my %c_port;
foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
return \%c_port;
}
sub c_id {
my $baystack = shift;
my $partial = shift;
my $lldp = $baystack->lldp_id($partial) || {};
my $cdp = $baystack->SUPER::c_id($partial) || {};
my %c_id;
foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
return \%c_id;
}
sub c_platform {
my $baystack = shift;
my $partial = shift;
my $lldp = $baystack->lldp_rem_sysdesc($partial) || {};
my $cdp = $baystack->SUPER::c_platform($partial) || {};
my %c_platform;
foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
return \%c_platform;
}
# Newer devices support ENTITY-MIB, use if available otherwise use proprietary
# methods.
sub e_index {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_index($partial) || $stack->ns_e_index($partial);
}
sub e_class {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_class($partial) || $stack->ns_e_class($partial);
}
sub e_descr {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_descr($partial) || $stack->ns_e_descr($partial);
}
sub e_name {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_name($partial) || $stack->ns_e_name($partial);
}
sub e_fwver {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_fwver($partial) || $stack->ns_e_fwver($partial);
}
sub e_hwver {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_hwver($partial) || $stack->ns_e_hwver($partial);
}
sub e_parent {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_parent($partial) || $stack->ns_e_parent($partial);
}
sub e_pos {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_pos($partial) || $stack->ns_e_pos($partial);
}
sub e_serial {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_serial($partial) || $stack->ns_e_serial($partial);
}
sub e_swver {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_swver($partial) || $stack->ns_e_swver($partial);
}
sub e_type {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_type($partial) || $stack->ns_e_type($partial);
}
sub e_vendor {
my $stack = shift;
my $partial = shift;
return $stack->SUPER::e_vendor($partial) || $stack->ns_e_vendor($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Baystack - SNMP Interface to Nortel Ethernet (Baystack)
Switches
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $baystack = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $baystack->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a Nortel
Ethernet Switch (Baystack) through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $baystack = new SNMP::Info::Layer2::Baystack(...);
=head2 Inherited Classes
=over
=item SNMP::Info::SONMP
=item SNMP::Info::NortelStack
=item SNMP::Info::RapidCity
=item SNMP::Info::LLDP
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=back
=head2 Inherited MIBs
See L<SNMP::Info::SONMP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::NortelStack/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::RapidCity/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $baystack->vendor()
Returns 'nortel'
=item $baystack->model()
Cross references $baystack->id() to the F<SYNOPTICS-MIB> and returns
the results. 303s and 304s have the same ID, so we have a hack
to return depending on which it is.
Returns BPS for Business Policy Switch
For others extracts and returns the switch numeric designation.
=item $baystack->os()
Returns 'baystack' or 'boss' depending on software version.
=item $baystack->os_bin()
Returns the firmware version extracted from C<sysDescr>.
=back
=head2 Overrides
=over
=item $baystack->index_factor()
Required by SNMP::Info::SONMP. Number representing the number of ports
reserved per slot within the device MIB.
Index factor on the Baystack switches are determined by the formula: Index
Factor = 64 if (model = 470 or (os eq 'boss' and operating in pure mode))
or else Index factor = 32.
Returns either 32 or 64 based upon the formula.
=back
=head2 Global Methods imported from SNMP::Info::SONMP
See L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::NortelStack
See L<SNMP::Info::NortelStack/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::RapidCity
See L<SNMP::Info::RapidCity/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer3
See L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $baystack->interfaces()
Returns reference to the map between IID and physical Port.
Slot and port numbers on the Baystack switches are determined by the
formula:
port = (Interface index % Index factor)
slot = (int(Interface index / Index factor)) + Slot offset
The physical port name is returned as slot.port.
=item $baystack->i_ignore()
Returns reference to hash of IIDs to ignore.
=item $baystack->i_mac()
Returns the C<ifPhysAddress> table entries.
Removes all entries matching '00:00:00:00:00:00' -- Certain
revisions of Baystack firmware report all zeros for each port mac.
=item $baystack->i_name()
Crosses C<ifName> with C<ifAlias> and returns the human set port name if
exists.
=back
=head2 F<ENTITY-MIB> Information
For older devices which do not support F<ENTITY-MIB>, these methods emulate
Physical Table methods using F<S5-CHASSIS-MIB>. See
L<SNMP::Info::NortelStack/"TABLE METHODS"> for details on ns_e_* methods.
=over
=item $baystack->e_index()
If the device doesn't support C<entPhysicalDescr>, this will try ns_e_index().
Note that this is based on C<entPhysicalDescr> due to implementation
details of SNMP::Info::Entity::e_index().
=item $baystack->e_class()
If the device doesn't support C<entPhysicalClass>, this will try ns_e_class().
=item $baystack->e_descr()
If the device doesn't support C<entPhysicalDescr>, this will try ns_e_descr().
=item $baystack->e_name()
If the device doesn't support C<entPhysicalName>, this will try ns_e_name().
=item $baystack->e_fwver()
If the device doesn't support C<entPhysicalFirmwareRev>, this will try
ns_e_fwver().
=item $baystack->e_hwver()
If the device doesn't support C<entPhysicalHardwareRev>, this will try
ns_e_hwver().
=item $baystack->e_parent()
If the device doesn't support C<entPhysicalContainedIn>, this will try
ns_e_parent().
=item $baystack->e_pos()
If the device doesn't support C<entPhysicalParentRelPos>, this will try
ns_e_pos().
=item $baystack->e_serial()
If the device doesn't support C<entPhysicalSerialNum>, this will try
ns_e_serial().
=item $baystack->e_swver()
If the device doesn't support C<entPhysicalSoftwareRev>, this will try
ns_e_swver().
=item $baystack->e_type()
If the device doesn't support C<entPhysicalVendorType>, this will try
ns_e_type().
=item $baystack->e_vendor()
If the device doesn't support C<entPhysicalMfgName>, this will try
ns_e_vendor().
=back
=head2 Topology information
Based upon the software version devices may support SynOptics Network
Management Protocol (SONMP) and Link Layer Discovery Protocol (LLDP). These
methods will query both and return the combination of all information. As a
result, there may be identical topology information returned from the two
protocols causing duplicate entries. It is the calling program's
responsibility to identify any duplicate entries and remove duplicates if
necessary.
=over
=item $baystack->hasCDP()
Returns true if the device is running either SONMP or LLDP.
=item $baystack->c_if()
Returns reference to hash. Key: iid Value: local device port (interfaces)
=item $baystack->c_ip()
Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different
IPv4 addresses, c_ip(), there is either a non-SONMP/LLDP device in between two or
more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $baystack->c_port()
Returns reference to hash. Key: iid Value: remote port (interfaces)
=item $baystack->c_id()
Returns reference to hash. Key: iid Value: string value used to identify the
chassis component associated with the remote system.
=item $baystack->c_platform()
Returns reference to hash. Key: iid Value: Remote Device Type
=back
=head2 Table Methods imported from SNMP::Info::SONMP
See L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::NortelStack
See L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::RapidCity
See L<SNMP::Info::RapidCity/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer3
See L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,459 +1,238 @@
# SNMP::Info::Layer2::C1900
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C1900;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoConfig SNMP::Info::Layer2
Exporter/;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::C1900::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'c1900_flash_status' => 'upgradeFlashBankStatus',
);
%SNMP::Info::Layer2::GLOBALS
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
'i_type2' => 'ifType',
# ESSWITCH-MIB
'c1900_p_index' => 'swPortIndex',
'c1900_p_ifindex' => 'swPortIfIndex',
'c1900_p_duplex' => 'swPortDuplexStatus',
'c1900_p_duplex_admin' => 'swPortFullDuplex',
'c1900_p_name' => 'swPortName',
'c1900_p_up_admin' => 'swPortAdminStatus',
'c1900_p_type' => 'swPortMediaCapability',
'c1900_p_media' => 'swPortConnectorType',
);
# ESSWITCH-MIB
'c1900_p_index' => 'swPortIndex',
'c1900_p_ifindex' => 'swPortIfIndex',
'c1900_p_duplex' => 'swPortDuplexStatus',
'c1900_p_duplex_admin' => 'swPortFullDuplex',
'c1900_p_name' => 'swPortName',
'c1900_p_up_admin' => 'swPortAdminStatus',
'c1900_p_type' => 'swPortMediaCapability',
'c1900_p_media' => 'swPortConnectorType',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
# Also known as the ESSWITCH-MIB
'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000'
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
# Also known as the ESSWITCH-MIB
'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000'
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
);
sub bulkwalk_no { return 1; }
sub cisco_comm_indexing { return 1; }
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
);
sub vendor {
return 'cisco';
}
sub os {
return 'catalyst';
}
sub os_ver {
my $c1900 = shift;
# Check for superclass one
my $os_ver = $c1900->SUPER::os_ver();
return $os_ver if defined $os_ver;
my $c1900_flash_status = $c1900->c1900_flash_status();
return unless defined $c1900_flash_status;
if ( $c1900_flash_status =~ m/V(\d+\.\d+(\.\d+)?)/ ) {
return $1;
}
return;
}
sub interfaces {
my $c1900 = shift;
my $partial = shift;
my $i_descr = $c1900->i_description($partial) || {};
foreach my $iid ( keys %$i_descr ) {
$i_descr->{$iid} =~ s/\s*$//;
}
return $i_descr;
}
sub i_duplex {
my $c1900 = shift;
my $partial = shift;
my $c1900 = shift;
my $interfaces = $c1900->interfaces();
my $c1900_p_index = $c1900->c1900_p_index();
my $c1900_p_duplex = $c1900->c1900_p_duplex();
my $c1900_p_duplex = $c1900->c1900_p_duplex($partial) || {};
my %reverse_1900 = reverse %$c1900_p_index;
my %i_duplex;
foreach my $if ( keys %$c1900_p_duplex ) {
my $duplex = $c1900_p_duplex->{$if};
next unless defined $duplex;
foreach my $if (keys %$interfaces){
my $port_1900 = $reverse_1900{$if};
next unless defined $port_1900;
my $duplex = $c1900_p_duplex->{$port_1900};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if} = $duplex;
$i_duplex{$if}=$duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $c1900 = shift;
my $partial = shift;
my $c1900 = shift;
my $interfaces = $c1900->interfaces();
my $c1900_p_index = $c1900->c1900_p_index();
my $c1900_p_admin = $c1900->c1900_p_duplex_admin();
my $c1900_p_admin = $c1900->c1900_p_duplex_admin($partial) || {};
my %reverse_1900 = reverse %$c1900_p_index;
my %i_duplex_admin;
foreach my $if ( keys %$c1900_p_admin ) {
my $duplex = $c1900_p_admin->{$if};
next unless defined $duplex;
foreach my $if (keys %$interfaces){
my $port_1900 = $reverse_1900{$if};
next unless defined $port_1900;
my $duplex = $c1900_p_admin->{$port_1900};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /disabled/i;
$duplex = 'full' if $duplex =~ /flow control/i;
$duplex = 'full' if $duplex =~ /enabled/i;
$duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex_admin{$if} = $duplex;
$i_duplex_admin{$if}=$duplex;
}
return \%i_duplex_admin;
}
sub i_name {
my $c1900 = shift;
my $partial = shift;
my $i_name = $c1900->orig_i_name($partial) || {};
my $c1900_p_name = $c1900->c1900_p_name($partial) || {};
foreach my $port ( keys %$c1900_p_name ) {
my $name = $c1900_p_name->{$port};
next unless defined $name;
next unless $name !~ /^\s*$/;
$i_name->{$port} = $name;
}
return $i_name;
}
sub set_i_duplex_admin {
sub i_type {
my $c1900 = shift;
my ( $duplex, $port ) = @_;
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/full 1 half 2 auto 3/;
my $i_type = $c1900->i_type2();
my $c1900_p_index = $c1900->c1900_p_index();
my $c1900_p_type = $c1900->c1900_p_type();
my $c1900_p_media = $c1900->c1900_p_media();
my $iid = $c1900->c1900_p_ifindex($port);
foreach my $p_iid (keys %$c1900_p_index){
my $port = $c1900_p_index->{$p_iid};
my $type = $c1900_p_type->{$p_iid};
my $media = $c1900_p_media->{$p_iid};
$duplex = lc($duplex);
next unless defined $port;
next unless defined $type;
next unless defined $media;
return 0 unless defined $duplexes{$duplex};
return $c1900->set_c1900_p_duplex_admin( $duplexes{$duplex}, $iid );
}
sub i_vlan {
my $c1900 = shift;
my $partial = shift;
# Overlap allows more than one VLAN per port. Unable to determine default
my $overlap = $c1900->bridgeGroupAllowMembershipOverlap()
|| $c1900->vlanAllowMembershipOverlap()
|| 'disabled';
if ( $overlap eq 'enabled' ) {
return;
$i_type->{$port} = "$type $media";
}
my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup()
|| $c1900->vlanMemberPortOfVlan();
my $i_pvid = {};
foreach my $idx ( keys %$member_of ) {
my @values = split( /\./, $idx );
my ( $vlan, $port ) = @values;
next unless $vlan;
next unless $port;
next if ( defined $partial and $port !~ /^$partial$/ );
my $value = $member_of->{$idx};
next if ( $value eq 'false' );
$i_pvid->{$port} = $vlan;
}
return $i_pvid;
return $i_type;
}
sub i_vlan_membership {
my $c1900 = shift;
my $partial = shift;
my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup()
|| $c1900->vlanMemberPortOfVlan();
my $i_vlan_membership = {};
foreach my $idx ( keys %$member_of ) {
my @values = split( /\./, $idx );
my ( $vlan, $port ) = @values;
next unless $vlan;
next unless $port;
next if ( defined $partial and $port !~ /^$partial$/ );
my $value = $member_of->{$idx};
next if ( $value eq 'false' );
push( @{ $i_vlan_membership->{$port} }, $vlan );
}
return $i_vlan_membership;
}
sub bp_index {
my $c1900 = shift;
my $partial = shift;
my $if_index = $c1900->i_index($partial);
my $index = $c1900->orig_bp_index($partial) || {};
foreach my $iid ( keys %$if_index ) {
$index->{$iid} = $iid if(!defined $index->{$iid});
}
return $index;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::C1900 - SNMP Interface to data from Cisco Catalyst 1900
Network Switches running CatOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c1900 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $c1900->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
SNMP::Info::Layer2::C1900 - SNMP Interface to old C1900 Network Switches
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Catalyst 1900 device through SNMP. See SNMP::Info for full documentation
Provides abstraction to the configuration information obtainable from a
C1900 device through SNMP. See inherited classes' documentation for
inherited methods.
Note that most of these devices only talk SNMP version 1, but not all.
Inherits from:
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
SNMP::Info::Layer2
my $c1900 = new SNMP::Info::Layer2::C1900(...);
Required MIBs:
=head2 Inherited classes
=over
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoConfig
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)>
F<ESSWITCH-MIB> is included in the Version 1 MIBs from Cisco.
STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)
MIBs listed in SNMP::Info::Layer2
ESSWITCH-MIB is included in the Version 1 MIBS from Cisco.
They can be found at ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $c1900 = new SNMP::Info::Layer2::C1900(DestHost => 'mycat1900' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item new SNMP::Info::Layer2::C1900()
Arguments passed to new() are passed on to SNMP::Session::new()
my $c1900 = new SNMP::Info::Layer2::C1900(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $c1900;
=back
=head2 Inherited MIBs
See L<SNMP::Info::CDP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::CiscoConfig/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $c1900->c1900_flash_status()
Usually contains the version of the software loaded in flash.
Used by os_ver()
C<STAND-ALONE-ETHERNET-SWITCH-MIB::upgradeFlashBankStatus>
=item $c1900->os()
Returns 'catalyst'
=item $c1900->os_ver()
Returns CatOS version if obtainable. First tries to use
SNMP::Info::CiscoStats->os_ver() . If that fails then it
checks for the presence of $c1900->c1900_flash_status() and culls
the version from there.
=item $c1900->vendor()
Returns 'cisco' :)
=back
=head2 Overrides
=over
=item $c1900->cisco_comm_indexing()
Returns 1. Use vlan indexing.
=item $c1900->bulkwalk_no
Return C<1>. Bulkwalk is turned off for this class.
=back
=head2 Globals imported from SNMP::Info::CDP
See L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoConfig
See L<SNMP::Info::CiscoConfig/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
=over
=item $c1900->interfaces()
Returns reference to the map between IID and physical Port.
=item $c1900->i_duplex()
Returns reference to map of IIDs to current link duplex
Crosses $c1900->c1900_p_index() with $c1900->c1900_p_duplex;
=item $c1900->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting
=item $c1900->i_name()
Crosses $c1900->c1900_p_index() with $c1900->c1900_p_duplex_admin;
Crosses C<ifName> with $c1900->c1900_p_name() and returns the human set port
name if exists.
=item $c1900->i_type()
=item $c1900->i_vlan()
Returns reference to hash of IID to port type
Returns a mapping between the interface and the VLAN / bridge group if overlap
is not enabled.
Takes the default ifType and overrides it with
=item $c1900->i_vlan_membership()
Returns reference to hash of arrays: key = interface, value = array of VLAN /
bridge group IDs.
Example:
my $interfaces = $c1900->interfaces();
my $vlans = $c1900->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";
}
=item $c1900->bp_index()
Returns a bp_index that contains the original bp_index entries and extra
entries for those interfaces listed in if_index, as some C1900 devices do not
return complete bp_indexes.
c1900_p_type() and c1900_p_media() if they exist.
=back
=head2 F<STAND-ALONE-ETHERNET-SWITCH-MIB> Switch Port Table Entries:
=head2 STAND-ALONE-ETHERNET-SWITCH-MIB Switch Port Table Entries:
=over
@@ -461,80 +240,43 @@ return complete bp_indexes.
Maps the Switch Port Table to the IID
C<swPortIfIndex>
B<swPortIfIndex>
=item $c1900->c1900_p_duplex()
Gives Port Duplex Info
(C<swPortDuplexStatus>)
B<swPortDuplexStatus>
=item $c1900->c1900_p_duplex_admin()
Gives admin setting for Duplex Info
(C<swPortFullDuplex>)
B<swPortFullDuplex>
=item $c1900->c1900_p_name()
Gives human set name for port
(C<swPortName>)
B<swPortName>
=item $c1900->c1900_p_up_admin()
Gives Admin status of port enabled.
(C<swPortAdminStatus>)
B<swPortAdminStatus>
=item $c1900->c1900_p_type()
Gives Type of port, i.e. C<"general-ethernet">
Gives Type of port, ie. "general-ethernet"
(C<swPortMediaCapability>)
B<swPortMediaCapability>
=item $c1900->c1900_p_media()
Gives the media of the port , i.e. "C<fiber-sc>"
Gives the media of the port , ie "fiber-sc"
(C<swPortConnectorType>)
=back
=head2 Table Methods imported from SNMP::Info::CDP
See L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoConfig
See L<SNMP::Info::CiscoConfig/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over
=item $c1900->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port C<ifIndex>. Speed
choices are 'auto', 'half', 'full'.
Example:
my %if_map = reverse %{$c1900->interfaces()};
$c1900->set_i_duplex_admin('auto', $if_map{'1'})
or die "Couldn't change port duplex. ",$c1900->error(1);
B<swPortConnectorType>
=back

View File

@@ -1,324 +1,192 @@
# SNMP::Info::Layer2::C2900
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C2900;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoConfig
SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::C2900::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
);
%SNMP::Info::Layer2::GLOBALS
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
'i_name' => 'ifAlias',
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
# C2900PortEntry
'c2900_p_index' => 'c2900PortIfIndex',
'c2900_p_duplex' => 'c2900PortDuplexStatus',
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
);
# C2900PortEntry
'c2900_p_index' => 'c2900PortIfIndex',
'c2900_p_duplex' => 'c2900PortDuplexStatus',
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'CISCO-C2900-MIB' => 'ciscoC2900MIB'
);
%MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS, 'CISCO-C2900-MIB' => 'ciscoC2900MIB',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
);
sub vendor {
return 'cisco';
}
sub cisco_comm_indexing {
return 1;
}
sub i_duplex {
my $c2900 = shift;
my $partial = shift;
my $interfaces = $c2900->interfaces($partial);
my $c2900_p_index = $c2900->c2900_p_index() || {};
my $c2900 = shift;
my $interfaces = $c2900->interfaces();
my $c2900_p_index = $c2900->c2900_p_index();
my $c2900_p_duplex = $c2900->c2900_p_duplex();
my %reverse_2900 = reverse %$c2900_p_index;
my %i_duplex;
foreach my $if ( keys %$interfaces ) {
foreach my $if (keys %$interfaces){
my $port_2900 = $reverse_2900{$if};
next unless defined $port_2900;
my $duplex = $c2900_p_duplex->{$port_2900};
next unless defined $duplex;
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if} = $duplex;
$i_duplex{$if}=$duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $c2900 = shift;
my $partial = shift;
my $interfaces = $c2900->interfaces($partial);
my $c2900_p_index = $c2900->c2900_p_index() || {};
my $c2900 = shift;
my $interfaces = $c2900->interfaces();
my $c2900_p_index = $c2900->c2900_p_index();
my $c2900_p_admin = $c2900->c2900_p_duplex_admin();
my %reverse_2900 = reverse %$c2900_p_index;
my %i_duplex_admin;
foreach my $if ( keys %$interfaces ) {
foreach my $if (keys %$interfaces){
my $port_2900 = $reverse_2900{$if};
next unless defined $port_2900;
my $duplex = $c2900_p_admin->{$port_2900};
next unless defined $duplex;
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex_admin{$if} = $duplex;
$i_duplex_admin{$if}=$duplex;
}
return \%i_duplex_admin;
}
sub set_i_speed_admin {
my $c2900 = shift;
my ( $speed, $iid ) = @_;
# map speeds to those the switch will understand
my %speeds = qw/auto 1 10 10000000 100 100000000/;
my $c2900_p_index = $c2900->c2900_p_index() || {};
my %reverse_2900 = reverse %$c2900_p_index;
$speed = lc($speed);
return unless defined $speeds{$speed};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_speed_admin( $speeds{$speed}, $iid );
}
sub set_i_duplex_admin {
my $c2900 = shift;
my ( $duplex, $iid ) = @_;
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/full 1 half 2 auto 3/;
my $c2900_p_index = $c2900->c2900_p_index() || {};
my %reverse_2900 = reverse %$c2900_p_index;
$duplex = lc($duplex);
return unless defined $duplexes{$duplex};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_duplex_admin( $duplexes{$duplex}, $iid );
}
# Use i_descritption for port key, cuz i_name can be manually entered.
sub interfaces {
my $c2900 = shift;
my $partial = shift;
my $interfaces = $c2900->i_index($partial) || {};
my $i_descr = $c2900->i_description($partial) || {};
my $c2900 = shift;
my $interfaces = $c2900->i_index();
my $i_descr = $c2900->i_description();
my %if;
foreach my $iid ( keys %$interfaces ) {
foreach my $iid (keys %$interfaces){
my $port = $i_descr->{$iid};
next unless defined $port;
$port =~ s/\./\//g if ( $port =~ /\d+\.\d+$/ );
$port =~ s/\./\//g if( $port =~ /\d+\.\d+$/);
$port =~ s/[^\d\/,()\w]+//gi;
$if{$iid} = $port;
}
return \%if;
return \%if
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Switches
running IOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c2900 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c2900->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Network Switches
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
C2900 device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
MIBS: CISCO-C2900-MIB
my $c2900 = new SNMP::Info::Layer2::C2900(...);
Inherits all SNMP::Info::Layer2 methods.
=head2 Inherited Classes
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $c2900 = new SNMP::Info::Layer2::C2900(DestHost => 'mycat2900' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::CiscoVTP
=item new SNMP::Info::Layer2::C2900()
=item SNMP::Info::CDP
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoConfig
=item SNMP::Info::Layer2
my $c2900 = new SNMP::Info::Layer2::C2900(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $c2900;
=back
=head2 Required MIBs
=over
=item F<CISCO-C2900-MIB>
Part of the v2 MIBs from Cisco.
=back
=head2 Inherited MIBs
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::CiscoConfig/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $c2900->vendor()
Returns 'cisco' :)
=item $c2900->cisco_comm_indexing()
Returns 1. Use vlan indexing.
Returns 'cisco' :)
=back
=head2 Globals imported from SNMP::Info::CiscoVTP
See L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoConfig
See L<SNMP::Info::CiscoConfig/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -326,118 +194,61 @@ to a hash.
=item $c2900->interfaces()
Returns reference to the map between IID and physical Port.
Returns reference to the map between IID and physical Port.
On the 2900 devices i_name isn't reliable, so we override to just the
description.
On the 2900 devices i_name isn't reliable, so we override to just the description.
Next all dots are changed for forward slashes so that the physical port name
is the same as the broad-casted CDP port name.
(Ethernet0.1 -> Ethernet0/1)
Next all dots are changed for forward slashes so that the physical port name
is the same as the broadcasted CDP port name.
(Ethernet0.1 -> Ethernet0/1)
Also, any weird characters are removed, as I saw a few pop up.
Also, any weird characters are removed, as I saw a few pop up.
=item $c2900->i_duplex()
Returns reference to map of IIDs to current link duplex
Returns reference to map of IIDs to current link duplex
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex()
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex;
=item $c2900->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin;
=back
=head2 F<C2900-MIB> Port Entry Table
=head2 C2900-MIB Port Entry Table
=over
=item $c2900->c2900_p_index()
Maps the Switch Port Table to the IID
Maps the Switch Port Table to the IID
(C<c2900PortIfIndex>)
B<c2900PortIfIndex>
=item $c2900->c2900_p_duplex()
Gives Port Duplex Info
Gives Port Duplex Info
(C<c2900PortDuplexStatus>)
B<c2900PortDuplexStatus>
=item $c2900->c2900_p_duplex_admin()
Gives admin setting for Duplex Info
Gives admin setting for Duplex Info
B<c2900PortDuplexState>
(C<c2900PortDuplexState>)
=item $c2900->c2900_p_speed_admin()
Gives Admin speed of port
Gives Admin speed of port
(C<c2900PortAdminSpeed>)
=back
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoConfig
See L<SNMP::Info::CiscoConfig/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over
=item $c2900->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port C<ifIndex>
Speed choices are 'auto', '10', '100'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_speed_admin() to utilize
port C<ifIndex>.
Example:
my %if_map = reverse %{$c2900->interfaces()};
$c2900->set_i_speed_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port speed. ",$c2900->error(1);
=item $c2900->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port C<ifIndex>
Speed choices are 'auto', 'half', 'full'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin() to utilize
port C<ifIndex>.
Example:
my %if_map = reverse %{$c2900->interfaces()};
$c2900->set_i_duplex_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port duplex. ",$c2900->error(1);
B<c2900PortAdminSpeed>
=back
=cut

View File

@@ -1,82 +1,142 @@
# SNMP::Info::Layer2::Catalyst
# $Id$
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Catalyst;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::CiscoStack;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Catalyst::ISA
= qw/SNMP::Info::CiscoStack SNMP::Info::CiscoVTP
SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoPortSecurity
SNMP::Info::Layer2 Exporter/;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT
%MYGLOBALS %MYMIBS %MYFUNCS %MYMUNGE %MUNGE $INIT/ ;
@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$DEBUG=0;
$VERSION = '2.06';
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoStack::MIBS,
);
%MYMIBS = (
'CISCO-STACK-MIB' => 'moduleType',
'CISCO-VTP-MIB' => 'vtpVlanIndex'
);
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%MYMIBS );
%MYGLOBALS = (
# these are in CISCO-STACK-MIB
'sysip' => 'sysIpAddr',
'netmask' => 'sysNetMask',
'broadcast' => 'sysBroadcast',
'serial' => 'chassisSerialNumberString',
'model' => 'chassisModel',
'ps1_type' => 'chassisPs1Type',
'ps1_status' => 'chassisPs1Status',
'ps2_type' => 'chassisPs2Type',
'ps2_status' => 'chassisPs2Status',
'slots' => 'chassisNumSlots',
'fan' => 'chassisFanStatus'
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
);
%SNMP::Info::Layer2::GLOBALS,
%MYGLOBALS
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS, %SNMP::Info::CiscoStack::FUNCS,
);
%MYFUNCS = (
'i_type2' => 'ifType',
# CISCO-STACK-MIB::moduleEntry
# These are blades in a catalyst device
'm_type' => 'moduleType',
'm_model' => 'moduleModel',
'm_serial' => 'moduleSerialNumber',
'm_status' => 'moduleStatus',
'm_name' => 'moduleName',
'm_ports' => 'moduleNumPorts',
'm_ports_status' => 'modulePortStatus',
'm_hwver' => 'moduleHwVersion',
'm_fwver' => 'moduleFwVersion',
'm_swver' => 'moduleSwVersion',
# Router Blades :
'm_ip' => 'moduleIPAddress',
'm_sub1' => 'moduleSubType',
'm_sub2' => 'moduleSubType2',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
# CISCO-VTP-MIB::VtpVlanEntry
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%MYFUNCS
);
%MYMUNGE = (
'm_ports_status' => \&munge_port_status,
'p_duplex_admin' => \&SNMP::Info::munge_bits,
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE, %SNMP::Info::CiscoStack::MUNGE,
);
# Inherit all the built in munging
%SNMP::Info::Layer2::MUNGE,
%MYMUNGE
);
%PORTSTAT = (1 => 'other',
2 => 'ok',
3 => 'minorFault',
4 => 'majorFault');
# Changes binary byte describing each port into ascii, and returns
# an ascii list separated by spaces.
sub munge_port_status {
my $status = shift;
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
return join(' ',@vals);
}
# Overidden Methods
@@ -87,88 +147,107 @@ sub i_physical {
my $p_port = $cat->p_port();
my %i_physical;
foreach my $port ( keys %$p_port ) {
foreach my $port (keys %$p_port) {
my $iid = $p_port->{$port};
$i_physical{$iid} = 1;
$i_physical{$iid} = 1;
}
return \%i_physical;
}
sub vendor {
return 'cisco';
}
sub i_type {
my $cat = shift;
sub os {
return 'catalyst';
}
my $p_port = $cat->p_port();
my $p_type = $cat->p_type();
sub os_ver {
my $cat = shift;
my $os_ver = $cat->SUPER::os_ver();
return $os_ver if defined $os_ver;
# Get more generic port types from IF-MIB
my $i_type = $cat->i_type2();
my $m_swver = $cat->m_swver();
return unless defined $m_swver;
# assume .1 entry is the chassis and the sw version we want.
return $m_swver->{1} if defined $m_swver->{1};
return;
}
# Workaround for incomplete bp_index
sub bp_index {
my $cat = shift;
my $p_index = $cat->p_port();
my $b_index = $cat->p_oidx();
my %bp_index;
foreach my $iid ( keys %$p_index ) {
my $ifidx = $p_index->{$iid};
next unless defined $ifidx;
my $bpidx = $b_index->{$iid} || 0;
$bp_index{$bpidx} = $ifidx;
# Now Override w/ port entries
foreach my $port (keys %$p_type) {
my $iid = $p_port->{$port};
$i_type->{$iid} = $p_type->{$port};
}
return \%bp_index;
return $i_type;
}
sub cisco_comm_indexing {
return 1;
# p_* functions are indexed to physical port. let's index these
# to snmp iid
sub i_name {
my $cat = shift;
my $p_port = $cat->p_port();
my $p_name = $cat->p_name();
my %i_name;
foreach my $port (keys %$p_name) {
my $iid = $p_port->{$port};
next unless defined $iid;
$i_name{$iid} = $p_name->{$port};
}
return \%i_name;
}
sub i_duplex {
my $cat = shift;
my $p_port = $cat->p_port();
my $p_duplex = $cat->p_duplex();
my %i_duplex;
foreach my $port (keys %$p_duplex) {
my $iid = $p_port->{$port};
$i_duplex{$iid} = $p_duplex->{$port};
}
return \%i_duplex;
}
sub i_duplex_admin {
my $cat = shift;
my $p_port = $cat->p_port();
my $p_duplex_admin = $cat->p_duplex_admin();
my %i_duplex_admin;
foreach my $port (keys %$p_duplex_admin) {
my $iid = $p_port->{$port};
next unless defined $iid;
my $duplex = $p_duplex_admin->{$port};
next unless defined $duplex;
my $string = 'other';
# see CISCO-STACK-MIB for a description of the bits
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
# we'll call it auto if both full and half are turned on, or if the
# specifically 'auto' flag bit is set.
$string = 'auto'
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
$i_duplex_admin{$iid} = $string;
}
return \%i_duplex_admin;
}
# $cat->interfaces() - Maps the ifIndex table to a physical port
sub interfaces {
my $cat = shift;
my $partial = shift;
my $i_index = $cat->i_index($partial);
my $portnames = $cat->p_port() || {};
my %portmap = reverse %$portnames;
my $self = shift;
my $interfaces = $self->i_index();
my $portnames = $self->p_port();
my %portmap = reverse %$portnames;
my %interfaces = ();
foreach my $iid ( keys %$i_index ) {
next unless defined $iid;
my $if = $i_index->{$iid};
my $port = $portmap{$iid};
$interfaces{$iid} = $port || $if;
foreach my $iid (keys %$interfaces) {
my $if = $interfaces->{$iid};
$interfaces{$if} = $portmap{$iid};
}
return \%interfaces;
}
sub i_name {
my $cat = shift;
my $partial = shift;
my $p_port = $cat->p_port() || {};
my $p_name = $cat->p_name() || {};
my %i_name;
foreach my $port ( keys %$p_name ) {
my $iid = $p_port->{$port};
next unless defined $iid;
next if ( defined $partial and $iid !~ /^$partial$/ );
$i_name{$iid} = $p_name->{$port};
}
return \%i_name;
sub vendor {
return 'cisco';
}
1;
@@ -176,146 +255,83 @@ __END__
=head1 NAME
SNMP::Info::Layer2::Catalyst - SNMP Interface to Cisco Catalyst devices
running Catalyst OS.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $cat = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $cat->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco devices running Catalyst OS
=head1 DESCRIPTION
SNMP::Info subclass to provide information for Cisco Catalyst series switches
running CatOS.
Provides abstraction to the configuration information obtainable from a
Catalyst device through SNMP. Information is stored in a number of
MIB's such as IF-MIB, CISCO-CDP-MIB, CISCO-STACK-MIB, CISCO-VTP-MIB,
and SWITCH-MIB.
This class includes the Catalyst 2920, 4000, 5000, 6000 (hybrid mode)
families.
=head1 AUTHOR
This subclass is not for all devices that have the name Catalyst. Note that
some Catalyst switches run IOS, like the 2900 and 3550 families. Cisco
Catalyst 1900 switches use their own MIB and have a separate subclass. Use
the method above to have SNMP::Info determine the appropriate subclass before
using this class directly.
Max Baker (C<max@warped.org>)
See SNMP::Info::device_type() for specifics.
=head1 SYNOPSIS
Note: Some older Catalyst switches will only talk SNMP version 1. Some
newer ones will not return all their data if connected via Version 1.
my $cat = new SNMP::Info::Layer2::Catalyst(DestHost => 'router' ,
Community => 'public' );
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $cat = new SNMP::Info::Layer2::Catalyst(...);
=head2 Inherited Classes
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::CiscoStack
=item new SNMP::Info::Layer2::Catalyst()
=item SNMP::Info::CiscoVTP
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoPortSecurity
=item SNMP::Info::Layer2
my $cat = new SNMP::Info::Layer2::Catalyst(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $cat;
=back
=head2 Required MIBs
=head1 GLOBAL Values
=over
=item Inherited Classes' MIBs
=item $cat->netmask()
(B<sysNetMask>)
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.
=item $cat->broadcast()
(B<sysBroadcast>)
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
=item $cat->serial()
(B<chassisSerialNumberString>)
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
=item $cat->model()
(B<chassisModel>)
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
=item $cat->ps1_type()
(B<chassisPs1Type>)
See L<SNMP::Info::CiscoPortSecurity/"Required MIBs"> for its own MIB
requirements.
=item $cat->ps2_type()
(B<chassisPs2Type>)
See L<SNMP::Info::Layer2/"Required MIBs"> for its own MIB requirements.
=item $cat->ps1_status()
(B<chassisPs1Status>)
=back
=item $cat->ps2_status()
(B<chassisPs2Status>)
These MIBs are found in the standard v2 MIBs from Cisco.
=item $cat->slots()
(B<chassisNumSlots>)
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $cat->os()
Returns 'catalyst'
=item $cat->os_ver()
Tries to use the value from SNMP::Info::CiscoStats->os_ver() and if it fails
it grabs $cat->m_swver()->{1} and uses that.
=item $cat->fan()
(B<chassisFanStatus>)
=item $cat->vendor()
Returns 'cisco'
=item $cat->cisco_comm_indexing()
Returns 1. Use vlan indexing.
Returns 'cisco'
=back
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in L<SNMP::Info::CiscoStack/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -323,52 +339,161 @@ to a hash.
=item $cat->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port
name.
=item $cat->i_name()
Returns reference to hash of iid to human set name.
C<portName>
Crosses p_port() with i_index() to get physical names.
=item $cat->i_physical()
Returns a map to IID for ports that are physical ports, not vlans, etc.
Returns a map to IID for ports that are physical ports, not vlans, etc.
=item $cat->bp_index()
=item $cat->i_type()
Returns reference to hash of bridge port table entries map back to interface
identifier (iid)
Crosses p_port() with p_type() and returns the results.
Crosses (C<portCrossIndex>) to (C<portIfIndex>) since some devices seem to
have problems with F<BRIDGE-MIB>
Overrides with ifType if p_type() isn't available.
=item $cat->i_name()
Crosses p_name with p_port and returns results.
=item $cat->i_duplex()
Crosses p_duplex with p_port and returns results.
=item $cat->i_duplex_admin()
Crosses p_duplex_admin with p_port.
Munges bit_string returned from p_duplex_admin to get duplex settings.
=back
=head2 Table Methods imported from SNMP::Info::CiscoStack
=head2 Module table
See documentation in L<SNMP::Info::CiscoStack/"TABLE METHODS"> for details.
This table holds configuration information for each of the blades installed in
the Catalyst device.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
=over
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=item $cat->m_type()
(B<moduleType>)
=head2 Table Methods imported from SNMP::Info::CDP
=item $cat->m_model()
(B<moduleModel>)
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=item $cat->m_serial()
(B<moduleSerialNumber>)
=head2 Table Methods imported from SNMP::Info::CiscoStats
=item $cat->m_status()
(B<moduleStatus>)
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=item $cat->m_name()
(B<moduleName>)
=head2 Table Methods imported from SNMP::Info::CiscoPortSecurity
=item $cat->m_ports()
(B<moduleNumPorts>)
See documentation in L<SNMP::Info::CiscoPortSecurity/"TABLE METHODS"> for
details.
=item $cat->m_ports_status()
Returns a list of space separated status strings for the ports.
To see the status of port 4 :
@ports_status = split(' ', $cat->m_ports_status() );
$port4 = $ports_status[3];
=head2 Table Methods imported from SNMP::Info::Layer2
(B<modulePortStatus>)
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=item $cat->m_ports_hwver()
(B<moduleHwVersion>)
=item $cat->m_ports_fwver()
(B<moduleFwVersion>)
=item $cat->m_ports_swver()
(B<moduleSwVersion>)
=item $cat->m_ports_ip()
(B<moduleIPAddress>)
=item $cat->m_ports_sub1()
(B<moduleSubType>)
=item $cat->m_ports_sub2()
(B<moduleSubType2>)
=back
=head2 Modules - Router Blades
=over
=item $cat->m_ip()
(B<moduleIPAddress>)
=item $cat->m_sub1()
(B<moduleSubType>)
=item $cat->m_sub2()
(B<moduleSubType2>)
=back
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
=over
=item $cat->p_name()
(B<portName>)
=item $cat->p_type()
(B<portType>)
=item $cat->p_status()
(B<portOperStatus>)
=item $cat->p_status2()
(B<portAdditionalStatus>)
=item $cat->p_speed()
(B<portAdminSpeed>)
=item $cat->p_duplex()
(B<portDuplex>)
=item $cat->p_port()
(B<portIfIndex>)
=back
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
=over
=item $cat->p_speed_admin()
(B<portCpbSpeed>)
=item $cat->p_duplex_admin()
(B<portCpbDuplex>)
=back
=head2 VLAN Entry Table
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
for a good treaty of how to connect to the VLANs
=over
=item $cat->v_state()
(B<vtpVlanState>)
=item $cat->v_type()
(B<vtpVlanType>)
=item $cat->v_name()
(B<vtpVlanName>)
=item $cat->v_mtu()
(B<vtpVlanMtu>)
=back
=cut

View File

@@ -1,521 +0,0 @@
# SNMP::Info::Layer2::Centillion
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Centillion;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::NortelStack;
use SNMP::Info::SONMP;
@SNMP::Info::Layer2::Centillion::ISA
= qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/;
@SNMP::Info::Layer2::Centillion::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS,
'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable',
'S5-COMMON-STATS-MIB' => 's5CmStat',
'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt',
'CENTILLION-CONFIG-MIB' => 'sysTFTPStart',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
'tftp_action' => 'sysTFTPStart',
'tftp_host' => 'sysTFTPIpAddress',
'tftp_file' => 'sysTFTPFileName',
'tftp_type' => 'sysTFTPFileType',
'tftp_result' => 'sysTFTPResult',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::SONMP::FUNCS,
# CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable
'centillion_p_index' => 'cnDot3ExtnIfIndex',
'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType',
'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType',
# S5-COMMON-STATS-MIB::s5CmSNodeTable
'fw_mac' => 's5CmSNodeMacAddr',
'fw_port' => 's5CmSNodeIfIndx',
# CENTILLION-VLAN-MIB::cnVlanPortMemberTable
'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex',
'centillion_i_vlan' => 'cnVlanPortMemberVID',
'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
sub os {
return 'centillion';
}
sub vendor {
return 'nortel';
}
sub i_ignore {
my $centillion = shift;
my $descr = $centillion->i_description();
my %i_ignore;
foreach my $if ( keys %$descr ) {
my $type = $descr->{$if};
# Skip virtual interfaces
$i_ignore{$if}++ if $type =~ /(VE|VID|vc|lp)/i;
}
return \%i_ignore;
}
sub interfaces {
my $centillion = shift;
my $i_index = $centillion->i_index();
my $i_descr = $centillion->i_description();
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
my $descr = $i_descr->{$iid};
# Skip ATM and virtual interfaces
next if $descr =~ /(VE|VID|vc|lp)/i;
# Index numbers are deterministic slot * 256 + port
my $port = $index % 256;
my $slot = int( $index / 256 );
my $slotport = "$slot.$port";
$slotport = "$descr" if $descr =~ /(mcp)/i;
$if{$index} = $slotport;
}
return \%if;
}
sub i_duplex {
my $centillion = shift;
my $port_index = $centillion->centillion_p_index();
my $port_duplex = $centillion->centillion_p_duplex();
my %i_duplex;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
my $duplex = $port_duplex->{$iid};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$index} = $duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $centillion = shift;
my $port_index = $centillion->centillion_p_index();
my $port_admin = $centillion->centillion_p_duplex_admin();
my %i_duplex_admin;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
my $duplex = $port_admin->{$iid};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex_admin{$index} = $duplex;
}
return \%i_duplex_admin;
}
sub i_vlan {
my $centillion = shift;
my $cn_vlan_index = $centillion->centillion_i_vlan_index();
my $cn_vlan = $centillion->centillion_i_vlan();
my %i_vlan;
foreach my $iid ( keys %$cn_vlan_index ) {
my $index = $cn_vlan_index->{$iid};
next unless defined $index;
my $vlan = $cn_vlan->{$iid};
next unless defined $vlan;
$i_vlan{$index} = $vlan;
}
return \%i_vlan;
}
sub model {
my $centillion = shift;
my $id = $centillion->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^sreg-//i;
return '5000BH' if ( $model =~ /5000BH/ );
return '5005BH' if ( $model =~ /5005BH/ );
return 'C100' if ( $model =~ /Centillion100/ );
return 'C50N' if ( $model =~ /Centillion50N/ );
return 'C50T' if ( $model =~ /Centillion50T/ );
return $model;
}
sub bp_index {
my $centillion = shift;
my $index = $centillion->fw_port();
my %bp_index;
foreach my $iid ( keys %$index ) {
my $b_index = $index->{$iid};
next unless defined $b_index;
#Index value is the same as ifIndex
$bp_index{$b_index} = $b_index;
}
return \%bp_index;
}
sub index_factor {
return 256;
}
sub slot_offset {
return 0;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Centillion - SNMP Interface to Nortel Centillion based
ATM Switches
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $centillion = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $centillion->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Centillion device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $centillion = new SNMP::Info::Layer2::centillion(...);
Note: This class supports version 4.X and 5.X which are VLAN based rather
than bridge group based.
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::NortelStack
=item SNMP::Info::SONMP
=back
=head2 Required MIBs
=over
=item F<CENTILLION-DOT3-EXTENSIONS-MIB>
=item F<S5-COMMON-STATS-MIB>
=item F<CENTILLION-VLAN-MIB>
=item F<CENTILLION-CONFIG-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::NortelStack/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::SONMP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $centillion->vendor()
Returns 'Nortel'
=item $centillion->model()
Cross references $centillion->id() to the F<SYNOPTICS-MIB> and returns
the results.
Removes C<sreg-> from the model name
=item $centillion->os()
Returns 'Centillion'
=item $centillion->tftp_action()
(C<sysTFTPStart>)
=item $centillion->tftp_host()
(C<sysTFTPIpAddress>)
=item $centillion->tftp_file()
(C<sysTFTPFileName>)
=item $centillion->tftp_type()
(C<sysTFTPFileType>)
=item $centillion->tftp_result()
(C<sysTFTPResult>)
=back
=head2 Overrides
=over
=item $centillion->layers()
Returns 00000011. Class emulates Layer 2 functionality through proprietary
MIBs.
=item $centillion->index_factor()
Required by SNMP::Info::SONMP. Number representing the number of ports
reserved per slot within the device MIB. Returns 256.
=item $centillion->slot_offset()
Required by SNMP::Info::SONMP. Offset if slot numbering does not
start at 0. Returns 0.
=back
=head2 Globals imported from SNMP::Info
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::NortelStack
See documentation in L<SNMP::Info::NortelStack/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $centillion->interfaces()
Returns reference to the map between IID and physical Port.
Slot and port numbers on the Passport switches are determined by the
formula:
port = index % 256
slot = int(index / 256)
The physical port name is returned as slot.port.
=item $centillion->i_duplex()
Returns reference to map of IIDs to current link duplex
=item $centillion->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting
=item $centillion->i_ignore()
Returns reference to hash of IIDs to ignore.
=item $centillion->fw_mac()
(C<s5CmSNodeMacAddr>)
=item $centillion->fw_port()
(C<s5CmSNodeIfIndx>)
=item $centillion->bp_index()
Returns a mapping between C<ifIndex> and the Bridge Table.
=item $centillion->i_vlan()
Returns a mapping between C<ifIndex> and the VLAN.
=back
=head2 Centillion 802.3 Extension Table (C<cnDot3ExtnTable>)
=over
=item $centillion->centillion_p_index()
Returns reference to hash. Maps table IIDs to Interface IIDs
(C<cnDot3ExtnIfIndex>)
=item $centillion->centillion_p_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs
(C<cnDot3ExtnIfOperConnectionType>)
=item $centillion->rc_centillion_p_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs
(C<cnDot3ExtnIfAdminConnectionType>)
=back
=head2 Centillion VLAN Table (C<cnVlanPortMemberTable>)
=over
=item $centillion->centillion_i_vlan_index()
Returns reference to hash. Key: Table entry, Value: Index
(C<cnVlanPortMemberIfIndex>)
=item $centillion->centillion_i_vlan()
Returns reference to hash. Key: Table entry, Value: VLAN ID
(C<cnVlanPortMemberVID>)
=item $centillion->centillion_i_vlan_type()
Returns reference to hash. Key: Table entry, Value: VLAN Type
(C<cnVlanPortMemberIngressType>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::NortelStack
See documentation in L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,242 +0,0 @@
# SNMP::Info::Layer2::Cisco
# $Id$
#
# Copyright (c) 2008 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Cisco;
use strict;
use Exporter;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoImage;
use SNMP::Info::CiscoRTT;
use SNMP::Info::CiscoQOS;
use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoImage
SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS
SNMP::Info::CiscoConfig SNMP::Info::Layer2
Exporter/;
@SNMP::Info::Layer2::Cisco::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoQOS::MIBS, %SNMP::Info::CiscoRTT::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::CiscoVTP::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoQOS::GLOBALS, %SNMP::Info::CiscoRTT::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoQOS::FUNCS, %SNMP::Info::CiscoRTT::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoQOS::MUNGE, %SNMP::Info::CiscoRTT::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
);
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Cisco - SNMP Interface to L3 and L2+L3 IOS Cisco Device
that are not covered in other classes.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $cisco = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $cisco->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Cisco Routers running IOS
=head2 Inherited Classes
=over
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
=item SNMP::Info::CiscoRTT
=item SNMP::Info::CiscoQOS
=item SNMP::Info::CiscoConfig
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoRTT/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoQOS/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoConfig/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Layer2/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $cisco->vendor()
Returns 'cisco'
=back
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoRTT
See documentation in L<SNMP::Info::CiscoRTT/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoQOS
See documentation in L<SNMP::Info::CiscoQOS/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoRTT
See documentation in L<SNMP::Info::CiscoRTT/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoQOS
See documentation in L<SNMP::Info::CiscoQOS/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,349 +0,0 @@
# SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry Switches
# $Id$
#
# Copyright (c) 2008 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Foundry;
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::FDP;
use SNMP::Info::EtherLike;
use SNMP::Info::MAU;
@SNMP::Info::Layer2::Foundry::ISA
= qw/SNMP::Info::Layer2 SNMP::Info::FDP SNMP::Info::EtherLike
SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer2::Foundry::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::FDP::MIBS,
%SNMP::Info::EtherLike::MIBS, %SNMP::Info::MAU::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::FDP::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS, %SNMP::Info::MAU::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::FDP::FUNCS,
%SNMP::Info::EtherLike::FUNCS, %SNMP::Info::MAU::FUNCS,
'test' => 'dot1dStpPortState',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::FDP::MUNGE,
%SNMP::Info::EtherLike::MUNGE, %SNMP::Info::MAU::MUNGE,
);
# Method OverRides
#sub bulkwalk_no { 1;}
*SNMP::Info::Layer2::Foundry::i_duplex = \&SNMP::Info::MAU::mau_i_duplex;
*SNMP::Info::Layer2::Foundry::i_duplex_admin
= \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer2::Foundry::i_vlan = \&SNMP::Info::Bridge::qb_i_vlan_t;
# todo doc these
sub os_ver {
my $foundry = shift;
my $e_name = $foundry->e_name();
# find entity table entry for "stackmanaget.1"
my $unit_iid = undef;
foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'stackmanaget.1';
}
# Default to OID method if no dice.
unless ( defined $unit_iid ) {
return $foundry->SUPER::model();
}
# Find Model Name
my $e_fwver = $foundry->e_fwver();
if ( defined $e_fwver->{$unit_iid} ) {
return $e_fwver->{$unit_iid};
}
# Not found in ENTITY-MIB, go up a level.
return $foundry->SUPER::os_ver();
}
sub model {
my $foundry = shift;
my $e_name = $foundry->e_name();
# find entity table entry for "unit.1"
my $unit_iid = undef;
foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1';
}
# Default to OID method if no dice.
unless ( defined $unit_iid ) {
return $foundry->SUPER::model();
}
# Find Model Name
my $e_model = $foundry->e_model();
if ( defined $e_model->{$unit_iid} ) {
return $e_model->{$unit_iid};
}
# Not found in ENTITY-MIB, go up a level.
return $foundry->SUPER::model();
}
sub serial {
my $foundry = shift;
my $e_name = $foundry->e_name();
# find entity table entry for "unit.1"
my $unit_iid = undef;
foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1';
}
return unless defined $unit_iid;
# Look up serial of found entry.
my $e_serial = $foundry->e_serial();
return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid};
return $foundry->SUPER::serial();
}
sub interfaces {
my $foundry = shift;
my $i_descr = $foundry->i_description;
my $i_name = $foundry->i_name;
# use ifName only if it is in portn
# format. For EdgeIrons
# else use ifDescr
foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid};
next unless defined $name;
$i_descr->{$iid} = $name
if $name =~ /^port\d+/i;
}
return $i_descr;
}
sub i_ignore {
my $foundry = shift;
my $i_type = $foundry->i_type();
my %i_ignore = ();
foreach my $iid ( keys %$i_type ) {
my $type = $i_type->{$iid} || '';
$i_ignore{$iid}++
# 33 is the console port
if $type =~ /(loopback|propvirtual|other|cpu|33)/i;
}
return \%i_ignore;
}
sub os {
return 'foundry';
}
sub vendor {
return 'foundry';
}
# this hangs on a edgeiron24g
# TODO: check by devicetype and deferr to SUPER if not bad device
sub stp_p_state { return; }
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry FastIron Network
Devices
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
This module is Deprecated. Please use Layer3::Foundry instead.
# Let SNMP::Info determine the correct subclass for you.
my $foundry = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $foundry->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
This module is Deprecated. Please use Layer3::Foundry instead.
This module provides support for Foundry EdgeIron Switches
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::FDP
=back
=head2 Required MIBs
=over
=item F<FOUNDRY-SN-ROOT-MIB>
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $foundry->model()
Returns model type.
=item $foundry->vendor()
Returns 'foundry'
=item $foundry->os()
Returns 'foundry'
=item $foundry->os_ver()
Returns the software version
=item $foundry->serial()
Returns the serial number
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::FDP
See documentation in L<SNMP::Info::FDP/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $foundry->interfaces()
Returns reference to hash of interface names to iids.
=item $foundry->i_ignore()
Returns reference to hash of interfaces to be ignored.
Ignores interfaces with descriptions of tunnel,loopback,null
=item $foundry->i_duplex()
Returns reference to hash of interface link duplex status.
Crosses $foundry->sw_duplex() with $foundry->sw_index()
=item $foundry->i_duplex_admin()
Returns reference to hash of interface administrative duplex status.
=item $foundry->stp_p_state()
"The port's current state as defined by application of the Spanning Tree
Protocol.
Skipped if device is an EdgeIron 24G due to reports of hangs.
(C<dot1dStpPortState>)
=item $foundry->i_vlan()
Returns a mapping between C<ifIndex> and the PVID or default VLAN.
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::FDP
See documentation in L<SNMP::Info::FDP/"TABLE METHODS"> for details.
=cut

File diff suppressed because it is too large Load Diff

View File

@@ -1,721 +0,0 @@
# SNMP::Info::Layer2::HP4000 - SNMP Interface to older HP ProCurve Switches (1600, 2400, 2424M, 4000 and 8000)
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::HP4000;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::MAU;
use SNMP::Info::CDP;
@SNMP::Info::Layer2::HP4000::ISA
= qw/SNMP::Info::Layer3 SNMP::Info::MAU
SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::HP4000::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS,
%SNMP::Info::LLDP::MIBS,
%SNMP::Info::CDP::MIBS,
'RFC1271-MIB' => 'logDescription',
'HP-ICF-OID' => 'hpSwitch4000',
'HP-VLAN' => 'hpVlanMemberIndex',
'STATISTICS-MIB' => 'hpSwitchCpuStat',
'NETSWITCH-MIB' => 'hpMsgBufFree',
'CONFIG-MIB' => 'hpSwitchConfig',
'SEMI-MIB' => 'hpHttpMgSerialNumber',
'HP-ICF-CHASSIS' => 'hpicfSensorObjectId',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'serial1' => 'hpHttpMgSerialNumber.0',
'hp_cpu' => 'hpSwitchCpuStat.0',
'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
'mem_free' => 'hpGlobalMemFreeBytes.1',
'mem_used' => 'hpGlobalMemAllocBytes.1',
'os_version' => 'hpSwitchOsVersion.0',
'os_bin' => 'hpSwitchRomVersion.0',
'mac' => 'hpSwitchBaseMACAddress.0',
'hp_vlans' => 'hpVlanNumber',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS,
%SNMP::Info::CDP::FUNCS,
'bp_index2' => 'dot1dBasePortIfIndex',
'i_type2' => 'ifType',
# RFC1271
'l_descr' => 'logDescription',
# HP-VLAN-MIB
'hp_v_index' => 'hpVlanDot1QID',
'hp_v_name' => 'hpVlanIdentName',
'hp_v_state' => 'hpVlanIdentState',
'hp_v_type' => 'hpVlanIdentType',
'hp_v_status' => 'hpVlanIdentStatus',
'hp_v_mac' => 'hpVlanAddrPhysAddress',
'hp_v_if_index' => 'hpVlanMemberIndex',
'hp_v_if_tag' => 'hpVlanMemberTagged2',
# CONFIG-MIB::hpSwitchPortTable
'hp_duplex' => 'hpSwitchPortEtherMode',
'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
'vendor_i_type' => 'hpSwitchPortType',
# HP-ICF-CHASSIS
'hp_s_oid' => 'hpicfSensorObjectId',
'hp_s_name' => 'hpicfSensorDescr',
'hp_s_status' => 'hpicfSensorStatus',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::MAU::MUNGE,
%SNMP::Info::CDP::MUNGE
);
%MODEL_MAP = (
'J4093A' => '2424M',
'J4110A' => '8000M',
'J4120A' => '1600M',
'J4121A' => '4000M',
'J4122A' => '2400M',
'J4122B' => '2424M',
);
# Method Overrides
sub cpu {
my $hp = shift;
return $hp->hp_cpu();
}
sub mem_total {
my $hp = shift;
return $hp->hp_mem_total();
}
sub os {
return 'hp';
}
sub os_ver {
my $hp = shift;
my $os_version = $hp->os_version();
return $os_version if defined $os_version;
# Some older ones don't have this value,so we cull it from the description
my $descr = $hp->description();
if ( $descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/ ) {
return $1;
}
return;
}
# Lookup model number, and translate the part number to the common number
sub model {
my $hp = shift;
my $id = $hp->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^hpswitch//i;
return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model;
}
sub interfaces {
my $hp = shift;
my $interfaces = $hp->i_index();
my $i_descr = $hp->i_description();
my %if;
foreach my $iid ( keys %$interfaces ) {
my $descr = $i_descr->{$iid};
next unless defined $descr;
$if{$iid} = $descr if ( defined $descr and length $descr );
}
return \%if
}
sub i_name {
my $hp = shift;
my $i_alias = $hp->i_alias();
my $e_name = $hp->e_name();
my $e_port = $hp->e_port();
my %i_name;
foreach my $port ( keys %$e_name ) {
my $iid = $e_port->{$port};
next unless defined $iid;
my $alias = $i_alias->{$iid};
next unless defined $iid;
$i_name{$iid} = $e_name->{$port};
# Check for alias
$i_name{$iid} = $alias if ( defined $alias and length($alias) );
}
return \%i_name;
}
sub i_duplex {
my $hp = shift;
return $hp->mau_i_duplex();
}
sub i_duplex_admin {
my $hp = shift;
my $partial = shift;
# Try HP MIB first
my $hp_duplex = $hp->hp_duplex_admin($partial);
if ( defined $hp_duplex and scalar( keys %$hp_duplex ) ) {
my %i_duplex;
foreach my $if ( keys %$hp_duplex ) {
my $duplex = $hp_duplex->{$if};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex{$if} = $duplex;
}
return \%i_duplex;
}
else {
return $hp->mau_i_duplex_admin();
}
}
sub vendor {
return 'hp';
}
sub log {
my $hp = shift;
my $log = $hp->l_descr();
my $logstring = undef;
foreach my $val ( values %$log ) {
next if $val =~ /^Link\s+(Up|Down)/;
$logstring .= "$val\n";
}
return $logstring;
}
sub slots {
my $hp = shift;
my $e_name = $hp->e_name();
return unless defined $e_name;
my $slots;
foreach my $slot ( keys %$e_name ) {
$slots++ if $e_name->{$slot} =~ /slot/i;
}
return $slots;
}
sub fan {
my $hp = shift;
return &_sensor( $hp, 'fan' );
}
sub ps1_status {
my $hp = shift;
return &_sensor( $hp, 'power', '^power supply 1' )
|| &_sensor( $hp, 'power', '^power supply sensor' );
}
sub ps2_status {
my $hp = shift;
return &_sensor( $hp, 'power', '^power supply 2' )
|| &_sensor( $hp, 'power', '^redundant' );
}
sub _sensor {
my $hp = shift;
my $search_type = shift || 'fan';
my $search_name = shift || '';
my $hp_s_oid = $hp->hp_s_oid();
my $result;
foreach my $sensor ( keys %$hp_s_oid ) {
my $sensortype = &SNMP::translateObj( $hp_s_oid->{$sensor} );
if ( $sensortype =~ /$search_type/i ) {
my $sensorname = $hp->hp_s_name()->{$sensor};
my $sensorstatus = $hp->hp_s_status()->{$sensor};
if ( $sensorname =~ /$search_name/i ) {
$result = $sensorstatus;
}
}
}
return $result;
}
# Bridge MIB does not map Bridge Port to ifIndex correctly on older models, but Bridge Port equals ifIndex in these devices
sub bp_index {
my $hp = shift;
my $partial = shift;
my $if_index = $hp->i_index($partial);
my %mod_bp_index;
foreach my $iid ( keys %$if_index ) {
$mod_bp_index{$iid} = $iid;
}
return \%mod_bp_index;
}
# VLAN methods. Devices in this class use the proprietary HP-VLAN-MIB.
sub v_index {
my $hp = shift;
my $partial = shift;
return $hp->hp_v_index($partial);
}
sub v_name {
my $hp = shift;
my $partial = shift;
return $hp->hp_v_name($partial);
}
sub i_vlan {
my $hp = shift;
# the hpvlanmembertagged2 table has an entry in the form of
# vlan.interface = /untagged/no/tagged/auto
my $i_vlan = {};
my $hp_v_index = $hp->hp_v_index();
my $hp_v_if_tag = $hp->hp_v_if_tag();
foreach my $row ( keys %$hp_v_if_tag ) {
my ( $index, $if ) = split( /\./, $row );
my $tag = $hp_v_if_tag->{$row};
my $vlan = $hp_v_index->{$index};
next unless ( defined $tag and $tag =~ /untagged/ );
$i_vlan->{$if} = $vlan if defined $vlan;
}
return $i_vlan;
}
sub i_vlan_membership {
my $hp = shift;
my $i_vlan_membership = {};
my $hp_v_index = $hp->hp_v_index();
my $hp_v_if_tag = $hp->hp_v_if_tag();
foreach my $row ( keys %$hp_v_if_tag ) {
my ( $index, $if ) = split( /\./, $row );
my $tag = $hp_v_if_tag->{$row};
my $vlan = $hp_v_index->{$index};
next unless ( defined $tag );
next if ( $tag eq 'no' );
push( @{ $i_vlan_membership->{$if} }, $vlan );
}
return $i_vlan_membership;
}
sub set_i_vlan {
my $hp = shift;
my $rv;
my $hp_v_index = $hp->hp_v_index();
my $hp_v_if_tag = $hp->hp_v_if_tag();
if (defined $hp_v_index and scalar(keys %$hp_v_index)){
my $vlan = shift;
my $iid = shift;
my $old_untagged;
# Hash to lookup VLAN index of the VID (dot1q tag)
my %vl_trans = reverse %$hp_v_index;
# Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB
my $vlan_index = $vl_trans{$vlan};
if (defined $vlan_index) {
# First, loop through table to determine current untagged vlan for the port we're about to change
foreach my $row (keys %$hp_v_if_tag){
my ($index,$if) = split(/\./,$row);
if ($if == $iid and $hp_v_if_tag->{$row} =~ /untagged/) {
# Store the row information of the current untagged VLAN and temporarily set it to tagged
$old_untagged = $row;
$rv = $hp->set_hp_v_if_tag(1, $row);
last;
}
}
# Then set our port untagged in the desired VLAN
my $rv = $hp->set_hp_v_if_tag(2, "$vlan_index.$iid");
if (defined $rv) {
# If vlan change is successful, remove VLAN that used to be untagged from the port
if (defined $old_untagged) {
$rv = $hp->set_hp_v_if_tag(3, $old_untagged);
$hp->error_throw("Error removing previous untagged vlan from port, should never happen...\n") unless defined $rv;
}
} else {
# If vlan change was not succesful, try to revert to the old situation.
if (defined $old_untagged) {
$rv = $hp->set_hp_v_if_tag(2, $old_untagged) if defined $old_untagged;
if (defined $rv) {
$hp->error_throw("VLAN change failed, restored port to previous configuration.\n");
} else {
$hp->error_throw("VLAN change failed, unable to restore old configuration. Check device.\n");
}
}
}
} else {
$hp->error_throw("Requested VLAN (VLAN ID: $vlan) not available on device.\n");
}
} else {
$hp->error_throw("Error retrieving VLAN information from device.\n");
}
return $rv;
}
sub set_i_vlan_tagged {
my $hp = shift;
my $vlan = shift;
my $iid = shift;
my $rv;
my $hp_v_index = $hp->hp_v_index();
if (defined $hp_v_index and scalar(keys %$hp_v_index)){
# Hash to lookup VLAN index of the VID (dot1q tag)
my %vl_trans = reverse %$hp_v_index;
# Translate the VLAN identifier (tag) value to the index used by the HP-VLAN MIB
my $vlan_index = $vl_trans{$vlan};
if (defined $vlan_index) {
# Set our port tagged in the desired VLAN
$rv = $hp->set_hp_v_if_tag(1, "$vlan_index.$iid");
} else {
$hp->error_throw("Requested VLAN (VLAN ID: $vlan) not available on device.\n");
}
}
return $rv;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::HP4000 - SNMP Interface to older HP ProCurve Switches (1600, 2400, 2424M, 4000 and 8000)
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $hp = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $hp->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
HP ProCurve Switch via SNMP.
Note: Some HP Switches will connect via SNMP version 1, but a lot of config
data will not be available. Make sure you try and connect with Version 2
first, and then fail back to version 1.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $hp = new SNMP::Info::Layer2::HP4000(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::MAU
=back
=head2 Required MIBs
=over
=item F<RFC1271-MIB>
Included in V2 mibs from Cisco
=item F<HP-ICF-OID>
=item F<HP-VLAN>
(this MIB new with SNMP::Info 0.8)
=item F<STATISTICS-MIB>
=item F<NETSWITCH-MIB>
=item F<CONFIG-MIB>
=back
The last five MIBs listed are from HP and can be found at
L<http://www.hp.com/rnd/software> or
L<http://www.hp.com/rnd/software/MIBs.htm>
=head1 Change Log
Version 0.4 - Removed F<ENTITY-MIB> e_*() methods to separate sub-class -
SNMP::Info::Entity
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $hp->cpu()
Returns CPU Utilization in percentage.
=item $hp->log()
Returns all the log entries from the switch's log that are not Link up or
down messages.
=item $hp->mem_free()
Returns bytes of free memory
=item $hp->mem_total()
Return bytes of total memory
=item $hp->mem_used()
Returns bytes of used memory
=item $hp->model()
Returns the model number of the HP Switch. Will translate between the HP Part
number and the common model number with this map :
%MODEL_MAP = (
'J4093A' => '2424M',
'J4110A' => '8000M',
'J4120A' => '1600M',
'J4121A' => '4000M',
'J4122A' => '2400M',
'J4122B' => '2424M',
);
=item $hp->os()
Returns hp
=item $hp->os_bin()
C<hpSwitchRomVersion.0>
=item $hp->os_ver()
Tries to use os_version() and if that fails will try and cull the version from
the description field.
=item $hp->os_version()
C<hpSwitchOsVersion.0>
=item $hp->serial()
Returns serial number if available through SNMP
=item $hp->slots()
Returns number of entries in $hp->e_name that have 'slot' in them.
=item $hp->vendor()
hp
=item $hp->fan()
Returns fan status
=item $hp->ps1_status()
Power supply 1 status
=item $hp->ps2_status()
Power supply 2 status
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $hp->interfaces()
Uses $hp->i_description()
=item $hp->i_duplex()
Returns reference to map of IIDs to current link duplex.
=item $hp->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting.
=item $hp->vendor_i_type()
Returns reference to hash of IIDs to HP specific port type (hpSwitchPortType).
=item $hp->i_name()
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
=item $hp->i_vlan()
Returns a mapping between C<ifIndex> and the PVID (default VLAN) or untagged
port when using F<HP-VLAN>.
=item $hp->i_vlan_membership()
Returns reference to hash of arrays: key = C<ifIndex>, value = array of VLAN
IDs. These are the VLANs which are members of the egress list for the port.
It is the union of tagged, untagged, and auto ports.
Example:
my $interfaces = $hp->interfaces();
my $vlans = $hp->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";
}
=item $hp->v_index()
Returns VLAN IDs
=item $hp->v_name()
Returns VLAN names
=item $hp->bp_index()
Returns reference to hash of bridge port table entries map back to interface
identifier (iid)
Returns (C<ifIndex>) for both key and value for 1600, 2424, 4000, and 8000
models since they seem to have problems with F<BRIDGE-MIB>
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over
=item set_i_vlan()
=item set_i_vlan_tagged()
=cut

View File

@@ -1,209 +0,0 @@
# SNMP::Info::Layer2::HPVC - SNMP Interface to HP VirtualConnect Switches
#
# Copyright (c) 2011 Jeroen van Ingen
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::HPVC;
use strict;
use Exporter;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::HPVC::ISA
= qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::HPVC::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'HPVC-MIB' => 'vcDomainName',
'CPQSINFO-MIB' => 'cpqSiSysSerialNum',
'HPVCMODULE-MIB' => 'vcModuleDomainName',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
'serial1' => 'cpqSiSysSerialNum.0',
'os_ver' => 'cpqHoSWRunningVersion.1',
'os_bin' => 'cpqHoFwVerVersion.1',
'productname' => 'cpqSiProductName.0',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer2::MUNGE,
);
# Method Overrides
sub os {
return 'hpvc';
}
sub vendor {
return 'hp';
}
sub model {
my $hp = shift;
return $hp->productname();
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::HPVC - SNMP Interface to HP VirtualConnect Switches
=head1 AUTHOR
Jeroen van Ingen
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $hp = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $hp->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
HP VirtualConnect Switch via SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $hp = new SNMP::Info::Layer2::HPVC(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<HPVC-MIB>
=item F<CPQSINFO-MIB>
=item F<HPVCMODULE-MIB>
=back
All required MIBs can be found in the netdisco-mibs package.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $hp->os()
Returns hpvc
=item $hp->os_bin()
C<cpqHoFwVerVersion.1>
=item $hp->os_ver()
C<cpqHoSWRunningVersion.1>
=item $hp->serial()
C<cpqSiSysSerialNum.0>
=item $hp->vendor()
hp
=item $hp->model()
C<cpqSiProductName.0>
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head1 MUNGES
=over
=back
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=cut

View File

@@ -1,248 +0,0 @@
# SNMP::Info::Layer2::N2270
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::N2270;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
use SNMP::Info::Airespace;
@SNMP::Info::Layer2::N2270::ISA
= qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::Airespace Exporter/;
@SNMP::Info::Layer2::N2270::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::SONMP::MIBS, %SNMP::Info::Airespace::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::SONMP::GLOBALS, %SNMP::Info::Airespace::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::SONMP::FUNCS, %SNMP::Info::Airespace::FUNCS,
);
%MUNGE = (
%SNMP::Info::MUNGE, %SNMP::Info::Bridge::MUNGE,
%SNMP::Info::SONMP::MUNGE, %SNMP::Info::Airespace::MUNGE,
);
sub os {
return 'nortel';
}
sub vendor {
return 'nortel';
}
sub model {
my $n2270 = shift;
my $id = $n2270->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^sreg-WLANSecuritySwitch//i;
return $model;
}
sub index_factor {
return 256;
}
sub slot_offset {
return 0;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::N2270 - SNMP Interface to Nortel 2270 Series Wireless
Switch
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $n2270 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $n2270->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Nortel 2270 Series Wireless Switch through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $n2270 = new SNMP::Info::Layer2::N2270(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::SONMP
=item SNMP::Info::Airespace
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::SONMP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Airespace/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $n2270->vendor()
Returns 'nortel'
=item $n2270->os()
Returns 'nortel'
=item $n2270->model()
Cross references $bayhub->id() to the F<SYNOPTICS-ROOT-MIB> and returns
the results.
Removes C<sreg-WLANSecuritySwitch> from the model name
=back
=head2 Overrides
=over
=item $bayhub->index_factor()
Required by SNMP::Info::SONMP. Number representing the number of ports
reserved per slot within the device MIB. Returns 256.
=item $bayhub->slot_offset()
Required by SNMP::Info::SONMP. Offset if slot numbering does not
start at 0. Returns 0.
=back
=head2 Globals imported from SNMP::Info
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Airespace
See documentation in L<SNMP::Info::Airespace/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item None
=back
=head2 Table Methods imported from SNMP::Info
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Airespace
See documentation in L<SNMP::Info::Airespace/"TABLE METHODS"> for details.
=cut

View File

@@ -1,586 +0,0 @@
# SNMP::Info::Layer2::NAP222x
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::NAP222x;
use strict;
use Exporter;
use SNMP::Info::SONMP;
use SNMP::Info::IEEE802dot11;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::NAP222x::ISA
= qw/SNMP::Info::SONMP SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::NAP222x::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::IEEE802dot11::MIBS,
%SNMP::Info::SONMP::MIBS, 'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::IEEE802dot11::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
'nt_hw_ver' => 'ntWlanSwHardwareVer',
'nt_fw_ver' => 'ntWlanSwBootRomVer',
'nt_sw_ver' => 'ntWlanSwOpCodeVer',
'nt_cc' => 'ntWlanSwCountryCode',
'tftp_action' => 'ntWlanTransferStart',
'tftp_host' => 'ntWlanFileServer',
'tftp_file' => 'ntWlanDestFile',
'tftp_type' => 'ntWlanFileType',
'tftp_result' => 'ntWlanFileTransferStatus',
'tftp_xtype' => 'ntWlanTransferType',
'tftp_src_file' => 'ntWlanSrcFile',
'ftp_user' => 'ntWlanUserName',
'ftp_pass' => 'ntWlanPassword',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::IEEE802dot11::FUNCS,
%SNMP::Info::SONMP::FUNCS,
# From ntWlanPortTable
'nt_prt_name' => 'ntWlanPortName',
'nt_dpx_admin' => 'ntWlanPortCapabilities',
'nt_auto' => 'ntWlanPortAutonegotiation',
'nt_dpx' => 'ntWlanPortSpeedDpxStatus',
# From ntWlanDot11PhyOperationTable
'nt_i_broadcast' => 'ntWlanDot11ClosedSystem',
# From ntWlanApVlanTable
'nt_i_vlan' => 'ntWlanApVlanDefaultVid',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
sub os {
return 'nortel';
}
sub os_bin {
my $nap222x = shift;
my $bin = $nap222x->nt_fw_ver();
return unless defined $bin;
if ( $bin =~ m/(\d+\.\d+\.\d+)/ ) {
return $1;
}
return;
}
sub model {
my $nap222x = shift;
my $descr = $nap222x->description();
return unless defined $descr;
return 'AP-2220' if ( $descr =~ /2220/ );
return 'AP-2221' if ( $descr =~ /2221/ );
return;
}
sub mac {
my $nap222x = shift;
my $i_mac = $nap222x->i_mac();
# Return Interface MAC
foreach my $entry ( keys %$i_mac ) {
my $sn = $i_mac->{$entry};
next unless $sn;
return $sn;
}
return;
}
sub serial {
my $nap222x = shift;
my $i_mac = $nap222x->i_mac();
# Return Interface MAC
foreach my $entry ( keys %$i_mac ) {
my $sn = $i_mac->{$entry};
next unless $sn;
return $sn;
}
return;
}
sub interfaces {
my $nap222x = shift;
my $partial = shift;
my $interfaces = $nap222x->i_index($partial) || {};
my $description = $nap222x->i_description($partial) || {};
my %interfaces = ();
foreach my $iid ( keys %$interfaces ) {
my $desc = $description->{$iid};
next unless defined $desc;
next if $desc =~ /lo/i;
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_duplex {
my $nap222x = shift;
my $partial = shift;
my $mode = $nap222x->nt_dpx($partial) || {};
my $port_name = $nap222x->nt_prt_name($partial) || {};
my $interfaces = $nap222x->interfaces($partial) || {};
my %i_duplex;
foreach my $if ( keys %$interfaces ) {
my $port = $interfaces->{$if};
next unless $port =~ /dp/i;
foreach my $idx ( keys %$mode ) {
my $name = $port_name->{$idx} || 'unknown';
next unless $name eq $port;
my $duplex = $mode->{$idx};
$duplex = 'other' unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if} = $duplex;
}
}
return \%i_duplex;
}
sub i_duplex_admin {
my $nap222x = shift;
my $partial = shift;
my $dpx_admin = $nap222x->nt_dpx_admin($partial) || {};
my $nt_auto = $nap222x->nt_auto($partial) || {};
my $interfaces = $nap222x->interfaces($partial) || {};
my $port_name = $nap222x->nt_prt_name($partial) || {};
my %i_duplex_admin;
foreach my $if ( keys %$interfaces ) {
my $port = $interfaces->{$if};
next unless $port =~ /dp/i;
foreach my $idx ( keys %$dpx_admin ) {
my $name = $port_name->{$idx} || 'unknown';
next unless $name eq $port;
my $duplex = $dpx_admin->{$idx};
my $auto = $nt_auto->{$idx};
$duplex = 'other' unless defined $duplex;
$duplex = 'half'
if ( $duplex =~ /half/i and $auto =~ /disabled/i );
$duplex = 'full'
if ( $duplex =~ /full/i and $auto =~ /disabled/i );
$duplex = 'auto' if $auto =~ /enabled/i;
$i_duplex_admin{$if} = $duplex;
}
}
return \%i_duplex_admin;
}
sub i_name {
my $nap222x = shift;
my $partial = shift;
my $interfaces = $nap222x->interfaces($partial) || {};
my %i_name;
foreach my $if ( keys %$interfaces ) {
my $desc = $interfaces->{$if};
next unless defined $desc;
my $name = 'unknown';
$name = 'Ethernet Interface' if $desc =~ /dp/i;
$name = 'Wireless Interface B' if $desc =~ /ndc/i;
$name = 'Wireless Interface A' if $desc =~ /ar/i;
$i_name{$if} = $name;
}
return \%i_name;
}
# dot1dBasePortTable does not exist and dot1dTpFdbPort does not map to ifIndex
sub bp_index {
my $nap222x = shift;
my $partial = shift;
my $interfaces = $nap222x->interfaces($partial) || {};
my %bp_index;
foreach my $iid ( keys %$interfaces ) {
my $desc = $interfaces->{$iid};
next unless defined $desc;
next unless $desc =~ /(ndc|ar)/i;
my $port = 1;
$port = 2 if $desc =~ /ndc/i;
$bp_index{$port} = $iid;
}
return \%bp_index;
}
# Indicies don't match anywhere in these devices! Need to override to match
# IfIndex.
sub i_ssidlist {
my $nap222x = shift;
my $partial = shift;
# modify partial to match index
if ( defined $partial ) {
$partial = $partial - 2;
}
my $ssids = $nap222x->orig_i_ssidlist($partial) || {};
my %i_ssidlist;
foreach my $iid ( keys %$ssids ) {
my $port = $iid + 2;
my $ssid = $ssids->{$iid};
next unless defined $ssid;
$i_ssidlist{$port} = $ssid;
}
return \%i_ssidlist;
}
sub i_ssidbcast {
my $nap222x = shift;
my $partial = shift;
# modify partial to match index
if ( defined $partial ) {
$partial = $partial - 2;
}
my $bcast = $nap222x->nt_i_broadcast($partial) || {};
my %i_ssidbcast;
foreach my $iid ( keys %$bcast ) {
my $port = $iid + 2;
my $bc = $bcast->{$iid};
next unless defined $bc;
$i_ssidbcast{$port} = $bc;
}
return \%i_ssidbcast;
}
sub i_80211channel {
my $nap222x = shift;
my $partial = shift;
# modify partial to match index
if ( defined $partial ) {
$partial = $partial - 2;
}
my $phy_type = $nap222x->dot11_phy_type($partial) || {};
my $cur_freq = $nap222x->dot11_cur_freq() || {};
my $cur_ch = $nap222x->dot11_cur_ch() || {};
my %i_80211channel;
foreach my $iid ( keys %$phy_type ) {
my $port = $iid + 2;
my $type = $phy_type->{$iid};
next unless defined $type;
if ( $type =~ /dsss/ ) {
my $ch = $cur_ch->{1};
next unless defined $ch;
$i_80211channel{$port} = $ch;
}
elsif ( $type =~ /ofdm/ ) {
my $ch = $cur_freq->{0};
next unless defined $ch;
$i_80211channel{$port} = $ch;
}
else {
next;
}
}
return \%i_80211channel;
}
sub i_vlan {
my $nap222x = shift;
my $partial = shift;
# modify partial to match index
if ( defined $partial ) {
$partial = $partial - 2;
}
my $vlans = $nap222x->nt_i_vlan($partial) || {};
my %i_vlan;
foreach my $iid ( keys %$vlans ) {
my $port = $iid + 2;
my $vlan = $vlans->{$iid};
next unless defined $vlan;
$i_vlan{$port} = $vlan;
}
return \%i_vlan;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::NAP222x - SNMP Interface to Nortel 2220 Series Access
Points
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $nap222x = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $nap222x->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a Nortel
2220 series wireless Access Points through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $nap222x = new SNMP::Info::Layer2::NAP222x(...);
=head2 Inherited Classes
=over
=item SNMP::Info::SONMP
=item SNMP::Info::IEEE802dot11
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<NORTEL-WLAN-AP-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::SONMP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::IEEE802dot11/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $nap222x->model()
Returns the model extracted from C<sysDescr>.
=item $nap222x->os()
Returns 'nortel'
=item $nap222x->os_bin()
Returns the firmware version extracted from C<ntWlanSwBootRomVer>.
=item $nap222x->mac()
Returns the MAC address of the first Ethernet Interface.
=item $nap222x->serial()
Returns the MAC address of the first Ethernet Interface.
=item $nap222x->nt_hw_ver()
Returns the hardware version.
(C<ntWlanSwHardwareVer>)
=item $nap222x->nt_cc()
Returns the country code of the AP.
(C<ntWlanSwHardwareVer>)
=item $nap222x->tftp_action()
(C<ntWlanTransferStart>)
=item $nap222x->tftp_host()
(C<ntWlanFileServer>)
=item $nap222x->tftp_file()
(C<ntWlanDestFile>)
=item $nap222x->tftp_type()
(C<ntWlanFileType>)
=item $nap222x->tftp_result()
(C<ntWlanFileTransferStatus>)
=item $nap222x->tftp_xtype()
(C<ntWlanTransferType>)
=item $nap222x->tftp_src_file()
(C<ntWlanSrcFile>)
=item $nap222x->ftp_user()
(C<ntWlanUserName>)
=item $nap222x->ftp_pass()
(C<ntWlanPassword>)
=back
=head2 Globals imported from SNMP::Info::SONMP
See L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::IEEE802dot11
See L<SNMP::Info::IEEE802dot11/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $nap222x->interfaces()
Returns reference to map of IIDs to physical ports.
=item $nap222x->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs.
(C<ntWlanPortSpeedDpxStatus>)
=item $nap222x->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs.
(C<ntWlanPortCapabilities>)
=item $nap222x->i_name()
Returns a human name based upon port description.
=item $nap222x->bp_index()
Returns a mapping between C<ifIndex> and the Bridge Table. This does not
exist in the MIB and bridge port index is not the same as C<ifIndex> so it is
created.
=item $nap222x->i_ssidlist()
Returns reference to hash. SSID's recognized by the radio interface.
=item $nap222x->i_ssidbcast()
Returns reference to hash. Indicates whether the SSID is broadcast.
=item $nap222x->i_80211channel()
Returns reference to hash. Current operating frequency channel of the radio
interface.
=item $nap222x->i_vlan()
The default Vlan ID of the radio interfaces.
(C<ntWlanApVlanDefaultVid>)
=back
=head2 Table Methods imported from SNMP::Info::SONMP
See L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::IEEE802dot11
See L<SNMP::Info::IEEE802dot11/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,199 +0,0 @@
# SNMP::Info::Layer2::Netgear
# $Id$
#
# Copyright (c) 2008 Bill Fenner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Netgear;
use strict;
use Exporter;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Netgear::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Netgear::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( %SNMP::Info::Layer2::MIBS, );
%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, );
%FUNCS = ( %SNMP::Info::Layer2::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer2::MUNGE, );
sub vendor {
return 'netgear';
}
sub os {
return 'netgear';
}
# Wish the OID-based method worked, but netgear scatters
# the sysObjectID values across all the device MIBs, and
# makes the device MIBs state secrets.
# They seem to set sysDescr to the model number, though,
# so we'll use that.
sub model {
my $netgear = shift;
return $netgear->description();
}
#
# This is model-dependent. Some netgear brand devices don't implement
# the bridge MIB forwarding table, so we use the Q-BRIDGE-MIB forwarding
# table. Fall back to the orig functions if the qb versions don't
# return anything.
sub fw_mac {
my $netgear = shift;
my $ret = $netgear->qb_fw_mac();
$ret = $netgear->orig_fw_mac() if ( !defined($ret) );
return $ret;
}
sub fw_port {
my $netgear = shift;
my $ret = $netgear->qb_fw_port();
$ret = $netgear->orig_fw_port() if ( !defined($ret) );
return $ret;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Netgear - SNMP Interface to Netgear switches
=head1 AUTHOR
Bill Fenner and Zoltan Erszenyi
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $netgear = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $netgear->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Netgear device through SNMP. See inherited classes' documentation for
inherited methods.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
MIBs listed in L<SNMP::Info::Layer2/"Required MIBs"> and its inherited
classes.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $netgear->vendor()
Returns 'netgear'
=item $netgear->os()
Returns 'netgear'
=item $netgear->model()
Returns description()
=back
=head2 Global Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of
a reference to a hash.
=head2 Overrides
=over
=item $netgear->fw_mac()
Returns reference to hash of forwarding table MAC Addresses.
Some devices don't implement the C<BRIDGE-MIB> forwarding table, so we use
the C<Q-BRIDGE-MIB> forwarding table. Fall back to the C<BRIDGE-MIB> if
C<Q-BRIDGE-MIB> doesn't return anything.
=item $netgear->fw_port()
Returns reference to hash of forwarding table entries port interface
identifier (iid)
Some devices don't implement the C<BRIDGE-MIB> forwarding table, so we use
the C<Q-BRIDGE-MIB> forwarding table. Fall back to the C<BRIDGE-MIB> if
C<Q-BRIDGE-MIB> doesn't return anything.
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,312 +0,0 @@
# SNMP::Info::Layer2::Orinoco
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Orinoco;
use strict;
use Exporter;
use SNMP::Info::IEEE802dot11;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Orinoco::ISA
= qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::IEEE802dot11::MIBS,
#'ORiNOCO-MIB' => 'orinoco',
);
%GLOBALS
= ( %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS, );
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::IEEE802dot11::FUNCS,
# ORiNOCO-MIB:oriWirelessIfPropertiesTable
#'ori_ssid' => 'oriWirelessIfNetworkName',
#'ori_channel' => 'oriWirelessIfChannel',
#'ori_closed_sys' => 'oriWirelessIfClosedSystem',
# ORiNOCO-MIB:oriSystemInvMgmtComponentTable
);
%MUNGE = ( %SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE, );
sub os {
return 'orinoco';
}
sub os_ver {
my $orinoco = shift;
my $descr = $orinoco->description();
return unless defined $descr;
if ( $descr =~ m/V(\d+\.\d+)/ ) {
return $1;
}
if ( $descr =~ m/v(\d+\.\d+\.\d+)/ ) {
return $1;
}
return;
}
sub os_bin {
my $orinoco = shift;
my $descr = $orinoco->description();
return unless defined $descr;
if ( $descr =~ m/V(\d+\.\d+)$/ ) {
return $1;
}
if ( $descr =~ m/v(\d+\.\d+\.\d+)$/ ) {
return $1;
}
return;
}
sub vendor {
return 'proxim';
}
sub model {
my $orinoco = shift;
my $descr = $orinoco->description();
return unless defined $descr;
return $1 if ( $descr =~ /(AP-\d+)/ );
return 'WavePOINT-II' if ( $descr =~ /WavePOINT-II/ );
return 'Outdoor Router' if ( $descr =~ /Wireless Router/ );
return;
}
sub serial {
my $orinoco = shift;
my $descr = $orinoco->description();
return unless defined $descr;
$descr = $1 if $descr =~ /SN-(\S+)/;
return $descr;
}
sub i_ignore {
my $orinoco = shift;
my $partial = shift;
my $descr = $orinoco->i_description($partial) || {};
my %i_ignore;
foreach my $if ( keys %$descr ) {
my $type = $descr->{$if};
# Skip virtual interfaces
$i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i;
}
return \%i_ignore;
}
sub interfaces {
my $orinoco = shift;
my $partial = shift;
my $interfaces = $orinoco->i_index($partial) || {};
my $descriptions = $orinoco->i_description($partial) || {};
my %interfaces = ();
foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid};
next unless defined $desc;
next if $desc =~ /(lo|empty|PCMCIA)/i;
$desc = 'AMD' if $desc =~ /AMD/;
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
#sub i_ssidbcast {
# my $orinoco = shift;
# my $partial = shift;
#
# my $bcast = $orinoco->ori_closed_sys($partial) || {};
#
# my %i_ssidbcast;
# foreach my $iid (keys %$bcast){
# my $bc = $bcast->{$iid};
# next unless defined $bc;
#
# $i_ssidbcast{$iid} = $bc;
# }
# return \%i_ssidbcast;
#}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Orinoco - SNMP Interface to Orinoco Series Access Points
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $orinoco = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $orinoco->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from
Orinoco Access Point through SNMP. Orinoco devices have been manufactured
by Proxim, Agere, and Lucent.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $orinoco = new SNMP::Info::Layer2::Orinoco(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::IEEE802dot11
=back
=head2 Required MIBs
=over
None.
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::IEEE802dot11/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $orinoco->vendor()
Returns 'proxim'
=item $orinoco->model()
Returns the model extracted from C<sysDescr>.
=item $orinoco->os()
Returns 'Orinoco'
=item $orinoco->os_ver()
Returns the software version extracted from C<sysDescr>.
=item $orinoco->os_bin()
Returns the firmware version extracted from C<sysDescr>.
=item $orinoco->serial()
Returns the serial number extracted from C<sysDescr>.
=back
=head2 Global Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::IEEE802dot11
See L<SNMP::Info::IEEE802dot11/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $orinoco->interfaces()
Returns reference to map of IIDs to physical ports.
=item $orinoco->i_ignore()
Returns reference to hash of IIDs to ignore.
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::IEEE802dot11
See L<SNMP::Info::IEEE802dot11/"TABLE METHODS"> for details.
=cut

View File

@@ -1,225 +0,0 @@
# SNMP::Info::Layer2::ZyXEL_DSLAM
# $Id$
#
# Copyright (c) 2008 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::ZyXEL_DSLAM;
use strict;
use Exporter;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::ZyXEL_DSLAM::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
# Set for No CDP
%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS );
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
'ip_adresses' => 'ipAdEntAddr',
'i_name' => 'ifDescr',
'i_description' => 'adslLineConfProfile',
);
%MIBS
= ( %SNMP::Info::Layer2::MIBS, 'ADSL-LINE-MIB' => 'adslLineConfProfile' );
%MUNGE = ( %SNMP::Info::Layer2::MUNGE );
sub layers {
my $zyxel = shift;
my $layers = $zyxel->layers();
return $layers if defined $layers;
# If these don't claim to have any layers, so we'll give them 1+2
return '00000011';
}
sub vendor {
return 'zyxel';
}
sub os {
return 'zyxel';
}
sub os_ver {
my $zyxel = shift;
my $descr = $zyxel->description();
if ( $descr =~ m/version (\S+) / ) {
return $1;
}
return;
}
sub model {
my $zyxel = shift;
my $desc = $zyxel->description();
if ( $desc =~ /8-port ADSL Module\(Annex A\)/ ) {
return "AAM1008-61";
}
elsif ( $desc =~ /8-port ADSL Module\(Annex B\)/ ) {
return "AAM1008-63";
}
return;
}
sub ip {
my $zyxel = shift;
my $ip_hash = $zyxel->ip_addresses();
my $found_ip;
foreach my $ip ( keys %{$ip_hash} ) {
$found_ip = $ip
if ( defined $ip
and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ );
}
return $found_ip;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::ZyXEL_DSLAM - SNMP Interface to ZyXEL DSLAM
=head1 AUTHOR
Dmitry Sergienko (C<dmitry@trifle.net>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $zyxel = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myhub',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $l2->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
ZyXEL device through SNMP. See inherited classes' documentation for
inherited methods.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<ADSL-LINE-MIB>
=item Inherited Classes
MIBs listed in L<SNMP::Info::Layer2/"Required MIBs"> and their inherited
classes.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $zyxel->vendor()
Returns 'ZyXEL' :)
=item $zyxel->os()
Returns 'ZyXEL'
=item $zyxel->os_ver()
Culls Version from description()
=item $zyxel->ip()
Returns IP Address of DSLAM.
(C<ipAdEntAddr>)
=item $zyxel->model()
Tries to cull out model out of the description field.
=item $zyxel->layers()
Returns 00000011.
=back
=head2 Global Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
=head2 Overrides
=over
=item $zyxel->i_name()
Returns reference to map of IIDs to port name (C<ifDescr>).
=item $zyxel->i_description()
Returns reference to map of IIDs to human-set port description (profile name).
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,197 +1,129 @@
# SNMP::Info::Layer3 - SNMP Interface to Layer3 devices
# $Id$
#
# Copyright (c) 2008 Max Baker -- All changes from Version 0.7 on
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::CDP;
use SNMP::Info::Bridge;
use SNMP::Info::EtherLike;
use SNMP::Info::Entity;
use SNMP::Info::PowerEthernet;
use SNMP::Info::IPv6;
use SNMP::Info::AdslLine;
@SNMP::Info::Layer3::ISA = qw/
SNMP::Info::PowerEthernet SNMP::Info::IPv6
SNMP::Info::Entity SNMP::Info::EtherLike
SNMP::Info::Bridge SNMP::Info::AdslLine
SNMP::Info Exporter/;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::ISA = qw/SNMP::Info SNMP::Info::CDP SNMP::Info::Bridge SNMP::Info::EtherLike Exporter/;
@SNMP::Info::Layer3::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
$INIT = 0;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::AdslLine::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::EtherLike::MIBS,
%SNMP::Info::Entity::MIBS,
%SNMP::Info::PowerEthernet::MIBS,
%SNMP::Info::IPv6::MIBS,
'IP-MIB' => 'ipNetToMediaIfIndex',
'OSPF-MIB' => 'ospfRouterId',
'BGP4-MIB' => 'bgpIdentifier',
);
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::EtherLike::MIBS,
'ENTITY-MIB' => 'entPhysicalName',
'HP-ICF-OID' => 'hpSwitch4000',
'CISCO-PRODUCTS-MIB' => 'sysName',
'OSPF-MIB' => 'ospfRouterId',
);
%GLOBALS = (
# Inherit the super class ones
%SNMP::Info::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1',
'router_ip' => 'ospfRouterId.0',
);
# Inherit the super class ones
%SNMP::Info::GLOBALS,
%SNMP::Info::AdslLine::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::PowerEthernet::GLOBALS,
%SNMP::Info::IPv6::GLOBALS,
'mac' => 'ifPhysAddress.1',
'serial1' =>
'.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
'router_ip' => 'ospfRouterId.0',
'bgp_id' => 'bgpIdentifier.0',
'bgp_local_as' => 'bgpLocalAs.0',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::AdslLine::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::Entity::FUNCS,
%SNMP::Info::PowerEthernet::FUNCS,
%SNMP::Info::IPv6::FUNCS,
# Obsolete Address Translation Table (ARP Cache)
'old_at_index' => 'atIfIndex',
'old_at_paddr' => 'atPhysAddress',
'old_at_netaddr' => 'atNetAddress',
# IP-MIB IP Net to Media Table (ARP Cache)
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# OSPF-MIB::ospfIfTable
'ospf_if_ip' => 'ospfIfIpAddress',
'ospf_if_area' => 'ospfIfAreaId',
'ospf_if_type' => 'ospfIfType',
'ospf_if_hello' => 'ospfIfHelloInterval',
'ospf_if_dead' => 'ospfIfRtrDeadInterval',
'ospf_if_admin' => 'ospfIfAdminStat',
'ospf_if_state' => 'ospfIfState',
# OSPF-MIB::ospfNbrTable
'ospf_ip' => 'ospfHostIpAddress',
'ospf_peers' => 'ospfNbrIpAddr',
'ospf_peer_id' => 'ospfNbrRtrId',
'ospf_peer_state' => 'ospfNbrState',
# BGP4-MIB::bgpPeerTable
'bgp_peers' => 'bgpPeerLocalAddr',
'bgp_peer_id' => 'bgpPeerIdentifier',
'bgp_peer_state' => 'bgpPeerState',
'bgp_peer_as' => 'bgpPeerRemoteAs',
'bgp_peer_addr' => 'bgpPeerRemoteAddr',
'bgp_peer_fsm_est_trans' => 'bgpPeerFsmEstablishedTransitions',
'bgp_peer_in_tot_msgs' => 'bgpPeerInTotalMessages',
'bgp_peer_in_upd_el_time' => 'bgpPeerInUpdateElapsedTime',
'bgp_peer_in_upd' => 'bgpPeerInUpdates',
'bgp_peer_out_tot_msgs' => 'bgpPeerOutTotalMessages',
'bgp_peer_out_upd' => 'bgpPeerOutUpdates',
# IP-MIB Net to Physical Table (ARP Cache)
'n2p_paddr' => 'ipNetToPhysicalPhysAddress',
'n2p_lastupdate' => 'ipNetToPhysicalLastUpdated',
'n2p_ptype' => 'ipNetToPhysicalType',
'n2p_pstate' => 'ipNetToPhysicalState',
'n2p_pstatus' => 'ipNetToPhysicalRowStatus',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
# IFMIB
'i_name2' => 'ifName',
# Address Translation Table (ARP Cache)
'at_index' => 'atIfIndex',
'at_paddr' => 'atPhysAddress',
'at_netaddr' => 'atNetAddress',
'ospf_ip' => 'ospfHostIpAddress'
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::AdslLine::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE,
%SNMP::Info::IPv6::MUNGE,
'old_at_paddr' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
'n2p_paddr' => \&SNMP::Info::munge_mac,
);
# Method OverRides
sub root_ip {
my $l3 = shift;
my $router_ip = $l3->router_ip();
my $ospf_ip = $l3->ospf_ip();
my $router_ip = $l3->router_ip();
my $ospf_ip = $l3->ospf_ip();
# return the first one found here (should be only one)
if ( defined $ospf_ip and scalar( keys %$ospf_ip ) ) {
foreach my $key ( keys %$ospf_ip ) {
# return the first one found here (should be only)
if (defined $ospf_ip and scalar(keys %$ospf_ip)){
foreach my $key (keys %$ospf_ip){
my $ip = $ospf_ip->{$key};
next if $ip eq '0.0.0.0';
next unless $l3->snmp_connect_ip($ip);
print " SNMP::Layer3::root_ip() using $ip\n" if $l3->debug();
print " SNMP::Layer3::root_ip() using $ip\n" if $DEBUG;
return $ip;
}
}
return $router_ip
if (( defined $router_ip )
and ( $router_ip ne '0.0.0.0' )
and ( $l3->snmp_connect_ip($router_ip) ) );
return;
return $router_ip if defined $router_ip;
return undef;
}
sub i_ignore {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {};
my $l3 = shift;
my $interfaces = $l3->interfaces();
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
foreach my $if (keys %$interfaces) {
# lo -> cisco aironet 350 loopback
if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|null)/i ) {
if ($interfaces->{$if} =~ /(tunnel|loopback|lo|null)/i){
$i_ignore{$if}++;
}
}
@@ -200,41 +132,20 @@ sub i_ignore {
sub serial {
my $l3 = shift;
my $chassis = $l3->chassis();
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
my $serial1 = $l3->serial1();
my $e_descr = $l3->e_descr() || {};
my $e_serial = $l3->e_serial() || {};
my $serial2 = $e_serial->{1} || undef;
my $chassis = $e_descr->{1} || undef;
# precedence
# serial2,chassis parse,serial1
return $serial2 if ( defined $serial2 and $serial2 !~ /^\s*$/ );
return $1
if ( defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i );
return $serial1 if ( defined $serial1 and $serial1 !~ /^\s*$/ );
return;
}
# $l3->model() - the sysObjectID returns an IID to an entry in
# $l3->model() - the sysObjectID returns an IID to an entry in
# the CISCO-PRODUCT-MIB. Look it up and return it.
sub model {
my $l3 = shift;
my $id = $l3->id();
unless ( defined $id ) {
print
" SNMP::Info::Layer3::model() - Device does not support sysObjectID\n"
if $l3->debug();
return;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^cisco//i;
$model =~ s/^catalyst//;
$model =~ s/^cat//;
@@ -242,35 +153,31 @@ sub model {
}
sub i_name {
my $l3 = shift;
my $partial = shift;
my $i_index = $l3->i_index($partial);
my $i_alias = $l3->i_alias($partial);
my $i_name2 = $l3->orig_i_name($partial);
my $l3 = shift;
my $i_index = $l3->i_index();
my $i_alias = $l3->i_alias();
my $i_name2 = $l3->i_name2();
my %i_name;
foreach my $iid ( keys %$i_name2 ) {
my $name = $i_name2->{$iid};
foreach my $iid (keys %$i_name2){
my $name = $i_name2->{$iid};
my $alias = $i_alias->{$iid};
$i_name{$iid}
= ( defined $alias and $alias !~ /^\s*$/ )
? $alias
: $name;
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ?
$alias :
$name;
}
return \%i_name;
}
sub i_duplex {
my $l3 = shift;
my $partial = shift;
my $el_index = $l3->el_index($partial);
my $el_duplex = $l3->el_duplex($partial);
my $l3 = shift;
my $el_index = $l3->el_index();
my $el_duplex = $l3->el_duplex();
my %i_index;
foreach my $el_port ( keys %$el_duplex ) {
foreach my $el_port (keys %$el_duplex){
my $iid = $el_index->{$el_port};
next unless defined $iid;
my $duplex = $el_duplex->{$el_port};
@@ -286,20 +193,18 @@ sub i_duplex {
# $l3->interfaces() - Map the Interfaces to their physical names
sub interfaces {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->i_index($partial);
my $descriptions = $l3->i_description($partial);
my $l3 = shift;
my $interfaces = $l3->i_index();
my $descriptions = $l3->i_description();
my %interfaces = ();
foreach my $iid ( keys %$interfaces ) {
foreach my $iid (keys %$interfaces){
my $desc = $descriptions->{$iid};
next unless defined $desc;
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
@@ -307,214 +212,102 @@ sub vendor {
my $l3 = shift;
my $descr = $l3->description();
my $id = $l3->id();
# .1.3.6.1.4.1.9.1 is the CISCO-PRODUCTS-MIB
# .1.3.6.1.4.1.9.9.368.4 is an old tree that Cisco CSSs were numbered from
return 'cisco' if $id =~ /^\Q.1.3.6.1.4.1.9.1.\E\d+$/;
return 'cisco' if $id =~ /^\Q.1.3.6.1.4.1.9.9.368.4.\E\d+/;
return 'cisco' if ( $descr =~ /(cisco|\bios\b)/i );
return 'foundry' if ( $descr =~ /foundry/i );
return 'unknown';
return 'cisco' if ($descr =~ /(cisco|ios)/i);
return 'foundry' if ($descr =~ /foundry/i);
}
sub at_index {
my $l3 = shift;
my $partial = shift;
return $l3->orig_at_index($partial) || $l3->old_at_index($partial);
}
sub at_paddr {
my $l3 = shift;
my $partial = shift;
return $l3->orig_at_paddr($partial) || $l3->old_at_paddr($partial);
}
sub at_netaddr {
my $l3 = shift;
my $partial = shift;
return $l3->orig_at_netaddr($partial) || $l3->old_at_netaddr($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3 - SNMP Interface to network devices serving Layer3 or
Layers 2 & 3
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $l3 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $l3->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
my $interfaces = $l3->interfaces();
my $i_up = $l3->i_up();
my $i_speed = $l3->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
SNMP::Info::Layer3 - Perl5 Interface to network devices using Layer3
=head1 DESCRIPTION
This class is usually used as a superclass for more specific device classes
listed under SNMP::Info::Layer3::* Please read all docs under SNMP::Info
first.
Provides generic methods for accessing SNMP data for Layer 3 network devices.
Includes support for Layer2+3 devices.
Includes support for Layer2+3 devices. See super classes for other inherited
methods.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
Inherits from:
my $l3 = new SNMP::Info::Layer3(...);
SNMP::Info
SNMP::Info::Bridge
SNMP::Info::CDP
SNMP::Info::EtherLike
=head2 Inherited Classes
Required MIBs:
ENTITY-MIB - For model identification
CISCO-PRODUCTS-MIB - For model identification
HP-ICF-OID - For model identification
MIBS listed in SNMP::Info::CDP, SNMP::Info::Bridge, and SNMP::Info::Etherlike
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
HP MIBs can be found at http://www.hp.com/rnd/software
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $l3 = new SNMP::Info::Layer3(DestHost => 'router' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item SNMP::Info
=item new SNMP::Info::Layer3()
=item SNMP::Info::Bridge (For L2/L3 devices)
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::EtherLike
=item SNMP::Info::Entity
=item SNMP::Info::PowerEthernet
=item SNMP::Info::IPv6
my $l3 = new SNMP::Info::Layer3(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $l3;
=back
=head2 Required MIBs
=over
=item F<IP-MIB>
=item F<OSPF-MIB>
=item F<BGP4-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::EtherLike/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Entity/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::PowerEthernet/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::IPv6/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $l3->mac()
Returns root port mac address
(C<ifPhysAddress.1>)
(B<ifPhysAddress.1>)
=item $l3->router_ip()
=item $l3->chassis()
(C<ospfRouterId.0>)
Returns Chassis type (model).
=item $l3->bgp_id()
(C<bgpIdentifier.0>)
Returns the BGP identifier of the local system
=item $l3->bgp_local_as()
Returns the local autonomous system number
(C<bgpLocalAs.0>)
=back
=head2 Overrides
=over
=item $l3->model()
Tries to reference $l3->id() to one of the product MIBs listed above
Removes 'cisco' from cisco devices for readability.
(B<entPhysicalDescr.1>)
=item $l3->serial()
Tries to cull a serial number from F<ENTITY-MIB>, description, and
F<OLD-CISCO->... MIB.
Trys to cull a serial number from $l3->chassis()
=item $l3->model()
Trys to reference $l3->id() to one of the product MIBs listed above
Removes 'cisco' from cisco devices for readability.
=item $l3->vendor()
Tries to cull a Vendor name from C<sysDescr>
=item $l3->root_ip()
Returns the primary IP used to communicate with the device. Returns the first
found: OSPF Router ID (C<ospfRouterId>) or any OSPF Host IP Address
(C<ospfHostIpAddress>).
Trys to cull a Vendor name from B<sysDescr>
=back
=head2 Globals imported from SNMP::Info
See L<SNMP::Info/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Bridge
See L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::EtherLike
See L<SNMP::Info::EtherLike/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Entity
See L<SNMP::Info::Entity/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -522,8 +315,7 @@ to a hash.
=item $l3->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port
name.
Returns the map between SNMP Interface Identifier (iid) and physical port name.
Only returns those iids that have a description listed in $l3->i_description()
@@ -537,7 +329,7 @@ Currently looks for tunnel,loopback,lo,null from $l3->interfaces()
Returns reference to hash of iid to human set name.
Defaults to C<ifName>, but checks for an C<ifAlias>
Defaults to B<ifName>, but checks for an B<ifAlias>
=item $l3->i_duplex()
@@ -546,244 +338,32 @@ Returns reference to hash of iid to current link duplex setting.
Maps $l3->el_index() to $l3->el_duplex, then culls out
full,half, or auto and sets the map to that value.
See L<SNMP::Info::Etherlike> for the el_index() and el_duplex() methods.
=back
=head2 F<IP-MIB> Arp Cache Table (C<ipNetToMediaTable>)
=over
=item $l3->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(C<ipNetToMediaIfIndex>)
If the device doesn't support C<ipNetToMediaIfIndex>, this will try
the deprecated C<atIfIndex>.
=item $l3->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(C<ipNetToMediaPhysAddress>)
If the device doesn't support C<ipNetToMediaPhysAddress>, this will try
the deprecated C<atPhysAddress>.
=item $l3->at_netaddr()
Returns reference to hash. Maps ARP table entries to IP addresses.
(C<ipNetToMediaNetAddress>)
If the device doesn't support C<ipNetToMediaNetAddress>, this will try
the deprecated C<atNetAddress>.
see SNMP::Info::Etherlike for the el_index() and el_duplex() methods.
=back
=head2 ARP Cache Entries
The C<atTable> has been deprecated since 1991. You should never need
to use these methods. See C<ipNetToMediaTable> above.
=over
=item $l3->old_at_index()
=item $l3->at_index()
Returns reference to map of IID to Arp Cache Entry
(C<atIfIndex>)
(B<atIfIndex>)
=item $l3->old_at_paddr()
=item $l3->at_paddr()
Returns reference to hash of Arp Cache Entries to MAC address
(C<atPhysAddress>)
(B<atPhysAddress>)
=item $l3->old_at_netaddr()
=item $l3->at_netaddr()
Returns reference to hash of Arp Cache Entries to IP Address
(C<atNetAddress>)
(B<atNetAddress>)
=back
=head2 BGP Peer Table (C<bgpPeerTable>)
=over
=item $l3->bgp_peers()
Returns reference to hash of BGP peer to local IP address
(C<bgpPeerLocalAddr>)
=item $l3->bgp_peer_id()
Returns reference to hash of BGP peer to BGP peer identifier
(C<bgpPeerIdentifier>)
=item $l3->bgp_peer_state()
Returns reference to hash of BGP peer to BGP peer state
(C<bgpPeerState>)
=item $l3->bgp_peer_as()
Returns reference to hash of BGP peer to BGP peer autonomous system number
(C<bgpPeerRemoteAs>)
=item $l3->bgp_peer_addr()
Returns reference to hash of BGP peer to BGP peer IP address
(C<bgpPeerRemoteAddr>)
=item $l3->bgp_peer_fsm_est_trans()
Returns reference to hash of BGP peer to the total number of times the BGP FSM
transitioned into the established state
(C<bgpPeerFsmEstablishedTransitions>)
=item $l3->bgp_peer_in_tot_msgs()
Returns reference to hash of BGP peer to the total number of messages received
from the remote peer on this connection
(C<bgpPeerInTotalMessages>)
=item $l3->bgp_peer_in_upd_el_time()
Returns reference to hash of BGP peer to the elapsed time in seconds since
the last BGP UPDATE message was received from the peer.
(C<bgpPeerInUpdateElapsedTime>)
=item $l3->bgp_peer_in_upd()
Returns reference to hash of BGP peer to the number of BGP UPDATE messages
received on this connection
(C<bgpPeerInUpdates>)
=item $l3->bgp_peer_out_tot_msgs()
Returns reference to hash of BGP peer to the total number of messages
transmitted to the remote peer on this connection
(C<bgpPeerOutTotalMessages>)
=item $l3->bgp_peer_out_upd()
Returns reference to hash of BGP peer to the number of BGP UPDATE messages
transmitted on this connection
(C<bgpPeerOutUpdates>)
=back
=head2 OSPF Interface Table (C<ospfIfTable>)
=over
=item $l3->ospf_if_ip()
Returns reference to hash of OSPF interface IP addresses
(C<ospfIfIpAddress>)
=item $l3->ospf_if_area()
Returns reference to hash of the OSPF area to which the interfaces connect
(C<ospfIfAreaId>)
=item $l3->ospf_if_type()
Returns reference to hash of the OSPF interfaces' type
(C<ospfIfType>)
=item $l3->ospf_if_hello()
Returns reference to hash of the OSPF interfaces' hello interval
(C<ospfIfHelloInterval>)
=item $l3->ospf_if_dead()
Returns reference to hash of the OSPF interfaces' dead interval
(C<ospfIfRtrDeadInterval>)
=item $l3->ospf_if_admin()
Returns reference to hash of the OSPF interfaces' administrative status
(C<ospfIfAdminStat>)
=item $l3->ospf_if_state()
Returns reference to hash of the OSPF interfaces' state
(C<ospfIfState>)
=back
=head2 OSPF Neighbor Table (C<ospfNbrTable>)
=over
=item $l3->ospf_peers()
Returns reference to hash of IP addresses the neighbor is using in its
IP Source Addresses
(C<ospfNbrIpAddr>)
=item $l3->ospf_peer_id()
Returns reference to hash of neighbor Router IDs
(C<ospfNbrRtrId>)
=item $l3->ospf_peer_state()
Returns reference to hash of state of the relationship with the neighbor
routers
(C<ospfNbrState>)
=back
=head2 Table Methods imported from SNMP::Info
See L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::EtherLike
See L<SNMP::Info::EtherLike/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::PowerEthernet
See L<SNMP::Info::PowerEthernet/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::IPv6
See L<SNMP::Info::IPv6/"TABLE METHODS"> for details.
=cut

View File

@@ -1,125 +1,102 @@
# SNMP::Info::Layer3::Aironet
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Aironet;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Aironet::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'AWCVX-MIB' => 'awcIfTable',
'IEEE802dot11-MIB' => 'dot11StationID',
);
$INIT = 0;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'AWCVX-MIB' => 'awcIfTable',
'IEEE802dot11-MIB' => 'dot11StationID',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'mac' => 'dot11StationID.2',
%SNMP::Info::Layer3::GLOBALS,
'mac' => 'dot11StationID.2',
# AWC Ethernet Table
'awc_duplex' => 'awcEtherDuplex.0',
);
# AWC Ethernet Table
'awc_duplex' => 'awcEtherDuplex.0',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
'i_mac2' => 'ifPhysAddress',
'i_mtu2' => 'ifMtu',
'i_ssid' => 'dot11DesiredSSID',
# Bridge-mib overrides
'fw_mac2' => 'dot1dTpFdbAddress',
'fw_port2' => 'dot1dTpFdbPort',
'bp_index2' => 'dot1dBasePortIfIndex',
# AWC Interface Table (awcIfTable)
'awc_default_mac' => 'awcIfDefaultPhyAddress',
'awc_mac' => 'awcIfPhyAddress',
'awc_ip' => 'awcIfIpAddress',
'awc_netmask' => 'awcIfIpNetMask',
'awc_msdu' => 'awcIfMSDUMaxLength',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
'i_mac2' => 'ifPhysAddress',
'i_mtu2' => 'ifMtu',
'i_ssid' => 'dot11DesiredSSID',
# Bridge-mib overrides
'fw_mac2' => 'dot1dTpFdbAddress',
'fw_port2' => 'dot1dTpFdbPort',
'bp_index2' => 'dot1dBasePortIfIndex',
# AWC Interface Table (awcIfTable)
'awc_default_mac' => 'awcIfDefaultPhyAddress',
'awc_mac' => 'awcIfPhyAddress',
'awc_ip' => 'awcIfIpAddress',
'awc_netmask' => 'awcIfIpNetMask',
'awc_msdu' => 'awcIfMSDUMaxLength',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'awc_mac' => \&SNMP::Info::munge_mac,
'fw_mac2' => \&SNMP::Info::munge_mac,
);
sub os {
return 'aironet';
}
sub os_ver {
my $aironet = shift;
my $descr = $aironet->description() || '';
# CAP340 11.21, AP4800-E 11.21
if ( $descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/ ) {
return $2;
}
if ( $descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/ ) {
return $1;
}
return;
}
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'awc_mac' => \&SNMP::Info::munge_mac,
'fw_mac2' => \&SNMP::Info::munge_mac,
);
# Override wireless port with static info
sub bp_index {
my $aironet = shift;
my $aironet = shift;
my $interfaces = $aironet->interfaces();
my $bp_index = $aironet->bp_index2();
foreach my $iid ( keys %$interfaces ) {
my $bp_index = $aironet->bp_index2();
foreach my $iid (keys %$interfaces){
my $port = $interfaces->{$iid};
# Hardwire the wireless port to the transparent bridge port
if ( $port =~ /awc/ ) {
$bp_index->{0} = $iid;
if ($port =~ /awc/){
$bp_index->{0}=$iid;
}
}
return $bp_index;
}
@@ -128,19 +105,16 @@ sub fw_mac {
my $aironet = shift;
my $fw_mac = $aironet->fw_mac2();
my $fw_port = $aironet->fw_port2();
my $bs_mac = $aironet->bs_mac();
my $bs_mac = $aironet->bs_mac();
# remove port 0 forwarding table entries, only port 0 static entries
foreach my $fw ( keys %$fw_mac ) {
foreach my $fw (keys %$fw_mac){
my $port = $fw_port->{$fw};
next unless defined $port;
delete $fw_mac->{$fw} if $port == 0;
}
foreach my $bs ( keys %$bs_mac ) {
my $entry = $bs;
$entry =~ s/\.0$//;
$fw_mac->{$entry} = $bs_mac->{$bs};
foreach my $bs (keys %$bs_mac){
$fw_mac->{$bs} = $bs_mac->{$bs};
}
return $fw_mac;
@@ -150,28 +124,28 @@ sub fw_mac {
sub fw_port {
my $aironet = shift;
my $fw_port = $aironet->fw_port2();
my $bs_port = $aironet->bs_port();
my $bs_port = $aironet->bs_port();
foreach my $bs ( keys %$bs_port ) {
my $entry = $bs;
$entry =~ s/\.0$//;
$fw_port->{$entry} = $bs_port->{$bs};
foreach my $bs (keys %$bs_port){
$fw_port->{$bs} = $bs_port->{$bs};
}
return $fw_port;
}
sub i_duplex {
my $aironet = shift;
my $aironet = shift;
my $interfaces = $aironet->interfaces();
my $awc_duplex = $aironet->awc_duplex();
my %i_duplex;
foreach my $iid ( keys %$interfaces ) {
foreach my $iid (keys %$interfaces){
my $name = $interfaces->{$iid};
if ( $name =~ /fec/ ) {
if ($name =~ /fec/){
$i_duplex{$iid} = $awc_duplex;
}
}
@@ -185,7 +159,7 @@ sub i_mac {
my $i_mac = $aironet->i_mac2();
my $awc_mac = $aironet->awc_mac();
foreach my $iid ( keys %$awc_mac ) {
foreach my $iid (keys %$awc_mac){
next unless defined $i_mac->{$iid};
$i_mac->{$iid} = $awc_mac->{$iid};
}
@@ -194,14 +168,14 @@ sub i_mac {
}
sub i_ignore {
my $aironet = shift;
my $aironet = shift;
my $interfaces = $aironet->interfaces();
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
$i_ignore{$if}++ if ( $interfaces->{$if} =~ /(rptr|lo)/ );
foreach my $if (keys %$interfaces){
$i_ignore{$if}++ if ($interfaces->{$if} =~ /(rptr|lo)/);
}
return \%i_ignore;
}
@@ -215,98 +189,55 @@ __END__
=head1 NAME
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless
Devices running Aironet software, not IOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $aironet = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $aironet->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices
=head1 DESCRIPTION
SNMP::Info subclass to provide access to SNMP data for an Aironet device
running Aironet software, not cisco IOS.
Inherits all methods from SNMP::Info::Layer3
Note there are two classes for Aironet devices :
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $aironet = new SNMP::Info::Layer3::Aironet(DestHost => 'myswitch',
Community => 'public');
my $mac = $aironet->mac();
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::Layer3::Aironet
=item new SNMP::Info::Layer3::Aironet()
This class is for devices running Aironet software (older)
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::Layer2::Aironet
This class is for devices running Cisco IOS software (newer)
my $aironet = new SNMP::Info::Layer3::Aironet(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $aironet;
=back
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $aironet = new SNMP::Info::Layer3::Aironet(...);
=head2 Inherited Classes
=head1 Globals
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<AWCVX-MIB>
=item F<IEEE802dot11-MIB>
=back
These MIBs are now included in the v2.tar.gz archive available from
ftp.cisco.com. Make sure you have a current version.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $aironet->awc_duplex()
Gives the admin duplex setting for the Ethernet Port.
C<awcEtherDuplex.0>
=item $aironet->mac()
Gives the MAC Address of the wireless side
C<dot11StationID.2>
B<dot11StationID.2>
=item $aironet->os()
=item $aironet->awc_duplex()
'aironet'
Gives the admin duplex setting for the Ethernet Port.
=item $aironet->os_ver
Tries to cull the version from the description field.
B<awcEtherDuplex.0>
=item $aironet->vendor()
@@ -314,14 +245,41 @@ Returns 'cisco'.
=back
=head2 Globals imported from SNMP::Info::Layer3
=head1 TABLE ENTRIES
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Aironet specific items
=head1 TABLE METHODS
=over
These are methods that return tables of information in the form of a reference
to a hash.
=item $aironet->awc_default_mac()
Gives the default MAC address of each interface.
B<awcIfDefaultPhyAddress>
=item $aironet->awc_mac()
Gives the actual MAC address of each interface.
B<awcIfPhyAddress>
=item $aironet->awc_ip()
Gives the IP Address assigned to each interface.
B<awcIfIpAddress>
=item $aironet->awc_netmask()
Gives the NetMask for each interface.
B<awcIfIpNetMask>
=item $aironet->awc_msdu()
B<awcIfMSDUMaxLength>
=back
=head2 Overrides
@@ -329,18 +287,18 @@ to a hash.
=item $aironet->bp_index()
Takes the bp_index() value from SNMP::Info::Bridge and overrides the wireless
port to be assigned to the transparent bridge port (port 0)
Takes the bp_index() value from SNMP::Info::Bridge and overrides the wireless port
to be assigned to the transparent bridge port (port 0)
=item $aironet->fw_mac()
Adds static table entries from bs_mac() to port 0 so that wireless MAC
addresses will be reported. Forwarding table entries for port 0 are removed.
Adds static table entries from bs_mac() to port 0 so that wireless MAC addresses will
be reported. Forwarding table entries for port 0 are removed.
=item $aironet->fw_port()
Adds the static table port mappings to the forwarding table port mappings by
adding bs_port() to fw_port()
Adds the static table port mappings to the forwarding table port mappings by adding
bs_port() to fw_port()
=item $aironet->i_duplex()
@@ -356,42 +314,4 @@ Ignores ports that are of type ``rptr'' and ``lo''.
=back
=head2 Aironet specific items
=over
=item $aironet->awc_default_mac()
Gives the default MAC address of each interface.
C<awcIfDefaultPhyAddress>
=item $aironet->awc_mac()
Gives the actual MAC address of each interface.
C<awcIfPhyAddress>
=item $aironet->awc_ip()
Gives the IP Address assigned to each interface.
C<awcIfIpAddress>
=item $aironet->awc_netmask()
Gives the NetMask for each interface.
C<awcIfIpNetMask>
=item $aironet->awc_msdu()
C<awcIfMSDUMaxLength>
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,552 +0,0 @@
# SNMP::Info::Layer3::AlcatelLucent
# $Id$
#
# Copyright (c) 2008 Bill Fenner
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::AlcatelLucent;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::MAU;
use SNMP::Info::LLDP;
@SNMP::Info::Layer3::AlcatelLucent::ISA = qw/SNMP::Info::LLDP SNMP::Info::MAU
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::AlcatelLucent::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS,
%SNMP::Info::LLDP::MIBS,
'ALCATEL-IND1-DEVICES' => 'familyOmniSwitch7000',
'ALCATEL-IND1-CHASSIS-MIB' => 'chasEntPhysOperStatus',
'ALU-POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus',
);
# Alcatel provides their own version of the POWER-ETHERNET-MIB,
# off in vendor-space, without renaming any of the objects.
# This means we have to *not* load the POWER-ETHERNET-MIB
# but can then still use the standard PowerEthernet module,
# but cannot try both so we hope Alcatel doesn't stop supporting
# their private version even if they get around to supporting the
# standard.
delete $MIBS{'POWER-ETHERNET-MIB'};
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::MAU::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::MAU::FUNCS,
%SNMP::Info::LLDP::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::MAU::MUNGE,
%SNMP::Info::LLDP::MUNGE,
);
# use MAU-MIB for admin. duplex and admin. speed
*SNMP::Info::Layer3::AlcatelLucent::i_duplex_admin
= \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer3::AlcatelLucent::i_speed_admin
= \&SNMP::Info::MAU::mau_i_speed_admin;
sub model {
my $alu = shift;
my $id = $alu->id();
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^device//;
return $model;
}
sub os {
return 'AOS';
}
sub vendor {
return 'alcatel-lucent';
}
sub os_ver {
my $alu = shift;
my $descr = $alu->description();
if ( $descr =~ m/^(\S+)/ ) {
return $1;
}
# No clue what this will try but hey
return $alu->SUPER::os_ver();
}
# ps1_type, ps1_status, ps2_type, ps2_status:
# Find the list of power supplies in the ENTITY-MIB
# e_class = powerSupply
# e_descr = ps_type
# chasEntPhysOperStatus = ps_status
sub _power_supplies {
my $alu = shift;
my $e_class = $alu->e_class();
my @supplies = ();
foreach my $key ( sort { int($a) cmp int($b) } keys %$e_class ) {
if ( $e_class->{$key} eq 'powerSupply' ) {
push( @supplies, int($key) );
}
}
return @supplies;
}
sub _ps_type {
my $alu = shift;
my $psnum = shift;
my @ps = $alu->_power_supplies();
if ( $psnum > $#ps ) {
return "none";
}
my $supply = $ps[$psnum];
my $descr = $alu->e_descr($supply);
return $descr->{$supply};
}
sub _ps_status {
my $alu = shift;
my $psnum = shift;
my @ps = $alu->_power_supplies();
if ( $psnum > $#ps ) {
return "not present";
}
my $supply = $ps[$psnum];
my $status = $alu->chasEntPhysOperStatus($supply);
return $status->{$supply};
}
sub ps1_type {
my $alu = shift;
return $alu->_ps_type(0);
}
sub ps2_type {
my $alu = shift;
return $alu->_ps_type(1);
}
sub ps1_status {
my $alu = shift;
return $alu->_ps_status(0);
}
sub ps2_status {
my $alu = shift;
return $alu->_ps_status(1);
}
# The interface description contains the software version, so
# to avoid losing historical information through a software upgrade
# we use interface name instead.
sub interfaces {
my $alu = shift;
my $partial = shift;
return $alu->orig_i_name($partial);
}
# Use Q-BRIDGE-MIB
sub fw_mac {
my $alu = shift;
my $partial = shift;
return $alu->qb_fw_mac($partial);
}
sub fw_port {
my $alu = shift;
my $partial = shift;
return $alu->qb_fw_port($partial);
}
# Work around buggy bp_index in 6.3.1.871.R01 and 6.3.1.975.R01
sub bp_index {
my $alu = shift;
my $partial = shift;
my $bp_index = $alu->SUPER::bp_index($partial);
#
# This device sometimes reports an ifIndex and sometimes reports
# dot1dBasePort for the dot1d port values - e.g.,
# in 6.3.1.871.R01 both dot1dTpFdbPort and dot1qTpFdbPort report
# the ifIndex; in 6.3.1.975.R01 dot1dTpFdbPort has been updated
# to report the dot1dBasePort but dot1qTpFdbPort still returns an
# ifIndex. For this reason, we augment the dot1dBasePort
# mapping with ifIndex->ifIndex mappings -- we can do this because
# the ifIndex and dot1dBasePort spaces don't overlap, at least for
# the ports we care about.
my @keys = keys %$bp_index;
foreach my $idx (@keys) {
my $ifIndex = $bp_index->{$idx};
$bp_index->{$ifIndex} = $ifIndex;
}
#
# In addition, aggregates aren't reported at all in bp_index.
# We grab them from i_index.
my $i_index = $alu->i_index();
foreach my $idx ( keys %$i_index ) {
my $ifIndex = $i_index->{$idx};
if ( int($ifIndex) > 40000001 ) {
$bp_index->{$ifIndex} = $ifIndex;
# dot1dTpFdbPort seems to use 4098, 4099, 4100 for
# 40000001, 40000002, 40000003. I guess this is
# 4096 + 1 + aggregate number.
my $tmp = sprintf( "%d", int($ifIndex) - 39995903 );
$bp_index->{$tmp} = $ifIndex;
}
}
return $bp_index;
}
# Workaround for unimplemented Q-BRIDGE-MIB::dot1qPvid
# If there is only one VLAN on which a given port is output
# untagged, then call that one the PVID. This is a guess that
# works in obvious configurations but may be wrong in
# subtle cases (like there's one output VLAN but a different
# input one - the only way to know that is via the dot1qPvid
# object)
#
# Newer versions have implemented dot1qPvid (but wrong, but
# that's just life)
#sub i_vlan {
# my $alu = shift;
#
# my $qb_v_untagged = $alu->qb_v_untagged();
# my $bp_index = $alu->bp_index();
# my $vlan_list = {};
# foreach my $vlan (keys %$qb_v_untagged) {
# my $portlist = $qb_v_untagged->{$vlan};
# my $port;
# for ($port = 0; $port <= $#$portlist; $port++) {
# if ($portlist->[$port]) {
# my $ifindex = $bp_index->{$port + 1};
# if ($ifindex) {
# push(@{$vlan_list->{$ifindex}}, int($vlan));
# }
# }
# }
# }
#
# my $i_vlan = {};
# foreach my $ifindex (keys %$vlan_list) {
# if ($#{$vlan_list->{$ifindex}} == 0) {
# $i_vlan->{$ifindex} = ${$vlan_list->{$ifindex}}[0];
# }
# }
# return $i_vlan;
#}
# Use LLDP
# (or at least try. The versions I've seen have two problems:
# 1. they report ifIndex values as 'local'; we don't support ifIndex
# but *could*
# 2. They report 0.0.0.0 as the management address
# )
sub hasCDP {
my $alu = shift;
return $alu->hasLLDP();
}
sub c_ip {
my $alu = shift;
my $partial = shift;
return $alu->lldp_ip($partial);
}
sub c_if {
my $alu = shift;
my $partial = shift;
return $alu->lldp_if($partial);
}
sub c_port {
my $alu = shift;
my $partial = shift;
return $alu->lldp_port($partial);
}
sub c_id {
my $alu = shift;
my $partial = shift;
return $alu->lldp_id($partial);
}
sub c_platform {
my $alu = shift;
my $partial = shift;
return $alu->lldp_rem_sysdesc($partial);
}
# Power-Ethernet ifIndex mapping. I've only seen this from a
# fixed-config single-module system, so this is only a plausible
# guess as to the mapping on a stack or modular system.
sub peth_port_ifindex {
my $alu = shift;
my $partial = shift;
my $peth_port_status = $alu->peth_port_status($partial);
my $peth_port_ifindex = {};
foreach my $key ( keys %$peth_port_status ) {
my @oid = split( m/\./, $key );
$peth_port_ifindex->{$key} = int( $oid[0] ) * 1000 + int( $oid[1] );
}
return $peth_port_ifindex;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::AlcatelLucent - SNMP Interface to Alcatel-Lucent OmniSwitch
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $alu = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $alu->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Alcatel-Lucent OmniSwitch devices
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::MAU
=item SNMP::Info::LLDP
=back
=head2 Required MIBs
=over
=item F<ALCATEL-IND1-DEVICES>
=item F<ALCATEL-IND1-CHASSIS-MIB>
=item F<ALU-POWER-ETHERNET-MIB>
Note that Alcatel-Lucent distributes their own proprietary version of the
F<POWER-ETHERNET-MIB>, but the MIB module name that they distribute is
simply F<POWER-ETHERNET-MIB>. This module must be hand-edited to change the
module name to F<ALU-POWER-ETHERNET-MIB> so that it can be used simultaneously
with the standard F<POWER-ETHERNET-MIB>.
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::MAU/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $alu->vendor()
Returns 'alcatel-lucent'
=item $alu->hasCDP()
Returns whether LLDP is enabled.
=item $alu->model()
Tries to reference $alu->id() to one of the product MIBs listed above
Removes 'device' from the name for readability.
=item $alu->os()
Returns 'AOS'
=item $alu->os_ver()
Grabs the os version from C<sysDescr>
=item $alu->ps1_type()
Return the type of the first power supply from the F<ENTITY-MIB>
=item $alu->ps2_type()
Return the type of the second power supply from the F<ENTITY-MIB>
=item $alu->ps1_status()
Return the status of the first power supply from the F<ALCATEL-IND1-CHASSIS-MIB>
=item $alu->ps2_status()
Return the status of the second power supply from the F<ALCATEL-IND1-CHASSIS-MIB>
=back
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $alu->interfaces()
Returns interface name from C<ifName>, since the default return value
of C<ifDescr> includes the OS version.
=item $alu->fw_mac()
Use the F<Q-BRIDGE-MIB> instead of F<BRIDGE-MIB>
=item $alu->fw_port()
Use the F<Q-BRIDGE-MIB> instead of F<BRIDGE-MIB>
=item $alu->bp_index()
Work around various bugs in the F<BRIDGE-MIB> and
F<Q-BRIDGE-MIB> implementations, by returning both
C<ifIndex> and C<dot1dBasePort> mappings to C<ifIndex> values.
=item $alu->c_id()
Returns LLDP information.
=item $alu->c_if()
Returns LLDP information.
=item $alu->c_ip()
Returns LLDP information.
=item $alu->c_platform()
Returns LLDP information.
=item $alu->c_port()
Returns LLDP information.
=item $alu->i_duplex_admin()
Returns info from F<MAU-MIB>
=item $alu->i_speed_admin()
Returns info from F<MAU-MIB>
=item $alu->peth_port_ifindex()
Returns the C<ifIndex> value for power-ethernet ports
using the OmniSwitch algorithm.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,544 +0,0 @@
# SNMP::Info::Layer3::AlteonAD
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All Rights Reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::AlteonAD;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'ALTEON-ROOT-MIB' => 'aceswitch184',
'ALTEON-TIGON-SWITCH-MIB' => 'hwPowerSupplyStatus',
'ALTEON-CHEETAH-SWITCH-MIB' => 'hwFanStatus',
'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt',
'ALTEON-CS-PHYSICAL-MIB' => 'vlanCurCfgLearn',
'ALTEON-TS-NETWORK-MIB' => 'ripCurCfgSupply',
'ALTEON-CHEETAH-NETWORK-MIB' => 'ripCurCfgIntfSupply',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'old_sw_ver' => 'ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion',
'new_sw_ver' => 'ALTEON_CHEETAH_SWITCH_MIB__agSoftwareVersion',
'old_tftp_action' => 'ALTEON_TIGON_SWITCH_MIB__agTftpAction',
'new_tftp_action' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpAction',
'old_tftp_host' => 'ALTEON_TIGON_SWITCH_MIB__agTftpServer',
'new_tftp_host' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpServer',
'old_tftp_file' => 'ALTEON_TIGON_SWITCH_MIB__agTftpCfgFileName',
'new_tftp_file' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpCfgFileName',
'old_tftp_result' => 'ALTEON_TIGON_SWITCH_MIB__agTftpLastActionStatus',
'new_tftp_result' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpLastActionStatus',
'old_ip_max' => 'ALTEON_TS_NETWORK_MIB__ipInterfaceTableMax',
'new_ip_max' => 'ALTEON_CHEETAH_NETWORK_MIB__ipInterfaceTableMax',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
# From agPortCurCfgTable
'old_ag_p_cfg_idx' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgIndx',
'new_ag_p_cfg_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgIndx',
'old_ag_p_cfg_pref' => 'agPortCurCfgPrefLink',
'new_ag_p_cfg_pref' => 'agPortCurCfgPreferred',
'old_ag_p_cfg_pvid' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPVID',
'new_ag_p_cfg_pvid' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPVID',
'old_ag_p_cfg_fe_auto' =>
'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthAutoNeg',
'new_ag_p_cfg_fe_auto' =>
'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthAutoNeg',
'old_ag_p_cfg_fe_mode' =>
'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthMode',
'new_ag_p_cfg_fe_mode' =>
'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthMode',
'old_ag_p_cfg_ge_auto' =>
'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgGigEthAutoNeg',
'new_ag_p_cfg_ge_auto' =>
'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgGigEthAutoNeg',
'old_ag_p_cfg_name' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName',
'new_ag_p_cfg_name' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPortName',
# From portInfoTable
'old_p_info_idx' => 'ALTEON_TS_PHYSICAL_MIB__portInfoIndx',
'new_p_info_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoIndx',
'old_p_info_mode' => 'ALTEON_TS_PHYSICAL_MIB__portInfoMode',
'new_p_info_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoMode',
# From ipCurCfgIntfTable
'old_ip_cfg_vlan' => 'ALTEON_TS_NETWORK_MIB__ipCurCfgIntfVlan',
'new_ip_cfg_vlan' => 'ALTEON_CHEETAH_NETWORK_MIB__ipCurCfgIntfVlan',
# From vlanCurCfgTable
'old_vlan_id' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanId',
'new_vlan_id' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanId',
'old_vlan_state' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgState',
'new_vlan_state' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgState',
'old_vlan_name' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanName',
'new_vlan_name' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanName',
'old_vlan_ports' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgPorts',
'new_vlan_ports' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgPorts',
);
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub model {
my $alteon = shift;
my $id = $alteon->id();
unless ( defined $id ) {
print
" SNMP::Info::Layer3::AlteonAD::model() - Device does not support sysObjectID\n"
if $alteon->debug();
return;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^aceswitch//;
$model =~ s/^acedirector/AD/;
$model =~ s/^(copper|fiber)Module/BladeCenter GbESM/;
return $model;
}
sub vendor {
return 'nortel';
}
sub os {
return 'alteon';
}
sub os_ver {
my $alteon = shift;
my $version = $alteon->new_sw_ver() || $alteon->old_sw_ver();
return unless defined $version;
return $version;
}
sub interfaces {
my $alteon = shift;
my $interfaces = $alteon->i_index();
my $descriptions = $alteon->i_description();
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %interfaces = ();
foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid};
next unless defined $desc;
if ( $desc =~ /(^net\d+)/ ) {
$desc = $1;
}
# IP interfaces are first followed by physical, number possible
# varies by switch model
elsif ( defined $ip_max and $iid > $ip_max ) {
$desc = ( $iid % $ip_max );
}
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_duplex {
my $alteon = shift;
my $p_mode = $alteon->new_p_info_mode()
|| $alteon->old_p_info_mode()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_duplex;
foreach my $if ( keys %$p_mode ) {
my $duplex = $p_mode->{$if};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
my $idx;
$idx = $if + $ip_max if ( defined $ip_max );
$i_duplex{$idx} = $duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $alteon = shift;
my $ag_pref = $alteon->new_ag_p_cfg_pref()
|| $alteon->old_ag_p_cfg_pref()
|| {};
my $ag_fe_auto = $alteon->new_ag_p_cfg_fe_auto()
|| $alteon->old_ag_p_cfg_fe_auto()
|| {};
my $ag_fe_mode = $alteon->new_ag_p_cfg_fe_mode()
|| $alteon->old_ag_p_cfg_fe_mode()
|| {};
my $ag_ge_auto = $alteon->new_ag_p_cfg_ge_auto()
|| $alteon->old_ag_p_cfg_ge_auto()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_duplex_admin;
foreach my $if ( keys %$ag_pref ) {
my $pref = $ag_pref->{$if};
next unless defined $pref;
my $string = 'other';
if ( $pref =~ /gigabit/i ) {
my $ge_auto = $ag_ge_auto->{$if};
$string = 'full' if ( $ge_auto =~ /off/i );
$string = 'auto' if ( $ge_auto =~ /on/i );
}
elsif ( $pref =~ /fast/i ) {
my $fe_auto = $ag_fe_auto->{$if};
my $fe_mode = $ag_fe_mode->{$if};
$string = 'half'
if ( $fe_mode =~ /half/i and $fe_auto =~ /off/i );
$string = 'full'
if ( $fe_mode =~ /full/i and $fe_auto =~ /off/i );
$string = 'auto' if $fe_auto =~ /on/i;
}
my $idx;
$idx = $if + $ip_max if ( defined $ip_max );
$i_duplex_admin{$idx} = $string;
}
return \%i_duplex_admin;
}
sub i_name {
my $alteon = shift;
my $p_name = $alteon->new_ag_p_cfg_name()
|| $alteon->old_ag_p_cfg_name()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_name;
foreach my $iid ( keys %$p_name ) {
my $name = $p_name->{$iid};
next unless defined $name;
my $idx;
$idx = $iid + $ip_max if ( defined $ip_max );
$i_name{$idx} = $name;
}
return \%i_name;
}
sub v_index {
my $alteon = shift;
my $partial = shift;
return $alteon->new_vlan_id($partial) || $alteon->old_vlan_id($partial);
}
sub v_name {
my $alteon = shift;
my $partial = shift;
return $alteon->new_vlan_name($partial)
|| $alteon->old_vlan_name($partial);
}
sub i_vlan {
my $alteon = shift;
my $ag_vlans = $alteon->new_ag_p_cfg_pvid()
|| $alteon->old_ag_p_cfg_pvid()
|| {};
my $ip_vlans = $alteon->new_ip_cfg_vlan()
|| $alteon->old_ip_cfg_vlan()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_vlan;
foreach my $if ( keys %$ip_vlans ) {
my $ip_vlanid = $ip_vlans->{$if};
next unless defined $ip_vlanid;
$i_vlan{$if} = $ip_vlanid;
}
foreach my $if ( keys %$ag_vlans ) {
my $ag_vlanid = $ag_vlans->{$if};
next unless defined $ag_vlanid;
my $idx;
$idx = $if + $ip_max if ( defined $ip_max );
$i_vlan{$idx} = $ag_vlanid;
}
return \%i_vlan;
}
sub i_vlan_membership {
my $alteon = shift;
my $v_ports = $alteon->old_vlan_ports()
|| $alteon->new_vlan_ports()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my $i_vlan_membership = {};
foreach my $vlan ( keys %$v_ports ) {
my $portlist = [ split( //, unpack( "B*", $v_ports->{$vlan} ) ) ];
my $ret = [];
# Convert portlist bit array to ifIndex array
for ( my $i = 0; $i <= scalar(@$portlist); $i++ ) {
my $idx;
$idx = $i + $ip_max if ( defined $ip_max );
push( @{$ret}, $idx ) if ( @$portlist[$i] );
}
#Create HoA ifIndex -> VLAN array
foreach my $port ( @{$ret} ) {
push( @{ $i_vlan_membership->{$port} }, $vlan );
}
}
return $i_vlan_membership;
}
# Bridge MIB does not map Bridge Port to ifIndex correctly on some code
# versions
sub bp_index {
my $alteon = shift;
my $b_index = $alteon->orig_bp_index();
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %bp_index;
foreach my $iid ( keys %$b_index ) {
my $port = $b_index->{$iid};
next unless defined $port;
$port = $port + $ip_max if ( defined $ip_max and $iid == $ip_max );
$bp_index{$iid} = $port;
}
return \%bp_index;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::AlteonAD - SNMP Interface to Nortel Alteon Layer 2-7
Switches.
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $alteon = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $alteon->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Nortel Alteon Series Layer 2-7 load balancing
switches and Nortel BladeCenter Layer2-3 GbE Switch Modules.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $alteon = new SNMP::Info::Layer3::AlteonAD(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<ALTEON-ROOT-MIB>
=item F<ALTEON-TIGON-SWITCH-MIB>
=item F<ALTEON-TS-PHYSICAL-MIB>
=item F<ALTEON-TS-NETWORK-MIB>
=item F<ALTEON-CS-PHYSICAL-MIB>
=item F<ALTEON-CHEETAH-SWITCH-MIB>
=item F<ALTEON-CHEETAH-NETWORK-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $alteon->model()
Returns model type. Checks $alteon->id() against the F<ALTEON-ROOT-MIB> and
then parses out C<aceswitch>, replaces C<acedirector> with AD, and replaces
copperModule/fiberModule with BladeCenter GbESM.
=item $alteon->vendor()
Returns 'nortel'
=item $alteon->os()
Returns 'alteon'
=item $alteon->os_ver()
Returns the software version reported by C<agSoftwareVersion>
=item $alteon->tftp_action()
(C<agTftpAction>)
=item $alteon->tftp_host()
(C<agTftpServer>)
=item $alteon->tftp_file()
(C<agTftpCfgFileName>)
=item $alteon->tftp_result()
(C<agTftpLastActionStatus>)
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $alteon->interfaces()
Returns reference to the map between IID and physical port.
Utilizes description for network interfaces. Ports are determined by
formula (C<ifIndex mod 256>).
=item $alteon->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs.
=item $alteon->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs.
=item $alteon->i_vlan()
Returns a mapping between C<ifIndex> and the PVID or default VLAN.
=item $alteon->i_vlan_membership()
Returns reference to hash of arrays: key = C<ifIndex>, value = array of VLAN
IDs. These are the VLANs which are members of the egress list for the port.
Example:
my $interfaces = $alteon->interfaces();
my $vlans = $alteon->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";
}
=item $alteon->v_index()
Returns VLAN IDs
=item $alteon->v_name()
Human-entered name for vlans.
=item $alteon->i_name()
Maps (C<agPortCurCfgPortName>) to port and returns the human set port name if
exists.
=item $alteon->bp_index()
Returns a mapping between C<ifIndex> and the Bridge Table.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,400 +0,0 @@
# SNMP::Info::Layer3::Altiga
# $Id$
#
# Copyright (c) 2008 Jeroen van Ingen Schenau
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Altiga;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Altiga::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Altiga::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE
$int_include_vpn $fake_idx $type_class/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'ALTIGA-VERSION-STATS-MIB' => 'alVersionString',
'ALTIGA-SESSION-STATS-MIB' => 'alActiveSessionCount',
'ALTIGA-HARDWARE-STATS-MIB' => 'alHardwarePs1Type',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
# From ALTIGA-VERSION-STATS-MIB
'os_ver' => 'alVersionString',
# From ALTIGA-SESSION-STATS-MIB
'vpn_act_sess' => 'alActiveSessionCount',
'vpn_total_sess' => 'alTotalSessionCount',
'vpn_max_sess' => 'alMaxSessionCount',
'vpn_l2l_sess' => 'alActiveLanToLanSessionCount',
'vpn_mgmt_sess' => 'alActiveManagementSessionCount',
'vpn_ras_sess' => 'alActiveRemoteAccessSessionCount',
# From ALTIGA-HARDWARE-STATS-MIB
'ps1_type' => 'alHardwarePs1Type',
'ps1_3v_alarm' => 'alHardwarePs1Voltage3vAlarm',
'ps1_5v_alarm' => 'alHardwarePs1Voltage5vAlarm',
'ps2_type' => 'alHardwarePs2Type',
'ps2_3v_alarm' => 'alHardwarePs2Voltage3vAlarm',
'ps2_5v_alarm' => 'alHardwarePs2Voltage5vAlarm',
'fan1_alarm' => 'alHardwareFan1RpmAlarm',
'fan2_alarm' => 'alHardwareFan2RpmAlarm',
'fan3_alarm' => 'alHardwareFan3RpmAlarm',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
'i_type2' => 'ifType',
'i_lastchange2' => 'ifLastChange',
'vpn_sess_status' => 'alActiveSessionRowStatus',
'vpn_sess_user' => 'alActiveSessionUserName',
'vpn_sess_peer_ip' => 'alActiveSessionIpAddress',
'vpn_sess_protocol' => 'alActiveSessionProtocol',
'vpn_sess_encr' => 'alActiveSessionEncrType',
'vpn_sess_start' => 'alActiveSessionStartTime',
'vpn_sess_conntime' => 'alActiveSessionConnectTime',
'vpn_sess_out_oct' => 'alActiveSessionOctetsSent',
'vpn_sess_in_oct' => 'alActiveSessionOctetsRcvd',
'vpn_sess_group' => 'alActiveSessionGroupName',
'vpn_sess_gid' => 'alActiveSessionGroupId',
'vpn_sess_rem_ip' => 'alActiveSessionPublicIpAddress',
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
'ps1_3v_alarm' => \&munge_alarm,
'ps1_5v_alarm' => \&munge_alarm,
'ps2_3v_alarm' => \&munge_alarm,
'ps2_5v_alarm' => \&munge_alarm,
'fan1_alarm' => \&munge_alarm,
'fan2_alarm' => \&munge_alarm,
'fan3_alarm' => \&munge_alarm,
);
# Variable to modify behaviour of "interfaces" subroutine.
# * When set to 0, "interfaces" returns only fixed interfaces from the IF-MIB,
# * When set to 1, "interfaces" returns fixed interfaces from IF-MIB and LAN-to-LAN tunnels from ALTIGA-SESSION-MIB
# TODO: This should be an instance method, not a class global
$int_include_vpn = 1;
# Variable to prepended to each tunnel index when tunnel is added to %interfaces, to avoid overwriting "real" ifIndex entries
$fake_idx = 3076;
# Variable to classify session types into categories: 0 - unclassified, 1 - LAN-to-LAN or fixed, 2 - RAS or dynamic, 3 - administrative
$type_class = {
'pptp' => 2,
'l2tp' => 2,
'ipsec' => 2,
'http' => 3,
'ftp' => 3,
'telnet' => 3,
'snmp' => 3,
'tftp' => 3,
'console' => 3,
'debugTelnet' => 3,
'debugConsole' => 3,
'other' => 3,
'ike' => 0,
'l2tpOverIpSec' => 2,
'ipsecLanToLan' => 1,
'ipsecOverUdp' => 2,
'ssh' => 3,
'vcaLanToLan' => 1,
'ipsecOverTcp' => 2,
'pppoe' => 2,
'ipsecOverNatT' => 2,
'ipsecLan2LanOverNatT' => 1,
'l2tpOverIpsecOverNatT' => 2,
'userHttps' => 2,
'pop3s' => 2,
'imap4s' => 2,
'smtps' => 2,
'httpsTunnel' => 2,
};
sub vendor {
return 'altiga';
}
sub os {
return 'altiga';
}
sub hasCDP {
return 0;
}
# $altiga->interfaces() - Map the Interfaces to their physical names
# Add interface number to interface name to prevent duplicate ifDescr
# Included statically configured VPN tunnels if ($int_include_vpn)
sub interfaces {
my $altiga = shift;
my $partial = shift;
my $interfaces = $altiga->i_index($partial);
my $descriptions = $altiga->i_description($partial);
my %int_rev = ();
my %interfaces = ();
foreach my $iid (sort {$a cmp $b} keys %$interfaces) {
my $desc = $descriptions->{$iid};
next unless defined $desc;
if (!exists $int_rev{$desc}) {
$interfaces{$iid} = $desc;
$int_rev{$desc} = $iid;
} else {
my $done = 0;
my $unique_desc;
my $cnt = 1;
until ($done) {
$cnt++;
$unique_desc = sprintf("%s (%d)", $desc, $cnt);
if (!exists $int_rev{$unique_desc}) {
$done++;
}
}
$int_rev{$unique_desc} = $iid;
$interfaces{$iid} = $unique_desc;
$interfaces{ $int_rev{$desc} } = sprintf("%s (%d)", $desc, 1);
}
}
if ($int_include_vpn) {
my $tun_type = $altiga->vpn_sess_protocol();
my $peer = $altiga->vpn_sess_peer_ip();
my $remote = $altiga->vpn_sess_rem_ip();
my $group = $altiga->vpn_sess_gid();
foreach my $tunnel (keys %$tun_type) {
if ($type_class->{$tun_type->{$tunnel}} eq 1) {
$interfaces{"$fake_idx.$tunnel"} = sprintf("%s VPN to %s", uc($tun_type->{$tunnel}), $remote->{$tunnel});
}
}
}
return \%interfaces;
}
sub i_type {
my $altiga = shift;
my $partial = shift;
my $types = $altiga->i_type2();
if ($int_include_vpn) {
my $tun_type = $altiga->vpn_sess_protocol();
foreach my $tunnel (keys %$tun_type) {
$types->{"$fake_idx.$tunnel"} = $tun_type->{$tunnel};
}
}
return $types;
}
sub i_lastchange {
my $altiga = shift;
my $partial = shift;
# TODO: This is what munges are for.
my $lastchange = $altiga->i_lastchange2();
if ($int_include_vpn) {
my $tun_start = $altiga->vpn_sess_start();
foreach my $tunnel (keys %$tun_start) {
$lastchange->{"$fake_idx.$tunnel"} = $tun_start->{$tunnel};
}
}
return $lastchange;
}
sub ps1_status {
my $altiga = shift;
my $alarm_3v = $altiga->ps1_3v_alarm() || "";
my $alarm_5v = $altiga->ps1_5v_alarm() || "";
return sprintf("3V: %s, 5V: %s", $alarm_3v, $alarm_5v);
}
sub ps2_status {
my $altiga = shift;
my $alarm_3v = $altiga->ps2_3v_alarm() || "";
my $alarm_5v = $altiga->ps2_5v_alarm() || "";
return sprintf("3V: %s, 5V: %s", $alarm_3v, $alarm_5v);
}
sub fan {
my $altiga = shift;
my $alarm_fan1 = $altiga->fan1_alarm() || "";
my $alarm_fan2 = $altiga->fan2_alarm() || "";
my $alarm_fan3 = $altiga->fan3_alarm() || "";
return sprintf("Fan 1: %s, Fan 2: %s, Fan 3: %s", $alarm_fan1, $alarm_fan2, $alarm_fan3);
}
sub munge_alarm {
my $alarm = shift;
if ($alarm eq 'false') {
return 'OK';
} elsif ($alarm eq 'true') {
return 'FAIL';
} else {
return "(n/a)";
}
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Altiga - SNMP Interface to Cisco (formerly Altiga) VPN concentrators
=head1 AUTHOR
Jeroen van Ingen Schenau
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $altiga = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'my_vpn_host',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $altiga->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Cisco (formerly Altiga) VPN concentrators
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 Class Variables (options)
=over
=item $SNMP::Info::Layer3::Altiga::int_include_vpn
Variable to modify behavior of "interfaces" subroutine.
* When set to 0, "interfaces" returns only fixed interfaces from the IF-MIB,
* When set to 1, "interfaces" returns fixed interfaces from IF-MIB and
LAN-to-LAN tunnels from ALTIGA-SESSION-MIB (default)
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $altiga->vendor()
Returns 'altiga'
=item $altiga->os()
Returns 'altiga'
=item $altiga->os_ver()
Tries to determine OS version from the C<sysDescr.0> field. Returns version or C<sysDescr.0>
=item $altiga->fan()
Combines results from C<fan1_alarm>, C<fan2_alarm>, and C<fam3_alarm> methods.
=item $altiga->hasCDP()
No.
=item $altiga->ps1_status()
Combines C<ps1_3v_alarm> and C<ps1_5v_alarm> methods.
=item $altiga->ps2_status()
Combines C<ps2_3v_alarm> and C<ps2_5v_alarm> methods.
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $altiga->interfaces()
This method overrides the interfaces() method inherited from SNMP::Info.
It provides a mapping between the Interface Table Index (iid) and the physical
port name, adding a port number to the port name to prevent duplicate names.
=item $altiga->i_lastchange()
Filters out the results depending on the value of $SNMP::Info::Layer3::Altiga::int_include_vpn
=item $altiga->i_type()
Filters out the results depending on the value of $SNMP::Info::Layer3::Altiga::int_include_vpn
=back
=head1 MUNGES
=over
=item munge_alarm()
Changes C<true> and C<false> to C<FAIL>, C<OK>, and C<(n/a)>.
=back
=cut

View File

@@ -1,324 +0,0 @@
# SNMP::Info::Layer3::Arista
# $Id$
#
# Copyright (c) 2008 Arista Networks, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Arista Networks, Inc. nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Arista;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::MAU;
use SNMP::Info::LLDP;
@SNMP::Info::Layer3::Arista::ISA = qw/SNMP::Info::LLDP SNMP::Info::MAU
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Arista::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS,
%SNMP::Info::LLDP::MIBS,
'ARISTA-PRODUCTS-MIB' => 'aristaProducts',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS,
%SNMP::Info::LLDP::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::MAU::MUNGE,
%SNMP::Info::LLDP::MUNGE,
);
# use MAU-MIB for admin. duplex and admin. speed
*SNMP::Info::Layer3::Arista::i_duplex_admin
= \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer3::Arista::i_speed_admin
= \&SNMP::Info::MAU::mau_i_speed_admin;
sub vendor {
return 'arista';
}
sub os {
return 'EOS';
}
sub os_ver {
my $arista = shift;
my $descr = $arista->description();
my $os_ver = undef;
$os_ver = $1 if ( $descr =~ /\s+EOS\s+version\s+(\S+)\s+/ );
return $os_ver;
}
sub model {
my $arista = shift;
my $id = $arista->id();
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^arista//;
return $model;
}
# Use Q-BRIDGE-MIB
sub fw_mac {
my $arista = shift;
my $partial = shift;
return $arista->qb_fw_mac($partial);
}
sub fw_port {
my $arista = shift;
my $partial = shift;
return $arista->qb_fw_port($partial);
}
# Use LLDP
sub hasCDP {
my $arista = shift;
return $arista->hasLLDP();
}
sub c_ip {
my $arista = shift;
my $partial = shift;
return $arista->lldp_ip($partial);
}
sub c_if {
my $arista = shift;
my $partial = shift;
return $arista->lldp_if($partial);
}
sub c_port {
my $arista = shift;
my $partial = shift;
return $arista->lldp_port($partial);
}
sub c_id {
my $arista = shift;
my $partial = shift;
return $arista->lldp_id($partial);
}
sub c_platform {
my $arista = shift;
my $partial = shift;
return $arista->lldp_rem_sysdesc($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Arista - SNMP Interface to Arista Networks EOS
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $arista = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $arista->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Arista Networks EOS-based devices
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::MAU
=item SNMP::Info::LLDP
=back
=head2 Required MIBs
=over
=item F<ARISTA-PRODUCTS-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::MAU/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar values from SNMP
=over
=item $arista->vendor()
Returns 'Arista Networks, Inc.'
=item $arista->hasCDP()
Returns whether LLDP is enabled.
=item $arista->model()
Tries to reference $arista->id() to one of the product MIBs listed above
Removes 'arista' from the name for readability.
=item $arista->os()
Returns 'EOS'
=item $arista->os_ver()
Grabs the os version from C<sysDescr>
=back
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $arista->fw_mac()
Use the F<Q-BRIDGE-MIB> instead of F<BRIDGE-MIB>
=item $arista->fw_port()
Use the F<Q-BRIDGE-MIB> instead of F<BRIDGE-MIB>
=item $arista->c_id()
Returns LLDP information.
=item $arista->c_if()
Returns LLDP information.
=item $arista->c_ip()
Returns LLDP information.
=item $arista->c_platform()
Returns LLDP information.
=item $arista->c_port()
Returns LLDP information.
=item $arista->i_duplex_admin()
Returns info from F<MAU-MIB>
=item $arista->i_speed_admin()
Returns info from F<MAU-MIB>
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,648 +0,0 @@
# SNMP::Info::Layer3::Aruba
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Aruba;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Aruba::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Aruba::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'WLSX-SWITCH-MIB' => 'wlsxHostname',
'WLSX-WLAN-MIB' => 'wlanAPFQLN',
'WLSR-AP-MIB' => 'wlsrHideSSID',
#'ALCATEL-IND1-TP-DEVICES' => 'familyOmniAccessWireless',
);
%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, );
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
# WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable
# Table index leafs do not return information
# therefore unable to use apBSSID. We extract
# the information from the IID instead.
'aruba_ap_name' => 'apLocation',
'aruba_ap_ip' => 'apIpAddress',
'aruba_ap_essid' => 'apESSID',
'aruba_ap_ssidbcast' => 'wlsrHideSSID',
# WLSX-WLAN-MIB::wlsxWlanAPTable
'aruba_perap_fqln' => 'wlanAPFQLN',
# WLSR-AP-MIB::wlsrConfigTable
'aruba_ap_channel' => 'apCurrentChannel',
# WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable
# Table index leafs do not return information
# therefore unable to use staAccessPointBSSID
# or staPhyAddress. We extract the information from
# the IID instead.
#'fw_port' => 'staAccessPointBSSID',
#'fw_mac' => 'staPhyAddress',
'fw_user' => 'staUserName',
);
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub layers {
return '00000111';
}
sub os {
my $aruba = shift;
my %osmap = (
'alcatel-lucent' => 'aos-w',
);
return $osmap{$aruba->vendor()} || 'airos';
}
sub vendor {
my $aruba = shift;
my $id = $aruba->id() || 'undef';
my %oidmap = (
6486 => 'alcatel-lucent',
);
$id = $1 if (defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/);
if (defined($id) and exists($oidmap{$id})) {
return $oidmap{$id};
}
else {
return 'aruba';
}
}
sub os_ver {
my $aruba = shift;
my $descr = $aruba->description();
return unless defined $descr;
if ( $descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/ ) {
return $1;
}
return;
}
sub model {
my $aruba = shift;
my $id = $aruba->id();
return unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
return $model;
}
# Thin APs do not support ifMIB requirement
#
# We return all BSSIDs as pseudo-ports on the controller.
sub i_index {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->orig_i_index($partial) || {};
my $ap_index = $aruba->aruba_ap_name($partial) || {};
my %if_index;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
$if_index{$iid} = $index;
}
# Get Attached APs as Interfaces
foreach my $ap_id ( keys %$ap_index ) {
# Convert the 0.254.123.456 index entry to a MAC address.
my $mac = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $ap_id ) );
$if_index{$ap_id} = $mac;
}
return \%if_index;
}
sub interfaces {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->i_index($partial) || {};
my $i_descr = $aruba->i_description($partial) || {};
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
if ( $index =~ /^\d+$/ ) {
# Replace the Index with the ifDescr field.
my $port = $i_descr->{$iid};
next unless defined $port;
$if{$iid} = $port;
}
elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
$if{$index} = $index;
}
else {
next;
}
}
return \%if;
}
# Most items are indexed by BSSID.
# aruba_perap_fqln is indexed by AP, so we use the
# [haven't decided yet] index to figure out all of the
# BSSIDs served by a given radio.
sub aruba_ap_fqln {
my $aruba = shift;
# I don't think $partial is meaningful in this context
my $perap_fqln = $aruba->aruba_perap_fqln();
my $channel = $aruba->wlanAPBssidChannel();
my $aruba_ap_fqln = {};
# Channel index is: AP, radio, BSSID
foreach my $idx (keys %$channel) {
my @oid = split(/\./, $idx );
my $ap = join(".", @oid[0..5]);
my $bssid = join(".", @oid[7..12]);
$aruba_ap_fqln->{$bssid} = $perap_fqln->{$ap};
}
return $aruba_ap_fqln;
}
sub i_name {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->i_index($partial) || {};
my $i_name2 = $aruba->orig_i_name($partial) || {};
my $ap_name = $aruba->aruba_ap_name($partial) || {};
my $ap_fqln = $aruba->aruba_ap_fqln($partial) || {};
my %i_name;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
if ( $index =~ /^\d+$/ ) {
my $name = $i_name2->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $name = $ap_fqln->{$iid} || $ap_name->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
else {
next;
}
}
return \%i_name;
}
sub i_ssidlist {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->i_index($partial) || {};
my $ap_ssid = $aruba->aruba_ap_essid($partial) || {};
my %i_ssid;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $ssid = $ap_ssid->{$iid};
next unless defined $ssid;
$i_ssid{$index} = $ssid;
}
else {
next;
}
}
return \%i_ssid;
}
sub i_80211channel {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->i_index($partial) || {};
my $ap_ch = $aruba->aruba_ap_channel($partial) || {};
my %i_ch;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $ch = $ap_ch->{$iid};
next unless defined $ch;
$i_ch{$index} = $ch;
}
else {
next;
}
}
return \%i_ch;
}
sub i_ssidbcast {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->i_index($partial) || {};
my $ap_bc = $aruba->aruba_ap_ssidbcast($partial) || {};
my %i_bc;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $bc = $ap_bc->{$iid};
next unless defined $bc;
$bc = ( $bc ? 0 : 1 );
$i_bc{$index} = $bc;
}
else {
next;
}
}
return \%i_bc;
}
# Wireless switches do not support the standard Bridge MIB
sub bp_index {
my $aruba = shift;
my $partial = shift;
my $i_index = $aruba->orig_i_index($partial) || {};
my $ap_index = $aruba->aruba_ap_name($partial) || {};
my %bp_index;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
$bp_index{$iid} = $index;
}
# Get Attached APs as Interfaces
foreach my $ap_id ( keys %$ap_index ) {
# Convert the 0.254.123.456 index entry to a MAC address.
my $mac = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $ap_id ) );
$bp_index{$mac} = $mac;
}
return \%bp_index;
}
sub fw_port {
my $aruba = shift;
my $partial = shift;
my $fw_idx = $aruba->fw_user($partial) || {};
my %fw_port;
foreach my $iid ( keys %$fw_idx ) {
if ( $iid
=~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/
)
{
my $port = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $2 ) );
$fw_port{$iid} = $port;
}
else {
next;
}
}
return \%fw_port;
}
sub fw_mac {
my $aruba = shift;
my $partial = shift;
my $fw_idx = $aruba->fw_user($partial) || {};
my %fw_mac;
foreach my $iid ( keys %$fw_idx ) {
if ( $iid
=~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/
)
{
my $mac = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $1 ) );
$fw_mac{$iid} = $mac;
}
else {
next;
}
}
return \%fw_mac;
}
# Return the BSSID in i_mac.
sub i_mac {
my $aruba = shift;
my $partial = shift;
# Start with the i_mac entries for the physical ports.
my $i_mac = $aruba->orig_i_mac($partial) || {};
# Add in all the BSSID entries.
my $i_index = $aruba->i_index($partial) || {};
foreach my $iid (keys %$i_index) {
my $index = $i_index->{$iid};
if ($index =~ /:/) {
$i_mac->{$index} = $index;
}
}
return $i_mac;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Aruba - SNMP Interface to Aruba wireless switches
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
my $aruba = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $aruba->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
SNMP::Info::Layer3::Aruba is a subclass of SNMP::Info that provides an
interface to Aruba wireless switches. The Aruba platform utilizes
intelligent wireless switches which control thin access points. The thin
access points themselves are unable to be polled for end station information.
This class emulates bridge functionality for the wireless switch. This enables
end station MAC addresses collection and correlation to the thin access point
the end station is using for communication.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $aruba = new SNMP::Info::Layer3::Aruba(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<WLSX-SWITCH-MIB>
=item F<WLSR-AP-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $aruba->model()
Returns model type. Cross references $aruba->id() with product IDs in the
Aruba MIB.
=item $aruba->vendor()
Returns 'aruba'
=item $aruba->os()
Returns 'airos'
=item $aruba->os_ver()
Returns the software version extracted from C<sysDescr>
=back
=head2 Overrides
=over
=item $aruba->layers()
Returns 00000011. Class emulates Layer 2 functionality for Thin APs through
proprietary MIBs.
=back
=head2 Globals imported from SNMP::Info::Layer3
See L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $aruba->i_index()
Returns reference to map of IIDs to Interface index.
Extends C<ifIndex> to support thin APs as device interfaces.
=item $aruba->interfaces()
Returns reference to map of IIDs to ports. Thin APs are implemented as device
interfaces. The thin AP BSSID is used as the port identifier.
=item $aruba->i_name()
Interface name. Returns (C<ifName>) for Ethernet interfaces and
(C<wlanAPFQLN> or C<apLocation>) for thin AP interfaces.
=item $aruba->i_mac()
Interface MAC address. Returns interface MAC address for Ethernet
interfaces and BSSID for thin AP interfaces.
=item $aruba->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $aruba->fw_port()
(C<staAccessPointBSSID>) as extracted from the IID.
=item $aruba->fw_mac()
(C<staPhyAddress>) as extracted from the IID.
=item $aruba->i_ssidlist()
Returns reference to hash. SSID's recognized by the radio interface.
(C<apESSID>)
=item $aruba->i_ssidbcast()
Returns reference to hash. Indicates whether the SSID is broadcast, true or
false.
(C<wlsrHideSSID>)
=item $aruba->i_80211channel()
Returns reference to hash. Current operating frequency channel of the radio
interface.
(C<apCurrentChannel>)
=item $aruba->aruba_ap_fqln()
Returns F<aruba_perap_fqln> indexed by BSSID instead of by AP.
=back
=head2 Aruba Switch AP Table (C<wlsxSwitchAccessPointTable>)
=over
=item $aruba->aruba_ap_name()
(C<apLocation>)
=item $aruba->aruba_ap_ip()
(C<apIpAddress>)
=item $aruba->aruba_ap_essid()
(C<apESSID>)
=item $aruba->aruba_ap_ssidbcast()
(C<wlsrHideSSID>)
=back
=head2 Aruba AP Table (C<wlsxWlanAPTable>)
=over
=item $aruba->aruba_perap_fqln()
(C<wlanAPFQLN>)
=back
=head2 Aruba Switch Station Management Table (C<wlsxSwitchStationMgmtTable>)
=over
=item $aruba->fw_user()
(C<staUserName>)
=back
=head2 Aruba Wireless AP Configuration Table (C<wlsrConfigTable>)
=over
=item $aruba->aruba_ap_channel()
(C<apCurrentChannel>)
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

File diff suppressed because it is too large Load Diff

View File

@@ -1,118 +1,170 @@
# SNMP::Info::Layer3::C3550
# $Id$
# Max Baker <max@warped.org>
#
# Copyright (c) 2008-2009 Max Baker changes from version 0.8 and beyond.
# Copyright (c) 2004 Regents of the University of California
# Copyright (c) 2003, Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C3550;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CiscoStack;
use SNMP::Info::LLDP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoConfig;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoImage;
use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3;
use SNMP::Info::CiscoStpExtensions;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
# NOTE : Top-most items gets precedence for @ISA
@SNMP::Info::Layer3::C3550::ISA = qw/
SNMP::Info::CiscoVTP
SNMP::Info::CiscoStpExtensions
SNMP::Info::CiscoStack
SNMP::Info::LLDP
SNMP::Info::CDP
SNMP::Info::CiscoStats
SNMP::Info::CiscoImage
SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoConfig
SNMP::Info::CiscoPower
SNMP::Info::Layer3
Exporter/;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/ ;
@SNMP::Info::Layer3::C3550::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::C3550::EXPORT_OK = qw//;
$VERSION = '2.06';
$DEBUG=0;
# NOTE: Order creates precedence
# Example: v_name exists in Bridge.pm and CiscoVTP.pm
# Bridge is called from Layer3 and CiscoStpExtensions
# So we want CiscoVTP to come last to get the right one.
# The @ISA order should match these orders.
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::LLDP::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStack::MIBS, %SNMP::Info::CiscoStpExtensions::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
);
%SNMP::Info::Layer3::MIBS,
'CISCO-STACK-MIB' => 'moduleType',
'CISCO-VTP-MIB' => 'vtpVlanIndex'
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoStpExtensions::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
);
%SNMP::Info::Layer3::GLOBALS,
'ports2' => 'ifNumber',
# these are in CISCO-STACK-MIB
'serial' => 'chassisSerialNumberString',
'ps1_type' => 'chassisPs1Type',
'ps1_status' => 'chassisPs1Status',
'ps2_type' => 'chassisPs2Type',
'ps2_status' => 'chassisPs2Status',
'fan' => 'chassisFanStatus'
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::LLDP::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS, %SNMP::Info::CiscoStpExtensions::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
);
%SNMP::Info::Layer3::FUNCS,
'i_type2' => 'ifType',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
# CISCO-VTP-MIB::VtpVlanEntry
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE, %SNMP::Info::CiscoStpExtensions::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
'm_ports_status' => \&munge_port_status,
'p_duplex_admin' => \&SNMP::Info::munge_bits,
);
%PORTSTAT = (1 => 'other',
2 => 'ok',
3 => 'minorFault',
4 => 'majorFault');
# Changes binary byte describing each port into ascii, and returns
# an ascii list separated by spaces.
sub munge_port_status {
my $status = shift;
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
return join(' ',@vals);
}
# Overidden Methods
sub i_type {
my $c3550 = shift;
my $p_port = $c3550->p_port();
my $p_type = $c3550->p_type();
# Get more generic port types from IF-MIB
my $i_type = $c3550->i_type2();
# Now Override w/ port entries
foreach my $port (keys %$p_type) {
my $iid = $p_port->{$port};
$i_type->{$iid} = $p_type->{$port};
}
return $i_type;
}
sub i_duplex {
my $c3550 = shift;
my $p_port = $c3550->p_port();
my $p_duplex = $c3550->p_duplex();
my %i_duplex;
foreach my $port (keys %$p_duplex) {
my $iid = $p_port->{$port};
$i_duplex{$iid} = $p_duplex->{$port};
}
return \%i_duplex;
}
sub i_duplex_admin {
my $c3550 = shift;
my $p_port = $c3550->p_port();
my $p_duplex_admin = $c3550->p_duplex_admin();
my %i_duplex_admin;
foreach my $port (keys %$p_duplex_admin) {
my $iid = $p_port->{$port};
next unless defined $iid;
my $duplex = $p_duplex_admin->{$port};
next unless defined $duplex;
my $string = 'other';
# see CISCO-STACK-MIB for a description of the bits
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
# we'll call it auto if both full and half are turned on, or if the
# specifically 'auto' flag bit is set.
$string = 'auto'
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
$i_duplex_admin{$iid} = $string;
}
return \%i_duplex_admin;
}
sub vendor {
return 'cisco';
@@ -120,14 +172,11 @@ sub vendor {
sub model {
my $c3550 = shift;
my $id = $c3550->id();
my $model = &SNMP::translateObj($id) || $id;
my $id = $c3550->id();
my $model = &SNMP::translateObj($id);
$model =~ s/^catalyst//;
$model =~ s/(24|48)$//;
# turn 355048 into 3550-48
if ( $model =~ /^(35\d\d)(\d\d(T|G)?)$/ ) {
$model = "$1-$2";
}
return $model;
}
@@ -135,540 +184,182 @@ sub model {
sub ports {
my $c3550 = shift;
my $id = $c3550->id();
my $ports2 = $c3550->ports2();
my $id = $c3550->id();
my $model = &SNMP::translateObj($id);
if ( $model =~ /(12|24|48)(C|T|TS|G|TS-E|TS-S|T-E)?$/ ) {
if ($model =~ /(24|48)$/) {
return $1;
}
my $ports = $c3550->orig_ports();
return $ports;
return $ports2;
}
# Verions prior to 12.1(22)EA1a use the older CiscoStack method
# Newer versions use the ETHERLIKE-MIB to report operational duplex.
# See http://www.ciscosystems.com/en/US/products/hw/switches/ps646/prod_release_note09186a00802a08ee.html
sub i_duplex {
my $c3550 = shift;
my $partial = shift;
my $el_duplex = $c3550->el_duplex($partial);
# Newer software
if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my %i_duplex;
foreach my $el_port ( keys %$el_duplex ) {
my $duplex = $el_duplex->{$el_port};
next unless defined $duplex;
$i_duplex{$el_port} = 'half' if $duplex =~ /half/i;
$i_duplex{$el_port} = 'full' if $duplex =~ /full/i;
}
return \%i_duplex;
}
# Fall back to CiscoStack method
else {
return $c3550->SUPER::i_duplex($partial);
}
}
# Software >= 12.1(22)EA1a uses portDuplex as admin setting
sub i_duplex_admin {
my $c3550 = shift;
my $partial = shift;
my $el_duplex = $c3550->el_duplex($partial);
# Newer software
if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c3550->p_port() || {};
my $p_duplex = $c3550->p_duplex() || {};
my $i_duplex_admin = {};
foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port};
next unless defined $iid;
next if ( defined $partial and $iid !~ /^$partial$/ );
$i_duplex_admin->{$iid} = $p_duplex->{$port};
}
return $i_duplex_admin;
}
# Fall back to CiscoStack method
else {
return $c3550->SUPER::i_duplex_admin($partial);
}
}
sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/;
my $c3550 = shift;
my ( $duplex, $iid ) = @_;
my $el_duplex = $c3550->el_duplex($iid);
# Auto duplex only supported on newer software
if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c3550->p_port() || {};
my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex};
$iid = $reverse_p_port{$iid};
return $c3550->set_p_duplex( $duplexes{$duplex}, $iid );
}
else {
return $c3550->SUPER::set_i_duplex_admin;
}
}
sub cisco_comm_indexing {
return 1;
}
# Use CDP and/or LLDP
sub hasCDP {
my $c3550 = shift;
return $c3550->hasLLDP() || $c3550->SUPER::hasCDP();
}
sub c_ip {
my $c3550 = shift;
my $partial = shift;
my $cdp = $c3550->SUPER::c_ip($partial) || {};
my $lldp = $c3550->lldp_ip($partial) || {};
my %c_ip;
foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
return \%c_ip;
}
sub c_if {
my $c3550 = shift;
my $partial = shift;
my $cdp = $c3550->SUPER::c_if($partial) || {};
my %c_if;
foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
# We need to match the lldp key with the ifIndex
# via lldpLocPortId and ifName
my $i_name = $c3550->ifName($partial) || {};
my $i_name_rev = {};
while ( my($key,$val) = each %$i_name ){
$i_name_rev->{$val} = $key;
}
my $loc_port_id = $c3550->lldpLocPortId($partial) || {};
my $lldp = $c3550->lldp_if($partial) || {};
foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid} || next;
my $name = $loc_port_id->{$if} || next;
my $i_index = $i_name_rev->{$name} || next;
$c_if{$iid} = $i_index;
}
return \%c_if;
}
sub c_port {
my $c3550 = shift;
my $partial = shift;
my $lldp = $c3550->lldp_port($partial) || {};
my $cdp = $c3550->SUPER::c_port($partial) || {};
my %c_port;
foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
return \%c_port;
}
sub c_id {
my $c3550 = shift;
my $partial = shift;
my $lldp = $c3550->lldp_id($partial) || {};
my $cdp = $c3550->SUPER::c_id($partial) || {};
my %c_id;
foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
return \%c_id;
}
sub c_platform {
my $c3550 = shift;
my $partial = shift;
my $lldp = $c3550->lldp_rem_sysdesc($partial) || {};
my $cdp = $c3550->SUPER::c_platform($partial) || {};
my %c_platform;
foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
return \%c_platform;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::C3550 - SNMP Interface to Cisco Catalyst 3550 Layer 2/3
Switches running IOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c3550 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c3550->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
SNMP::Info::Layer3::C3550 - Perl5 Interface to Cisco Catalyst 3550 Layer 2/3 Switches running IOS
=head1 DESCRIPTION
Abstraction subclass for Cisco Catalyst 3550 Layer 2/3 Switches.
Abstraction subclass for Cisco Catalyst 3550 Layer 2/3 Switches. These devices run
IOS but have some of the same charactersitics as the Catalyst WS-C family (5xxx,6xxx).
For example, forwarding tables are held in VLANs, and extened interface information
is gleened from CISCO-SWITCH-MIB.
These devices run IOS but have some of the same characteristics as the
Catalyst WS-C family (5xxx,6xxx). For example, forwarding tables are held in
VLANs, and extended interface information is gleaned from F<CISCO-SWITCH-MIB>.
=head1 AUTHOR
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
Max Baker (C<max@warped.org>)
my $c3550 = new SNMP::Info::Layer3::C3550(...);
=head1 SYNOPSIS
=head2 Inherited Classes
my $c3550 = new SNMP::Info::Layer3::C3550(DestHost => 'router' ,
Community => 'public' );
See L<SNMP::Info> and L<SNMP::Info::Layer3> for all the inherited methods.
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::Layer3
=item new SNMP::Info::Layer3::C3550()
=item SNMP::Info::CiscoSTPExtensions
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::CiscoPower
=item SNMP::Info::CiscoPortSecurity
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
=item SNMP::Info::CDP
=item SNMP::Info::LLDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
my $c3550 = new SNMP::Info::Layer3::C3550(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $c3550;
=back
=head2 Required MIBs
=head1 GLOBAL Values
=over
=item Inherited Classes' MIBs
=item $c3550->serial()
(B<chassisSerialNumberString>)
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=item $c3550->model()
(B<chassisModel>)
See L<SNMP::Info::CiscoStpExtensions/"Required MIBs"> for its own MIB requirements.
=item $c3550->ps1_type()
(B<chassisPs1Type>)
See L<SNMP::Info::CiscoPower/"Required MIBs"> for its own MIB requirements.
=item $c3550->ps2_type()
(B<chassisPs2Type>)
See L<SNMP::Info::CiscoPortSecurity/"Required MIBs"> for its own MIB
requirements.
=item $c3550->ps1_status()
(B<chassisPs1Status>)
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
=item $c3550->ps2_status()
(B<chassisPs2Status>)
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.
=item $c3550->slots()
(B<chassisNumSlots>)
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $c3550->fan()
(B<chassisFanStatus>)
=item $c3550->vendor()
Returns 'cisco'
=item $c3550->model()
Will take the translated model number and try to format it better.
355048 -> 3550-48
355012G -> 3550-12G
=item $c3550->ports()
Tries to cull the number of ports from the model number.
=item $c3550->cisco_comm_indexing()
Returns 1. Use vlan indexing.
Returns 'cisco'
=back
=head2 Topology information
Based upon the firmware version Cisco devices may support Link Layer Discovery
Protocol (LLDP) in addition to Cisco Discovery Protocol (CDP). These methods
will query both and return the combination of all information. As a result,
there may be identical topology information returned from the two protocols
causing duplicate entries. It is the calling program's responsibility to
identify any duplicate entries and remove duplicates if necessary.
=over
=item $c3550->hasCDP()
Returns true if the device is running either CDP or LLDP.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStpExtensions
See documentation in L<SNMP::Info::CiscoStpExtensions/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoPower
See documentation in L<SNMP::Info::CiscoPower/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in L<SNMP::Info::CiscoStack/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $c3550->c_if()
Returns reference to hash. Key: iid Value: local device port (interfaces)
=item $c3550->c_ip()
Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different
IPv4 addresses, c_ip(), there is either a non-CDP/LLDP device in between two
or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $c3550->c_port()
Returns reference to hash. Key: iid Value: remote port (interfaces)
=item $c3550->c_id()
Returns reference to hash. Key: iid Value: string value used to identify the
chassis component associated with the remote system.
=item $c3550->c_platform()
Returns reference to hash. Key: iid Value: Remote Device Type
=back
=head1 TABLE ENTRIES
=head2 Overrides
=over
=item $c3550->i_type()
Crosses p_port() with p_type() and returns the results.
Overrides with ifType if p_type() isn't available.
=item $c3550->i_name()
Crosses p_name with p_port and returns results.
=item $c3550->i_duplex()
Returns reference to hash of iid to current link duplex setting.
Software version 12.1(22)EA1a or greater returns duplex based upon the
result of $c3550->el_duplex(). Otherwise it uses the result of
the call to CiscoStack::i_duplex().
See L<SNMP::Info::Etherlike> for el_duplex() method and
L<SNMP::Info::CiscoStack> for its i_duplex() method.
Crosses p_duplex with p_port and returns results.
=item $c3550->i_duplex_admin()
Returns reference to hash of iid to administrative duplex setting.
Crosses p_duplex_admin with p_port.
Software version 12.1(22)EA1a or greater returns duplex based upon the
result of $c3550->p_duplex(). Otherwise it uses the result of
the call to CiscoStack::i_duplex().
See L<SNMP::Info::CiscoStack> for its i_duplex() and p_duplex() methods.
=item $c3550->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port C<ifIndex>.
Speed choices are 'auto', 'half', 'full'.
Crosses $c3550->p_port() with $c3550->p_duplex() to utilize port C<ifIndex>.
Example:
my %if_map = reverse %{$c3550->interfaces()};
$c3550->set_i_duplex_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port duplex. ",$c3550->error(1);
Munges bit_string returned from p_duplex_admin to get duplex settings.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=over
=head2 Table Methods imported from SNMP::Info::CiscoStpExtensions
=item $c3550->p_name()
(B<portName>)
See documentation in L<SNMP::Info::CiscoStpExtensions/"TABLE METHODS"> for details.
=item $c3550->p_type()
(B<portType>)
=head2 Table Methods imported from SNMP::Info::CiscoPower
=item $c3550->p_status()
(B<portOperStatus>)
See documentation in L<SNMP::Info::CiscoPower/"TABLE METHODS"> for details.
=item $c3550->p_status2()
(B<portAdditionalStatus>)
=head2 Table Methods imported from SNMP::Info::CiscoPortSecurity
=item $c3550->p_speed()
(B<portAdminSpeed>)
See documentation in L<SNMP::Info::CiscoPortSecurity/"TABLE METHODS"> for
details.
=item $c3550->p_duplex()
(B<portDuplex>)
=head2 Table Methods imported from SNMP::Info::CiscoVTP
=item $c3550->p_port()
(B<portIfIndex>)
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=back
=head2 Table Methods imported from SNMP::Info::CiscoStack
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
See documentation in L<SNMP::Info::CiscoStack/"TABLE METHODS"> for details.
=over
=head2 Table Methods imported from SNMP::Info::CDP
=item $c3550->p_speed_admin()
(B<portCpbSpeed>)
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=item $c3550->p_duplex_admin()
(B<portCpbDuplex>)
=head2 Table Methods imported from SNMP::Info::LLDP
=back
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=head2 VLAN Entry Table
=head2 Table Methods imported from SNMP::Info::CiscoStats
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
for a good treaty of how to connect to the VLANs
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
=over
See documentation in L<SNMP::Info::CiscoImage/"TABLE METHODS"> for details.
=item $c3550->v_state()
(B<vtpVlanState>)
=item $c3550->v_type()
(B<vtpVlanType>)
=item $c3550->v_name()
(B<vtpVlanName>)
=item $c3550->v_mtu()
(B<vtpVlanMtu>)
=back
=cut

View File

@@ -1,319 +0,0 @@
# SNMP::Info::Layer3::C4000
# $Id$
#
# Copyright (c) 2008 Bill Fenner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C4000;
use strict;
use Exporter;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoImage;
use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::CiscoConfig;
use SNMP::Info::MAU;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::C4000::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoImage
SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoConfig SNMP::Info::MAU
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::C4000::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS,
%SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
'CISCO-ENVMON-MIB' => 'ciscoEnvMonMIB',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
'ps1_type' => 'ciscoEnvMonSupplyStatusDescr.1',
'ps1_status' => 'ciscoEnvMonSupplyState.1',
'ps2_type' => 'ciscoEnvMonSupplyStatusDescr.2',
'ps2_status' => 'ciscoEnvMonSupplyState.2',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
'fan_state' => 'ciscoEnvMonFanState',
'fan_descr' => 'ciscoEnvMonFanStatusDescr',
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::MAU::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
);
# Override Inheritance for these specific methods
# use MAU-MIB for admin. duplex and admin. speed
*SNMP::Info::Layer3::C4000::i_duplex_admin
= \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer3::C4000::i_speed_admin
= \&SNMP::Info::MAU::mau_i_speed_admin;
sub fan {
my $c4000 = shift;
my $fan_state = $c4000->fan_state();
my $fan_descr = $c4000->fan_descr();
my $ret = "";
my $s = "";
foreach my $i ( sort { $a <=> $b } keys %$fan_state ) {
$ret .= $s . $fan_descr->{$i} . ": " . $fan_state->{$i};
$s = ", ";
}
return if ( $s eq "" );
return $ret;
}
sub cisco_comm_indexing { return 1; }
1;
__END__
=head1 NAME
SNMP::Info::Layer3::C4000 - SNMP Interface to Cisco Catalyst 4000 Layer 2/3
Switches running IOS
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c4000 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c4000->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Cisco Catalyst 4000 Layer 2/3 Switches.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $c4000 = new SNMP::Info::Layer3::C4000(...);
=head2 Inherited Classes
=over
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
=item SNMP::Info::CiscoPortSecurity
=item SNMP::Info::CiscoConfig
=item SNMP::Info::MAU
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoPortSecurity/"Required MIBs"> for its own MIB
requirements.
See L<SNMP::Info::CiscoConfig/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::MAU/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $c4000->cisco_comm_indexing()
Returns 1. Use vlan indexing.
=item $c4000->fan()
Returns fan status
=back
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $c4000->i_duplex()
Parses mau_index and mau_link to return the duplex information for
interfaces.
=item $c4000->i_duplex_admin()
Parses C<mac_index>,C<mau_autostat>,C<mau_type_admin> in
order to find the admin duplex setting for all the interfaces.
Returns either (auto,full,half).
=item $c4000->i_speed_admin()
Returns administrative speed for interfaces.
=back
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"TABLE METHODS"> for
details.
=head2 Table Methods imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,444 +0,0 @@
# SNMP::Info::Layer3::C6500
# $Id$
#
# Copyright (c) 2008-2009 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C6500;
use strict;
use Exporter;
use SNMP::Info::CiscoStack;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoImage;
use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::CiscoConfig;
use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3;
use SNMP::Info::CiscoStpExtensions;
use SNMP::Info::CiscoVTP;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
# NOTE : Top-most items gets precedence for @ISA
@SNMP::Info::Layer3::C6500::ISA = qw/
SNMP::Info::CiscoVTP
SNMP::Info::CiscoStpExtensions
SNMP::Info::CiscoStack
SNMP::Info::CDP
SNMP::Info::CiscoImage
SNMP::Info::CiscoStats
SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoConfig
SNMP::Info::CiscoPower
SNMP::Info::Layer3
Exporter
/;
@SNMP::Info::Layer3::C6500::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
# NOTE: Order creates precedence
# Example: v_name exists in Bridge.pm and CiscoVTP.pm
# Bridge is called from Layer3 and CiscoStpExtensions
# So we want CiscoVTP to come last to get the right one.
# The @ISA order should match these orders.
%MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoStpExtensions::MIBS, %SNMP::Info::CiscoVTP::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoStpExtensions::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoStpExtensions::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CiscoStpExtensions::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
);
sub vendor {
return 'cisco';
}
sub cisco_comm_indexing { return 1; }
# Newer versions use the ETHERLIKE-MIB to report operational duplex.
sub i_duplex {
my $c6500 = shift;
my $partial = shift;
my $el_duplex = $c6500->el_duplex($partial);
# Newer software
if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my %i_duplex;
foreach my $el_port ( keys %$el_duplex ) {
my $duplex = $el_duplex->{$el_port};
next unless defined $duplex;
$i_duplex{$el_port} = 'half' if $duplex =~ /half/i;
$i_duplex{$el_port} = 'full' if $duplex =~ /full/i;
}
return \%i_duplex;
}
# Fall back to CiscoStack method
else {
return $c6500->SUPER::i_duplex($partial);
}
}
# Newer software uses portDuplex as admin setting
sub i_duplex_admin {
my $c6500 = shift;
my $partial = shift;
my $el_duplex = $c6500->el_duplex($partial);
# Newer software
if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c6500->p_port() || {};
my $p_duplex = $c6500->p_duplex() || {};
my $i_duplex_admin = {};
foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port};
next unless defined $iid;
next if ( defined $partial and $iid !~ /^$partial$/ );
$i_duplex_admin->{$iid} = $p_duplex->{$port};
}
return $i_duplex_admin;
}
# Fall back to CiscoStack method
else {
return $c6500->SUPER::i_duplex_admin($partial);
}
}
sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/;
my $c6500 = shift;
my ( $duplex, $iid ) = @_;
my $el_duplex = $c6500->el_duplex($iid);
# Auto duplex only supported on newer software
if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c6500->p_port() || {};
my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex};
$iid = $reverse_p_port{$iid};
return $c6500->set_p_duplex( $duplexes{$duplex}, $iid );
}
else {
return $c6500->SUPER::set_i_duplex_admin;
}
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::C6500 - SNMP Interface to Cisco Catalyst 6500 Layer 2/3
Switches running IOS and/or CatOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c6500 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c6500->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches.
These devices run IOS but have some of the same characteristics as the
Catalyst WS-C family (5xxx). For example, forwarding tables are held in
VLANs, and extended interface information is gleaned from F<CISCO-SWITCH-MIB>.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $c6500 = new SNMP::Info::Layer3::C6500(...);
=head2 Inherited Classes
=over
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
=item SNMP::Info::CiscoPortSecurity
=item SNMP::Info::CiscoConfig
=item SNMP::Info::CiscoPower
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoStpExtensions
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoPortSecurity/"Required MIBs"> for its own MIB
requirements.
See L<SNMP::Info::CiscoConfig/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoPower/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStpExtensions/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $c6500->vendor()
Returns 'cisco'
=item $c6500->cisco_comm_indexing()
Returns 1. Use vlan indexing.
=back
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in L<SNMP::Info::CiscoStack/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoPower
See documentation in L<SNMP::Info::CiscoPower/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStpExtensions
See documentation in L<SNMP::Info::CiscoStpExtensions/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $c6500->i_duplex()
Returns reference to hash of iid to current link duplex setting.
Newer software versions return duplex based upon the result of
$c6500->el_duplex(). Otherwise it uses the result of the call to
CiscoStack::i_duplex().
See L<SNMP::Info::Etherlike> for el_duplex() method and
L<SNMP::Info::CiscoStack> for its i_duplex() method.
=item $c6500->i_duplex_admin()
Returns reference to hash of iid to administrative duplex setting.
Newer software versions return duplex based upon the result of
$c6500->p_duplex(). Otherwise it uses the result of the call to
CiscoStack::i_duplex().
See L<SNMP::Info::CiscoStack> for its i_duplex() and p_duplex() methods.
=item $c6500->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port C<ifIndex>.
Speed choices are 'auto', 'half', 'full'.
Crosses $c6500->p_port() with $c6500->p_duplex() to utilize port C<ifIndex>.
Example:
my %if_map = reverse %{$c6500->interfaces()};
$c6500->set_i_duplex_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port duplex. ",$c6500->error(1);
=back
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStack
See documentation in L<SNMP::Info::CiscoStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"TABLE METHODS"> for
details.
=head2 Table Methods imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoPower
See documentation in L<SNMP::Info::CiscoPower/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStpExtensions
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
See documentation in L<SNMP::Info::CiscoStpExtensions/"TABLE METHODS"> for details.
=cut

View File

@@ -1,315 +0,0 @@
# SNMP::Info::Layer3::Cisco
# $Id$
#
# Copyright (c) 2008 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Cisco;
use strict;
use Exporter;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoImage;
use SNMP::Info::CiscoRTT;
use SNMP::Info::CiscoQOS;
use SNMP::Info::CiscoConfig;
use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoImage
SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS
SNMP::Info::CiscoConfig SNMP::Info::CiscoPower
SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::Cisco::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoQOS::MIBS,
%SNMP::Info::CiscoRTT::MIBS,
%SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
'CISCO-EIGRP-MIB' => 'cEigrpAsRouterId',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoQOS::GLOBALS,
%SNMP::Info::CiscoRTT::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS, 'eigrp_id' => 'cEigrpAsRouterId',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoQOS::FUNCS,
%SNMP::Info::CiscoRTT::FUNCS,
%SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
# EIGRP
'eigrp_peers' => 'cEigrpPeerAddr',
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoQOS::MUNGE,
%SNMP::Info::CiscoRTT::MUNGE,
%SNMP::Info::CiscoImage::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
'eigrp_peers' => \&SNMP::Info::munge_ip,
);
sub i_vlan {
my ($cisco) = shift;
my ($partial) = shift;
my ($i_type) = $cisco->i_type($partial);
my ($i_descr) = $cisco->i_description($partial);
my %i_vlan;
foreach my $idx ( keys %$i_descr ) {
if ( $i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135 ) {
if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) {
$i_vlan{$idx} = $1;
}
}
}
return \%i_vlan;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Cisco - SNMP Interface to L3 and L2+L3 IOS Cisco Device
that are not covered in other classes.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $cisco = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $cisco->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Cisco Routers running IOS
=head2 Inherited Classes
=over
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
=item SNMP::Info::CiscoRTT
=item SNMP::Info::CiscoQOS
=item SNMP::Info::CiscoConfig
=item SNMP::Info::Power
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<CISCO-EIGRP-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoRTT/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoQOS/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoConfig/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::CiscoPower/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $cisco->vendor()
Returns 'cisco'
=item $cisco->eigrp_id()
(C<cEigrpAsRouterId>)
=back
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoRTT
See documentation in L<SNMP::Info::CiscoRTT/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoQOS
See documentation in L<SNMP::Info::CiscoQOS/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoPower
See documentation in L<SNMP::Info::CiscoPower/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $cisco->eigrp_peers()
Returns EIGRP peer IP addresses
(C<cEigrpPeerAddr>)
=item $cisco->i_vlan()
Returns a mapping between C<ifIndex> and the PVID or default VLAN.
=back
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in L<SNMP::Info::CiscoImage/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoRTT
See documentation in L<SNMP::Info::CiscoRTT/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoQOS
See documentation in L<SNMP::Info::CiscoQOS/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoConfig
See documentation in L<SNMP::Info::CiscoConfig/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoPower
See documentation in L<SNMP::Info::CiscoPower/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,223 +0,0 @@
# SNMP::Info::Layer3::CiscoFWSM
# $Id$
#
# Copyright (c) 2010 Brian De Wolf
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::CiscoFWSM;
use strict;
use Exporter;
use SNMP::Info::Layer3::Cisco;
@SNMP::Info::Layer3::CiscoFWSM::ISA = qw/SNMP::Info::Layer3::Cisco
Exporter/;
@SNMP::Info::Layer3::CiscoFWSM::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::Cisco::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::Cisco::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::Cisco::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::Cisco::MUNGE,
);
# For FWSMs, the ipNetToPhysicalPhysAddress table appears to be of the form:
# $ifindex.$inetaddresstype.$proto.$ip_address -> $mac_address
#
# Using the output of ipNetToPhysicalPhysAddress, we can emulate the other
# functions.
#
# This doesn't really line up to what at_* return, so we munge it
sub at_paddr {
my ($fwsm) = shift;
my ($partial) = shift;
my $paddrs = $fwsm->n2p_paddr($partial);
my $n_paddrs = {};
foreach my $key (keys %$paddrs) {
my $paddr = $paddrs->{$key};
my @parts = split /\./, $key;
my ($ifindex, $addrtype, $proto) = splice @parts, 0, 3;
my $ip = join ".", @parts;
next if($proto != 4); # at_paddr doesn't support non-IPv4
$n_paddrs->{"$ifindex.$ip"} = $paddr;
}
return $n_paddrs;
}
sub at_netaddr {
my ($fwsm) = shift;
my ($partial) = shift;
my $paddrs = $fwsm->n2p_paddr($partial);
my $netaddrs = {};
foreach my $key (keys %$paddrs) {
my $paddr = $paddrs->{$key};
my @parts = split /\./, $key;
my ($ifindex, $addrtype, $proto) = splice @parts, 0, 3;
my $ip = join ".", @parts;
next if($proto != 4); # at_netaddr doesn't support non-IPv4
$netaddrs->{"$ifindex.$ip"} = $ip;
}
return $netaddrs;
}
sub at_ifaddr {
my ($fwsm) = shift;
my ($partial) = shift;
my $paddrs = $fwsm->n2p_paddr($partial);
my $ifaddrs = {};
foreach my $key (keys %$paddrs) {
my $paddr = $paddrs->{$key};
my @parts = split /\./, $key;
my ($ifindex, $addrtype, $proto) = splice @parts, 0, 3;
my $ip = join ".", @parts;
next if($proto != 4); # at_ifaddr doesn't support non-IPv4
$ifaddrs->{"$ifindex.$ip"} = $ip;
}
return $ifaddrs;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::CiscoFWSM - SNMP Interface to Firewall Services Modules for
features not covered elsewhere.
=head1 AUTHOR
Brian De Wolf
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $fwsm = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $fwsm->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Cisco Firewall Services Modules
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3::Cisco
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3::Cisco/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
=head2 Global Methods imported from SNMP::Info::Layer3::Cisco
See documentation in L<SNMP::Info::Layer3::Cisco/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=back
=head2 Overrides
=over
=item $fwsm->at_paddr()
This function derives the at_paddr information from the n2p_paddr() table as
the MIB to provide that information isn't supported on FWSMs.
=item $fwsm->at_netaddr()
This function derives the at_netaddr information from the n2p_paddr() table as
the MIB to provide that information isn't supported on FWSMs.
=item $fwsm->at_ifaddr()
This function derives the at_ifaddr information from the n2p_paddr() table as
the MIB to provide that information isn't supported on FWSMs.
=back
=head2 Table Methods imported from SNMP::Info::Layer3::Cisco
See documentation in L<SNMP::Info::Layer3::Cisco/"TABLE METHODS"> for details.
=cut

View File

@@ -1,313 +0,0 @@
# SNMP::Info::Layer3::Contivity
# $Id$
#
# Copyright (c) 2010 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Contivity;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Layer3;
use SNMP::Info::Entity;
@SNMP::Info::Layer3::Contivity::ISA
= qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::Entity::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::Entity::FUNCS,
);
%MUNGE = (
%SNMP::Info::MUNGE, %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::Entity::MUNGE,
);
sub layers {
return '00000100';
}
sub vendor {
return 'nortel';
}
sub model {
my $contivity = shift;
my $e_model = $contivity->e_model() || {};
my $model = $e_model->{1} || undef;
return $1 if ( defined $model and $model =~ /(CES\d+|NVR\d+)/i );
return;
}
sub os {
return 'contivity';
}
sub os_ver {
my $contivity = shift;
my $descr = $contivity->description();
return unless defined $descr;
if ( $descr =~ m/V(\d+_\d+\.\d+)/i ) {
return $1;
}
return;
}
sub mac {
my $contivity = shift;
my $i_mac = $contivity->i_mac();
# Return Interface MAC
foreach my $entry ( keys %$i_mac ) {
my $sn = $i_mac->{$entry};
next unless $sn;
return $sn;
}
return;
}
sub serial {
my $contivity = shift;
my $e_serial = $contivity->e_serial() || {};
my $serial = $e_serial->{1} || undef;
return $1 if ( defined $serial and $serial =~ /(\d+)/ );
return;
}
sub interfaces {
my $contivity = shift;
my $partial = shift;
my $description = $contivity->i_description($partial) || {};
my %interfaces = ();
foreach my $iid ( keys %$description ) {
my $desc = $description->{$iid};
# Skip everything except Ethernet interfaces
next unless ( defined $desc and $desc =~ /fe/i );
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_name {
my $contivity = shift;
my $partial = shift;
my $i_name2 = $contivity->orig_i_name($partial) || {};
my %i_name;
foreach my $iid ( keys %$i_name2 ) {
my $name = $i_name2->{$iid};
#Skip everything except Ethernet interfaces
next unless ( defined $name and $name =~ /fe/i );
$name = $1 if $name =~ /(fei\.\d+\.\d+)/;
$i_name{$iid} = $name;
}
return \%i_name;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Contivity - SNMP Interface to Nortel VPN Routers
(Contivity Extranet Switches).
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $contivity = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $contivity->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Nortel VPN Routers (Contivity Extranet Switch).
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $contivity = new SNMP::Info::Layer3::Contivity(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Layer3
=item SNMP::Info::Entity
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Entity/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $contivity->vendor()
Returns 'Nortel'
=item $contivity->model()
Returns the chassis name.
(C<entPhysicalModelName.1>)
=item $contivity->os()
Returns C<'CES'>
=item $contivity->os_ver()
Returns the software version extracted from (C<sysDescr>).
=item $contivity->serial()
Returns the chassis serial number.
(C<entPhysicalSerialNum.1>)
=item $contivity->mac()
Returns the MAC address of the first Ethernet Interface.
=back
=head2 Overrides
=over
=item $contivity->layers()
Returns 00000100. Contivity does not support bridge MIB, so override reported
layers.
=back
=head2 Globals imported from SNMP::Info
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $contivity->interfaces()
Returns reference to the map between IID and physical Port. Skips loopback
and tunnel interfaces.
=item $contivity->i_name()
Interface Name field. Skips loopback and tunnel interfaces.
=back
=head2 Table Methods imported from SNMP::Info
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=cut

View File

@@ -1,424 +0,0 @@
# SNMP::Info::Layer3::Dell - SNMP Interface to Dell devices
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Dell;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Dell::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'RADLAN-Physicaldescription-MIB' => 'rlPhdStackReorder',
'RADLAN-rlInterfaces' => 'rlIfNumOfLoopbackPorts',
'RADLAN-HWENVIROMENT' => 'rlEnvPhysicalDescription',
'Dell-Vendor-MIB' => 'productIdentificationVersion',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'os_ver' => 'productIdentificationVersion',
'dell_id_name' => 'productIdentificationDisplayName',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
# RADLAN-rlInterfaces:swIfTable
'dell_duplex_admin' => 'swIfDuplexAdminMode',
'dell_duplex' => 'swIfDuplexOperMode',
'dell_tag_mode' => 'swIfTaggedMode',
'dell_i_type' => 'swIfType',
'dell_fc_admin' => 'swIfFlowControlMode',
'dell_speed_admin' => 'swIfSpeedAdminMode',
'dell_auto' => 'swIfSpeedDuplexAutoNegotiation',
'dell_fc' => 'swIfOperFlowControlMode',
# RADLAN-Physicaldescription-MIB:rlPhdUnitGenParamTable
'dell_unit' => 'rlPhdUnitGenParamStackUnit',
'dell_sw_ver' => 'rlPhdUnitGenParamSoftwareVersion',
'dell_fw_ver' => 'rlPhdUnitGenParamFirmwareVersion',
'dell_hw_ver' => 'rlPhdUnitGenParamHardwareVersion',
'dell_serial_no' => 'rlPhdUnitGenParamSerialNum',
'dell_asset_no' => 'rlPhdUnitGenParamAssetTag',
# RADLAN-COPY-MIB:rlCopyTable
'dell_cp_idx' => 'rlCopyIndex',
'dell_cp_sloc' => 'rlCopySourceLocation',
'dell_cp_sip' => 'rlCopySourceIpAddress',
'dell_cp_sunit' => 'rlCopySourceUnitNumber',
'dell_cp_sfile' => 'rlCopySourceFileName',
'dell_cp_stype' => 'rlCopySourceFileType',
'dell_cp_dloc' => 'rlCopyDestinationLocation',
'dell_cp_dip' => 'rlCopyDestinationIpAddress',
'dell_cp_dunit' => 'rlCopyDestinationUnitNumber',
'dell_cp_dfile' => 'rlCopyDestinationFileName',
'dell_cp_dtype' => 'rlCopyDestinationFileType',
'dell_cp_state' => 'rlCopyOperationState',
'dell_cp_bkgnd' => 'rlCopyInBackground',
'dell_cp_rstatus' => 'rlCopyRowStatus',
# RADLAN-HWENVIROMENT:rlEnvMonSupplyStatusTable
'dell_pwr_src' => 'rlEnvMonSupplySource',
'dell_pwr_state' => 'rlEnvMonSupplyState',
'dell_pwr_desc' => 'rlEnvMonSupplyStatusDescr',
# RADLAN-HWENVIROMENT:rlEnvMonFanStatusTable
'dell_fan_state' => 'rlEnvMonFanState',
'dell_fan_desc' => 'rlEnvMonFanStatusDescr',
);
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
# Method OverRides
sub model {
my $dell = shift;
my $name = $dell->dell_id_name();
my $descr = $dell->description();
if ( defined $name and $name =~ m/(\d+)/ ) {
return $1;
}
# Don't have a vendor MIB for D-Link
else {
return $descr;
}
}
sub vendor {
my $dell = shift;
return $dell->_vendor();
}
sub os {
my $dell = shift;
return $dell->_vendor();
}
sub serial {
my $dell = shift;
my $numbers = $dell->dell_serial_no();
foreach my $key ( keys %$numbers ) {
my $serial = $numbers->{$key};
return $serial if ( defined $serial and $serial !~ /^\s*$/ );
next;
}
# Last resort
return $dell->SUPER::serial();
}
sub interfaces {
my $dell = shift;
my $partial = shift;
my $i_descr = $dell->i_description($partial) || {};
my $i_name = $dell->orig_i_name($partial) || {};
# Descriptions are all the same on some Dells, so use name instead if
# available
foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid};
next unless defined $name;
$i_descr->{$iid} = $name;
}
return $i_descr;
}
sub i_duplex_admin {
my $dell = shift;
my $partial = shift;
my $interfaces = $dell->interfaces($partial) || {};
my $dell_duplex = $dell->dell_duplex_admin($partial) || {};
my $dell_auto = $dell->dell_auto($partial) || {};
my %i_duplex_admin;
foreach my $if ( keys %$interfaces ) {
my $duplex = $dell_duplex->{$if};
next unless defined $duplex;
my $auto = $dell_auto->{$if} || 'false';
$duplex = 'half' if ( $duplex =~ /half/i and $auto =~ /false/i );
$duplex = 'full' if ( $duplex =~ /half/i and $auto =~ /false/i );
$duplex = 'auto' if $auto =~ /true/i;
$i_duplex_admin{$if} = $duplex;
}
return \%i_duplex_admin;
}
# Use same methods as netgear. Some device didn't implement the bridge MIB
# forwarding table and some don't return MACs for VLANs other than default yet
# don't support community indexing, so we use the Q-BRIDGE-MIB forwarding
# table. Fall back to the orig functions if the qb versions don't
# return anything.
sub fw_mac {
my $dell = shift;
my $ret = $dell->qb_fw_mac();
$ret = $dell->orig_fw_mac() if ( !defined($ret) );
return $ret;
}
sub fw_port {
my $dell = shift;
my $ret = $dell->qb_fw_port();
$ret = $dell->orig_fw_port() if ( !defined($ret) );
return $ret;
}
sub _vendor {
my $dell = shift;
my $id = $dell->id() || 'undef';
my %oidmap = (
2 => 'ibm',
171 => 'dlink',
674 => 'dell',
3955 => 'linksys',
);
$id = $1 if ( defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/ );
if ( defined($id) and exists( $oidmap{$id} ) ) {
return $oidmap{$id};
}
else {
return 'dlink';
}
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Dell - SNMP Interface to Dell Power Connect Network
Devices
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $dell = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $dell->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from an
Dell Power Connect device through SNMP. D-Link and the IBM BladeCenter
Gigabit Ethernet Switch Module also use this module based upon MIB support.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $dell = new SNMP::Info::Layer3::Dell(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<Dell-Vendor-MIB>
=item F<RADLAN-Physicaldescription-MIB>
=item F<RADLAN-rlInterfaces>
=item F<RADLAN-HWENVIROMENT>
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $dell->os_ver()
(C<productIdentificationVersion>)
=item $dell->dell_id_name()
(C<productIdentificationDisplayName>)
=item $dell->model()
Returns model type. Returns numeric from
(C<productIdentificationDisplayName>) if available, otherwise if returns
description().
=item $dell->vendor()
Returns 'dell', 'dlink', or 'ibm' based upon the IANA enterprise number in
id(). Defaults to 'dlink'.
=item $dell->os()
Returns 'dell', 'dlink', or 'ibm' based upon the IANA enterprise number in
id(). Defaults to 'dlink'.
=back
=head2 Overrides
=over
=item $dell->serial()
Returns serial number. Returns (C<rlPhdUnitGenParamSerialNum>) if available,
otherwise uses the Layer3 serial method.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 RADLAN Interface Table (C<swIfTable>)
=over
=item $dell->dell_duplex_admin()
(C<swIfDuplexAdminMode>)
=item $dell->dell_duplex()
(C<swIfDuplexOperMode>)
=item $dell->dell_tag_mode()
(C<swIfTaggedMode>)
=item $dell->dell_i_type()
(C<swIfType>)
=item $dell->dell_fc_admin()
(C<swIfFlowControlMode>)
=item $dell->dell_speed_admin()
(C<swIfSpeedAdminMode>)
=item $dell->dell_auto()
(C<swIfSpeedDuplexAutoNegotiation>)
=item $dell->dell_fc()
(C<swIfOperFlowControlMode>)
=back
=head2 Overrides
=over
=item $dell->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port
name. Uses name if available instead of description since descriptions are
sometimes not unique.
=item $dell->i_duplex_admin()
Returns reference to hash of iid to current link administrative duplex
setting.
=item $dell->fw_mac()
Returns reference to hash of forwarding table MAC Addresses.
Some devices don't implement the C<BRIDGE-MIB> forwarding table, so we use
the C<Q-BRIDGE-MIB> forwarding table. Fall back to the C<BRIDGE-MIB> if
C<Q-BRIDGE-MIB> doesn't return anything.
=item $dell->fw_port()
Returns reference to hash of forwarding table entries port interface
identifier (iid)
Some devices don't implement the C<BRIDGE-MIB> forwarding table, so we use
the C<Q-BRIDGE-MIB> forwarding table. Fall back to the C<BRIDGE-MIB> if
C<Q-BRIDGE-MIB> doesn't return anything.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,531 +0,0 @@
# SNMP::Info::Layer3::Enterasys - SNMP Interface to Enterasys devices
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Enterasys;
use strict;
use Exporter;
use SNMP::Info::MAU;
use SNMP::Info::LLDP;
use SNMP::Info::CDP;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Enterasys::ISA = qw/SNMP::Info::MAU SNMP::Info::LLDP
SNMP::Info::CDP SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::Enterasys::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::LLDP::MIBS, %SNMP::Info::MAU::MIBS,
'ENTERASYS-OIDS-MIB' => 'etsysOidDevice',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::MAU::GLOBALS,
'mac' => 'dot1dBaseBridgeAddress',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::LLDP::FUNCS, %SNMP::Info::MAU::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::MAU::MUNGE,
);
sub model {
my $enterasys = shift;
my $id = $enterasys->id();
unless ( defined $id ) {
print
" SNMP::Info::Layer3::Enterasys::model() - Device does not support sysObjectID\n"
if $enterasys->debug();
return;
}
my $model = &SNMP::translateObj($id);
$model =~ s/^etsysOidDev//i;
$model =~ s/^etsysOidPhy//i;
return $id unless defined $model;
return $model;
}
sub vendor {
return 'enterasys';
}
sub os {
return 'enterasys';
}
sub os_ver {
my $enterasys = shift;
my $descr = $enterasys->description();
return unless defined $descr;
if ( $descr =~ m/\bRev ([\d.]*)/ ) {
return $1;
}
return;
}
# Use ifName as it is used for CDP and LLDP.
sub interfaces {
my $enterasys = shift;
my $partial = shift;
# We need the original ifName, SUPER:: would give us a method definition
# in a higher class, we could use orig_ but just call the MIB leaf since
# that's what we really want anyway.
return $enterasys->ifName($partial)
|| $enterasys->i_description($partial);
}
sub i_ignore {
my $enterasys = shift;
my $partial = shift;
my $interfaces = $enterasys->i_type($partial) || {};
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
if ( $interfaces->{$if} =~ /(rs232|tunnel|loopback|\blo\b|null)/i ) {
$i_ignore{$if}++;
}
}
return \%i_ignore;
}
sub i_duplex {
my $enterasys = shift;
my $partial = shift;
return $enterasys->mau_i_duplex($partial);
}
sub i_duplex_admin {
my $enterasys = shift;
my $partial = shift;
return $enterasys->mau_i_duplex_admin($partial);
}
# Normal BRIDGE-MIB has issues on some devices, duplicates and
# non-increasing oids, Use Q-BRIDGE-MIB for macsuck
sub fw_mac {
my $enterasys = shift;
my $partial = shift;
return $enterasys->qb_fw_mac($partial);
}
sub fw_port {
my $enterasys = shift;
my $partial = shift;
return $enterasys->qb_fw_port($partial);
}
# Use CDP and/or LLDP
#
# LLDP table timefilter implementation continuously increments when walked
# and we may never reach the end of the table. This behavior can be
# modified with the "set snmp timefilter break disable" command,
# unfortunately it is not the default. Query with a partial value of zero
# which means no time filter.
sub hasCDP {
my $enterasys = shift;
return $enterasys->hasLLDP() || $enterasys->SUPER::hasCDP();
}
sub c_ip {
my $enterasys = shift;
my $partial = shift;
my $cdp = $enterasys->SUPER::c_ip($partial) || {};
my $lldp = $enterasys->lldp_ip(0) || {};
my %c_ip;
foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
return \%c_ip;
}
sub c_if {
my $enterasys = shift;
my $partial = shift;
my $lldp = $enterasys->lldp_if(0) || {};
my $cdp = $enterasys->SUPER::c_if($partial) || {};
my %c_if;
foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
return \%c_if;
}
sub c_port {
my $enterasys = shift;
my $partial = shift;
my $lldp = $enterasys->lldp_port(0) || {};
my $cdp = $enterasys->SUPER::c_port($partial) || {};
my %c_port;
foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
return \%c_port;
}
sub c_id {
my $enterasys = shift;
my $partial = shift;
my $lldp = $enterasys->lldp_id(0) || {};
my $cdp = $enterasys->SUPER::c_id($partial) || {};
my %c_id;
foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
return \%c_id;
}
sub c_platform {
my $enterasys = shift;
my $partial = shift;
my $lldp = $enterasys->lldp_rem_sysdesc(0) || {};
my $cdp = $enterasys->SUPER::c_platform($partial) || {};
my %c_platform;
foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
return \%c_platform;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Enterasys - SNMP Interface to Enterasys Network Devices
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $enterasys = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $enterasys->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from an
Enterasys device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $enterasys = new SNMP::Info::Layer3::Enterasys(...);
=head2 Inherited Classes
=over
=item SNMP::Info::MAU
=item SNMP::Info::LLDP
=item SNMP::Info::CDP
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<ENTERASYS-OIDS-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::MAU/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $enterasys->model()
Returns model type. Checks $enterasys->id() against the
F<ENTERASYS-OIDS-MIB>.
=item $enterasys->vendor()
Returns enterasys
=item $enterasys->os()
Returns enterasys
=item $enterasys->os_ver()
Returns os version extracted from C<sysDescr>
=item $enterasys->mac()
Returns base mac
(C<dot1dBaseBridgeAddress>)
=back
=head2 Overrides
=over
=back
=head2 Globals imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $enterasys->interfaces()
Mapping between the Interface Table Index (iid) and the physical port name.
=item $enterasys->i_ignore()
Returns reference to hash. Creates a key for each IID that should be ignored.
Currently looks for rs232, tunnel,loopback,lo,null from
$enterasys->interfaces()
=item $enterasys->i_duplex()
See documentation for mau_i_duplex() in L<SNMP::Info::MAU/"TABLE METHODS">.
=item $enterasys->i_duplex_admin()
See documentation for mau_i_duplex_admin() in
L<SNMP::Info::MAU/"TABLE METHODS">.
=item $enterasys->fw_mac()
Returns reference to hash of forwarding table MAC Addresses.
=item $enterasys->fw_port()
Returns reference to hash of forwarding table entries port interface
identifier (iid).
(C<dot1qTpFdbPort>)
=back
=head2 Topology information
Based upon the firmware version Enterasys devices may support Cabletron
Discovery Protocol (CTRON CDP), Cisco Discovery Protocol (CDP), Link Layer
Discovery Protocol (LLDP), or all. This module currently supports CDP and
LLDP, but not CTRON CDP. These methods will query both CDP and LLDP and
return the combination of all information. As a result, there may be
identical topology information returned from the two protocols
causing duplicate entries. It is the calling program's responsibility to
identify any duplicate entries and remove duplicates if necessary.
=over
=item $enterasys->hasCDP()
Returns true if the device is running either CDP or LLDP.
=item $enterasys->c_if()
Returns reference to hash. Key: iid Value: local device port (interfaces)
=item $enterasys->c_ip()
Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different
IPv4 addresses, c_ip(), there is either a non-CDP/LLDP device in between two
or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $enterasys->c_port()
Returns reference to hash. Key: iid Value: remote port (interfaces)
=item $enterasys->c_id()
Returns reference to hash. Key: iid Value: string value used to identify the
chassis component associated with the remote system.
=item $enterasys->c_platform()
Returns reference to hash. Key: iid Value: Remote Device Type
=back
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,838 +0,0 @@
# SNMP::Info::Layer3::Extreme - SNMP Interface to Extreme devices
# $Id$
#
# Copyright (c) 2008 Eric Miller
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Extreme;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::MAU;
@SNMP::Info::Layer3::Extreme::ISA
= qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS,
'EXTREME-BASE-MIB' => 'extremeAgent',
'EXTREME-SYSTEM-MIB' => 'extremeSystem',
'EXTREME-FDB-MIB' => 'extremeSystem',
'EXTREME-VLAN-MIB' => 'extremeVlan',
'EXTREME-POE-MIB' => 'extremePethSystemAdminEnable',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
'serial1' => 'extremeSystemID.0',
'temp' => 'extremeCurrentTemperature',
'ps1_status_old' => 'extremePrimaryPowerOperational.0',
'ps1_status_new' => 'extremePowerSupplyStatus.1',
'ps2_status_old' => 'extremeRedundantPowerStatus.0',
'ps2_status_new' => 'extremePowerSupplyStatus.2',
'mac' => 'dot1dBaseBridgeAddress',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS,
'fan_state' => 'extremeFanOperational',
# EXTREME-FDB-MIB:extremeFdbMacFdbTable
'ex_fw_mac' => 'extremeFdbMacFdbMacAddress',
'ex_fw_port' => 'extremeFdbMacFdbPortIfIndex',
'ex_fw_status' => 'extremeFdbMacFdbStatus',
# EXTREME-VLAN-MIB:extremeVlanIfTable
'ex_vlan_descr' => 'extremeVlanIfDescr',
'ex_vlan_global_id' => 'extremeVlanIfGlobalIdentifier',
# EXTREME-VLAN-MIB:extremeVlanEncapsIfTable
'ex_vlan_encap_tag' => 'extremeVlanEncapsIfTag',
'peth_port_power' => 'extremePethPortMeasuredPower',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::MAU::MUNGE,
'ex_fw_mac' => \&SNMP::Info::munge_mac,
'ps1_status_old' => \&munge_true_ok,
'ps1_status_new' => \&munge_power_stat,
'ps2_status_old' => \&munge_power_stat,
'ps2_status_new' => \&munge_power_stat,
'fan_state' => \&munge_true_ok,
);
# Method OverRides
*SNMP::Info::Layer3::Extreme::i_duplex = \&SNMP::Info::MAU::mau_i_duplex;
*SNMP::Info::Layer3::Extreme::i_duplex_admin
= \&SNMP::Info::MAU::mau_i_duplex_admin;
sub model {
my $extreme = shift;
my $id = $extreme->id();
unless ( defined $id ) {
print
" SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n"
if $extreme->debug();
return;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
return $model;
}
sub vendor {
return 'extreme';
}
sub os {
return 'extreme';
}
sub os_ver {
my $extreme = shift;
my $descr = $extreme->description();
return unless defined $descr;
if ( $descr =~ m/Version ([\d.]*)/ ) {
return $1;
}
return;
}
#
# ifName is a nice concise port name on Extreme devices.
# Layer3.pm defaults to i_description, which is verbose
# and has spaces. However, ifName has the IP address
# assigned for router interfaces, so we use ifDescr
# for those.
sub interfaces {
my $extreme = shift;
my $partial = shift;
my $i_name = $extreme->orig_i_name($partial);
my $i_description = $extreme->orig_i_description($partial);
my $interfaces = {};
foreach my $idx ( keys %$i_name ) {
if ( $i_name->{$idx} =~ /\([0-9.]+\)/ ) {
$interfaces->{$idx} = $i_description->{$idx};
}
else {
$interfaces->{$idx} = $i_name->{$idx};
}
}
return $interfaces;
}
#
# Ignore VLAN meta-interfaces and loopback
sub i_ignore {
my $extreme = shift;
my $partial = shift;
my $i_description = $extreme->i_description($partial) || {};
my %i_ignore;
foreach my $if ( keys %$i_description ) {
if ( $i_description->{$if}
=~ /^(802.1Q Encapsulation Tag \d+|VLAN \d+|lo\d+)/i )
{
$i_ignore{$if}++;
}
}
return \%i_ignore;
}
# When we use the extreme_fw_* objects, we're not using BRIDGE-MIB.
# Either way, Extreme uses a 1:1 mapping of bridge interface ID to
# ifIndex.
sub bp_index {
my $extreme = shift;
my $if_index = $extreme->i_index();
my %bp_index;
foreach my $iid ( keys %$if_index ) {
$bp_index{$iid} = $iid;
}
return \%bp_index;
}
sub munge_true_ok {
my $val = shift;
return unless defined($val);
return "OK" if ( $val eq 'true' );
return "Not OK" if ( $val eq 'false' );
return $val;
}
sub munge_power_stat {
my $val = shift;
return unless defined($val);
$val =~ s/^present//;
$val =~ s/^not/Not /i;
return $val;
}
sub ps1_status {
my $extreme = shift;
my $ps1_status = $extreme->ps1_status_new();
return $ps1_status || $extreme->ps1_status_old();
}
sub ps2_status {
my $extreme = shift;
my $ps2_status = $extreme->ps2_status_new();
return $ps2_status || $extreme->ps2_status_old();
}
sub fan {
my $extreme = shift;
my $fan_state = $extreme->fan_state();
my $ret = "";
my $s = "";
foreach my $i ( sort { $a <=> $b } keys %$fan_state ) {
$ret .= $s . $i . ": " . $fan_state->{$i};
$s = ", ";
}
return if ( $s eq "" );
return $ret;
}
# Newer versions of the Extreme firmware have vendor-specific tables
# for this; those are ex_fw_*(). Older firmware versions don't have
# these tables, so we use the BRIDGE-MIB tables.
sub fw_mac {
my $extreme = shift;
my $fw_mac = $extreme->ex_fw_mac;
return $fw_mac if defined($fw_mac);
return $extreme->orig_fw_mac();
}
sub fw_port {
my $extreme = shift;
my $fw_port = $extreme->ex_fw_port;
return $fw_port if defined($fw_port);
return $extreme->orig_fw_port();
}
sub fw_status {
my $extreme = shift;
my $fw_status = $extreme->ex_fw_status;
return $fw_status if defined($fw_status);
return $extreme->orig_fw_status();
}
# Mapping the virtual VLAN interfaces:
# The virtual VLAN interfaces in extremeVlanIfTable
# are the higher layer above the interfaces that are
# untagged, and also above an interface in
# extremeVlanEncapsIfTable that does the encapsulation.
# Note that it's possible to have a VLAN defined that
# does not have a tag, if it has all native interfaces.
# To represent this, we use a negative version of the
# internal VLAN ID (the deprecated extremeVlanIfGlobalIdentifier)
sub _if2tag {
my $extreme = shift;
my $partial = shift;
my $stack = shift || $extreme->ifStackStatus($partial);
my $encap_tag = $extreme->ex_vlan_encap_tag();
my $vlan_descr = $extreme->ex_vlan_descr();
my $stackmap = {};
foreach my $idx ( keys %$stack ) {
my ( $higher, $lower ) = split( /\./, $idx );
$stackmap->{$higher}->{$lower} = $stack->{$idx};
}
my %if2tag = ();
my $missed = 0;
foreach my $if ( keys %$vlan_descr ) {
$if2tag{$if} = -1;
foreach my $tagif ( keys %$encap_tag ) {
if ( defined( $stackmap->{$if}->{$tagif} )
&& $stackmap->{$if}->{$tagif} eq 'active' )
{
$if2tag{$if} = $encap_tag->{$tagif};
}
}
if ( $if2tag{$if} == -1 ) {
$missed++;
}
}
if ($missed) {
my $global_id = $extreme->ex_vlan_global_id();
foreach my $if ( keys %if2tag ) {
$if2tag{$if} = -$global_id->{$if}
if ( $if2tag{$if} == -1 && defined( $global_id->{$if} ) );
}
}
return \%if2tag;
}
# No partial support in v_name or v_index, because the obivous partial
# is the VLAN ID and the index here is the ifIndex of
# the VLAN interface.
sub v_name {
my $extreme = shift;
return $extreme->ex_vlan_descr();
}
sub v_index {
my $extreme = shift;
return $extreme->_if2tag();
}
sub i_vlan {
my $extreme = shift;
my $partial = shift;
my $stack = $extreme->ifStackStatus($partial);
my $encap_tag = $extreme->ex_vlan_encap_tag();
my $vlan_descr = $extreme->ex_vlan_descr();
my $stackmap = {};
foreach my $idx ( keys %$stack ) {
my ( $higher, $lower ) = split( /\./, $idx );
$stackmap->{$higher}->{$lower} = $stack->{$idx};
}
my $if2tag = $extreme->_if2tag( $partial, $stack );
#
# Now that we've done all that mapping work, we can map the
# ifStack indexes.
my %i_vlan = ();
foreach my $if ( keys %$if2tag ) {
foreach my $lowif ( keys %{ $stackmap->{$if} } ) {
$i_vlan{$lowif} = $if2tag->{$if};
}
}
return \%i_vlan;
}
sub i_vlan_membership {
my $extreme = shift;
my $partial = shift;
my $stack = $extreme->ifStackStatus($partial);
my $encap_tag = $extreme->ex_vlan_encap_tag();
my $vlan_descr = $extreme->ex_vlan_descr();
my $stackmap = {};
foreach my $idx ( keys %$stack ) {
my ( $higher, $lower ) = split( /\./, $idx );
$stackmap->{$higher}->{$lower} = $stack->{$idx};
}
my $if2tag = $extreme->_if2tag( $partial, $stack );
#
# Now that we've done all that mapping work, we can map the
# ifStack indexes.
my %i_vlan_membership = ();
foreach my $if ( keys %$if2tag ) {
foreach my $lowif ( keys %{ $stackmap->{$if} } ) {
push( @{ $i_vlan_membership{$lowif} }, $if2tag->{$if} );
}
}
#
# Now add all the tagged ports.
foreach my $if ( keys %$encap_tag ) {
foreach my $lowif ( keys %{ $stackmap->{$if} } ) {
push( @{ $i_vlan_membership{$lowif} }, $encap_tag->{$if} );
}
}
return \%i_vlan_membership;
}
# VLAN management.
# See extreme-vlan.mib for a detailed description of
# Extreme's use of ifStackTable and EXTREME-VLAN-MIB.
sub set_i_vlan {
my $extreme = shift;
return $extreme->_extreme_set_i_vlan( 0, @_ );
}
sub set_i_pvid {
my $extreme = shift;
return $extreme->_extreme_set_i_vlan( 1, @_ );
}
# set_i_vlan implicitly turns off any encapsulation
# set_i_pvid retains any encapsulation
# otherwise they do the same: set the unencapsulated
# vlan ID.
# First arg to _set_i_vlan is whether or not to turn
# off any encapsulation.
sub _extreme_set_i_vlan {
my $extreme = shift;
my ( $is_pvid, $vlan_id, $ifindex ) = @_;
my $encap_tag = $extreme->ex_vlan_encap_tag();
# The inverted stack MIB would make this easier, since
# we need to find the vlan interface
# that's stacked above $ifindex.
my $cur_stack = $extreme->ifStackStatus();
#
# create inverted stack
my $invstack;
foreach my $idx ( keys %$cur_stack ) {
my ( $higher, $lower ) = split( /\./, $idx );
$invstack->{$lower}->{$higher} = $cur_stack->{$idx};
}
# create vlan tag -> encap interface map
my %encapif = reverse %$encap_tag;
# now find encap interface from tag
my $encapidx = $encapif{$vlan_id};
if ( !defined($encapidx) ) {
$extreme->error_throw(
"can't map $vlan_id to encapsulation interface");
return;
}
# now find vlan interface stacked above encap
my @abovevlan = keys %{ $invstack->{$encapidx} };
if ( @abovevlan != 1 ) {
$extreme->error_throw(
"can't map encap interface $encapidx for $vlan_id to encapsulation interface"
);
return;
}
my $vlanidx = $abovevlan[0];
my $rv;
# Delete old VLAN mapping
foreach my $oldidx ( keys %{ $invstack->{$ifindex} } ) {
if ( $is_pvid && defined( $encap_tag->{$oldidx} ) ) {
next; # Don't delete tagged mappings
}
$rv = $extreme->set_ifStackStatus( "destroy",
$oldidx . "." . $ifindex );
unless ($rv) {
$extreme->error_throw(
"Unable to remove $ifindex from old VLAN index $oldidx");
return;
}
}
# Add new VLAN mapping
$rv = $extreme->set_ifStackStatus( "createAndGo",
$vlanidx . "." . $ifindex );
unless ($rv) {
$extreme->error_throw(
"Unable to add new VLAN index $vlanidx to ifIndex $ifindex");
return;
}
# XXX invalidate cache of ifstack?
# XXX Info.pm library function for this?
# XXX set_ should do invalidation?
# $store = $extreme->store(); delete $store->{ifStackStatus}; $extreme->store($store);
# $extreme->{_ifStackStatus} = 0;
return $rv;
}
sub set_remove_i_vlan_tagged {
my $extreme = shift;
my ( $vlan_id, $ifindex ) = @_;
my $encap_tag = $extreme->ex_vlan_encap_tag();
# create vlan tag -> encap interface map
my %encapif = reverse %$encap_tag;
# now find encap interface from tag
my $encapidx = $encapif{$vlan_id};
if ( !defined($encapidx) ) {
$extreme->error_throw(
"can't map $vlan_id to encapsulation interface");
return;
}
my $rv = $extreme->set_ifStackStatus( "destroy",
$encapidx . "." . $ifindex );
unless ($rv) {
$extreme->error_throw(
"Unable to delete VLAN encap ifIndex $encapidx for VLAN $vlan_id from ifIndex $ifindex"
);
return;
}
# invalidate cache of ifstack?
return $rv;
}
sub set_add_i_vlan_tagged {
my $extreme = shift;
my ( $vlan_id, $ifindex ) = @_;
my $encap_tag = $extreme->ex_vlan_encap_tag();
# create vlan tag -> encap interface map
my %encapif = reverse %$encap_tag;
# now find encap interface from tag
my $encapidx = $encapif{$vlan_id};
if ( !defined($encapidx) ) {
$extreme->error_throw(
"can't map $vlan_id to encapsulation interface");
return;
}
my $rv = $extreme->set_ifStackStatus( "createAndGo",
$encapidx . "." . $ifindex );
unless ($rv) {
$extreme->error_throw(
"Unable to add VLAN encap ifIndex $encapidx for VLAN $vlan_id to ifIndex $ifindex"
);
return;
}
# invalidate cache of ifstack?
return $rv;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Extreme - Perl5 Interface to Extreme Network Devices
=head1 AUTHOR
Eric Miller, Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $extreme = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $extreme->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from an
Extreme device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $extreme = new SNMP::Info::Layer3::Extreme(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::MAU
=back
=head2 Required MIBs
=over
=item F<EXTREME-BASE-MIB>
=item F<EXTREME-SYSTEM-MIB>
=item F<EXTREME-FDB-MIB>
=item F<EXTREME-VLAN-MIB>
=item F<EXTREME-POE-MIB>
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $extreme->model()
Returns model type. Checks $extreme->id() against the F<EXTREME-BASE-MIB>.
=item $extreme->vendor()
Returns extreme
=item $extreme->os()
Returns extreme
=item $extreme->os_ver()
Parses device operating system version from description()
=item $extreme->serial()
Returns serial number
(C<extremeSystemID>)
=item $extreme->temp()
Returns system temperature
(C<extremeCurrentTemperature>)
=item $extreme->ps1_status()
Returns status of power supply 1
(C<extremePowerSupplyStatus.1>)
=item $extreme->ps2_status()
Returns status of power supply 2
(C<extremePowerSupplyStatus.2>)
=item $extreme->fan()
Returns fan status
(C<extremeFanOperational.1>)
=item $extreme->mac()
Returns base mac
(C<dot1dBaseBridgeAddress>)
=back
=head2 Overrides
=over
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $extreme->interfaces()
Returns a mapping between the Interface Table Index (iid) and the physical
port name.
=item $extreme->i_duplex()
Parses mau_index and mau_link to return the duplex information for
interfaces.
=item $extreme->i_duplex_admin()
Parses C<mac_index>,C<mau_autostat>,C<mau_type_admin> in
order to find the admin duplex setting for all the interfaces.
Returns either (auto,full,half).
=item $extreme->i_ignore()
Returns reference to hash. Increments value of IID if port is to be ignored.
Ignores VLAN meta interfaces and loopback
=item $extreme->fw_mac()
(C<extremeFdbMacFdbMacAddress>)
=item $extreme->fw_port()
(C<extremeFdbMacFdbPortIfIndex>)
=item $extreme->fw_status()
(C<extremeFdbMacFdbStatus>)
=item $extreme->i_vlan()
Returns a mapping between C<ifIndex> and the VLAN.
=item $extreme->i_vlan_membership()
Returns reference to hash of arrays: key = C<ifIndex>, value = array of VLAN
IDs. These are the VLANs which are members of the egress list for the port.
Example:
my $interfaces = $extreme->interfaces();
my $vlans = $extreme->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";
}
=item $extreme->v_index()
Returns VLAN IDs
=item $extreme->v_name()
Returns VLAN names
(C<extremeVlanIfDescr>)
=item $extreme->bp_index()
Returns reference to hash of bridge port table entries map back to interface
identifier (iid)
Returns (C<ifIndex>) for both key and value since we're using
F<EXTREME-FDB-MIB> rather than F<BRIDGE-MIB>.
=item $extreme->peth_port_power()
Power supplied by PoE ports, in milliwatts
("extremePethPortMeasuredPower")
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods
or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over
=item $extreme->set_i_vlan ( vlan, ifIndex )
Changes an access (untagged) port VLAN, must be supplied with the numeric
VLAN ID and port C<ifIndex>. This method should only be used on end station
(non-trunk) ports.
Example:
my %if_map = reverse %{$extreme->interfaces()};
$extreme->set_i_vlan('2', $if_map{'FastEthernet0/1'})
or die "Couldn't change port VLAN. ",$extreme->error(1);
=item $extreme->set_i_pvid ( pvid, ifIndex )
Sets port default VLAN, must be supplied with the numeric VLAN ID and
port C<ifIndex>. This method should only be used on trunk ports.
Example:
my %if_map = reverse %{$extreme->interfaces()};
$extreme->set_i_pvid('2', $if_map{'FastEthernet0/1'})
or die "Couldn't change port default VLAN. ",$extreme->error(1);
=item $extreme->set_add_i_vlan_tagged ( vlan, ifIndex )
Adds the VLAN to the enabled VLANs list of the port, must be supplied with the
numeric VLAN ID and port C<ifIndex>.
Example:
my %if_map = reverse %{$extreme->interfaces()};
$extreme->set_add_i_vlan_tagged('2', $if_map{'FastEthernet0/1'})
or die "Couldn't add port to egress list. ",$extreme->error(1);
=item $extreme->set_remove_i_vlan_tagged ( vlan, ifIndex )
Removes the VLAN from the enabled VLANs list of the port, must be supplied
with the numeric VLAN ID and port C<ifIndex>.
Example:
my %if_map = reverse %{$extreme->interfaces()};
$extreme->set_remove_i_vlan_tagged('2', $if_map{'FastEthernet0/1'})
or die "Couldn't add port to egress list. ",$extreme->error(1);
=back
=head1 Data Munging Callback Subroutines
=over
=item $extreme->munge_power_stat()
Removes 'present' and changes 'not' to 'Not' in the front of a string.
=item $extreme->munge_true_ok()
Replaces 'true' with "OK" and 'false' with "Not OK".
=back
=cut

View File

@@ -1,100 +1,133 @@
# SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry devices
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Foundry;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::FDP;
use SNMP::Info::LLDP;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
$INIT = 0;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS,
%SNMP::Info::FDP::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
);
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
# IP-FORWARD-MIB
# ETHERLIKE-MIB
# RFC1398-MIB
# RMON-MIB
# IF-MIB
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::FDP::GLOBALS,
'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1',
'temp' => 'snChasActualTemperature',
'ps1_type' => 'snChasPwrSupplyDescription.1',
'ps1_status' => 'snChasPwrSupplyOperStatus.1',
'fan' => 'snChasFanOperStatus.1',
# Inherit the super class ones
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1',
'serial' => 'snChasSerNum',
'temp' => 'snChasActualTemperature',
'ps1_type' => 'snChasPwrSupplyDescription.1',
'ps1_status' => 'snChasPwrSupplyOperStatus.1',
'fan' => 'snChasFanOperStatus.1',
#'serial' => 'enterprises.1991.1.1.1.1.2.0',
#'temp' => 'enterprises.1991.1.1.1.1.18.0',
#'ps1_type' => 'enterprises.1991.1.1.1.2.1.1.2.1',
#'ps1_status' => 'enterprises.1991.1.1.1.2.1.1.3.1',
#'fan' => 'enterprises.1991.1.1.1.3.1.1.3.1'
);
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS,
%SNMP::Info::FDP::FUNCS,
# FOUNDRY-SN-SWITCH-GROUP-MIB
# snSwPortInfoTable - Switch Port Information Group
'sw_index' => 'snSwPortIfIndex',
'sw_duplex' => 'snSwPortInfoChnMode',
'sw_type' => 'snSwPortInfoMediaType',
'sw_speed' => 'snSwPortInfoSpeed',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# FOUNDRY-MIB
# snSwPortInfoTable - Switch Port Information Group
'sw_index' => 'snSwPortIfIndex',
'sw_duplex' => 'snSwPortInfoChnMode',
'sw_type' => 'snSwPortInfoMediaType',
'sw_speed' => 'snSwPortInfoSpeed',
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
%SNMP::Info::FDP::MUNGE,
);
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
# Method OverRides
# Add our i_aliases if they are set (manually)
sub i_name {
my $foundry = shift;
my $i_name = $foundry->i_name2();
my $i_alias = $foundry->i_alias();
foreach my $iid (keys %$i_name){
my $alias = $i_alias->{$iid};
next unless defined $alias;
next unless length($alias);
$i_name->{$iid} = $i_alias->{$iid};
}
return $i_name;
}
sub i_ignore {
my $foundry = shift;
my $partial = shift;
my $interfaces = $foundry->interfaces($partial) || {};
my $interfaces = $foundry->interfaces();
my $i_descr = $foundry->i_descr();
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) {
foreach my $if (keys %$interfaces) {
# lo -> cisco aironet 350 loopback
if ($interfaces->{$if} =~ /(tunnel|loopback|lo|lb|null)/i){
$i_ignore{$if}++;
}
}
@@ -103,18 +136,12 @@ sub i_ignore {
sub i_duplex {
my $foundry = shift;
my $partial = shift;
my $sw_index = $foundry->sw_index($partial);
my $sw_duplex = $foundry->sw_duplex($partial);
unless ( defined $sw_index and defined $sw_duplex ) {
return $foundry->SUPER::i_duplex();
}
my $sw_index = $foundry->sw_index();
my $sw_duplex= $foundry->sw_duplex();
my %i_duplex;
foreach my $sw_port ( keys %$sw_duplex ) {
my $iid = $sw_index->{$sw_port};
foreach my $sw_port (keys %$sw_duplex){
my $iid = $sw_index->{$sw_port};
my $duplex = $sw_duplex->{$sw_port};
next if $duplex =~ /none/i;
$i_duplex{$iid} = 'half' if $duplex =~ /half/i;
@@ -123,425 +150,176 @@ sub i_duplex {
return \%i_duplex;
}
sub i_type {
my $foundry = shift;
my $sw_index = $foundry->sw_index();
my $sw_type= $foundry->sw_type();
my %i_type;
foreach my $sw_port (keys %$sw_type){
my $iid = $sw_index->{$sw_port};
my $type = $sw_type->{$sw_port};
next unless defined $type;
$i_type{$iid} = $type;
}
return \%i_type;
}
sub i_speed {
my $foundry = shift;
my $sw_index = $foundry->sw_index();
my $sw_speed= $foundry->sw_speed();
my %i_speed;
foreach my $sw_port (keys %$sw_speed){
my $iid = $sw_index->{$sw_port};
my $speed = $sw_speed->{$sw_port};
next unless defined $speed;
$speed = 'auto' if $speed =~ /auto/i;
$speed = '10 Mbps' if $speed =~ /s10m/i;
$speed = '100 Mbps' if $speed =~ /s100m/i;
$speed = '1.0 Gbps' if $speed =~ /s1g/i;
$speed = '45 Mbps' if $speed =~ /s45M/i;
$speed = '155 Mbps' if $speed =~ /s155M/i;
$i_speed{$iid} = $speed;
}
return \%i_speed;
}
# $foundry->model() - looks for xxnnnn in the description
sub model {
my $foundry = shift;
my $id = $foundry->id();
my $model = &SNMP::translateObj($id);
my $id = $foundry->id();
my $desc = $foundry->description();
my $model = &SNMP::translateObj($id);
# EdgeIron
if ( $id =~ /\.1991\.1\.[45]\./ ) {
my $e_name = $foundry->e_name();
# Find entity table entry for "unit.1"
my $unit_iid = undef;
foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1';
}
# Find Model Name
my $e_model = $foundry->e_model();
if ( defined $e_model->{$unit_iid} ) {
return $e_model->{$unit_iid};
}
}
return $id unless defined $model;
$model =~ s/^sn//;
$model = $1 if $desc =~ /\s+([a-z]{2}\d{4})\D/i;
return $model;
}
sub os {
return 'foundry';
# $foundry->interfaces() - Map the Interfaces to their physical names
sub interfaces {
my $foundry = shift;
my $interfaces = $foundry->i_index();
my $descriptions = $foundry->i_description();
my %ifs = ();
foreach my $iid (keys %$interfaces){
$ifs{$iid} = $descriptions->{$iid};
}
return \%ifs;
}
sub vendor {
return 'foundry';
}
sub os_ver {
my $foundry = shift;
return $foundry->snAgImgVer() if ( defined $foundry->snAgImgVer() );
# Some older ones don't have this value,so we cull it from the description
my $descr = $foundry->description();
if ( $descr =~ m/Version (\d\S*)/ ) {
return $1;
}
# EdgeIron
my $e_name = $foundry->e_name();
# find entity table entry for "stackmanaget.1"
my $unit_iid = undef;
foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'stackmanaget.1';
}
if ( defined $unit_iid ) {
# Find Model Name
my $e_fwver = $foundry->e_fwver();
if ( defined $e_fwver->{$unit_iid} ) {
return $e_fwver->{$unit_iid};
}
}
# Last resort
return $foundry->SUPER::os_ver();
}
sub serial {
my $foundry = shift;
# Return chassis serial number if available
return $foundry->snChasSerNum() if ( $foundry->snChasSerNum() );
# If no chassis serial use first module serial
my $mod_serials = $foundry->snAgentConfigModuleSerialNumber();
foreach my $mod ( sort keys %$mod_serials ) {
my $serial = $mod_serials->{$mod} || '';
next unless defined $serial;
return $serial;
}
# EdgeIron
my $e_name = $foundry->e_name();
# find entity table entry for "unit.1"
my $unit_iid = undef;
foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1';
}
if ( defined $unit_iid ) {
# Look up serial of found entry.
my $e_serial = $foundry->e_serial();
return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid};
}
# Last resort
return $foundry->SUPER::serial();
}
sub interfaces {
my $foundry = shift;
my $partial = shift;
my $i_descr = $foundry->i_description($partial) || {};
my $i_name = $foundry->i_name($partial) || {};
# Use ifName for EdgeIrons else use ifDescr
foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid};
next unless defined $name;
$i_descr->{$iid} = $name
if $name =~ /^port\d+/i;
}
return $i_descr;
}
# Reported hangs on a EdgeIron 24G
sub stp_p_state {
my $foundry = shift;
my $partial = shift;
my $descr = $foundry->description();
if ( $descr =~ m/\bEdgeIron 24G\b/ ) {
return;
}
return $foundry->SUPER::stp_p_state($partial) || {};
}
# Use FDP and/or LLDP
sub hasCDP {
my $foundry = shift;
return $foundry->hasLLDP() || $foundry->SUPER::hasCDP();
}
sub c_ip {
my $foundry = shift;
my $partial = shift;
my $cdp = $foundry->SUPER::c_ip($partial) || {};
my $lldp = $foundry->lldp_ip($partial) || {};
my %c_ip;
foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
return \%c_ip;
}
sub c_if {
my $foundry = shift;
my $partial = shift;
my $lldp = $foundry->lldp_if($partial) || {};
my $cdp = $foundry->SUPER::c_if($partial) || {};
my %c_if;
foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
return \%c_if;
}
sub c_port {
my $foundry = shift;
my $partial = shift;
my $lldp = $foundry->lldp_port($partial) || {};
my $cdp = $foundry->SUPER::c_port($partial) || {};
my %c_port;
foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
return \%c_port;
}
sub c_id {
my $foundry = shift;
my $partial = shift;
my $lldp = $foundry->lldp_id($partial) || {};
my $cdp = $foundry->SUPER::c_id($partial) || {};
my %c_id;
foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
return \%c_id;
}
sub c_platform {
my $foundry = shift;
my $partial = shift;
my $lldp = $foundry->lldp_rem_sysdesc($partial) || {};
my $cdp = $foundry->SUPER::c_platform($partial) || {};
my %c_platform;
foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
return \%c_platform;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry Network Devices
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $foundry = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $foundry->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry Network Devices
=head1 DESCRIPTION
Abstraction subclass for Foundry Networks devices.
This module provides limited functionality from older Foundry devices.
Specifically designed for a FI4802
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
Data comes RFC1213 and FOUNDRY-SN-ROOT-MIB
my $foundry = new SNMP::Info::Layer3::Foundry(...);
Inherits all methods from both SNMP::Info and SNMP::Info::Bridge
=head2 Inherited Classes
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $foundry = new SNMP::Info::Layer3::Foundry(DestHost => 'switch' ,
Community => 'public' );
See L<SNMP::Info> and L<SNMP::Info::Layer3> for all inherited methods.
=head1 CREATING AN OBJECT
=over
=item SNMP::Info::Layer3;
=item new SNMP::Info::Layer3::Foundry()
=item SNMP::Info::FDP;
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::LLDP;
my $foundry = new SNMP::Info::Layer3::Foundry(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $foundry;
=back
=head2 Required MIBs
=over
=item F<FOUNDRY-SN-ROOT-MIB>
=item F<FOUNDRY-SN-AGENT-MIB>
=item F<FOUNDRY-SN-SWITCH-GROUP-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::FDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head1 GLOBAL VALUES
=over
=item $foundry->model()
Returns model type. Checks $foundry->id() against the F<FOUNDRY-SN-ROOT-MIB>
and removes 'C<sn>'. EdgeIron models determined through F<ENTITY-MIB>.
Returns model type. Checks $foundry->id() against the
FOUNDRY-SN-ROOT-MIB and then parses out xxNNNN
=item $foundry->vendor()
Returns 'foundry'
=item $foundry->os()
Returns 'foundry'
=item $foundry->os_ver()
Returns the software version
Returns 'foundry' :)
=item $foundry->mac()
Returns MAC Address of root port.
Returns MAC Address of root port.
(C<ifPhysAddress.1>)
(B<ifPhysAddress.1>)
=item $foundry->chassis()
Returns Chassis type.
Returns Chassis type.
(C<entPhysicalDescr.1>)
(B<entPhysicalDescr.1>)
=item $foundry->serial()
Returns serial number of device.
Returns serial number of device.
(B<snChasSerNum>)
=item $foundry->temp()
Returns the chassis temperature
Returns the chassis temperature
(C<snChasActualTemperature>)
(B<snChasActualTemperature>)
=item $foundry->ps1_type()
Returns the Description for the power supply
Returns the Description for the power supply
(C<snChasPwrSupplyDescription.1>)
(B<snChasPwrSupplyDescription.1>)
=item $foundry->ps1_status()
Returns the status of the power supply.
Returns the status of the power supply.
(C<snChasPwrSupplyOperStatus.1>)
(B<snChasPwrSupplyOperStatus.1>)
=item $foundry->fan()
Returns the status of the chassis fan.
Returns the status of the chassis fan.
(C<snChasFanOperStatus.1>)
(B<snChasFanOperStatus.1>)
=back
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::FDP
See documentation in L<SNMP::Info::FDP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -549,119 +327,94 @@ to a hash.
=item $foundry->interfaces()
Returns reference to hash of interface names to iids.
Returns reference to hash of interface names to iids.
Uses B<ifDescr>.
=item $foundry->i_name()
Returns reference to hash of interface names.
Trys for B<ifAlias> and Defaults to B<ifName>
=item $foundry->i_ignore()
Returns reference to hash of interfaces to be ignored.
Returns reference to hash of interfaces to be ignored.
Ignores interfaces with descriptions of tunnel,loopback,null
Ignores interfaces with descriptions of tunnel,loopback,null
=item $foundry->i_duplex()
Returns reference to hash of interface link duplex status.
Returns reference to hash of interface link duplex status.
Crosses $foundry->sw_duplex() with $foundry->sw_index()
Crosses $foundry->sw_duplex() with $foundry->sw_index()
=item $foundry->stp_p_state()
=item $foundry->i_type()
"The port's current state as defined by application of the Spanning Tree
Protocol.
Returns reference to hash of interface types.
Crosses $foundry->sw_type() with $foundry->sw_index()
Skipped if device is an EdgeIron 24G due to reports of hangs.
=item $foundry->i_speed()
(C<dot1dStpPortState>)
Returns reference to hash of interface speeds .
Crosses $foundry->sw_speeD() with $foundry->sw_index() and
does a little munging.
=back
=head2 Foundry Switch Port Information Table (C<snSwPortIfTable>)
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $foundry->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $foundry->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $foundry->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Foundry Switch Port Information Table (B<snSwPortIfTable>)
=over
=item $foundry->sw_index()
Returns reference to hash. Maps Table to Interface IID.
Returns reference to hash. Maps Table to Interface IID.
(C<snSwPortIfIndex>)
(B<snSwPortIfIndex>)
=item $foundry->sw_duplex()
Returns reference to hash. Current duplex status for switch ports.
Returns reference to hash. Current duplex status for switch ports.
(C<snSwPortInfoChnMode>)
(B<snSwPortInfoChnMode>)
=item $foundry->sw_type()
Returns reference to hash. Current Port Type .
Returns reference to hash. Current Port Type .
(C<snSwPortInfoMediaType>)
(B<snSwPortInfoMediaType>)
=item $foundry->sw_speed()
Returns reference to hash. Current Port Speed.
Returns reference to hash. Current Port Speed.
(C<snSwPortInfoSpeed>)
(B<snSwPortInfoSpeed>)
=back
=head2 Topology information
Based upon the software version devices may support Foundry Discovery
Protocol (FDP) and Link Layer Discovery Protocol (LLDP). These
methods will query both and return the combination of all information. As a
result, there may be identical topology information returned from the two
protocols causing duplicate entries. It is the calling program's
responsibility to identify any duplicate entries and remove duplicates if
necessary.
=over
=item $foundry->hasCDP()
Returns true if the device is running either FDP or LLDP.
=item $foundry->c_if()
Returns reference to hash. Key: iid Value: local device port (interfaces)
=item $foundry->c_ip()
Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different
IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two
or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $foundry->c_port()
Returns reference to hash. Key: iid Value: remote port (interfaces)
=item $foundry->c_id()
Returns reference to hash. Key: iid Value: string value used to identify the
chassis component associated with the remote system.
=item $foundry->c_platform()
Returns reference to hash. Key: iid Value: Remote Device Type
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::FDP
See documentation in L<SNMP::Info::FDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,590 +0,0 @@
# SNMP::Info::Layer3::HP9300 - SNMP Interface to HP Foundry OEM devices
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::HP9300;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::FDP;
use SNMP::Info::LLDP;
@SNMP::Info::Layer3::HP9300::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::HP9300::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS,
%SNMP::Info::FDP::MIBS,
'HP-SN-ROOT-MIB' => 'hp',
'HP-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
'HP-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::FDP::GLOBALS,
'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1',
'temp' => 'snChasActualTemperature',
'ps1_type' => 'snChasPwrSupplyDescription.1',
'ps1_status' => 'snChasPwrSupplyOperStatus.1',
'fan' => 'snChasFanOperStatus.1',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS,
%SNMP::Info::FDP::FUNCS,
# HP-SN-SWITCH-GROUP-MIB
# snSwPortInfoTable - Switch Port Information Group
# Fully qualify these since FDP class will load
# FOUNDRY-SN-SWITCH-GROUP-MIB which contains the same leaf names
'sw_index' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortIfIndex',
'sw_duplex' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoChnMode',
'sw_type' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoMediaType',
'sw_speed' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoSpeed',
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
%SNMP::Info::FDP::MUNGE,
);
sub i_ignore {
my $hp9300 = shift;
my $partial = shift;
my $interfaces = $hp9300->interfaces($partial) || {};
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) {
$i_ignore{$if}++;
}
}
return \%i_ignore;
}
sub i_duplex {
my $hp9300 = shift;
my $partial = shift;
my $sw_index = $hp9300->sw_index($partial);
my $sw_duplex = $hp9300->sw_duplex($partial);
unless ( defined $sw_index and defined $sw_duplex ) {
return $hp9300->SUPER::i_duplex();
}
my %i_duplex;
foreach my $sw_port ( keys %$sw_duplex ) {
my $iid = $sw_index->{$sw_port};
my $duplex = $sw_duplex->{$sw_port};
next if $duplex =~ /none/i;
$i_duplex{$iid} = 'half' if $duplex =~ /half/i;
$i_duplex{$iid} = 'full' if $duplex =~ /full/i;
}
return \%i_duplex;
}
sub model {
my $hp9300 = shift;
my $id = $hp9300->id();
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^hpSwitch//;
return $model;
}
sub os {
return 'hp';
}
sub vendor {
return 'hp';
}
sub os_ver {
my $hp9300 = shift;
return $hp9300->snAgImgVer() if ( defined $hp9300->snAgImgVer() );
# Some older ones don't have this value,so we cull it from the description
my $descr = $hp9300->description();
if ( $descr =~ m/Version (\d\S*)/ ) {
return $1;
}
# Last resort
return $hp9300->SUPER::os_ver();
}
sub serial {
my $hp9300 = shift;
# Return chassis serial number if available
return $hp9300->snChasSerNum() if ( $hp9300->snChasSerNum() );
# If no chassis serial use first module serial
my $mod_serials = $hp9300->snAgentConfigModuleSerialNumber();
foreach my $mod ( sort keys %$mod_serials ) {
my $serial = $mod_serials->{$mod} || '';
next unless defined $serial;
return $serial;
}
# Last resort
return $hp9300->SUPER::serial();
}
sub interfaces {
my $hp9300 = shift;
my $partial = shift;
my $i_descr = $hp9300->i_description($partial) || {};
my $i_name = $hp9300->i_name($partial) || {};
# Use ifName for EdgeIrons else use ifDescr
foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid};
next unless defined $name;
$i_descr->{$iid} = $name
if $name =~ /^port\d+/i;
}
return $i_descr;
}
# Use FDP and/or LLDP
sub hasCDP {
my $hp9300 = shift;
return $hp9300->hasLLDP() || $hp9300->SUPER::hasCDP();
}
sub c_ip {
my $hp9300 = shift;
my $partial = shift;
my $cdp = $hp9300->SUPER::c_ip($partial) || {};
my $lldp = $hp9300->lldp_ip($partial) || {};
my %c_ip;
foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid};
next unless defined $ip;
$c_ip{$iid} = $ip;
}
return \%c_ip;
}
sub c_if {
my $hp9300 = shift;
my $partial = shift;
my $lldp = $hp9300->lldp_if($partial) || {};
my $cdp = $hp9300->SUPER::c_if($partial) || {};
my %c_if;
foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid};
next unless defined $if;
$c_if{$iid} = $if;
}
return \%c_if;
}
sub c_port {
my $hp9300 = shift;
my $partial = shift;
my $lldp = $hp9300->lldp_port($partial) || {};
my $cdp = $hp9300->SUPER::c_port($partial) || {};
my %c_port;
foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid};
next unless defined $port;
$c_port{$iid} = $port;
}
return \%c_port;
}
sub c_id {
my $hp9300 = shift;
my $partial = shift;
my $lldp = $hp9300->lldp_id($partial) || {};
my $cdp = $hp9300->SUPER::c_id($partial) || {};
my %c_id;
foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid};
next unless defined $id;
$c_id{$iid} = $id;
}
return \%c_id;
}
sub c_platform {
my $hp9300 = shift;
my $partial = shift;
my $lldp = $hp9300->lldp_rem_sysdesc($partial) || {};
my $cdp = $hp9300->SUPER::c_platform($partial) || {};
my %c_platform;
foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid};
next unless defined $platform;
$c_platform{$iid} = $platform;
}
return \%c_platform;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::HP9300 - SNMP Interface to HP Foundry OEM Network Devices
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $hp9300 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $hp9300->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for HP network devices which Foundry Networks was the
Original Equipment Manufacturer (OEM) such as the HP ProCurve 9300 series.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $hp9300 = new SNMP::Info::Layer3::HP9300(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3;
=item SNMP::Info::FDP;
=item SNMP::Info::LLDP;
=back
=head2 Required MIBs
=over
=item F<HP-SN-ROOT-MIB>
=item F<HP-SN-AGENT-MIB>
=item F<HP-SN-SWITCH-GROUP-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::FDP/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $hp9300->model()
Returns model type. Checks $hp9300->id() against the F<HP-SN-ROOT-MIB>
and removes C<hpSwitch>.
=item $hp9300->vendor()
Returns 'hp'
=item $hp9300->os()
Returns 'hp'
=item $hp9300->os_ver()
Returns the software version
=item $hp9300->mac()
Returns MAC Address of root port.
(C<ifPhysAddress.1>)
=item $hp9300->chassis()
Returns Chassis type.
(C<entPhysicalDescr.1>)
=item $hp9300->serial()
Returns serial number of device.
=item $hp9300->temp()
Returns the chassis temperature
(C<snChasActualTemperature>)
=item $hp9300->ps1_type()
Returns the Description for the power supply
(C<snChasPwrSupplyDescription.1>)
=item $hp9300->ps1_status()
Returns the status of the power supply.
(C<snChasPwrSupplyOperStatus.1>)
=item $hp9300->fan()
Returns the status of the chassis fan.
(C<snChasFanOperStatus.1>)
=back
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::FDP
See documentation in L<SNMP::Info::FDP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $hp9300->interfaces()
Returns reference to hash of interface names to iids.
=item $hp9300->i_ignore()
Returns reference to hash of interfaces to be ignored.
Ignores interfaces with descriptions of tunnel,loopback,null
=item $hp9300->i_duplex()
Returns reference to hash of interface link duplex status.
Crosses $hp9300->sw_duplex() with $hp9300->sw_index()
=back
=head2 Switch Port Information Table (C<snSwPortIfTable>)
=over
=item $hp9300->sw_index()
Returns reference to hash. Maps Table to Interface IID.
(C<snSwPortIfIndex>)
=item $hp9300->sw_duplex()
Returns reference to hash. Current duplex status for switch ports.
(C<snSwPortInfoChnMode>)
=item $hp9300->sw_type()
Returns reference to hash. Current Port Type .
(C<snSwPortInfoMediaType>)
=item $hp9300->sw_speed()
Returns reference to hash. Current Port Speed.
(C<snSwPortInfoSpeed>)
=back
=head2 Topology information
Based upon the software version devices may support Foundry Discovery
Protocol (FDP) and Link Layer Discovery Protocol (LLDP). These
methods will query both and return the combination of all information. As a
result, there may be identical topology information returned from the two
protocols causing duplicate entries. It is the calling program's
responsibility to identify any duplicate entries and remove duplicates
if necessary.
=over
=item $hp9300->hasCDP()
Returns true if the device is running either FDP or LLDP.
=item $hp9300->c_if()
Returns reference to hash. Key: iid Value: local device port (interfaces)
=item $hp9300->c_ip()
Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different
IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two
or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $hp9300->c_port()
Returns reference to hash. Key: iid Value: remote port (interfaces)
=item $hp9300->c_id()
Returns reference to hash. Key: iid Value: string value used to identify the
chassis component associated with the remote system.
=item $hp9300->c_platform()
Returns reference to hash. Key: iid Value: Remote Device Type
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::FDP
See documentation in L<SNMP::Info::FDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,341 +0,0 @@
# SNMP::Info::Layer3::Juniper
# $Id$
#
# Copyright (c) 2008 Bill Fenner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Juniper;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::LLDP;
@SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 SNMP::Info::LLDP Exporter/;
@SNMP::Info::Layer3::Juniper::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS,
'JUNIPER-CHASSIS-DEFINES-MIB' => 'jnxChassisDefines',
'JUNIPER-MIB' => 'jnxBoxAnatomy',
);
%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
'serial' => 'jnxBoxSerialNo.0', );
%FUNCS = ( %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS,
);
%MUNGE = ( %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::LLDP::MUNGE,
);
sub vendor {
return 'juniper';
}
sub os {
return 'junos';
}
sub os_ver {
my $juniper = shift;
my $descr = $juniper->description();
return unless defined $descr;
if ( $descr =~ m/kernel JUNOS (\S+)/ ) {
return $1;
}
return;
}
sub model {
my $l3 = shift;
my $id = $l3->id();
unless ( defined $id ) {
print
" SNMP::Info::Layer3::Juniper::model() - Device does not support sysObjectID\n"
if $l3->debug();
return;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^jnxProductName//i;
return $model;
}
# Override the fancy Layer3.pm serial function
sub serial {
my $juniper = shift;
return $juniper->orig_serial();
}
sub i_vlan {
my ($juniper) = shift;
my ($partial) = shift;
my ($i_type) = $juniper->i_type($partial);
my ($i_descr) = $juniper->i_description($partial);
my %i_vlan;
foreach my $idx ( keys %$i_descr ) {
if ( $i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135 ) {
if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) {
$i_vlan{$idx} = $1;
}
}
}
return \%i_vlan;
}
# Use Q-BRIDGE-MIB for bridge forwarding tables
sub fw_mac {
my $juniper = shift;
my $partial = shift;
return $juniper->qb_fw_mac($partial);
}
sub fw_port {
my $juniper = shift;
my $partial = shift;
return $juniper->qb_fw_port($partial);
}
# Use LLDP
sub hasCDP {
my $juniper = shift;
return $juniper->hasLLDP();
}
sub c_ip {
my $juniper = shift;
my $partial = shift;
return $juniper->lldp_ip($partial);
}
sub c_if {
my $juniper = shift;
my $partial = shift;
return $juniper->lldp_if($partial);
}
sub c_port {
my $juniper = shift;
my $partial = shift;
return $juniper->lldp_port($partial);
}
sub c_id {
my $juniper = shift;
my $partial = shift;
return $juniper->lldp_id($partial);
}
sub c_platform {
my $juniper = shift;
my $partial = shift;
return $juniper->lldp_rem_sysdesc($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Juniper - SNMP Interface to L3 Juniper Devices
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $juniper = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $juniper->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Juniper Routers running JUNOS
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::LLDP
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $juniper->vendor()
Returns C<'juniper'>
=item $juniper->os()
Returns C<'junos'>
=item $juniper->os_ver()
Returns the software version extracted from C<sysDescr>.
=item $juniper->model()
Returns the model from C<sysObjectID>, with C<jnxProductNameremoved> from the
beginning.
=item $juniper->serial()
Returns serial number
(C<jnxBoxSerialNo.0>)
=item $juniper->hasCDP()
Returns whether LLDP is enabled.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $juniper->i_vlan()
Returns the list of interfaces whose C<ifType> is l2vlan(135), and
the VLAN ID extracted from the interface description.
=item $juniper->c_id()
Returns LLDP information.
=item $juniper->c_if()
Returns LLDP information.
=item $juniper->c_ip()
Returns LLDP information.
=item $juniper->c_platform()
Returns LLDP information.
=item $juniper->c_port()
Returns LLDP information.
=back
=head2 Forwarding Table (C<dot1dTpFdbEntry>)
=over
=item $juniper->fw_mac()
Returns reference to hash of forwarding table MAC Addresses
(C<dot1dTpFdbAddress>)
=item $juniper->fw_port()
Returns reference to hash of forwarding table entries port interface
identifier (iid)
(C<dot1dTpFdbPort>)
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,196 +0,0 @@
# SNMP::Info::Layer3::Microsoft
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Microsoft;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Microsoft::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Microsoft::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( %SNMP::Info::Layer3::MIBS, );
%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, );
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub vendor {
return 'microsoft';
}
sub os {
return 'windows';
}
sub os_ver {
return '';
}
sub model {
return 'Windows Router';
}
sub serial {
return '';
}
# $l3->interfaces() - Map the Interfaces to their physical names
# Add interface number to interface name because if MS Win
# have identical interface cards ("HP NC7782 Gigabit Server Adapter"
# for example), than MS Win return identical ifDescr
sub interfaces {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->i_index($partial);
my $descriptions = $l3->i_description($partial);
my %interfaces = ();
foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid};
next unless defined $desc;
$interfaces{$iid} = sprintf( "(%U) %s", $iid, $desc );
}
return \%interfaces;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Microsoft - SNMP Interface to L3 Microsoft Windows router
=head1 AUTHOR
begemot
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $router = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $router->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Microsoft Routers running Microsoft Windows OS
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $router->vendor()
Returns C<'microsoft'>
=item $router->os()
Returns C<'windows'>
=item $router->os_ver()
Returns ''
=item $router->model()
Returns C<'Windows Router'>
=item $router->serial()
Returns ''
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $router->interfaces()
Map the Interfaces to their physical names. Adds interface number to
interface name because identical interface cards return identical C<ifDescr>.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,175 +0,0 @@
# SNMP::Info::Layer3::Mikrotik
# $Id$
#
# Copyright (c) 2011 Jeroen van Ingen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Mikrotik;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Mikrotik::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Mikrotik::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'HOST-RESOURCES-MIB' => 'hrSystem',
'MIKROTIK-MIB' => 'mtxrLicVersion',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'hrSystemUptime' => 'hrSystemUptime',
'os_ver' => 'mtxrLicVersion',
);
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub vendor {
return 'mikrotik';
}
sub model {
my $mikrotik = shift;
my $descr = $mikrotik->description() || '';
my $model = undef;
$model = $1 if ( $descr =~ /^RouterOS\s+(\S+)$/i );
return $model;
}
sub os {
return 'routeros';
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Mikrotik - SNMP Interface to Mikrotik devices
=head1 AUTHORS
Jeroen van Ingen
initial version based on SNMP::Info::Layer3::NetSNMP by Bradley Baetz and Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $mikrotik = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $mikrotik->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Mikrotik devices
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<HOST-RESOURCES-MIB>
=item F<MIKROTIK-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $mikrotik->vendor()
Returns 'mikrotik'.
=item $mikrotik->os()
Returns 'routeros'.
=item $mikrotik->model()
Tries to extract the device model from C<sysDescr>.
=item $mikrotik->os_ver()
Returns the value of C<mtxrLicVersion>.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
None.
=over
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
=cut

View File

@@ -1,318 +0,0 @@
# SNMP::Info::Layer3::N1600 - SNMP Interface to Nortel N16XX devices
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::N1600;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::SONMP;
@SNMP::Info::Layer3::N1600::ISA
= qw/SNMP::Info::Layer3 SNMP::Info::SONMP Exporter/;
@SNMP::Info::Layer3::N1600::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::SONMP::MIBS,
'SWL2MGMT-MIB' => 'swL2MgmtMIB',
'RAPID-CITY' => 'rapidCity',
);
%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::SONMP::GLOBALS, );
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::SONMP::FUNCS,
# SWL2MGMT-MIB
# swL2PortInfoTable
'n1600_nway_status' => 'swL2PortInfoNwayStatus',
# swL2PortCtrlTable
'n1600_nway_state' => 'swL2PortCtrlNwayState',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
# Method OverRides
sub model {
my $n1600 = shift;
my $id = $n1600->id();
unless ( defined $id ) {
print
" SNMP::Info::Layer3::N1600::model() - Device does not support sysObjectID\n"
if $n1600->debug();
return;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^rcA//i;
return $model;
}
sub vendor {
return 'nortel';
}
sub os {
return 'passport';
}
sub os_ver {
my $n1600 = shift;
my $descr = $n1600->description();
return unless defined $descr;
if ( $descr =~ m/(\d+\.\d+\.\d+\.\d+)/ ) {
return $1;
}
return;
}
sub interfaces {
my $n1600 = shift;
my $partial = shift;
my $i_index = $n1600->i_index($partial) || {};
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
my $slotport = "1.$index";
$if{$iid} = $slotport;
}
return \%if;
}
sub i_duplex {
my $n1600 = shift;
my $partial = shift;
my $nway_status = $n1600->n1600_nway_status($partial) || {};
my %i_duplex;
foreach my $iid ( keys %$nway_status ) {
my $duplex = $nway_status->{$iid};
next unless defined $duplex;
next if $duplex =~ /other/i;
$i_duplex{$iid} = 'half' if $duplex =~ /half/i;
$i_duplex{$iid} = 'full' if $duplex =~ /full/i;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $n1600 = shift;
my $partial = shift;
my $nway_state = $n1600->n1600_nway_state($partial) || {};
my %i_duplex;
foreach my $iid ( keys %$nway_state ) {
my $duplex = $nway_state->{$iid};
next unless defined $duplex;
next if $duplex =~ /other/i;
$i_duplex{$iid} = 'half' if $duplex =~ /half/i;
$i_duplex{$iid} = 'full' if $duplex =~ /full/i;
$i_duplex{$iid} = 'auto' if $duplex =~ /nway-enabled/i;
}
return \%i_duplex;
}
# Required for SNMP::Info::SONMP
sub index_factor {
return 64;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::N1600 - SNMP Interface to Nortel 16XX Network Devices
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $n1600 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $n1600->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a Nortel
N16XX device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $n1600 = new SNMP::Info::Layer3::N1600(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::SONMP
=back
=head2 Required MIBs
=over
=item F<SWL2MGMT-MIB>
=item F<RAPID-CITY>
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $n1600->bulkwalk_no
Return C<1>. Bulkwalk is currently turned off for this class.
=item $n1600->model()
Returns model type. Checks $n1600->id() against the
F<RAPID-CITY-MIB> and then parses out C<rcA>.
=item $n1600->vendor()
Returns 'nortel'
=item $n1600->os()
Returns 'passport'
=item $n1600->os_ver()
Returns os version extracted from C<sysDescr>.
=back
=head2 Overrides
=over
=item $n1600->index_factor()
Required by SNMP::Info::SONMP. Number representing the number of ports
reserved per slot within the device MIB.
Returns 64 since largest switch has 48 ports. Since these switches can
not stack, the only requirement to reserve more than the max number of ports.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::SONMP
See documentation in SNMP::SONMP::Layer3 for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $n1600->interfaces()
Returns reference to hash of interface names to iids.
Places a 1 in front of index number. This is required for compatibility with
SNMP::Info::SONMP.
=item $n1600->i_duplex()
Returns reference to hash of interface operational link duplex status.
=item $n1600->i_duplex_admin()
Returns reference to hash of interface administrative link duplex status.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,253 +0,0 @@
# SNMP::Info::Layer3::NetSNMP
# $Id$
#
# Copyright (c) 2008 Bill Fenner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::NetSNMP;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::NetSNMP::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::NetSNMP::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'UCD-SNMP-MIB' => 'versionTag',
'NET-SNMP-TC' => 'netSnmpAgentOIDs',
'HOST-RESOURCES-MIB' => 'hrSystem',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'netsnmp_vers' => 'versionTag',
'hrSystemUptime' => 'hrSystemUptime',
);
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub vendor {
return 'Net-SNMP';
}
sub os {
my $netsnmp = shift;
my $descr = $netsnmp->description();
return $1 if ( $descr =~ /^(\S+)\s+/ );
return;
}
sub os_ver {
my $netsnmp = shift;
my $descr = $netsnmp->description();
my $vers = $netsnmp->netsnmp_vers();
my $os_ver = undef;
$os_ver = $1 if ( $descr =~ /^\S+\s+\S+\s+(\S+)\s+/ );
if ($vers) {
$os_ver = "???" unless defined($os_ver);
$os_ver .= " / Net-SNMP " . $vers;
}
return $os_ver;
}
sub serial {
return '';
}
# sysUptime gives us the time since the SNMP daemon has restarted,
# so return the system uptime since that's probably what the user
# wants. (Caution: this could cause trouble if using
# sysUptime-based discontinuity timers or other TimeStamp
# objects.
sub uptime {
my $netsnmp = shift;
my $uptime;
$uptime = $netsnmp->hrSystemUptime();
return $uptime if defined $uptime;
return $netsnmp->SUPER::uptime();
}
sub i_ignore {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
# lo0 etc
if ( $interfaces->{$if} =~ /\blo\d*\b/i ) {
$i_ignore{$if}++;
}
}
return \%i_ignore;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::NetSNMP - SNMP Interface to L3 Net-SNMP Devices
=head1 AUTHORS
Bradley Baetz and Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $netsnmp = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $netsnmp->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Net-SNMP devices
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<UCD-SNMP-MIB>
=item F<NET-SNMP-TC>
=item F<HOST-RESOURCES-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $netsnmp->vendor()
Returns 'Net-SNMP'.
=item $netsnmp->os()
Returns the OS extracted from C<sysDescr>.
=item $netsnmp->os_ver()
Returns the software version extracted from C<sysDescr>, along
with the Net-SNMP version.
=item $netsnmp->uptime()
Returns the system uptime instead of the agent uptime.
NOTE: discontinuity timers and other Time Stamp based objects
are based on agent uptime, so use orig_uptime().
=item $netsnmp->serial()
Returns ''.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $netsnmp->i_ignore()
Returns reference to hash. Increments value of IID if port is to be ignored.
Ignores loopback
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
=head1 NOTES
In order to cause SNMP::Info to classify your device into this class, it
may be necessary to put a configuration line into your F<snmpd.conf>
similar to
sysobjectid .1.3.6.1.4.1.8072.3.2.N
where N is the object ID for your OS from the C<NET-SNMP-TC> MIB (or
255 if not listed). Some Net-SNMP installations default to an
incorrect return value for C<system.sysObjectId>.
In order to recognize a Net-SNMP device as Layer3, it may be necessary
to put a configuration line similar to
sysservices 76
in your F<snmpd.conf>.
=cut

View File

@@ -1,207 +0,0 @@
# SNMP::Info::Layer3::Netscreen
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Netscreen;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Netscreen::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Netscreen::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'NETSCREEN-SMI' => 'netscreenSetting',
'NETSCREEN-PRODUCTS-MIB' => 'netscreenGeneric',
'NETSCREEN-INTERFACE-MIB' => 'nsIfIndex',
'NETSCREEN-SET-GEN-MIB' => 'nsSetGenSwVer',
);
%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, 'os_version' => 'nsSetGenSwVer', );
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub layers {
return '01001100';
}
sub vendor {
return 'netscreen';
}
sub os {
return 'screenos';
}
sub os_ver {
my $netscreen = shift;
my $descr = $netscreen->description();
if ( $descr =~ m/version (\d\S*) \(SN: / ) {
return $1;
}
return;
}
sub serial {
my $netscreen = shift;
my $e_serial = $netscreen->e_serial() || {};
my $serial = $e_serial->{1} || undef;
return $1 if ( defined $serial and $serial =~ /(\d+)/ );
my $descr = $netscreen->description();
if ( $descr =~ m/version .*\(SN: (\d\S*),/ ) {
return $1;
}
return;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Netscreen - SNMP Interface to Juniper Netscreen Devices
=head1 AUTHOR
Kent Hamilton
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $netscreen = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $netscreen->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Netscreen device through SNMP. See inherited classes' documentation for
inherited methods.
my $netscreen = new SNMP::Info::Layer3::Netscreen(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<NETSCREEN-SMI>
=item F<NETSCREEN-PRODUCTS-MIB>
=item F<NETSCREEN-INTERFACE-MIB>
=item F<NETSCREEN-SET-GEN-MIB>
=item Inherited Classes
See L<SNMP::Info::Layer3/"Required MIBs"> and its inherited classes.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $netscreen->vendor()
Returns 'netscreen'
=item $netscreen->os()
Returns C<'screenos'>
=item $netscreen->os_ver()
Extracts the OS version from the description string.
=item $netscreen->serial()
Returns serial number..
=back
=head2 Overrides
=over
=item $netscreen->layers()
Returns 01001100. Device doesn't report layers properly, modified to reflect
Layer3 functionality.
=back
=head2 Globals imported from SNMP::Info::Layer3
See L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Table Methods imported from SNMP::Info::Layer3
See L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,220 +0,0 @@
# SNMP::Info::Layer3::PacketFront
# $Id$
#
# Copyright (c) 2011 Jeroen van Ingen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::PacketFront;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::PacketFront::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::PacketFront::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'UCD-SNMP-MIB' => 'versionTag',
'NET-SNMP-TC' => 'netSnmpAgentOIDs',
'HOST-RESOURCES-MIB' => 'hrSystem',
'PACKETFRONT-PRODUCTS-MIB' => 'drg100',
'PACKETFRONT-DRG-MIB' => 'productName',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'snmpd_vers' => 'versionTag',
'hrSystemUptime' => 'hrSystemUptime',
);
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub vendor {
return 'packetfront';
}
sub os {
# Only DRGOS for now (not tested with other product lines than DRG series)
my $pfront = shift;
my $descr = $pfront->description();
if ( $descr =~ /drgos/i ) {
return 'drgos';
} else {
return undef;
}
}
sub os_ver {
my $pfront = shift;
my $descr = $pfront->description();
my $os_ver = undef;
if ( $descr =~ /Version:\sdrgos-(\w+)-([\w\-\.]+)/ ) {
$os_ver = $2;
}
return $os_ver;
}
sub serial {
my $pfront = shift;
return $pfront->productSerialNo();
}
sub i_ignore {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
# lo0 etc
if ( $interfaces->{$if} =~ /\blo\d*\b/i ) {
$i_ignore{$if}++;
}
}
return \%i_ignore;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::PacketFront - SNMP Interface to PacketFront devices
=head1 AUTHORS
Jeroen van Ingen
initial version based on SNMP::Info::Layer3::NetSNMP by Bradley Baetz and Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $pfront = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myrouter',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $pfront->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for PacketFront devices
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<UCD-SNMP-MIB>
=item F<NET-SNMP-TC>
=item F<HOST-RESOURCES-MIB>
=item F<PACKETFRONT-PRODUCTS-MIB>
=item F<PACKETFRONT-DRG-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $pfront->vendor()
Returns 'packetfront'.
=item $pfront->os()
Returns the OS extracted from C<sysDescr>.
=item $pfront->os_ver()
Returns the software version extracted from C<sysDescr>.
=item $pfront->serial()
Returns the value of productSerialNo.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $pfront->i_ignore()
Returns reference to hash. Increments value of IID if port is to be ignored.
Ignores loopback
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
=cut

File diff suppressed because it is too large Load Diff

View File

@@ -1,294 +0,0 @@
# SNMP::Info::Layer3::Pf
# $Id$
#
# Copyright (c) 2010 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Pf Networks, Inc. nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Pf;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::LLDP;
@SNMP::Info::Layer3::Pf::ISA = qw/SNMP::Info::LLDP SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Pf::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS,
# Enterprise container where BEGEMOT-* lives
'FOKUS-MIB' => 'fokus',
# MIBs used included in Layer3 and above:
# UDP-MIB
# TCP-MIB
# IF-MIB
#
# Stuff in these MIBs but not used for Netdisco yet for my test device:
#
#'BEGEMOT-SNMPD-MIB',
#'BEGEMOT-PF-MIB',
#'BEGEMOT-NETGRAPH-MIB',
#'BEGEMOT-MIB2-MIB',
#'BEGEMOT-HOSTRES-MIB',
# HOST-RESOURCES-MIB
# IP-FORWARD-MIB
#
# Nothing in these MIBs for my test device:
#
#'BEGEMOT-IP-MIB',
#'BEGEMOT-MIB',
#'BEGEMOT-BRIDGE-MIB',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::LLDP::MUNGE,
);
sub vendor {
return 'FreeBSD';
}
sub model {
my $pf = shift;
my $descr = $pf->description() || '';
my $model = undef;
$model = $1 if ( $descr =~ /FreeBSD\s+(\S+)/ );
return $model if defined $model;
return $pf->os_ver();
}
sub os {
return 'Pf';
}
sub os_ver {
my $pf = shift;
my $id = $pf->id();
my $os_ver = &SNMP::translateObj($id);
return $id unless defined $os_ver;
# From /usr/share/snmp/defs/tree.def on a Pf Machine
# (2 begemotSnmpdDefs
# (1 begemotSnmpdAgent
# (1 begemotSnmpdAgentFreeBSD OID op_dummy)
# We're leaving the 1.1 and trimming off up to the 2
$os_ver =~ s/fokus.1.1.2.//;
return $os_ver;
}
# Use LLDP
sub hasCDP {
my $pf = shift;
return $pf->hasLLDP();
}
sub c_ip {
my $pf = shift;
my $partial = shift;
return $pf->lldp_ip($partial);
}
sub c_if {
my $pf = shift;
my $partial = shift;
return $pf->lldp_if($partial);
}
sub c_port {
my $pf = shift;
my $partial = shift;
return $pf->lldp_port($partial);
}
sub c_id {
my $pf = shift;
my $partial = shift;
return $pf->lldp_id($partial);
}
sub c_platform {
my $pf = shift;
my $partial = shift;
return $pf->lldp_rem_sysdesc($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Pf - SNMP Interface to FreeBSD-Based Firewalls using Pf /Pf Sense
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $pf = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $pf->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Free-BSD PF-Based devices
=head1 LLDP Support
LLDP Support is included but untested in this Device Class. It is reported
that the available CDP/LLDP modules for net-snmp don't work on FreeBSD (on
which pfSense is based) as they assume certain Linux specific Ethernet
structures. This problem is apparently solved on PF based firewall appliances
by using the ladvd package, for which a port may be found here:
L<http://www.freshports.org/net/ladvd/>. I'm not sure if this module ties into
Net-SNMP or not.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::LLDP
=back
=head2 Required MIBs
=over
=item F<FOKUS-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::LLDP/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar values from SNMP
=over
=item $pf->vendor()
Returns 'FreeBSD'
=item $pf->hasCDP()
Returns whether LLDP is enabled.
=item $pf->model()
Grabs the os version from C<sysDescr>
=item $pf->os()
Returns 'Pf'
=item $pf->os_ver()
Tries to reference $pf->id() to one of the product MIBs listed above.
Will probably return a truncation of the default OID for pf-based systems
C<enterprises.12325.1.1.2.1.1>.
=back
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $pf->c_id()
Returns LLDP information.
=item $pf->c_if()
Returns LLDP information.
=item $pf->c_ip()
Returns LLDP information.
=item $pf->c_platform()
Returns LLDP information.
=item $pf->c_port()
Returns LLDP information.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=cut

View File

@@ -1,204 +0,0 @@
# SNMP::Info::Layer3::Sun
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Sun;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Sun::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Sun::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( %SNMP::Info::Layer3::MIBS, );
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'sun_hostid' => '.1.3.6.1.4.1.42.3.1.2.0',
'motd' => '.1.3.6.1.4.1.42.3.1.3.0',
);
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub vendor {
return 'sun';
}
sub os {
return 'sun';
}
sub os_ver {
my $sun = shift;
my $descr = $sun->motd();
return unless defined $descr;
if ( $descr =~ m/SunOS (\S+)/ ) {
return $1;
}
return;
}
sub model {
return 'Solaris Router';
}
sub serial {
my $sun = shift;
my $serial = unpack( "H*", $sun->sun_hostid() );
return $serial;
}
sub i_ignore {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore;
foreach my $if ( keys %$interfaces ) {
# lo0
if ( $interfaces->{$if} =~ /\blo0\b/i ) {
$i_ignore{$if}++;
}
}
return \%i_ignore;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Sun - SNMP Interface to L3 Sun Solaris
=head1 AUTHOR
begemot
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $sun = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'mysunrouter',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $sun->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Sun Routers running SunOS
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $sun->vendor()
Returns 'sun'
=item $sun->os()
Returns 'sun'
=item $sun->os_ver()
Returns the software version extracted from message of the day.
=item $sun->model()
Returns 'Solaris Router'
=item $sun->serial()
Returns serial number
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $sun->i_ignore()
Returns reference to hash. Increments value of IID if port is to be ignored.
Ignores loopback
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,194 +0,0 @@
# SNMP::Info::Layer3::Timetra
# $Id$
#
# Copyright (c) 2008 Bill Fenner
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Timetra;
use strict;
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Timetra::ISA = qw/SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::Timetra::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( %SNMP::Info::Layer3::MIBS, 'TIMETRA-GLOBAL-MIB' => 'timetraReg', );
%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, );
%FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub model {
my $timetra = shift;
my $id = $timetra->id();
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^tmnxModel//;
return $model;
}
sub os {
return 'TiMOS';
}
sub vendor {
return 'alcatel-lucent';
}
sub os_ver {
my $timetra = shift;
my $descr = $timetra->description();
if ( $descr =~ m/^TiMOS-(\S+)/ ) {
return $1;
}
# No clue what this will try but hey
return $timetra->SUPER::os_ver();
}
# The interface description contains the SFP type, so
# to avoid losing historical information through a configuration change
# we use interface name instead.
sub interfaces {
my $alu = shift;
my $partial = shift;
return $alu->orig_i_name($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Timetra - SNMP Interface to Alcatel-Lucent SR
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $alu = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $alu->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Alcatel-Lucent Service Routers
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item F<TIMETRA-GLOBAL-MIB>
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $alu->vendor()
Returns 'alcatel-lucent'
=item $alu->os()
Returns 'TiMOS'
=item $alu->os_ver()
Grabs the version string from C<sysDescr>.
=item $alu->model()
Tries to reference $alu->id() to one of the product MIBs listed above
Removes 'tmnxModel' from the name for readability.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $alu->interfaces()
Returns C<ifName>, since the default Layer3 C<ifDescr> varies based
upon the transceiver inserted.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,331 +1,152 @@
# SNMP::Info::MAU - Media Access Unit - RFC 2668
# $Id$
#
# Copyright (c) 2008 Max Baker changes from version 0.8 and beyond.
# SNMP::Info::MAU - Media Access Unit - RFC2668
# Max Baker <max@warped.org>
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::MAU;
$VERSION = 0.3;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::MAU::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$VERSION = '2.06';
$INIT = 0;
%MIBS = ( 'MAU-MIB' => 'mauMod' );
%MIBS = ('MAU-MIB' => 'mauMod');
%GLOBALS = ();
%GLOBALS = (
);
%FUNCS = (
# Interface MAU Table
'mau_index' => 'ifMauIfIndex',
'mau_link' => 'ifMauType',
'mau_status' => 'ifMauStatus',
'mau_up' => 'ifMauMediaAvailable',
'mau_type' => 'ifMauTypeList',
'mau_type_admin' => 'ifMauDefaultType',
# Interface Auto-Negotiation Table
'mau_auto' => 'ifMauAutoNegSupported',
'mau_autostat' => 'ifMauAutoNegAdminStatus',
'mau_autosent' => 'ifMauAutoNegCapAdvertised',
'mau_autorec' => 'ifMauAutoNegCapReceived',
);
# Interface MAU Table
'mau_index' => 'ifMauIfIndex',
'mau_link' => 'ifMauType',
'mau_status' => 'ifMauStatus',
'mau_up' => 'ifMauMediaAvailable',
'mau_type' => 'ifMauTypeList',
'mau_type_admin' => 'ifMauDefaultType',
# Interface Auto-Negotiation Table
'mau_auto' => 'ifMauAutoNegSupported',
'mau_autostat' => 'ifMauAutoNegAdminStatus',
'mau_autosent' => 'ifMauAutoNegCapAdvertised',
'mau_autorec' => 'ifMauAutoNegCapReceived',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
# Add ones for our class
'mau_type' => \&munge_int2bin,
'mau_autosent' => \&munge_int2bin,
'mau_autorec' => \&munge_int2bin,
);
# Inherit all the built in munging
%SNMP::Info::MUNGE,
# Add ones for our class
'mau_type' => \&munge_int2bin,
'mau_autosent' => \&munge_int2bin,
'mau_autorec' => \&munge_int2bin,
);
sub munge_int2bin {
my $int = shift;
return unless defined $int;
return unpack( "B32", pack( "N", $int ) );
return undef unless defined $int;
return unpack("B32", pack("N", $int));
}
sub _isfullduplex {
my $mau = shift;
sub _isfullduplex{
my $mau = shift;
my $mautype = shift;
my @full_types = qw/11 13 16 18 20/;
foreach my $type (@full_types) {
return 1 if ( substr( $mautype, 32 - $type, 1 ) eq '1' );
foreach my $type ( @full_types ) {
return 1 if (substr($mautype,32-$type,1) eq '1')
}
return 0;
}
sub _ishalfduplex {
my $mau = shift;
sub _ishalfduplex{
my $mau = shift;
my $mautype = shift;
my @half_types = qw/10 12 15 17 19/;
foreach my $type (@half_types) {
return 1 if ( substr( $mautype, 32 - $type, 1 ) eq '1' );
foreach my $type ( @half_types ) {
return 1 if (substr($mautype,32-$type,1) eq '1')
}
return 0;
}
my %_mau_i_speed_map = (
'10' => '10 Mbps',
'100' => '100 Mbps',
'1000' => '1.0 Gbps',
'10Gig' => '10 Gbps',
);
sub mau_i_speed_admin {
my $mau = shift;
my $mau_index = $mau->mau_index();
my $mau_type_admin = $mau->mau_type_admin();
my %i_speed_admin;
foreach my $mau_port ( keys %$mau_type_admin ) {
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $type_adminoid = $mau_type_admin->{$mau_port};
my $type_admin = &SNMP::translateObj($type_adminoid);
next unless defined $type_admin;
if ( $type_adminoid eq '.0.0' ) {
$i_speed_admin{$iid} = 'auto';
}
elsif ($type_admin =~ /^dot3MauType(.*)Base/
&& $_mau_i_speed_map{$1} )
{
$i_speed_admin{$iid} = $_mau_i_speed_map{$1};
}
}
return \%i_speed_admin;
}
sub mau_i_duplex {
my $mau = shift;
my $mau_index = $mau->mau_index();
my $mau_link = $mau->mau_link();
my %i_duplex;
foreach my $mau_port ( keys %$mau_link ) {
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $linkoid = $mau_link->{$mau_port};
my $link = &SNMP::translateObj($linkoid);
next unless defined $link;
my $duplex = undef;
if ( $link =~ /fd$/i ) {
$duplex = 'full';
}
elsif ( $link =~ /hd$/i ) {
$duplex = 'half';
}
$i_duplex{$iid} = $duplex if defined $duplex;
}
return \%i_duplex;
}
sub mau_i_duplex_admin {
my $mau = shift;
my $partial = shift;
my $mau_index = $mau->mau_index() || {};
if ($partial) {
my %rev_mau_index = reverse %$mau_index;
$partial = $rev_mau_index{$partial};
}
my $mau_autostat = $mau->mau_autostat($partial) || {};
my $mau_type_admin = $mau->mau_type_admin($partial) || {};
# Older HP4000's don't implement ifMauDefaultType, but we can
# figure out from ifMauAutoNegCapAdvertised what we'd like.
if ( !defined($mau_type_admin) ) {
if ( defined($mau_index) ) {
return mau_i_duplex_admin_old( $mau, $mau_index, $mau_autostat );
}
else {
return;
}
}
my %i_duplex_admin;
foreach my $mau_port ( keys %$mau_type_admin ) {
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $autostat = $mau_autostat->{$mau_port};
if ( defined $autostat and $autostat =~ /enabled/i ) {
$i_duplex_admin{$iid} = 'auto';
next;
}
my $type_adminoid = $mau_type_admin->{$mau_port};
my $type_admin = &SNMP::translateObj($type_adminoid);
next unless defined $type_admin;
my $duplex = undef;
if ( $type_admin =~ /fd$/i ) {
$duplex = 'full';
}
elsif ( $type_admin =~ /hd$/i ) {
$duplex = 'half';
}
elsif ( $type_admin eq 'zeroDotZero' ) {
$duplex = 'auto';
}
$i_duplex_admin{$iid} = $duplex if defined $duplex;
}
return \%i_duplex_admin;
}
sub mau_i_duplex_admin_old {
my $mau = shift;
my $mau_index = shift;
my $mau_autostat = shift;
my $interfaces = $mau->interfaces();
my $mau_autosent = $mau->mau_autosent();
my %mau_reverse = reverse %$mau_index;
my %i_duplex_admin;
foreach my $iid ( keys %$interfaces ) {
my $mau_index = $mau_reverse{$iid};
next unless defined $mau_index;
my $autostat = $mau_autostat->{$mau_index};
# HP25xx has this value
if ( defined $autostat and $autostat =~ /enabled/i ) {
$i_duplex_admin{$iid} = 'auto';
next;
}
my $type = $mau_autosent->{$mau_index};
next unless defined $type;
if ( $type == 0 ) {
$i_duplex_admin{$iid} = 'none';
next;
}
my $full = $mau->_isfullduplex($type);
my $half = $mau->_ishalfduplex($type);
if ( $full and !$half ) {
$i_duplex_admin{$iid} = 'full';
}
elsif ($half) {
$i_duplex_admin{$iid} = 'half';
}
}
return \%i_duplex_admin;
}
1;
__END__
=head1 NAME
SNMP::Info::MAU - SNMP Interface to Medium Access Unit (MAU) MIB (RFC 2668)
via SNMP
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
my $mau = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'hpswitch',
Community => 'public',
Version => 2
);
my $class = $mau->class();
print " Using device sub class : $class\n";
SNMP::Info::MAU - Perl5 Interface to SNMP Medium Access Unit (MAU) MIB (RFC2668)
=head1 DESCRIPTION
SNMP::Info::MAU is a subclass of SNMP::Info that supplies access to the
F<MAU-MIB> (RFC 2668). This MIB is sometimes implemented on Layer 2 network
devices like HP Switches. MAU = Media Access Unit.
The MAU table contains link and duplex info for the port itself and the device
MAU-MIB is used by Layer 2 devices like HP Switches . The MAU table
contains link and duplex info for the port itself and the device
connected to that port.
Normally you use or create a subclass of SNMP::Info that inherits this one.
Do not use directly.
Inherits all methods from SNMP::Info
For debugging purposes call the class directly as you would SNMP::Info
=head1 AUTHOR
my $mau = new SNMP::Info::MAU(...);
Max Baker (C<max@warped.org>)
=head2 Inherited Classes
=head1 SYNOPSIS
None.
my $mau = new SNMP::Info::MAU( DestHost => 'myswitch',
Community => 'public');
=head2 Required MIBs
=head1 CREATING AN OBJECT
=over
=item F<MAU-MIB>
=item new SNMP::Info::MAU()
Arguments passed to new() are passed on to SNMP::Session::new()
my $mau = new SNMP::Info::MAU(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $mau;
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head1 MAU Global Configuration Values
=over
@@ -333,55 +154,21 @@ These are methods that return scalar value from SNMP
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $mau->mau_i_duplex()
Parses mau_index and mau_link to return the duplex information for
interfaces.
=item $mau->mau_i_duplex_admin()
Parses C<mac_index>,C<mau_autostat>,C<mau_type_admin> in
order to find the admin duplex setting for all the interfaces.
Returns either (auto,full,half).
=item $mau->mau_i_duplex_admin_old()
Called by mau_i_duplex_admin() if C<mau_type_admin> is empty.
Parses C<mau_index>,C<mau_autostat>,C<mau_autosent> in
order to find the admin duplex setting for all the interfaces.
Returns either (auto,none,full,half).
=item $mau->mau_i_speed_admin()
Returns admin speed setting for all the interfaces.
=back
=head2 MAU INTERFACE TABLE METHODS
=head1 MAU INTERFACE TABLE ENTRIES
=over
=item $mau->mau_index() - Returns a list of interfaces
and their index in the MAU IF Table.
(C<ifMauIfIndex>)
(B<ifMauIfIndex>)
=item $mau->mau_link() - Returns the type of Media Access used.
This is essentially the type of link in use.
eg. dot3MauType100BaseTXFD - 100BaseT at Full Duplex
(C<ifMauType>)
(B<ifMauType>)
=item $mau->mau_status() - Returns the admin link condition as
@@ -394,16 +181,16 @@ and their index in the MAU IF Table.
Use 5 and !5 to see if the link is up or down on the admin side.
(C<ifMauStatus>)
(B<ifMauStatus>)
=item $mau->mau_up() - Returns the current link condition
(C<ifMauMediaAvailable>)
(B<ifMauMediaAvailable>)
=item $mau->mau_type() - Returns a 32bit string reporting the capabilities
of the port from a MAU POV.
Directly from F<MAU-MIB> :
Directly from the MAU-MIB :
Bit Capability
0 other or unknown
1 AUI
@@ -427,33 +214,26 @@ of the port from a MAU POV.
19 100BASE-T2 half duplex mode
20 100BASE-T2 full duplex mode
(C<ifMauTypeList>)
=item $mau->mau_type_admin()
(C<ifMauDefaultType>)
(B<ifMauTypeList>)
=item $mau->mau_auto() - Returns status of auto-negotiation mode for ports.
(C<ifMauAutoNegAdminStatus>)
=item $mau->mau_autostat()
(C<ifMauAutoNegAdminStatus>)
(B<ifMauAutoNegAdminStatus>)
=item $mau->mau_autosent() - Returns a 32 bit bit-string representing the
capabilities we are broadcasting on that port
Uses the same decoder as $mau->mau_type().
(C<ifMauAutoNegCapAdvertised>)
(B<ifMauAutoNegCapAdvertised>)
=item $mau->mau_autorec() - Returns a 32 bit bit-string representing the
capabilities of the device on the other end.
Uses the same decoder as $mau->mau_type().
(C<ifMauAutoNegCapReceived>)
(B<ifMauAutoNegCapReceived>)
=back
@@ -465,14 +245,13 @@ capabilities of the device on the other end.
=item $mau->_isfullduplex(bitstring)
Boolean. Checks to see if any of the full_duplex types from mau_type()
are high. Currently bits 11,13,16,18,20.
Boolean. Checks to see if any of the full_duplex types from mau_type() are
high. Currently bits 11,13,16,18,20.
=item $mau->_ishalfduplex(bitstring)
Boolean. Checks to see if any of the half_duplex types from mau_type()
are high. Currently bits 10,12,15,17,19.
Boolean. Checks to see if any of the half_duplex types from mau_type() are
high. Currently bits 10,12,15,17,19.
=back
=cut

View File

@@ -1,912 +0,0 @@
# SNMP::Info::NortelStack
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::NortelStack;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::NortelStack::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
# S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below
'S5-AGENT-MIB' => 's5AgMyGrpIndx',
'S5-CHASSIS-MIB' => 's5ChasType',
'S5-REG-MIB' => 's5ChasTypeVal',
);
%GLOBALS = (
# From S5-AGENT-MIB
'ns_ag_ver' => 's5AgInfoVer',
'ns_op_mode' => 's5AgSysCurrentOperationalMode',
'ns_auto_pvid' => 's5AgSysAutoPvid',
'tftp_host' => 's5AgSysTftpServerAddress',
'tftp_file' => 's5AgSysBinaryConfigFilename',
'tftp_action' => 's5AgInfoFileAction',
'tftp_result' => 's5AgInfoFileStatus',
'vlan' => 's5AgSysManagementVlanId',
# From S5-CHASSIS-MIB
'ns_serial' => 's5ChasSerNum',
'ns_ch_type' => 's5ChasType',
'ns_cfg_chg' => 's5ChasGblConfChngs',
'ns_cfg_time' => 's5ChasGblConfLstChng',
);
%FUNCS = (
# From S5-AGENT-MIB::s5AgMyIfTable
'i_cfg_file' => 's5AgMyIfCfgFname',
'i_cfg_host' => 's5AgMyIfLdSvrAddr',
# From S5-CHASSIS-MIB::s5ChasGrpTable
'ns_grp_type' => 's5ChasGrpType',
# From S5-CHASSIS-MIB::s5ChasComTable
'ns_com_grp_idx' => 's5ChasComGrpIndx',
'ns_com_idx' => 's5ChasComIndx',
'ns_com_sub_idx' => 's5ChasComSubIndx',
'ns_com_type' => 's5ChasComType',
'ns_com_descr' => 's5ChasComDescr',
'ns_com_ver' => 's5ChasComVer',
'ns_com_serial' => 's5ChasComSerNum',
# From S5-CHASSIS-MIB::s5ChasStoreTable
'ns_store_grp_idx' => 's5ChasStoreGrpIndx',
'ns_store_com_idx' => 's5ChasStoreComIndx',
'ns_store_sub_idx' => 's5ChasStoreSubIndx',
'ns_store_idx' => 's5ChasStoreIndx',
'ns_store_type' => 's5ChasStoreType',
'ns_store_size' => 's5ChasStoreCurSize',
'ns_store_ver' => 's5ChasStoreCntntVer',
);
%MUNGE = (
'ns_ch_type' => \&SNMP::Info::munge_e_type,
'ns_grp_type' => \&munge_ns_grp_type,
'ns_com_type' => \&SNMP::Info::munge_e_type,
'ns_store_type' => \&SNMP::Info::munge_e_type,
);
sub os_ver {
my $stack = shift;
my $ver = $stack->ns_ag_ver();
return unless defined $ver;
if ( $ver =~ m/(\d+\.\d+\.\d+\.\d+)/ ) {
return $1;
}
if ( $ver =~ m/V(\d+\.\d+\.\d+)/i ) {
return $1;
}
return;
}
sub os_bin {
my $stack = shift;
my $ver = $stack->ns_ag_ver();
return unless defined $ver;
if ( $ver =~ m/(\d+\.\d+\.\d+\.\d+)/i ) {
return $1;
}
if ( $ver =~ m/V(\d+\.\d+.\d+)/i ) {
return $1;
}
return;
}
# Need to override here since overridden in Layer2 and Layer3 classes
sub serial {
my $stack = shift;
my $ver = $stack->ns_serial();
return $ver unless !defined $ver;
return;
}
# Pseudo ENTITY-MIB methods for older switches with don't support ENTITY-MIB
# This class supports both stackable and chassis based switches, identify if
# we have a stackable so that we return appropriate entPhysicalClass
sub _ns_e_is_virtual {
my $stack = shift;
# We really only need one value, but we want this cached since most
# methods call it at least via ns_e_index()
my $v_test = $stack->s5ChasComRelPos() || {};
return $v_test->{'8.1.0'};
}
# Identify is the stackable is actually a stack vs. single switch
sub _ns_e_is_stack {
my $stack = shift;
my $s_test = $stack->ns_e_class() || {};
foreach my $iid ( keys %$s_test ) {
my $class = $s_test->{$iid};
next unless defined $class;
return 1 if ( $class eq 'stack' );
}
return 0;
}
sub ns_e_index {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_com_grp_idx($partial) || {};
my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_index;
foreach my $iid ( keys %$ns_e_idx ) {
# Skip backplane, power, sensor, fan, clock - these aren't in the
# newer devices ENTITY-MIB we're emulating
next if ( $iid =~ /^[24567]/ );
next if ( ($is_virtual) and ( $iid =~ /^8/ or $iid eq '1.0.0' ) );
# Format into consistent integer format so that numeric sorting works
my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid );
$ns_e_index{$iid} = $index;
}
return \%ns_e_index;
}
sub ns_e_class {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $classes = $stack->ns_grp_type();
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_class;
foreach my $iid ( keys %$ns_e_idx ) {
my ( $grp, $idx, $sub ) = split( /\./, $iid );
next unless defined $grp;
my $class = $classes->{$grp};
next unless defined $class;
my $enc = $ns_grp_enc->{$grp};
# Handle quirks of dealing with both stacks and chassis
if ( ( !$is_virtual ) and ( $grp == 1 ) ) {
$class = 'module';
}
if ( ($is_virtual) and ( $grp == 3 ) and !( $idx % $enc ) ) {
$class = 'chassis';
}
$ns_e_class{$iid} = $class;
}
return \%ns_e_class;
}
sub ns_e_descr {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_descr = $stack->ns_com_descr($partial) || {};
my %ns_e_descr;
foreach my $iid ( keys %$ns_e_idx ) {
my $descr = $ns_e_descr->{$iid};
next unless defined $descr;
$ns_e_descr{$iid} = $descr;
}
return \%ns_e_descr;
}
sub ns_e_name {
my $stack = shift;
my $partial = shift;
my $ns_class = $stack->ns_e_class() || {};
my $ns_e_idx = $stack->ns_e_index() || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_name;
foreach my $iid ( keys %$ns_e_idx ) {
my ( $grp, $idx, $sub ) = split( /\./, $iid );
my $class = $ns_class->{$iid};
next unless defined $class;
my $enc = $ns_grp_enc->{$grp};
if ( ( !$is_virtual ) and ( $grp == 1 ) ) {
$ns_e_name{$iid} = 'Supervisory Module';
}
elsif ( $class eq 'stack' ) {
$ns_e_name{$iid} = 'Stack Master Unit';
}
elsif ( $class eq 'chassis' ) {
if ($is_virtual) {
my $unit = $idx / $enc;
$ns_e_name{$iid} = "Switch Unit $unit";
}
else {
$ns_e_name{$iid} = "Chassis";
}
}
elsif ( $class eq 'module' ) {
if ($is_virtual) {
my $unit = int( $idx / $enc );
my $mda = $idx % $enc;
$ns_e_name{$iid} = "Switch Unit $unit, MDA $mda";
}
elsif ( $sub != 0 ) {
$ns_e_name{$iid} = "Module Slot $idx, Subcomponent $sub";
}
else {
$ns_e_name{$iid} = "Module Slot $idx";
}
}
}
return \%ns_e_name;
}
sub ns_e_hwver {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_ver = $stack->ns_com_ver($partial) || {};
my %ns_e_hwver;
foreach my $iid ( keys %$ns_e_idx ) {
my $ver = $ns_e_ver->{$iid};
next unless defined $ver;
$ns_e_hwver{$iid} = $ver;
}
return \%ns_e_hwver;
}
sub ns_e_vendor {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my %ns_e_vendor;
foreach my $iid ( keys %$ns_e_idx ) {
my $vendor = 'nortel';
$ns_e_vendor{$iid} = $vendor;
}
return \%ns_e_vendor;
}
sub ns_e_serial {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_serial = $stack->ns_com_serial($partial) || {};
my %ns_e_serial;
foreach my $iid ( keys %$ns_e_idx ) {
my $serial = $ns_e_serial->{$iid};
next unless defined $serial;
$ns_e_serial{$iid} = $serial;
}
return \%ns_e_serial;
}
sub ns_e_type {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_type = $stack->ns_com_type($partial) || {};
my $is_stack = $stack->_ns_e_is_stack();
my $ch_type = $stack->ns_ch_type();
my %ns_e_type;
foreach my $iid ( keys %$ns_e_idx ) {
my $type = $ns_e_type->{$iid};
next unless defined $type;
if ( $is_stack and $iid =~ /^1/ ) {
$type = $ch_type;
}
$ns_e_type{$iid} = $type;
}
return \%ns_e_type;
}
sub ns_e_pos {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_stack = $stack->_ns_e_is_stack();
my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_pos;
foreach my $iid ( keys %$ns_e_idx ) {
my ( $grp, $pos, $idx ) = split( /\./, $iid );
next unless defined $grp;
next unless defined $pos;
if ( $grp == 1 ) {
if ($is_stack) {
$pos = -1;
}
else {
$pos = 99;
}
}
elsif ( $grp == 3 and $idx == 0 ) {
my $enc = $ns_grp_enc->{$grp};
if ( $is_virtual and ( $pos % $enc ) ) {
$pos = int( $pos % $enc );
}
elsif ( $is_virtual and !$is_stack and !( $pos % $enc ) ) {
$pos = -1;
}
elsif ( $is_virtual and !( $pos % $enc ) ) {
$pos = ( $pos / $enc );
}
}
elsif ( !$is_stack and $grp == 3 ) {
$pos = $idx;
}
elsif ( $grp == 8 ) {
$pos = -1;
}
$ns_e_pos{$iid} = $pos;
}
return \%ns_e_pos;
}
sub ns_e_fwver {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_ver = $stack->ns_store_ver($partial) || {};
my $ns_e_type = $stack->ns_store_type($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virt = $stack->_ns_e_is_virtual();
my %ns_e_fwver;
foreach my $iid ( keys %$ns_e_type ) {
my $type = $ns_e_type->{$iid};
next unless defined $type;
next unless $type =~ /(rom|boot|fw)/i;
my $ver = $ns_e_ver->{$iid};
next unless defined $ver;
$iid =~ s/\.\d+$//;
if ($is_virt) {
my ( $grp, $idx, $pos ) = split( /\./, $iid );
my $enc = $ns_grp_enc->{$grp};
$idx = $idx * $enc;
$iid = "3.$idx.$pos";
}
$ns_e_fwver{$iid} = $ver;
}
return \%ns_e_fwver;
}
sub ns_e_swver {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_ver = $stack->ns_store_ver($partial) || {};
my $ns_e_type = $stack->ns_store_type($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virt = $stack->_ns_e_is_virtual();
my %ns_e_swver;
foreach my $iid ( keys %$ns_e_type ) {
my $type = $ns_e_type->{$iid};
next unless defined $type;
next unless $type =~ /(flash)/i;
my $ver = $ns_e_ver->{$iid};
next unless defined $ver;
$iid =~ s/\.\d+$//;
if ($is_virt) {
my ( $grp, $idx, $pos ) = split( /\./, $iid );
my $enc = $ns_grp_enc->{$grp};
$idx = $idx * $enc;
$iid = "3.$idx.$pos";
}
$ns_e_swver{$iid} = $ver;
}
return \%ns_e_swver;
}
sub ns_e_parent {
my $stack = shift;
my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_stack = $stack->_ns_e_is_stack();
my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_parent;
foreach my $iid ( keys %$ns_e_idx ) {
my $index = $ns_e_idx->{$iid};
my ( $grp, $idx, $pos ) = split( /\./, $iid );
next unless defined $grp;
if ( $grp == 8 ) {
$ns_e_parent{$iid} = '0';
}
if ( $grp == 1 ) {
if ($is_stack) {
$ns_e_parent{$iid} = '0';
}
else {
$ns_e_parent{$iid} = '080100';
}
}
if ( $grp == 3 ) {
my $enc = $ns_grp_enc->{$grp};
if ( $idx % $enc ) {
my $npos = ( $idx % $enc ) * $enc;
my @parent = ( $grp, $npos, $pos );
my $parent = join( '', map { sprintf "%02d", $_ } @parent );
$ns_e_parent{$iid} = $parent;
}
elsif ($is_stack) {
$ns_e_parent{$iid} = '010100';
}
elsif ( $is_virtual and !$is_stack ) {
$ns_e_parent{$iid} = 0;
}
elsif ( $pos == 0 ) {
$ns_e_parent{$iid} = '080100';
}
else {
my $parent = $iid;
$parent =~ s/\.\d+$/\.00/;
$parent = join( '', map { sprintf "%02d", $_ } split /\./,
$parent );
$ns_e_parent{$iid} = $parent;
}
}
next;
}
return \%ns_e_parent;
}
sub munge_ns_grp_type {
my $oid = shift;
my %e_class = (
Sup => 'stack',
Bkpl => 'backplane',
Brd => 'module',
Pwr => 'powerSupply',
TmpSnr => 'sensor',
Fan => 'fan',
Clk => 'other',
Unit => 'chassis',
);
my $name = &SNMP::translateObj($oid);
$name =~ s/s5ChasGrp//;
if ( ( defined($name) ) and ( exists( $e_class{$name} ) ) ) {
$name = $e_class{$name};
}
return $name if defined($name);
return $oid;
}
1;
__END__
=head1 NAME
SNMP::Info::NortelStack - SNMP Interface to the Nortel F<S5-AGENT-MIB> and
F<S5-CHASSIS-MIB>
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $stack = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $stack->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::NortelStack is a subclass of SNMP::Info that provides an interface
to F<S5-AGENT-MIB> and F<S5-CHASSIS-MIB>. These MIBs are used across the
Nortel Stackable Ethernet Switches (BayStack), as well as, older Nortel
devices such as the Centillion family of ATM switches.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<S5-AGENT-MIB>
=item F<S5-CHASSIS-MIB>
=item F<S5-ROOT-MIB> and F<S5-TCS-MIB> are required by the other MIBs.
=back
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
=item $stack->os_ver()
Returns the software version extracted from (C<s5AgInfoVer>)
=item $stack->os_bin()
Returns the firmware version extracted from (C<s5AgInfoVer>)
=item $stack->serial()
Returns serial number of the chassis
(C<s5ChasSerNum>)
=item $stack->ns_ag_ver()
Returns the version of the agent in the form
'major.minor.maintenance[letters]'.
(C<s5AgInfoVer>)
=item $stack->ns_op_mode()
Returns the stacking mode.
(C<s5AgSysCurrentOperationalMode>)
=item $stack->tftp_action()
This object is used to download or upload a config file or an image file.
(C<s5AgInfoFileAction>)
=item $stack->tftp_result()
Returns the status of the latest action as shown by $stack->tftp_action().
(C<s5AgInfoFileStatus>)
=item $stack->ns_auto_pvid()
Returns the value indicating whether adding a port as a member of a VLAN
automatically results in its PVID being set to be the same as that VLAN ID.
(C<s5AgSysAutoPvid>)
=item $stack->tftp_file()
Name of the binary configuration file that will be downloaded/uploaded when
the $stack->tftp_action() object is set.
(C<s5AgSysBinaryConfigFilename>)
=item $stack->tftp_host()
The IP address of the TFTP server for all TFTP operations.
(C<s5AgSysTftpServerAddress>)
=item $stack->vlan()
Returns the VLAN ID of the system's management VLAN.
(C<s5AgSysManagementVlanId>)
=item $stack->ch_ser()
Returns the serial number of the chassis.
(C<s5ChasSerNum>)
=item $stack->ns_cfg_chg()
Returns the total number of configuration changes (other than attachment
changes, or physical additions or removals) in the chassis that have been
detected since cold/warm start.
(C<s5ChasGblConfChngs>)
=item $stack->ns_cfg_time()
Returns the value of C<sysUpTime> when the last configuration change (other
than attachment changes, or physical additions or removals) in the chassis
was detected.
(C<s5ChasGblConfLstChng>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Agent Interface Table (C<s5AgMyIfTable>)
=over
=item $stack->i_cfg_file()
Returns reference to hash. Key: Table entry, Value: Name of the file
(C<s5AgMyIfCfgFname>)
=item $stack->i_cfg_host()
Returns reference to hash. Key: Table entry, Value: IP address of the load
server
(C<s5AgMyIfLdSvrAddr>)
=back
=head2 Chassis Components Table (C<s5ChasComTable>)
=over
=item $stack->ns_com_grp_idx()
Returns reference to hash. Key: Table entry, Value: Index of the chassis
level group which contains this component.
(C<s5ChasComGrpIndx>)
=item $stack->ns_com_idx()
Returns reference to hash. Key: Table entry, Value: Index of the component
in the group. For modules in the 'board' group, this is the slot number.
(C<s5ChasComIndx>)
=item $stack->ns_com_sub_idx()
Returns reference to hash. Key: Table entry, Value: Index of the
sub-component in the component.
(C<s5ChasComSubIndx>)
=item $stack->ns_com_type()
Returns reference to hash. Key: Table entry, Value: Type
(C<s5ChasComType>)
=item $stack->ns_com_descr()
Returns reference to hash. Key: Table entry, Value: Description
(C<s5ChasComDescr>)
=item $stack->ns_com_ver()
Returns reference to hash. Key: Table entry, Value: Version
(C<s5ChasComVer>)
=item $stack->ns_com_serial()
Returns reference to hash. Key: Table entry, Value: Serial Number
(C<s5ChasComSerNum>)
=back
=head2 Storage Area Table (C<s5ChasStoreTable>)
=over
=item $stack->ns_store_grp_idx()
Returns reference to hash. Key: Table entry, Value: Index of the chassis
level group.
(C<s5ChasStoreGrpIndx>)
=item $stack->ns_store_idx()
Returns reference to hash. Key: Table entry, Value: Index of the group.
(C<s5ChasStoreComIndx>)
=item $stack->ns_store_sub_idx()
Returns reference to hash. Key: Table entry, Value: Index of the
sub-component.
(C<s5ChasStoreSubIndx>)
=item $stack->ns_store_idx()
Returns reference to hash. Key: Table entry, Value: Index of the storage
area.
(C<s5ChasStoreIndx>)
=item $stack->ns_store_type()
Returns reference to hash. Key: Table entry, Value: Type
(C<s5ChasStoreType>)
=item $stack->ns_store_size()
Returns reference to hash. Key: Table entry, Value: Size
(C<s5ChasStoreCurSize>)
=item $stack->ns_store_ver()
Returns reference to hash. Key: Table entry, Value: Version
(C<s5ChasStoreCntntVer>)
=back
=head2 Pseudo F<ENTITY-MIB> information
These methods emulate F<ENTITY-MIB> Physical Table methods using
F<S5-CHASSIS-MIB>.
=over
=item $stack->ns_e_index()
Returns reference to hash. Key: IID, Value: Integer, Indices are combined
into a six digit integer, each index is two digits padded with leading zero if
required.
=item $stack->ns_e_class()
Returns reference to hash. Key: IID, Value: General hardware type
(C<s5ChasGrpDescr>).
Group is stripped from the string. Values may be Supervisory Module,
Back Plane, Board, Power Supply, Sensor, Fan, Clock, Unit.
=item $stack->ns_e_descr()
Returns reference to hash. Key: IID, Value: Human friendly name
(C<s5ChasComDescr>)
=item $stack->ns_e_name()
Returns reference to hash. Key: IID, Value: Human friendly name
=item $stack->ns_e_hwver()
Returns reference to hash. Key: IID, Value: Hardware version
(C<s5ChasComVer>)
=item $stack->ns_e_vendor()
Returns reference to hash. Key: IID, Value: nortel
=item $stack->ns_e_serial()
Returns reference to hash. Key: IID, Value: Serial number
(C<s5ChasComSerNum>)
=item $stack->ns_e_pos()
Returns reference to hash. Key: IID, Value: The relative position among all
entities sharing the same parent.
(C<s5ChasComSubIndx>)
=item $stack->ns_e_type()
Returns reference to hash. Key: IID, Value: Type of component/sub-component
as defined under C<s5ChasComTypeVal> in F<S5-REG-MIB>.
=item $stack->ns_e_fwver()
Returns reference to hash. Key: IID, Value: Firmware revision.
Value of C<s5ChasStoreCntntVer> for entries with rom, boot, or firmware in
C<s5ChasStoreType>.
=item $stack->ns_e_swver()
Returns reference to hash. Key: IID, Value: Software revision.
Value of C<s5ChasStoreCntntVer> for entries with "flash" in
C<s5ChasStoreType>.
=item $stack->ns_e_parent()
Returns reference to hash. Key: IID, Value: The value of ns_e_index() for the
entity which 'contains' this entity. A value of zero indicates this entity
is not contained in any other entity.
=back
=head1 Data Munging Callback Subroutines
=over
=item $stack->munge_ns_grp_type()
Munges C<s5ChasGrpType> into an C<ENTITY-MIB PhysicalClass> equivalent.
=back
=cut

View File

@@ -1,255 +0,0 @@
# SNMP::Info::PowerEthernet
# $Id$
#
# Copyright (c) 2008 Bill Fenner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::PowerEthernet;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::PowerEthernet::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::PowerEthernet::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '2.06';
%MIBS = ( 'POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus' );
%GLOBALS = ();
%FUNCS = (
# parts of pethPsePortTable
'peth_port_admin' => 'pethPsePortAdminEnable',
'peth_port_status' => 'pethPsePortDetectionStatus',
'peth_port_class' => 'pethPsePortPowerClassifications',
# pethMainPseTable
'peth_power_watts' => 'pethMainPsePower',
'peth_power_status' => 'pethMainPseOperStatus',
'peth_power_consumption' => 'pethMainPseConsumptionPower',
'peth_power_threshold' => 'pethMainPseUsageThreshold',
);
%MUNGE = ();
# POWER-ETHERNET-MIB doesn't define a mapping of its
# "module"/"port" index to ifIndex. Different vendors
# do this in different ways. This is a poor fallback:
# if all of the module values = 1, return the port number
# on the assumption that port number = ifindex.
# If there is a module != 1, this heuristic doesn't work
# so returns undef.
sub peth_port_ifindex {
my $peth = shift;
my $partial = shift;
my $peth_port_status = $peth->peth_port_status($partial);
my $peth_port_ifindex;
foreach my $i ( keys %$peth_port_status ) {
my ( $module, $port ) = split( /\./, $i );
if ( $module != 1 ) {
# This heuristic won't work, so say that we got nothing.
# If you have this case, you have to write a device-specific
# version of this function.
return;
}
$peth_port_ifindex->{$i} = $port;
}
return $peth_port_ifindex;
}
# Subclasses are encouraged to override this method to report
# what has actually been negotiated with the device, if a
# protocol with more values (e.g., CDP) has been used.
sub peth_port_neg_power {
my $peth = shift;
my $partial = shift;
my $peth_port_status = $peth->peth_port_status($partial);
my $peth_port_class = $peth->peth_port_class($partial);
my $poemax = { 'class0' => 12950, 'class1' => 3840, 'class2' => 6490, 'class3' => 12950,
'class4' => 25500 };
my $peth_port_neg_power = {};
foreach my $i ( keys %$peth_port_status ) {
if ($peth_port_status->{$i} eq 'deliveringPower') {
$peth_port_neg_power->{$i} = $poemax->{ $peth_port_class->{$i} };
}
}
return $peth_port_neg_power;
}
1;
__END__
=head1 NAME
SNMP::Info::PowerEthernet - SNMP Interface to data stored in
F<POWER-ETHERNET-MIB>.
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $poe = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $poe->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
F<POWER-ETHERNET-MIB> is used to describe PoE (IEEE 802.3af)
Create or use a device subclass that inherit this class. Do not use directly.
For debugging purposes you can call this class directly as you would
SNMP::Info
my $poe = new SNMP::Info::PowerEthernet (...);
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item F<POWER-ETHERNET-MIB>
=back
=head1 GLOBALS
none.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Power Port Table
Selected values from the C<pethPsePortTable>
=over
=item $poe->peth_port_admin()
Administrative status: is this port permitted to deliver power?
C<pethPsePortAdminEnable>
=item $poe->peth_port_status()
Current status: is this port delivering power, searching, disabled, etc?
C<pethPsePortDetectionStatus>
=item $poe->peth_port_class()
Device class: if status is delivering power, this represents the 802.3af
class of the device being powered.
C<pethPsePortPowerClassifications>
=item $poe->peth_port_ifindex()
A mapping function from the C<pethPsePortTable> INDEX of
module.port to an C<ifIndex>. The default mapping ignores the
module (returning undef if there are any module values greater
than 1) and returns the port number, assuming that there is a
1:1 mapping.
This mapping is more or less left up to the device vendor to
implement; the MIB gives only very weak guidance.
A given device class may implement its own version
of this function (e.g., see Info::CiscoPower).
=item $poe->peth_port_neg_power()
The power, in milliwatts, that has been committed to this port.
This value is derived from the 802.3af class of the device being
powered, but may be overridden by a subclass that has information
from another source (e.g., if a different protocol, such as CDP,
was used to negotiate the power level.)
=back
=head2 Power Supply Table
=over
=item $poe->peth_power_watts()
The power supply's capacity, in watts.
C<pethMainPsePower>
=item $poe->peth_power_status()
The power supply's operational status.
C<pethMainPseOperStatus>
=item $poe->peth_power_consumption()
How much power, in watts, this power supply has been committed to
deliver. (Note: certain devices seem to supply this value in milliwatts,
so be cautious interpreting it.)
C<pethMainPseConsumptionPower>
=item $poe->peth_power_threshold()
The threshold (in percent) of consumption required to raise an
alarm.
C<pethMainPseUsageThreshold>
=back
=cut

File diff suppressed because it is too large Load Diff

View File

@@ -1,419 +0,0 @@
# SNMP::Info::SONMP
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::SONMP;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::SONMP::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '2.06';
%MIBS = (
'SYNOPTICS-ROOT-MIB' => 'synoptics',
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop',
);
%GLOBALS = (
'cdp_id' => 's5EnMsTopIpAddr',
'cdp_run' => 's5EnMsTopStatus',
);
%FUNCS = (
# From S5-ETH-MULTISEG-TOPOLOGY-MIB::TopNmmTable
'sonmp_topo_slot' => 's5EnMsTopNmmSlot',
'sonmp_topo_port' => 's5EnMsTopNmmPort',
'sonmp_topo_ip' => 's5EnMsTopNmmIpAddr',
'sonmp_topo_seg' => 's5EnMsTopNmmSegId',
'sonmp_topo_mac' => 's5EnMsTopNmmMacAddr',
'sonmp_topo_platform' => 's5EnMsTopNmmChassisType',
'sonmp_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
%MUNGE = ( 'sonmp_topo_mac' => \&SNMP::Info::munge_mac );
sub index_factor {
return 32;
}
sub slot_offset {
return 1;
}
sub port_offset {
return 0;
}
sub hasCDP {
my $sonmp = shift;
return $sonmp->cdp_run();
}
sub c_if {
my $sonmp = shift;
my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot($partial) || {};
my $index_factor = $sonmp->index_factor();
my $slot_offset = $sonmp->slot_offset();
my $port_offset = $sonmp->port_offset();
my $model = $sonmp->model();
my %c_if;
foreach my $entry ( keys %$sonmp_topo_port ) {
my $port = $sonmp_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
my $slot = $sonmp_topo_slot->{$entry} || 0;
if ( $model eq 'Baystack Hub' ) {
my $comidx = $slot;
if ( !( $comidx % 5 ) ) {
$slot = ( $slot / 5 );
}
elsif ( $comidx =~ /[16]$/ ) {
$slot = int( $slot / 5 );
$port = 25;
}
elsif ( $comidx =~ /[27]$/ ) {
$slot = int( $slot / 5 );
$port = 26;
}
}
my $index = ( ( $slot - $slot_offset ) * $index_factor )
+ ( $port - $port_offset );
$c_if{$entry} = $index;
}
return \%c_if;
}
sub c_ip {
my $sonmp = shift;
my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_ip = $sonmp->sonmp_topo_ip($partial) || {};
my %c_ip;
foreach my $entry ( keys %$sonmp_topo_ip ) {
my $port = $sonmp_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
my $ip = $sonmp_topo_ip->{$entry};
$c_ip{$entry} = $ip;
}
return \%c_ip;
}
sub c_port {
my $sonmp = shift;
my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_seg = $sonmp->sonmp_topo_seg($partial) || {};
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {};
my %c_port;
foreach my $entry ( keys %$sonmp_topo_seg ) {
my $port = $sonmp_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
my $seg = $sonmp_topo_seg->{$entry};
my $platform = $sonmp_topo_platform->{$entry};
# AP-222x Series does not adhere to port numbering
if ( $platform =~ /AccessPoint/i ) {
$c_port{$entry} = 'dp0';
}
# BayHubs send the lower three bytes of the MAC not the slot/port
elsif ( $seg > 4000 ) {
$c_port{$entry} = 'unknown';
}
else {
# Segment id is (256 * remote slot_num) + (remote_port)
my $remote_port = $seg % 256;
my $remote_slot = int( $seg / 256 );
$c_port{$entry} = "$remote_slot.$remote_port";
}
}
return \%c_port;
}
sub c_platform {
my $sonmp = shift;
my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {};
my %c_platform;
foreach my $entry ( keys %$sonmp_topo_platform ) {
my $port = $sonmp_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
my $platform = $sonmp_topo_platform->{$entry};
$c_platform{$entry} = $platform;
}
return \%c_platform;
}
sub mac {
my $sonmp = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
my $sonmp_topo_mac = $sonmp->sonmp_topo_mac();
foreach my $entry ( keys %$sonmp_topo_port ) {
my $port = $sonmp_topo_port->{$entry};
next unless $port == 0;
my $mac = $sonmp_topo_mac->{$entry};
return $mac;
}
# Topology turned off, not supported.
return;
}
1;
__END__
=head1 NAME
SNMP::Info::SONMP - SNMP Interface to SynOptics Network Management Protocol
(SONMP)
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
my $sonmp = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
my $class = $sonmp->class();
print " Using device sub class : $class\n";
$hascdp = $sonmp->hasCDP() ? 'yes' : 'no';
# Print out a map of device ports with CDP neighbors:
my $interfaces = $sonmp->interfaces();
my $c_if = $sonmp->c_if();
my $c_ip = $sonmp->c_ip();
my $c_port = $sonmp->c_port();
foreach my $cdp_key (keys %$c_ip){
my $iid = $c_if->{$cdp_key};
my $port = $interfaces->{$iid};
my $neighbor = $c_ip->{$cdp_key};
my $neighbor_port = $c_port->{$cdp_key};
print "Port : $port connected to $neighbor / $neighbor_port\n";
}
=head1 DESCRIPTION
SNMP::Info::SONMP is a subclass of SNMP::Info that provides an object oriented
interface to the SynOptics Network Management Protocol (SONMP) information
through SNMP.
SONMP is a Layer 2 protocol that supplies topology information of devices that
also speak SONMP, mostly switches and hubs. SONMP is implemented in
SynOptics, Bay, and Nortel devices. SONMP has been rebranded by Bay then
Nortel and is know by several different names, most recently Nortel
Discovery Protocol (NDP).
Create or use a device subclass that inherits this class. Do not use
directly.
Each device implements a subset of the global and cache entries.
Check the return value to see if that data is held by the device.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item F<SYNOPTICS-ROOT-MIB>
=item F<S5-ETH-MULTISEG-TOPOLOGY-MIB>
=back
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
=item $sonmp->index_factor()
Returns a number representing the number of ports reserved per slot or switch
within the device MIB. Defaults to 32.
=item $sonmp->slot_offset()
Returns the offset if slot numbering does not start at 0. Defaults to 1.
=item $sonmp->port_offset()
Returns the offset if port numbering does not start at 0. Defaults to 0.
=item $cdp->hasCDP()
Is SONMP is active in this device?
=item $sonmp->cdp_id()
Returns the IP that the device is sending out for its Nmm topology info.
(C<s5EnMsTopIpAddr>)
=item $sonmp->cdp_run()
Returns true if SONMP is on for this device.
(C<s5EnMsTopStatus>)
=item $sonmp->mac()
Returns MAC of the advertised IP address of the device.
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Layer2 Topology info (C<s5EnMsTopNmmTable>)
=over
=item $sonmp->sonmp_topo_slot()
Returns reference to hash. Key: Table entry, Value:slot number
(C<s5EnMsTopNmmSlot>)
=item $sonmp->sonmp_topo_port()
Returns reference to hash. Key: Table entry, Value:Port Number
(interface iid)
(C<s5EnMsTopNmmPort>)
=item $sonmp->sonmp_topo_ip()
Returns reference to hash. Key: Table entry, Value:Remote IP address of entry
(C<s5EnMsTopNmmIpAddr>)
=item $sonmp->sonmp_topo_seg()
Returns reference to hash. Key: Table entry, Value:Remote Segment ID
(C<s5EnMsTopNmmSegId>)
=item $sonmp->sonmp_topo_mac()
(C<s5EnMsTopNmmMacAddr>)
Returns reference to hash. Key: Table entry, Value:Remote MAC address
=item $sonmp->sonmp_topo_platform
Returns reference to hash. Key: Table entry, Value:Remote Device Type
(C<s5EnMsTopNmmChassisType>)
=item $sonmp->sonmp_topo_localseg
Returns reference to hash. Key: Table entry, Value: Boolean, if
bay_topo_seg() is local.
(C<s5EnMsTopNmmLocalSeg>)
=back
=head2 Pseudo CDP information
All entries with port=0 are local and ignored.
=over
=item $sonmp->c_if()
Returns reference to hash. Key: IID, Value: Local port (interfaces)
=item $sonmp->c_ip()
Returns reference to hash. Key: IID, Value: Remote IP address
If multiple entries exist with the same local port, c_if(), with different
IPv4 addresses, c_ip(), there is either a non SONMP device in between two or
more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper.
=item $sonmp->c_port()
Returns reference to hash. Key: IID, Value: Remote port (interfaces)
=item $sonmp->c_platform()
Returns reference to hash. Key: IID, Value: Remote device type
=back
=cut

View File

@@ -1,98 +1,24 @@
ChangeLog
COPYRIGHT
DEVELOP
DeviceMatrix.txt
Info.pm
Info/AdslLine.pm
Info/Airespace.pm
Info/Bridge.pm
Info/CDP.pm
Info/CiscoConfig.pm
Info/CiscoImage.pm
Info/CiscoPortSecurity.pm
Info/CiscoPower.pm
Info/CiscoQOS.pm
Info/CiscoRTT.pm
Info/CiscoStack.pm
Info/CiscoStats.pm
Info/CiscoStpExtensions.pm
Info/CiscoVTP.pm
Info/Entity.pm
Info/EtherLike.pm
Info/FDP.pm
Info/IEEE802dot11.pm
Info/IPv6.pm
Info/Layer1.pm
Info/Layer1/Allied.pm
Info/Layer1/Asante.pm
Info/Layer1/Bayhub.pm
Info/Layer1/Cyclades.pm
Info/Layer1/S3000.pm
Info/Layer2.pm
Info/Layer2/Airespace.pm
Info/Layer2/Aironet.pm
Info/Layer2/Allied.pm
Info/Layer2/Bay.pm
Info/Layer2/Baystack.pm
Info/Layer2/C1900.pm
Info/Layer2/C2900.pm
Info/Layer2/Catalyst.pm
Info/Layer2/Centillion.pm
Info/Layer2/Cisco.pm
Info/Layer2/Foundry.pm
Info/Layer2/HP.pm
Info/Layer2/HP4000.pm
Info/Layer2/HPVC.pm
Info/Layer2/N2270.pm
Info/Layer2/NAP222x.pm
Info/Layer2/Netgear.pm
Info/Layer2/Orinoco.pm
Info/Layer2/ZyXEL_DSLAM.pm
Info/Layer3.pm
Info/Layer3/Aironet.pm
Info/Layer3/AlcatelLucent.pm
Info/Layer3/AlteonAD.pm
Info/Layer3/Altiga.pm
Info/Layer3/Arista.pm
Info/Layer3/Aruba.pm
Info/Layer3/BayRS.pm
Info/Layer3/C3550.pm
Info/Layer3/C4000.pm
Info/Layer3/C6500.pm
Info/Layer3/Cisco.pm
Info/Layer3/CiscoFWSM.pm
Info/Layer3/Contivity.pm
Info/Layer3/Dell.pm
Info/Layer3/Enterasys.pm
Info/Layer3/Extreme.pm
Info/Layer3/Foundry.pm
Info/Layer3/HP9300.pm
Info/Layer3/Juniper.pm
Info/Layer3/Microsoft.pm
Info/Layer3/Mikrotik.pm
Info/Layer3/N1600.pm
Info/Layer3/Netscreen.pm
Info/Layer3/NetSNMP.pm
Info/Layer3/PacketFront.pm
Info/Layer3/Passport.pm
Info/Layer3/Pf.pm
Info/Layer3/Sun.pm
Info/Layer3/Timetra.pm
Info/LLDP.pm
Info/Layer3/C3550.pm
Info/MAU.pm
Info/NortelStack.pm
Info/PowerEthernet.pm
Info/RapidCity.pm
Info/SONMP.pm
MANIFEST
Makefile.PL
MANIFEST This list of files
README
t/00-load.t
t/docmunge
t/make_dev_matrix.pl
t/pod-coverage.t
t/pod.t
t/prereq.t
t/push_ver
t/run_test
t/test_class.pl
test.pl

View File

@@ -1,25 +0,0 @@
# Version control files and dirs.
\bRCS\b
\bCVS\b
,v$
\B\.svn\b
\B\.git\b
# Makemaker generated files and dirs.
^MANIFEST\.
^Makefile$
^blib/
^MakeMaker-\d
# Temp, old and emacs backup files.
~$
\.old$
^#.*#$
^\.#
# Private Regression Tests
\d+_local_
\.?perl\w+\.?rc$
# Komodo project file
\.kpf$

View File

@@ -1,39 +1,21 @@
# Module makefile for SNMP::Info (using ExtUtils::MakeMaker)
# SNMP::Info - Makefile.PL
# $Id$
require 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'SNMP::Info',
AUTHOR => 'Eric A. Miller <emiller@cpan.org>',
VERSION_FROM => 'Info.pm',
ABSTRACT_FROM => 'Info.pm',
PREREQ_PM => {
'Test::More' => 0,
'Math::BigInt' => 0,
'SNMP' => 0,
},
PMLIBDIRS => [ 'Info', '$(BASEEXT)' ],
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'SNMP-Info-*' },
realclean => { FILES => 'Makefile.old' },
( ( ExtUtils::MakeMaker->VERSION() lt '6.25' ) ? ( 'PL_FILES' => {} )
: ()
),
( ( ExtUtils::MakeMaker->VERSION() gt '6.30' ) ? ( 'LICENSE' => 'bsd' )
: ()
'NAME' => 'SNMP::Info',
'VERSION_FROM' => 'Info.pm',
# SNMP not available on CPAN -- not installable by CPAN
# 'PREREQ_PM' => {'SNMP' => '4'},
($] >= 5.005 ?
(ABSTRACT_FROM => 'Info.pm',
AUTHOR => 'Max Baker <max@warped.org>')
: ()
),
'PMLIBDIRS' => ['Info','$(BASEEXT)'],
);
);
sub MY::postamble {
"
sub MY::postamble { "
.PHONY: readme
readme: README
README: Info.pm
pod2text -l Info.pm > README";
}
readme:
pod2text -l Info.pm > README" }

2472
README

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +0,0 @@
# .perltidyrc - PBP perltidy configuration file for SNMP::Info
# $Id$
-l=78 # Max line width is 78 cols
-i=4 # Indent level is 4 cols
-ci=4 # Continuation indent is 4 cols
-nst # Output to STDOUT
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
-bt=1 # Medium brace tightness
-sbt=1 # Medium square bracket tightness
-bbt=1 # Medium block brace tightness
-nsfs # No space before semicolons
-nolq # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= && += -= /= |= >>= ||= .= %= ^= x=" # Break before all operators

View File

@@ -1,13 +0,0 @@
#!/usr/bin/perl
# 00-load.t - Test loading of SNMP::Info
# $Id$
use strict;
use warnings;
use Test::More tests => 1;
BEGIN {
use_ok( 'SNMP::Info' );
}
diag( "Testing SNMP::Info $SNMP::Info::VERSION, Perl $], $^X" );

View File

@@ -1,14 +0,0 @@
#!/usr/bin/perl
# 00_local_distribution.t - Private test to check distribution
# $Id$
use strict;
use warnings;
use Test::More;
eval { require Test::Distribution; };
plan skip_all => 'Optional Test::Distribution not installed' if ($@);
# Skip POD tests as we will test separately
import Test::Distribution not => [ qw/pod podcover/ ];

View File

@@ -1,46 +0,0 @@
#!/usr/bin/perl
# 00_local_versionsync.t - Private test to check that all modules are listed in Info.pm
# $Id$
use warnings;
use strict;
use File::Find;
use Test::More;
eval "use File::Slurp";
plan skip_all => "File::Slurp required for testing version sync"
if $@;
plan qw(no_plan);
my %Items;
# Grab all the =item's from Info.pm
open (I,"blib/lib/SNMP/Info.pm") or fail("Can't open Info.pm");
while (<I>) {
next unless /^\s*=item\s*(\S+)/;
$Items{$1}++;
}
close I;
#warn "items : ",join(', ',keys %Items),"\n";
# Check that each package is represented in Info.pm docs
find({wanted => \&check_version, no_chdir => 1}, 'blib');
sub check_version {
# $_ is the full path to the file
return unless (m{blib/lib/}xms and m{\.pm \z}xms);
my $content = read_file($_);
# Make sure that this package is listed in Info.pm
fail($_) unless $content =~ m/^\s*package\s+(\S+)\s*;/m;
my $package = $1;
return if $package eq 'SNMP::Info';
fail($_) unless defined $Items{$package};
pass($_);
}

View File

@@ -1,13 +0,0 @@
#!/usr/bin/perl
# 00_local_perlcritic.t - Test file for PBP compliance for SNMP::Info
# $Id$
use strict;
use warnings;
use Test::More;
eval "use Test::Perl::Critic (-profile => 't/perlcritic.rc')";
plan skip_all => "Test::Perl::Critic required for testing PBP compliance" if $@;
Test::Perl::Critic::all_critic_ok();

View File

@@ -1,252 +0,0 @@
#!/usr/bin/perl
# 00_local_spelling.t - Private test to spell check documentation
# $Id$
use warnings;
use strict;
use Test::More;
eval "use Test::Spelling";
plan skip_all => "Test::Spelling required for checking spelling"
if $@;
set_spell_cmd('aspell list');
add_stopwords(<DATA>);
all_pod_files_spelling_ok();
__DATA__
5000BH
accelar
acl
adsl
af
agere
airespace
aironet
airos
Alcatel
alcatel
alteon
Altiga
altiga
AOS
ap
APs
Arista
arista
arn
arp
aruba
asa
asante
ascii
asn
ati
attr
augenstein
autonegotiate
autospecify
baetz
bayrs
baystack
bcn
begemot
bes
bgp
bigint
bigiron
bitmask
bladecenter
bln
bpdus
BSSID
bulkrepeaters
bulkwalk
cabletron
catos
cdp
centillion
circuitless
cisco
cisco's
ciscovtp
cli
conf
config
contivity
CPAN
cpu
ctron
cyclades
datatype
deauthenticate
debugsnmp
dlink
dmitry
DOCSIS
ds
dslam
dslams
dsss
dynamicgvrp
eapol
edgeiron
eigrp
enterasys
EOS
erszenyi
ess
etherlike
ethernet
extranet
fastiron
fdb
fdp
fenner
fsm
FWSM
fwsm
gbe
gbesm
getnext
Ghz
gigabit
hartmaier
iana
ibm
icf
ieee
ietf
ifindex
igmp
iid
iids
indices
ingen
ios
ip
IPV
IPv
jeroen
junos
kramarov
lans
linksys
lldp
loopback
loopdetect
lorensen
lsb
Lucent
lucent
luiggi
lwapp
macfilter
mau
maxrepeaters
mbs
mckeown
mda
MIB
mibdirs
mib
mibs
milliwatts
msb
mtu
multi
multicast
multiseg
multivlan
munge
munges
namespace
ndp
netdisco
netgear
netmask
netscreen
nmm
nopassword
nortel
nosuch
oem
ofdm
oid
oids
OmniSwitch
os
osi
ospf
overridable
pae
petri
phy
pinkoski
poe
pov
powerconnect
procurve
propvirtual
proxim
pvid
qbridge
qos
queueing
radlan
rapidcity
readme
readonly
rebranded
retrynosuch
rom
rtt
rttmon
sca
Schenau
sergienko
sieborger
SNMP
snmp
SNMP's
snmpv2
snmpv3
snmpwalk
solaris
sonmp
ssid
SSID's
SSIDs
Stickland
stackable
stdout
stg
stp
subcomponents
subnet
sunos
supply's
synoptics
sys
telesyn
telesys
tftp
tftpfilename
tftpserver
TiMOS
tmnxModel
todo
tuttle
ucsc
uninstall
uptime
vlan
vlans
vpn
vtp
watanabe
wlan
wlans
WS
zoltan
zyxel

View File

@@ -1,45 +0,0 @@
#!/usr/bin/perl
# 00_local_versionsync.t - Private test to check all version numbers match
# $Id$
use warnings;
use strict;
use File::Find;
use Test::More;
eval "use File::Slurp";
plan skip_all => "File::Slurp required for testing version sync"
if $@;
plan qw(no_plan);
my $last_version = undef;
find({wanted => \&check_version, no_chdir => 1}, 'blib');
if (! defined $last_version) {
fail('Failed to find any files with $VERSION');
}
sub check_version {
# $_ is the full path to the file
return if (! m{blib/script/}xms && ! m{\.pm \z}xms);
my $content = read_file($_);
# only look at perl scripts, not sh scripts
return if (m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms);
my @version_lines = $content =~ m/ ( [^\n]* \$VERSION\s= [^\n]* ) /gxms;
if (@version_lines == 0) {
fail($_);
}
for my $line (@version_lines) {
if (!defined $last_version) {
$last_version = shift @version_lines;
pass($_);
}
else {
is($line, $last_version, $_);
}
}
}

View File

@@ -1,35 +0,0 @@
#!/usr/bin/perl -i.bak
#
# [Re-]write POD to create cross-links between Required MIBs, GLOBALS
# and TABLE METHODS sections.
# This is a horrible jumble of heuristics, but works with
# all of the existing files. It has only one false positive: HP.pm's
# mention of an SNMP::Info version number.
#
$section = undef;
$waiting = 0;
while (<>) {
if (eof) {
$section = undef;
$waiting = 0;
}
if (/^=head(\d)/) {
$sl = $1;
if ($sl <= $level) {
$section = undef;
}
if (/(TABLE METHODS|GLOBALS|Required MIBs)/) {
$section = $1;
$level = $sl;
if ($section eq 'TABLE METHODS' || $section eq 'GLOBALS') {
$waiting = 1;
}
}
if ($waiting && /imported/i) {
$waiting = 0;
}
} elsif (defined($section) && !$waiting && /^[^=]/ && /SNMP::Info/) {
s,(?:L<)?(SNMP::Info[a-zA-Z0-9:]*)(?:/[^>]+)?(?:>)?,L<$1/"$section">,g;
}
print;
}

View File

@@ -1,337 +0,0 @@
#!/usr/bin/perl -w
# $Id$
$DevMatrix = '../DeviceMatrix.txt';
$DevHTML = 'DeviceMatrix.html';
$DevPNG = 'DeviceMatrix.png';
$Attributes= {};
# Parse Data File
$matrix = parse_data($DevMatrix);
# Graph it for fun
eval "use GraphViz::Data::Structure;";
if ($@) {
print "GraphViz::Data::Structure not installed. $@\n";
} else {
my %graph = ();
foreach my $vendor (sort sort_nocase keys %$matrix){
$graph{$vendor} = {};
foreach my $family (sort sort_nocase keys %{$matrix->{$vendor}->{families}} ){
my @models;
foreach my $mod (keys %{$matrix->{$vendor}->{families}->{$family}->{models}}){
push(@models,split(/\s*,\s*/,$mod));
}
if (scalar @models){
$graph{$vendor}->{$family}=\@models;
} else {
$graph{$vendor}->{$family}=[];
}
}
}
my $now = scalar localtime;
my $gvds = GraphViz::Data::Structure->new(\%graph,Orientation=>'vertical',
Colors=> 'Deep',
graph => {label=>"SNMP::Info and Netdisco Supported Devices \n $now",'fontpath'=>'/usr/local/netdisco','fontname'=>'lucon',concentrate=>'true','overlap'=>'false',spline=>'true',bgcolor=>'wheat'},
node => {fontname=>'lucon'},
);
$gvds->graph()->as_png($DevPNG);
}
print "Creating $DevHTML\n";
open (HTML, "> $DevHTML") or die "Can't open $DevHTML. $!\n";
$old_fh = select(HTML);
&html_head;
print_vendors($matrix);
foreach my $vendor (sort sort_nocase keys %$matrix){
print "<A NAME=\"$vendor\"><SPAN CLASS=\"vendor\"><B>$vendor</B></SPAN></A>\n";
print "<DL>\n";
my $vendor_defaults = $matrix->{$vendor}->{defaults};
print_notes($vendor_defaults,1);
my $families = $matrix->{$vendor}->{families};
foreach my $family (sort sort_nocase keys %$families ) {
print "<DT>$family Family\n";
my $family_defaults = $families->{$family}->{defaults};
print_notes($family_defaults,2);
my $models = $families->{$family}->{models};
foreach my $model (sort sort_nocase keys %$models ){
my $model_defaults = $models->{$model}->{defaults};
print "<DD>$model\n";
print "<DL>\n";
print_notes($model_defaults,3);
print "<DT><DD><TABLE BORDER=1>\n";
print_headers();
print "<TR>\n";
foreach my $a (sort sort_nocase keys %$Attributes) {
my $val;
next if $a eq 'note';
$val = ['-'];
$class = 'none';
if (defined $model_defaults->{$a}) {
$val = $model_defaults->{$a};
$class = 'model';
} elsif (defined $family_defaults->{$a}){
$val = $family_defaults->{$a};
$class = 'family';
} elsif (defined $vendor_defaults->{$a}){
$val = $vendor_defaults->{$a};
$class = 'vendor';
}
print " <TD CLASS='$class'>",join("<BR>\n",@$val),"</TD>\n";
}
print "</TR></TABLE>\n";
print "</DL>\n";
}
}
print "</DL>\n";
}
&html_tail;
select ($old_fh);
close (HTML) or die "Can't write $DevHTML. $!\n";
# Data Structures
# Matrix =
# ( vendor => { families => { family => family_hash },
# defaults => { cmd => [values] },
# }
# )
# Family Hash
# ( models => { model => model_hash },
# defaults => { cmd => [values] }
# )
# Model Hash
# ( defaults => { cmd => [values] } )
sub parse_data {
my $file = shift;
my %ignore = map { $_ => 1 } @_;
my $Matrix;
my @Lines;
open (DM, "< $file") or die "Can't open $file. $!\n";
{
@Lines = <DM>;
}
close (DM);
my ($device,$family,$vendor,$class);
foreach my $line (@Lines){
chomp($line);
# Comments
$line =~ s/#.*//;
# Blank Lines
next if $line =~ /^\s*$/;
# Trim whitespace
$line =~ s/^\s+//;
$line =~ s/\s+$//;
my ($cmd,$value);
if ($line =~ /^([a-z-_]+)\s*:\s*(.*)$/) {
$cmd = $1; $value = $2;
} else {
print "What do i do with this line : $line \n";
next;
}
if (exists $ignore{$cmd}){
print "Ignoring $cmd\n";
}
# Set Class {vendor,family,device}
if ($cmd eq 'device-vendor'){
$vendor = $value;
$family = $model = undef;
$Matrix->{$vendor} = {} unless defined $Matrix->{$vendor};
$class = $Matrix->{$vendor};
$class->{defaults}->{type}='vendor';
next;
}
if ($cmd eq 'device-family'){
$family = $value;
$model = undef;
print "$family has no vendor.\n" unless defined $vendor;
$Matrix->{$vendor}->{families}->{$family} = {}
unless defined $Matrix->{$vendor}->{families}->{$family};
$class = $Matrix->{$vendor}->{families}->{$family};
$class->{defaults}->{type}='family';
next;
}
if ($cmd eq 'device') {
$model = $value;
print "$model has no family.\n" unless defined $family;
print "$model has no vendor.\n" unless defined $vendor;
$Matrix->{$vendor}->{families}->{$family}->{models}->{$model} = {}
unless defined $Matrix->{$vendor}->{families}->{$family}->{models}->{$model};
$class = $Matrix->{$vendor}->{families}->{$family}->{models}->{$model};
$class->{defaults}->{type}='device';
next;
}
# Store attribute
push (@{$class->{defaults}->{$cmd}} , $value);
$Attributes->{$cmd}++;
}
return $Matrix;
}
sub sort_nocase {
return lc($a) cmp lc($b);
}
sub print_notes {
my $defaults = shift;
my $level = shift;
my $notes = $defaults->{note} || [];
foreach my $note (@$notes){
if ($note =~ s/^!//){
$note = '<SPAN CLASS="note">' . $note . '</SPAN>';
}
}
if (scalar @$notes){
print "<DT>\n";
my $print_note = join("\n<LI>",@$notes);
print "<UL TYPE='square'><LI>$print_note</UL>\n";
}
}
sub print_vendors {
my $matrix=shift;
print "<h1>Device Vendors</h1>\n";
foreach my $vendor (sort sort_nocase keys %$matrix){
print "[<A HREF=\"#$vendor\">$vendor</A>]\n";
}
print "<HR>\n";
}
sub html_head {
print <<"end_head";
<HTML>
<HEAD>
<TITLE>SNMP::Info - Device Compatibility Matrix</TITLE>
<STYLE TYPE="text/css" MEDIA="screen">
<!--
BODY { font-family:arial,helvetica,sans-serif; font-size:12pt; }
TD { font-family:arial,helvetica,sans-serif; font-size:10pt; }
TH { font-family:arial,helvetica,sans-serif; font-size:10pt; background:#F0F0F0; }
H1 { font-family:arial,helvetica,sans-serif; font-size:14pt; }
.vendor { font-size:12pt; color:#777777; }
.family { font-size:12pt; color:blue; }
.model { font-size:12pt; color:red; }
.note { color:red; }
//-->
</STYLE>
</HEAD>
<BODY>
<h1>SNMP::Info - Device Compatibility Matrix</h1>
<P>
end_head
}
sub html_tail {
print <<'end_tail';
<HR>
<h1>Color Key</h1>
[<SPAN CLASS="model">Model Attribute</SPAN>]
[<SPAN CLASS="family">Family Attribute</SPAN>]
[<SPAN CLASS="vendor">Vendor Attribute</SPAN>]
<h1>Attribute Key</h1>
A value of <B>-</B> signifies the information is not specified and can
be assumed working.
<TABLE BORDER=1>
<TR>
<TD>Arpnip</TD>
<TD>Ability to collect ARP tables for MAC to IP translation.</TD>
</TR>
<TR>
<TD>CDP</TD>
<TD>Cisco Discovery Protocol usable.
<UL>
<LI><tt>Yes</tt> - Has CDP information through CISCO-CDP-MIB
<LI><tt>Proprietary</tt> means the device has its own L2 Discovery Protocol.
</UL>
</TD>
</TR>
<TR>
<TD>Class</TD>
<TD>SNMP::Info Class the the device currently uses. Devices using more generic
interfaces like <tt>Layer2</tt> or <tt>Layer3</tt> may eventually get their
own subclass.
</TD>
</TR>
<TR>
<TD>Duplex</TD>
<TD>Ability to cull duplex settings from device.<BR>
<UL>
<LI><tt>no</tt> - Can't recover current or admin setting.
<LI><tt>link</tt> - Can get current setting only.
<LI><tt>both</tt> - Can get admin and link setting.
<LI><tt>write</tt> - Can get admin and link setting and perform sets.
</UL>
</TD>
</TR>
<TR>
<TD>Macsuck</TD>
<TD>Ability to get CAM tables for MAC to switch port mapping.<BR>
<UL>
<LI><TT>no</TT> - Have not found an SNMP method to get data yet.
<LI><TT>yes</TT> - Can get through normal SWITCH-MIB method.
<LI><TT>vlan</TT> - Have to re-connect to each VLAN and then fetch with normal
method.
</UL>
</TD>
</TR>
<TR>
<TD>Modules</TD>
<TD>Ability to gather hardware module information.</TD>
</TR>
<TR>
<TD>Portmac</TD>
<TD>Whether the device will list the MAC address of the switch port on each
switch port when doing a Macsuck.
</TD>
</TR>
<TR>
<TD>Ver</TD>
<TD>SNMP Protocol Version the device has to use.</TD>
</TR>
<TR>
<TD>Vlan</TD>
<TD>Ability to get VLAN port assignments.<BR>
<UL>
<LI><TT>no</TT> - Have not found an SNMP method to get data yet.
<LI><TT>yes</TT> - Can read information.
<LI><TT>write</TT> - Can read and write (set).
</UL>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
end_tail
}
sub print_headers {
print "<TR>\n";
foreach my $a (sort sort_nocase keys %$Attributes) {
next if $a eq 'note';
print " <TH>$a</TH>\n";
}
print "</TR>\n";
}

View File

@@ -1,290 +0,0 @@
# perlcritic.rc - Perl::Critic configuration file for SNMP::Info
# $Id$
# Items commented with "Modified back to default" are not set IAW PBP.
##############################################################################
# This Perl::Critic configuration file sets the Policy severity levels
# according to Damian Conway's own personal recommendations. Feel free to
# use this as your own, or make modifications.
##############################################################################
[Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr]
severity = 3
[Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock]
severity = 1
[Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect]
severity = 5
[Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval]
severity = 5
[Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit]
severity = 2
[Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan]
severity = 4
[Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa]
severity = 4
[Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep]
severity = 3
[Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap]
severity = 3
[Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep]
severity = 4
[Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap]
severity = 4
[Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction]
severity = 5
[Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock]
severity = 3
[Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading]
severity = 3
[Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA]
severity = 4
[Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless]
severity = 5
[Perl::Critic::Policy::CodeLayout::ProhibitHardTabs]
severity = 3
[Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins]
severity = 1
[Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists]
severity = 2
[Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines]
severity = 4
[Perl::Critic::Policy::CodeLayout::RequireTidyCode]
severity = 1
[Perl::Critic::Policy::CodeLayout::RequireTrailingCommas]
severity = 3
[Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops]
severity = 3
[Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse]
severity = 3
[Perl::Critic::Policy::ControlStructures::ProhibitDeepNests]
severity = 3
[Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions]
severity = 5
[Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls]
severity = 4
[Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks]
severity = 4
[Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode]
severity = 4
[Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks]
severity = 4
[Perl::Critic::Policy::Documentation::RequirePodAtEnd]
severity = 2
[Perl::Critic::Policy::Documentation::RequirePodSections]
severity = 2
[Perl::Critic::Policy::ErrorHandling::RequireCarping]
severity = 4
[Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators]
severity = 3
[Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles]
severity = 5
[Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest]
severity = 4
[Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect]
severity = 4
[Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop]
severity = 5
[Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen]
severity = 4
[Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint]
severity = 3
[Perl::Critic::Policy::Miscellanea::ProhibitFormats]
severity = 3
[Perl::Critic::Policy::Miscellanea::ProhibitTies]
severity = 4
[-Perl::Critic::Policy::Miscellanea::RequireRcsKeywords]
[Perl::Critic::Policy::Modules::ProhibitAutomaticExportation]
severity = 4
[Perl::Critic::Policy::Modules::ProhibitEvilModules]
severity = 5
[Perl::Critic::Policy::Modules::ProhibitMultiplePackages]
severity = 4
[Perl::Critic::Policy::Modules::RequireBarewordIncludes]
severity = 5
[Perl::Critic::Policy::Modules::RequireEndWithOne]
severity = 4
[Perl::Critic::Policy::Modules::RequireExplicitPackage]
severity = 4
[Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage]
severity = 5
[Perl::Critic::Policy::Modules::RequireVersionVar]
severity = 4
[Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames]
severity = 3
[Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseSubs]
severity = 1
[Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseVars]
severity = 1
[Perl::Critic::Policy::References::ProhibitDoubleSigils]
severity = 4
[Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest]
severity = 4
# Modified back to default from 5 - To Do
[Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting]
severity = 2
# Modified back to default from 5 - To Do
[Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching]
severity = 3
[Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils]
severity = 2
[Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms]
severity = 4
[Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity]
severity = 3
[Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef]
severity = 5
[Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes]
severity = 4
[Perl::Critic::Policy::Subroutines::ProtectPrivateSubs]
severity = 3
[Perl::Critic::Policy::Subroutines::RequireFinalReturn]
severity = 5
[Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict]
severity = 5
[Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings]
severity = 4
[Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride]
severity = 4
[Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels]
severity = 3
[Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict]
severity = 5
[Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings]
severity = 4
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma]
severity = 4
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes]
severity = 2
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters]
severity = 2
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals]
severity = 1
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros]
severity = 5
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitMismatchedOperators]
severity = 2
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators]
severity = 4
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes]
severity = 2
[Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings]
severity = 3
[Perl::Critic::Policy::ValuesAndExpressions::RequireInterpolationOfMetachars]
severity = 1
[Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators]
severity = 2
[Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator]
severity = 4
[Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator]
severity = 4
[Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations]
severity = 5
[Perl::Critic::Policy::Variables::ProhibitLocalVars]
severity = 2
[Perl::Critic::Policy::Variables::ProhibitMatchVars]
severity = 4
[Perl::Critic::Policy::Variables::ProhibitPackageVars]
severity = 3
[Perl::Critic::Policy::Variables::ProhibitPunctuationVars]
severity = 2
[Perl::Critic::Policy::Variables::ProtectPrivateVars]
severity = 3
[Perl::Critic::Policy::Variables::RequireInitializationForLocalVars]
severity = 5
[Perl::Critic::Policy::Variables::RequireLexicalLoopIterators]
severity = 5
[Perl::Critic::Policy::Variables::RequireNegativeIndices]
severity = 4

Some files were not shown because too many files have changed in this diff Show More