Compare commits

..

196 Commits

Author SHA1 Message Date
Eric Miller
70f20d2330 update for 1.07 2007-11-27 03:25:53 +00:00
Eric Miller
48e9b0b030 update for 1.07 2007-11-27 03:17:36 +00:00
Eric Miller
11db00b66c update for 1.07 2007-11-27 03:05:07 +00:00
Eric Miller
89dc775392 updates for 1.07 2007-11-27 03:00:25 +00:00
Eric Miller
6d5f27fd3a add modules attribute 2007-11-27 02:59:18 +00:00
Eric Miller
e1ab8a43ba Prep 1.07 beta release 2007-11-26 04:24:52 +00:00
Eric Miller
081325c68d Accommodate for differences between AN/ARN and ASN in Pseudo ENTITY-MIB methods 2007-11-26 03:38:15 +00:00
Eric Miller
004de3d29b Add support for e_name() in Psuedo ENTITY-MIB methods 2007-11-26 03:32:11 +00:00
Eric Miller
8b5ba1e959 Airespace and CDP changes 2007-11-24 03:25:35 +00:00
Eric Miller
149e97c2d6 - [ 1663699 ] Implement vmVoiceVlanId in i_vlan_membership()
- Trunk VLANs only exist on ports which are trunking
2007-11-24 03:23:13 +00:00
Eric Miller
60cb2b8c20 Psuedo ENTITY-MIB information 2007-11-24 03:18:13 +00:00
Eric Miller
a714c46fba - [ 1780872 ] Incorrect detection of admin duplex on older HP Procurve (Robert Kerr)
- [ 1835187 ] New HP devices (perand)
2007-11-21 21:34:40 +00:00
Eric Miller
692ccd0e97 Slight logic change to c_ip() to retain backwards compatibility. 2007-11-21 20:35:58 +00:00
Eric Miller
e0aa0835cd [ 1769604 ] Include support for extended vlan membership in CiscoVTP.pm 2007-11-21 04:23:38 +00:00
Eric Miller
845a0c4121 [ 1780874 ] c_ip doesn't check cdpCacheAddressType 2007-11-21 04:20:58 +00:00
Eric Miller
57a6ec56e3 More Nortel support 2007-11-20 03:49:09 +00:00
Eric Miller
4d53aa41e2 Return "zeroDotZero" for slots and containers in e_type() 2007-11-20 03:48:20 +00:00
Eric Miller
214534b211 - Correct indexing in Psuedo ENTITY-MIB methods
- Refactor ns_e_pos() for both chassis and stackables
2007-11-20 03:45:15 +00:00
Eric Miller
5ac0d946a7 - [1833182] Info/Layer2/Baystack.pm: get model number for ERS 2500 (David Sieb�rger)
- [1833190] Info/Layer2/Baystack.pm: fix index_factor (David Sieb�rger)
- Revert 1.16, fixed issue upstream
2007-11-19 04:28:01 +00:00
Eric Miller
bd908a6952 [1833174] Info.pm: recognise new Nortel switches as Layer2::Baystack (David Sieb�rger) 2007-11-19 04:25:17 +00:00
Eric Miller
400e94ea27 - Override ip_netmask() to get masks for virtual and cpu interfaces
- rc_vlan_name() has changed to v_name() for compatibility purposes
- Silence warnings on uninitialized variables when searching for virtual management interfaces
2007-11-19 02:59:31 +00:00
Eric Miller
1d286d8388 Add rc_virt_mask and rc_cpu_mask so that we can get masks on virtual and cpu interfaces 2007-11-19 02:50:42 +00:00
Eric Miller
bf79dd333f Fix for uninitialized value errors in i_mac() 2007-11-10 17:48:58 +00:00
Eric Miller
c882e63dad whitespace 2007-11-10 17:46:12 +00:00
Eric Miller
710e7afbe6 Remove a mistaken comment in previous commit 2007-11-04 05:01:42 +00:00
Eric Miller
e51c9c1da2 - Implement v_index() and v_name() consistently across classes in support of Netdisco 0.96
- Don't query dynamic VLANs - table may be too large on some devices
2007-11-04 03:29:47 +00:00
Eric Miller
b17f04e762 Fix for uninitialized value in i_name() 2007-11-04 02:58:01 +00:00
Eric Miller
a6d16bdfc9 [ 1782392 ] Warnings from C1900.pm 2007-11-04 02:51:35 +00:00
Eric Miller
b6377596f8 Support both stackable and chassis based switches for psuedo ENTITY-MIB methods for older switches 2007-10-10 03:51:30 +00:00
Eric Miller
b5d1210f72 Make Psuedo ENTITY-MIB methods work with all routers supported by the class 2007-10-10 03:45:47 +00:00
Eric Miller
af038c491b Add chassis info to psuedo ENTITY-MIB methods 2007-10-10 03:35:11 +00:00
Eric Miller
4af016ea4f Can't point FUNC at a method, must override in a method. 2007-10-10 03:31:42 +00:00
Eric Miller
a2d94315c3 - Use Q-BRIDGE-MIB for macsuck from bridge class rather than redefining
- Model cosmetics
2007-10-10 02:38:36 +00:00
Eric Miller
e87e076b6a Use Q-BRIDGE-MIB for macsuck from bridge class rather than defining our own. 2007-10-10 02:28:00 +00:00
Eric Miller
dfbc7cfd07 Fix to avoid inheritance issues in psuedo classes with e_index() 2007-10-10 02:24:58 +00:00
Bill Fenner
696efaad82 Turn on bulkwalk - this is a big source of inefficiency for
a class that handles some of the bigger hardware.  If you need
bulkwalk off, turn it off when creating the class (e.g., with
bulkwalk_no in netdisco)
2007-10-09 17:57:23 +00:00
Bill Fenner
b435382a5e Map 207 to Layer2::Allied 2007-10-09 17:53:23 +00:00
Bill Fenner
ea65ed57af Teach Baystack's e_index() that Entity's e_index() is implemented based
on e_descr() - otherwise, Entity's e_index() will always return a mapping
even if the device doesn't implement the ENTITY-MIB.
2007-10-08 22:30:30 +00:00
Bill Fenner
f3058e4e9c Add i_vlan, copied from my L3::Cisco.pm implementation. 2007-08-13 12:52:05 +00:00
Bill Fenner
75b570af95 Include CiscoPower. 2007-07-30 15:32:18 +00:00
Bill Fenner
840d8a48ba Add PowerEthernet support. 2007-07-30 15:27:35 +00:00
Bill Fenner
b5fec8dbde Add support for POWER-ETHERNET-MIB and CISCO-POWER-ETHERNET-EXT-MIB 2007-07-30 15:25:28 +00:00
Bill Fenner
123dc84f05 Get i_vlan from Layer3 Cisco from the sub-interface ID. 2007-07-18 16:39:11 +00:00
Bill Fenner
98ceee3212 Update the MIBs actually required and where to get them. 2007-07-18 16:37:47 +00:00
Eric Miller
ab08aa1de1 Some devices have issues with BRIDGE-MIB (duplicates and non-increasing oids). Use Q-BRIDGE-MIB for macsuck. 2007-06-26 01:35:17 +00:00
Eric Miller
e8c0a78e67 - Enterasys support
- L2::C1900 bridge group (VLAN) reporting
- CiscoStack duplex reporting improvement
2007-06-25 22:05:07 +00:00
Eric Miller
0c583b7838 Enterasys support 2007-06-25 22:02:27 +00:00
Eric Miller
7515cb0ab0 Remove propvirtual from i_ignore() so we capture VLAN interfaces and their associated MACs. 2007-06-20 03:12:20 +00:00
Eric Miller
fc4d9cac24 Remove i_ignore(), use Layer2 definition. 2007-06-20 03:09:24 +00:00
Eric Miller
8d496beceb Remove device specific i_type(), use standard IF-MIB values. 2007-06-20 03:07:41 +00:00
Eric Miller
ce1fac9e86 - Correct operational and administrative duplex reporting.
- Remove device specific i_type() use standard IF-MIB values.
- Remove PORT-SECURITY-MIB from CiscoStack as these are now in CiscoPortSecurity class.
- Move interfaces() and i_name() methods out of CiscoStack to L2::Catalyst so we can remove globs from L3:C3550 and L3::C6500.
2007-06-20 03:05:29 +00:00
Eric Miller
659d38b0db More CiscoVTP removal clean up 2007-06-20 02:52:24 +00:00
Eric Miller
56a4238632 - Remove CiscoVTP from inheritance, devices do not support it.
- Enable VLAN / bridge group reporting with i_vlan() and i_vlan_membership().
- Remove device specific i_type(), return standard IF-MIB values.
2007-06-20 02:49:26 +00:00
Eric Miller
4c9f9d9876 Method name change - Alexander Hartmaier 2007-06-19 01:52:32 +00:00
Eric Miller
533104ce55 [ 1670427 ] Info.pm modifications - allow partials on i_speed (Justin Hunter) 2007-06-19 01:48:57 +00:00
Eric Miller
06fd442dce Extreme VLAN support
Update partial table support
2007-06-14 03:34:05 +00:00
Bill Fenner
8955e25c4f Add new VLAN methods to Extreme.
Add additional powersupply and fan info.

Use the concise interface name (e.g., "1/32"), instead of description
(e.g., "RMON Port 32 on Unit 1").
2007-06-13 15:11:04 +00:00
Eric Miller
f543768c7b Fix detection of Cisco PIX and ASA. 2007-06-13 02:56:18 +00:00
Eric Miller
4c33cfecff Prep 1.05 2007-06-13 02:52:43 +00:00
Eric Miller
2070f9b9e0 Support partial table fetches on overridden table methods.
Prep 1.05
2007-06-13 02:48:44 +00:00
Eric Miller
069695f570 Sync new files 2007-06-12 03:19:31 +00:00
Eric Miller
ad300684c3 Updates for 1.05 2007-06-12 03:18:20 +00:00
Eric Miller
98d120717a [ 1681923 ] Preliminary MS Windows router support (begemot) 2007-06-11 02:45:20 +00:00
Eric Miller
1ebe34ce90 [ 1681923 ] Preliminary MS Windows router support (begemot) 2007-06-11 02:38:53 +00:00
Eric Miller
9565c908c6 Annotate that this module is deprecated. 2007-06-11 00:54:20 +00:00
Eric Miller
85f36d3831 Foundry updates.
SNMP set method updates.
2007-06-09 03:37:01 +00:00
Eric Miller
77aca4b628 Depreciate L2::Foundry, use new L3::Foundry for all Foundry devices.
Enable the use of raw mib leaf names from loaded MIBs in set operations.
Clear attribute cache on successful SNMP set.
POD updates.
2007-06-09 03:29:44 +00:00
Eric Miller
7602c30d96 Add LLDP support.
Support partial table fetches on overridden table methods.
Modification to support Foundry devices in single class.
Pod updates.
2007-06-09 03:07:49 +00:00
Eric Miller
c5b2894d23 Emulate ENTITY-MIB Physical Table methods in Passport class 2007-05-17 02:23:44 +00:00
Eric Miller
508a86b563 Emulate ENTITY-MIB Physical Table methods using RAPID-CITY MIB 2007-05-17 02:19:11 +00:00
Eric Miller
01faf96ccb Catch up on updates 2007-04-21 03:22:31 +00:00
Eric Miller
3edb813da7 Pass $attr twice to _load_attr( ) in AUTOLOAD when using a mib leaf to make sure data is cached. 2007-04-21 02:43:55 +00:00
Eric Miller
8cae0c74fb Emulate ENTITY-MIB Physical Table methods using Wellfleet-HARDWARE-MIB and Wellfleet-MODULE-MIB. 2007-04-21 02:37:14 +00:00
Eric Miller
feefe2dcee - Add new VLAN methods to include VLAN set methods. Testers needed.
-  POD updates.
2007-04-17 03:44:42 +00:00
Eric Miller
7a40aa02ed more POD 2007-04-17 03:18:58 +00:00
Eric Miller
5d9ac88750 - Add new VLAN methods to include VLAN set methods. Testers needed.
-  Support partial table fetches on overridden table methods.
-  POD updates.
2007-04-16 03:25:35 +00:00
Eric Miller
93c54da5ba [ 1577927 ] Add EIGRP Neighbor Tables (Andrew Herrick) 2007-04-15 03:39:01 +00:00
Eric Miller
d9c87bdfbd - Modify inheritance to use Cisco classes before generic classes
- [ 1670428 ] add CiscoConfig inheritance
- Remove globs which shouldn't be needed with new inheritance chain
- Add CiscoPortSecurity inheritance so we can remove port security from CiscoStack
- POD updates
2007-04-15 02:44:14 +00:00
Eric Miller
6bbc902c75 Copyright and license 2007-04-14 23:59:35 +00:00
Eric Miller
79a4a55265 entPhysicalIndex (e_index) is not-accessible. Create e_index method to facilitate emulation methods in other classes 2007-04-14 23:57:31 +00:00
Eric Miller
67081eed26 Emulate ENTITY-MIB Physical Table methods using S5-CHASSIS-MIB for older devices. 2007-04-14 20:54:57 +00:00
Eric Miller
be37a24fc9 - Modify inheritance to use Cisco classes before generic classes
- Remove globs which shouldn't be needed with new inheritance chain
- POD updates
2007-04-06 03:37:26 +00:00
Eric Miller
269d2b7be9 - Support partial table fetches on overridden table methods.
-  Use IID as key for hashes, remove unnecessary code.
-  Align with other topology classes, return all data.  c_ip() no longer returns and an array for multiple neighbors on a local port.
2007-04-06 02:10:58 +00:00
Eric Miller
749ad55af1 Add LLDP support 2007-04-06 02:00:45 +00:00
Eric Miller
866d28a36d Fix for incorrect mib leaf logic in AUTOLOAD. 2007-04-06 01:58:16 +00:00
Eric Miller
1a3b3ae009 - Patches from Alexander Hartmaier
- POD update for new LLDP class
2007-04-05 02:47:07 +00:00
Eric Miller
b5edc85a56 Initial commit - based upon the work of Bernhard Augenstein 2007-04-04 02:19:28 +00:00
Eric Miller
bb9e6f5101 [ 1670413 ] CDP.pm -- power drawn support (Justin Hunter) 2007-04-03 02:53:52 +00:00
Eric Miller
9d37614f66 [ 1670407 ] MAU.pm partials (Justin Hunter) 2007-04-03 02:40:47 +00:00
Eric Miller
669989434c - Enable calls to SUPER class to find autoloaded methods (Bernhard Augenstein)
- Modify AUTOLOAD so that single instance MIB leafs return a scalar like GLOBALS while MIB leafs in tables return reference to hash like FUNCS.  Do not access %SNMP::MIB directly to prevent autovivification.
2007-04-03 02:19:39 +00:00
Eric Miller
fb44b0b4b1 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. 2007-04-03 01:25:22 +00:00
Bill Fenner
09f80eeed7 Translate OIDs returned by Entity MIB e_type 2007-02-26 00:19:15 +00:00
Bill Fenner
e5c81896aa Implement v_index as a function, since the OID is not-accessible and
can't be walked.
2007-02-20 03:06:04 +00:00
Bill Fenner
7ad7d1e338 Add -n for no bulkwalk.
Allow -x to be specified multiple times to go with Info.pm's new
 Debug=2 output.
2007-02-15 23:11:43 +00:00
Bill Fenner
1b0c212a95 Increased debugging in _load_attr(). The most verbose requires
Debug = 2.
Print an error in AUTOLOAD if it's called without a class; this
 is likely to be a typo in a function call in a module implementation
 and the default error message is just confusing.
2007-02-15 23:10:55 +00:00
Bill Fenner
0dc9174c83 Fix uptime fetching code.
Minor documentation fixes.
2007-02-15 21:49:59 +00:00
Bill Fenner
70197f35ee Add Layer3::NetSNMP, combining some of my work with that submitted by
Bradley Baetz in patch 1557529.
2007-02-14 23:58:31 +00:00
Eric Miller
5c0cefefba [ 1644841 ] Airespace serial number 2007-01-26 03:44:11 +00:00
Eric Miller
54633a7b99 [ 1638153 ] Add rptrAddrTrackNewLastSrcAddress to Layer1's functions 2007-01-25 04:30:38 +00:00
Eric Miller
cde34cfc99 Cisco Airespace wireless controller support 2007-01-25 03:59:38 +00:00
Bill Fenner
41dac34246 Fix typo in name of OID for e_pos. Also add pod for e_pos. 2006-12-02 04:06:27 +00:00
Bill Fenner
b1e0261216 Handle SNMPv1 noSuchName response - iid = '' and val = ''.
Getting noSuchName in response to a getnext for an empty table
 resulted in a return value of { '' => '' } instead of undef.
Fixes [1596554]
2006-11-23 06:51:38 +00:00
Bill Fenner
84b1160c23 Hook up Netgear by enterprise number. 2006-11-23 06:17:10 +00:00
Bill Fenner
0cededc7ba Add a netgear class, based on Zoltan Erszenyi's work with the
GSM 7224 and my brief encounter with an FSM 726.
2006-11-23 06:12:46 +00:00
Eric Miller
0b932064ed Cyclades terminal server support 2006-11-20 19:36:14 +00:00
Eric Miller
c4c0cbb597 Fix doc cut and paste 2006-11-20 16:29:21 +00:00
Eric Miller
24662f2352 Initial Import 2006-11-20 16:19:28 +00:00
Bill Fenner
d460c5a473 Some of the links were broken since some pages used
TABLE ENTRIES and others used TABLE METHODS.  Since
README says TABLE METHODS, let's standardize on that.
2006-11-18 00:23:26 +00:00
Bill Fenner
87063bc4d3 Update Required MIBs, GLOBALS and TABLE ENTRIES sections to
include links in cross-references to other SNMP::Info pages.
2006-11-17 00:59:33 +00:00
Bill Fenner
948921930b Remove custom ipNetToMediaTable implementations, and inherit them
from Layer3.pm
Use orig_foo() instead of custom versions
Rename 'serial' to 'serial1' so Layer3.pm's serial() sub will use it
2006-11-17 00:25:14 +00:00
Bill Fenner
dc494ff038 Implement Dot11 Transmission Power Table (dot11PhyTxPowerTable)
and a helper function, dot11_cur_tx_pwr_mw(), which performs the
 necessary dereferencing to get the current tx power level in mw.
2006-11-16 17:39:04 +00:00
Bill Fenner
a98e163c7c Add interfaces to Q-BRIDGE Filtering Database Table (dot1qFdbTable):
qb_fw_mac, qb_fw_port, qb_fw_status.  These can be used directly
 in place of fw_mac, fw_port, fw_status for devices that only
 populate dot1qFdbTable and not dot1dFdbTable.
2006-11-15 21:10:23 +00:00
Eric Miller
e6428abc0b Cached globals in set operations are bad :-( 2006-11-15 19:48:20 +00:00
Eric Miller
9597095b50 Prep 1.05 2006-11-15 19:38:20 +00:00
Eric Miller
905272a3bc Doc update 2006-11-15 19:26:27 +00:00
Eric Miller
5da4035b03 Add loop detect option and code for getnext table column walks. 2006-11-15 18:01:27 +00:00
Eric Miller
435af3cf82 - Fix for bug where an SNMP error in any operation would cause subsequent table get operations to fail in the same session, originally identified by Nicolai Petri.
- Implemented Justin Hunter's suggestion to enable dynamic methods in AUTOLOAD with MIB Leaf node names for loaded MIBs without definition in %FUNCS.
- Enable load_ methods for %GLOBALS and MIB Leaf node names.
- Allow partial table fetches with load_ methods.
- Allow a single instance partial table fetch with iid = 0, can be used to support non-table MIB Leaf node name fetches.
- Documentation updates.
2006-11-14 04:07:23 +00:00
Eric Miller
afc53b176b Changes to CiscoVTP, OSPF neighbor table, CiscoConfig class. 2006-11-04 03:27:16 +00:00
Eric Miller
8624b0d63a - Throw errors with error_throw()
- Better input parameter validation
- Only allow set_i_vlan() on access ports
- Change order of egress list processing in set_i_vlan() in case we're given the same VID
2006-11-04 03:08:38 +00:00
Eric Miller
1ac5cdd110 Fix in i_vlan() and i_vlan_membership() for newer code 2006-11-03 22:17:33 +00:00
Bill Fenner
1be0292e78 Override the Layer3 serial number fetching. 2006-11-03 19:06:43 +00:00
Bill Fenner
523deb988a If the result is a ref to an array, print the array.
(Have to be careful about becoming Data::Dumper...)
2006-11-03 16:53:10 +00:00
Eric Miller
4ae815c6f9 - Add new VLAN methods.
- Support partial table fetches on overridden table methods.
- Document new set methods and other doc updates.
2006-11-02 20:49:45 +00:00
Eric Miller
d46b124674 - Support for "write mem" and "write net" for older IOS versions
- Added appropriate debugging output and throw errors as expected
- Timeout value to prevent an infinite loop while waiting for the device to report success or failure.
2006-11-01 21:37:29 +00:00
Eric Miller
df9a335052 Initial Import
SF Patch 1555001 - CiscoConfig.pm (Justin Hunter)
2006-10-30 21:35:45 +00:00
Eric Miller
038a6c7714 Documentation updates 2006-10-30 17:57:10 +00:00
Eric Miller
301d14acf0 document recent changes 2006-10-30 03:41:34 +00:00
Eric Miller
c5a0e40065 - Add OSPF Neighbor Table, SF Patch 1577918 by Andrew Herrick
- Add OSPF Interface Table
- Documentation updates
2006-10-28 03:21:31 +00:00
Eric Miller
b8c03fa9c1 - Change inheritance - Layer2 and IEEE802dot11
- Implement i_ssidlist(), and i_80211channel() methods through IEEE802dot11 class
- Use orig_ syntax. Remove redundant items
- Support partial table fetches on overridden table methods
- Documentation updates
2006-10-27 15:23:11 +00:00
Eric Miller
3da742fa1d - Implement i_ssidlist(), i_ssidbcast(), and i_80211channel() methods.
- Use orig_ syntax. Remove redundant items.
- Support partial table fetches on overridden table methods.
- Documentation updates.
2006-10-20 20:05:22 +00:00
Eric Miller
a1199f6ff0 Initial commit 2006-10-20 18:27:16 +00:00
Max Baker
4dc43891df pod fix 2006-10-18 18:02:35 +00:00
Max Baker
7aede0a35e allow translateObj() to fail by adding default return value. fix reported warnings 2006-10-18 16:52:33 +00:00
Max Baker
8b0239fdde added 7200 series note about IOS version 2006-10-18 16:42:20 +00:00
Eric Miller
ab632849bf - Extend interfaces - Each radio interface instead of just one interface per AP. Added virtual interfaces (AP tunnel terminations).
- Implemention of additional MIB leafs and tables.
- Implement i_ssidlist(), i_ssidbcast(), and i_80211channel() methods.
- Use orig_ syntax. Remove redundant items.
- Support partial table fetches on overridden table methods.
- Documentation.
2006-10-12 21:48:32 +00:00
Bill Fenner
cec6e00384 in test_fn(), call test_global() if we get something back from the
method that's not a hash.  This enables "-p foo" on the command line
 for a foo that's not a hash.
2006-10-12 17:53:45 +00:00
Eric Miller
3656c6e42a Initial Import 2006-10-03 02:56:36 +00:00
Eric Miller
b93278fa93 Add definitions to support new VLAN methods.
Documention updates.
2006-10-03 02:24:37 +00:00
Eric Miller
ff37bab36d bp_port () definition fix - Nicolai Petri bug report 2006-10-03 01:38:36 +00:00
Eric Miller
f3783daf05 Doc updates 2006-10-01 03:16:28 +00:00
Eric Miller
8c01484a5d Support partial table fetches on overridden table methods.
Pod updates.
2006-10-01 03:08:55 +00:00
Eric Miller
d8994dc737 Rework regex again for conflicts between 8100 and 1100 series. 2006-09-29 13:56:42 +00:00
Eric Miller
88890649bf Support for dual speed 10/100 hubs 2006-09-29 03:18:57 +00:00
Eric Miller
d46842bd8e Detection of older dual speed Bay hubs.
SF Patch 1557530 - OC-48 interfaces - Bradley Baetz
2006-09-29 03:13:58 +00:00
Eric Miller
c240cfc854 Regex fix for 8110 2006-09-29 01:52:48 +00:00
Eric Miller
81f5534a6a Support partial table fetches on overridden table methods.
Add set_i_duplex_admin ( ) method.
Document new set method and other doc updates.
2006-09-29 01:42:34 +00:00
Eric Miller
e60a1a6931 Nortel ERS 1600 series < 2.1 use L3::N1600 others now use L3::Passport 2006-09-19 16:28:28 +00:00
Eric Miller
72e8f46633 ERS 1600 series code versions >= 2.1 now use this class 2006-09-19 16:24:09 +00:00
Eric Miller
d7c0959d27 Passport class detection changes 2006-09-19 15:45:23 +00:00
Max Baker
862e8b6006 Added CGESM to C2900 in device_type() 2006-09-06 17:42:05 +00:00
Max Baker
c9b47de8d1 logic inversion error 2006-09-06 17:34:29 +00:00
Max Baker
0dd90a24dd *** empty log message *** 2006-09-06 17:30:21 +00:00
Max Baker
9cfc0bcd64 added bypass of old vlan info if we already see the port is marked trunk 2006-09-06 17:28:53 +00:00
Max Baker
1820299dcf added all entries from ifEntry table in IF-MIB and their descriptions. reorderd to match in %FUNC 2006-09-06 17:17:00 +00:00
Eric Miller
acbfa7484b Override serial() as required since overridden in L2 / L3.
Doc updates.
2006-09-01 18:40:12 +00:00
Eric Miller
67fd776431 Support partial table fetches on overridden table methods.
Optimize i_duplex_admin() and i_duplex().
Override serial() as required since overridden in L3.
Document new set methods and other doc updates.
2006-09-01 15:53:43 +00:00
Eric Miller
c04dd5b3b5 Inherit from Layer3. Use orig_ syntax. Remove redundant items.
Support partial table fetches on overridden table methods.
Pod updates.
2006-09-01 02:09:51 +00:00
Eric Miller
b8b2d337d5 Pod update. 2006-08-30 17:06:25 +00:00
Eric Miller
8b0ffdf079 Use orig_ attrib, remove redundant items.
Support partial table fetches on overridden table methods.
Pod updates.
2006-08-30 17:01:55 +00:00
Eric Miller
eb8328c36d Implement i_ssidlist(), i_ssidbcast(), and i_80211channel() methods.
Inherit from Layer2.  Use orig_ syntax. Remove redundant items.
Support partial table fetches on overridden table methods.
Pod updates.
2006-08-30 03:05:37 +00:00
Eric Miller
2ab9bb0053 Add NetScreen support. SF patch ID 1507463. 2006-08-30 02:17:19 +00:00
Eric Miller
fae8e8396f Pod changes. 2006-08-30 02:07:08 +00:00
Eric Miller
cdccde0c7d Initial Import. 2006-08-30 02:02:58 +00:00
Eric Miller
ee829539c2 Use orig_ attrib, remove redundant items.
Support partial table fetches on overridden table methods.
Pod updates.
2006-08-28 19:56:31 +00:00
Eric Miller
832679ac4f Inherit from Layer2. Use orig_ syntax. Remove redundant items.
Support partial table fetches on overridden table methods.
Pod updates.
2006-08-28 19:51:52 +00:00
Eric Miller
45af60459f Basic Sun support - SF Patch 1544637 contributed by begemot 2006-08-23 19:48:47 +00:00
Eric Miller
2586fc9309 Initial import - SF Patch 1544637 contributed by begemot 2006-08-23 19:45:16 +00:00
Eric Miller
01cafebf89 Inherit from Layer3. Use orig_ syntax. Remove redundant items.
Support partial table fetches on overridden table methods.
Rework methods to use least amount of SNMP queries based upon calling context.
2006-08-23 19:34:10 +00:00
Eric Miller
9d530e2a62 Enable partial table fetches in overridden methods - Justin Hunter SF Patch ID 1542883. 2006-08-22 19:32:00 +00:00
Eric Miller
c130b9a49e Fix SNMPv1 partial table fetches, bug introduced by patch to enable single instance partial table fetches. 2006-08-22 01:42:56 +00:00
Eric Miller
c10bf98500 Add new VLAN methods and align i_vlan( ) with other classes.
Add set_i_speed_admin ( ) and set_i_duplex_admin ( ) methods.
Fix POD name.
2006-08-17 02:02:40 +00:00
Eric Miller
83fb73389a Bill's patch to allow single instance partial table fetches. 2006-08-17 01:54:27 +00:00
Eric Miller
f9933dcb4f start 1.05 documentation 2006-08-11 02:42:41 +00:00
Eric Miller
74ccc599fe Add generic device type detection using IANA assigned enterpise number extracted from sysObjectID. Add Dell switch detection. 2006-08-11 02:26:26 +00:00
Eric Miller
362acb9217 Initial import - support for Dell Power Connect switches 2006-08-10 02:36:13 +00:00
Eric Miller
a3038adbd0 Fix POD 2006-08-10 02:30:32 +00:00
Eric Miller
8015e59161 fix C1130, C1240 2006-07-08 02:43:43 +00:00
Eric Miller
7a94ddcc26 date for 1.04 2006-07-08 02:17:21 +00:00
Eric Miller
4e73ff2bae updates for 1.04 2006-07-08 02:04:10 +00:00
Eric Miller
257eb48e70 doc updates for 1.04 2006-07-08 02:02:34 +00:00
Eric Miller
cf1564d598 doc updates 2006-07-08 02:01:22 +00:00
Eric Miller
e83380c7c5 add L2::Cisco 2006-07-08 01:35:52 +00:00
Eric Miller
799a06b63a prep 1.04, capture older versions of BayRS 2006-07-08 01:25:40 +00:00
Eric Miller
b55e15a568 prep 1.04 2006-06-30 21:33:47 +00:00
Eric Miller
6b3edc3232 capture older versions 2006-06-30 21:24:23 +00:00
Max Baker
f65332f9cc added detection for C3400 w/ metrobase to L3/C3550 class 2006-06-26 23:00:27 +00:00
Max Baker
3416928233 added c2940 support, fixed typo in Orinoco detection. 2006-06-20 18:26:52 +00:00
Max Baker
4d262872c8 added sysID to debug messages for data collection purposes 2006-06-20 05:00:23 +00:00
Max Baker
795ae41d68 changed detection of HP ProCurve devices. New firmware doesn't have the string HP in the description... maybe we should use OIDs :-) 2006-06-20 04:34:59 +00:00
Max Baker
2e17b5c64a *** empty log message *** 2006-06-20 03:58:45 +00:00
Max Baker
ddca296e2a added generic L2::Cisco class and fixed warnings in CiscoStack 2006-06-20 03:58:10 +00:00
Eric Miller
af5d1d6c03 device detection 2006-06-20 02:43:50 +00:00
Eric Miller
2f07667560 device detection for Cisco Aironet 1130/1240, Cisco Sup Eng 2/32, Cisco 2960 2006-06-20 02:10:52 +00:00
Bill Fenner
1fac4cb13c Remove CiscoStack from @ISA 2006-04-15 19:02:44 +00:00
Bill Fenner
aa8c86ddcd Add debug option, -x or --debug 2006-04-15 01:20:40 +00:00
Eric Miller
83751acf91 1.03-beta 2006-04-14 15:54:38 +00:00
75 changed files with 15671 additions and 3022 deletions

116
ChangeLog
View File

@@ -1,6 +1,103 @@
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
ChangeLog $Id$
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
@@ -35,7 +132,8 @@ version 1.0 (04/07/06) - CVS only. No official release
+ 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 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
@@ -81,7 +179,8 @@ verison 0.9 (11/15/04)
+ 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 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
@@ -136,8 +235,10 @@ version 0.4 (04/29/03)
* 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.
* 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()
@@ -150,8 +251,8 @@ version 0.4 (04/29/03)
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>
@@ -168,7 +269,8 @@ 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

View File

@@ -6,17 +6,34 @@
# $Id$
# Airespace (pre-Cisco)
device-vendor: Airespace
cdp:no
arpnip: no
macsuck: yes
portmac: yes
duplex: both
vlan: yes
modules: yes
class: Layer2::Airespace
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-family: Airespace Wireless Controllers
device: 3500, 4101, 4102
# Allied
device-vendor: Allied Telesyn
cdp:no
device-family: Allied Hubs
class: Layer1::Allied
ver: 1
arpnip: no
macsuck: no
duplex: no
device-family: Allied Hubs
device: AT-3624T
device-family: AT-8000 Switches
@@ -26,8 +43,6 @@ macsuck: yes
# Aruba
device-vendor: Aruba
device-family: Aruba Wireless Controllers
arpnip: no
macsuck: yes
portmac: yes
@@ -35,18 +50,20 @@ duplex: no
class: Layer2::Aruba
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
device-family: Aruba Wireless Controllers
device: 5000
# Asante
device-vendor: Asante
device-family: Asante Hubs
class: Layer1::Asante
ver: 1
arpnip: no
macsuck: no
duplex: no
device-family: Asante Hubs
device: 1012
# Bay
@@ -57,13 +74,14 @@ note: See Nortel
device-vendor: Cisco
cdp: yes
ver: 2
modules: yes
note: Error in CISCO-TC-MIB. See README for how to patch.
device-family: Aironet
note: IOS and Aironet OS versions
class: Layer3::Aironet
device: AIRAP1100, AP1200, C1100
device: AIRAP1100, AP1200, C1100, C1130, C1240
note: IOS based device
class: Layer2::Aironet
@@ -76,12 +94,12 @@ note: Aironet based device
device-family: 1000
duplex: no
ver: 1
class: Layer3
class: Layer3::Cisco
device: 1003
device-family: 1700
class: Layer3
class: Layer3::Cisco
device: 1710
duplex: link
@@ -91,44 +109,46 @@ duplex: no
macsuck: yes
arpnip: yes
ver: 1
class: Layer3
class: Layer3::Cisco
device: 2501
device: 2501,2503,2511,2514
device: 2503
device: AS2509RJ
device: AS2511RJ
device: 2511
device: 2514
device: AS2509RJ,AS2511RJ
device-family: 2600
duplex: link
arpnip: yes
macsuck: yes
class: Layer3
class: Layer3::Cisco
device:2610,2610XM,2611,2620,2620XM,2621
device:2621XM
device:2610,2610XM,2611,2620,2620XM,2621,2621XM
device:2651XM
device:2691
device-family: 2800
duplex: link
arpnip: yes
macsuck: yes
class: Layer3::Cisco
device: 2811,2821,2851
device-family: 3600
class: Layer3
class: Layer3::Cisco
device: 3620
device: 3640
duplex: no
device-family:7200
class: Layer3::Cisco
note: !"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
class: Layer3::Cisco
device: 7507
duplex: no
@@ -136,7 +156,7 @@ note: !Duplex settings are falsely reported in older IOS versions
device-family: AS5000
duplex: no
class: Layer3
class: Layer3::Cisco
device: AS5300
@@ -205,7 +225,7 @@ vlan: write
note: Acts just like IOS Catalyst 6500 series
class: Layer3::C6500
device: 2970G-24T-E
device: 2960, 2970G-24T-E
device-family: Catalyst 3500 XL
portmac: yes
@@ -234,6 +254,8 @@ note: Comes in flavors that support L2, L3 or combo.
device: 3550-12T
device: 3400 w/ MetroBase Image
device: 3550
note: L2/L3 Switch
arpnip: yes
@@ -293,11 +315,7 @@ note: !Macsuck not working?
device: wsc5000
note: !Has nasty tendency to not give you all SNMP data ,flaky for some older Catalyst versions.
device: wsc5505
device: wsc5509
device: wsc5500
device: wsc5500,wsc5505,wsc5509
device: wsx5302
arpnip: yes
@@ -349,23 +367,77 @@ 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
# 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
# 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
device: C2G124-24, C2G124-48
device-family: Matrix
device: Matrix N-Series DFE
# Extreme
device-vendor: Extreme Networks
device-family: Alpine and Summit
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
# Foundry
device-vendor: Foundry Networks
note: CDP --> FDP.
vlan: yes
modules: no
device-family: FastIron
class: Layer3::Foundry
@@ -376,7 +448,7 @@ device: FastIron 4802
device-family: EdgeIron
ver: 2
class: Layer2::Foundry
class: Layer3::Foundry
cdp: yes
duplex: yes
macsuck: yes
@@ -391,21 +463,22 @@ note: FDP enabled.
duplex: yes
macsuck: yes
arpnip: yes
device:FWSX424
device:SI400 Router
device: FWSX424
device: ServerIronGT
device: FLS624, FLS648
# HP
device-vendor: HP
class: Layer2::HP
ver: 2
modules: yes
device-family: HP ProCurve
duplex: both
macsuck: yes
arpnip: no
cdp: yes
vlan: yes
vlan: write
note: CDP only available with newer ROM versions.
device: 2512
@@ -423,6 +496,22 @@ duplex: link
device: 4108GL,8000,2626,2650,8000
note: VLAN info in Q-BRIDGE-MIB
# Juniper
device-vendor: Juniper
arpnip: yes
device-family: M-series router
class: Layer3::Juniper
device: M-series router
device-family: NetScreen
class: Layer3::Netscreen
device: Netscreen
# NetScreen
device-vendor: NetScreen
note: See Juniper
# Net-SNMP
device-vendor: Net-SNMP
class: Layer3
@@ -430,24 +519,21 @@ ver: 2
device-family: Linux
note: net-snmp 4.x agent and 5.x agent.
device: Linux routers
device-family: BSD
# Juniper
device-vendor: Juniper
device-family: M-series router
arpnip: yes
device: BSD routers
# NORTEL
device-vendor: Nortel
macsuck: yes
cdp: proprietary
note: CDP --> SONMP.
device-family: BayStack Hub
macsuck: yes
duplex: both
cdp: proprietary
ver: 1
modules: yes
class: Layer1::Bayhub
note: Uses proprietary MIBs to provide MAC to port mapping.
note: !Requires Advanced or Advanced Analyzer NMM
@@ -457,11 +543,10 @@ device: 102
device: System 5000
device-family: Ethernet Switch/Baystack Switch
arpnip: no
macsuck: yes
duplex: both
vlan: yes
cdp: proprietary
vlan: write
modules: yes
class: Layer2::Baystack
device: 303,304
@@ -484,20 +569,30 @@ device: BPS
device-family: Ethernet Routing Switch/Baystack Switch
arpnip: yes
macsuck: yes
duplex: both
vlan: yes
cdp: proprietary
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
macsuck: yes
duplex: both
cdp: proprietary
vlan: yes
class: Layer2::Centillion
note: !Must be on version 4.x or 5.x (VLAN based) software.
@@ -511,58 +606,39 @@ device: C100
device: C50
device-family: AP222x
macsuck: yes
duplex: both
cdp: proprietary
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
device: AP-2221
device: AP-2220, AP-2221
device-family: Alteon AD
arpnip: yes
macsuck: 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
device: AD2,AD3,AD4
device: AD3
device: AD4
device: 180
device: 183
device: 184
device: 180,183,184
device-family: Multiprotocol Router/BayRS
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
cdp: no
vlan: yes
modules: yes
class: Layer3::BayRS
device: AN
device: AN,ARN,ASN,BLN,BCN
device: ARN
device: ASN
device: BLN
device: Passport 2430
device: Passport 5430
device: 2430,5430
device-family: VPN Router/Contivity
arpnip: yes
@@ -570,13 +646,14 @@ 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
device: 1500,1600,1700,1740,1750
device: 2500,2600,2700
@@ -586,9 +663,10 @@ device-family: Ethernet Routing Switch/Passport/Accelar LAN
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
duplex: write
cdp: proprietary
vlan: yes
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.
@@ -601,17 +679,28 @@ device: 8106,8110
device: 1050,1100,1150,1200
device-family: Ethernet Routing Switch/Passport 1600
device-family: Ethernet Routing Switch/Passport 1600 (Software < 2.1)
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
cdp: proprietary
vlan: yes
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
@@ -631,6 +720,7 @@ 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.
@@ -638,21 +728,25 @@ device: 2270
# Proxim
device-vendor: Proxim
device-family: Orinoco
macsuck: yes
duplex: no
cdp: no
class: Layer2::Orinoco
device: AP-1000
device-family: Orinoco
device: AP-2000
device: AP-4000
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

590
Info.pm

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Bridge;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -57,8 +57,9 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'stp_time' => 'dot1dStpTimeSinceTopologyChange',
'stp_root' => 'dot1dStpDesignatedRoot',
# Q-BRIDGE-MIB
'qb_vlans_max' => 'dot1qMaxSupportedVlans',
'qb_vlans' => 'dot1qNumVlans',
'qb_vlans_max' => 'dot1qMaxSupportedVlans',
'qb_vlans' => 'dot1qNumVlans',
'qb_next_vlan_index' => 'dot1qNextFreeLocalVlanIndex',
);
%FUNCS = (
@@ -68,9 +69,9 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'fw_status' => 'dot1dTpFdbStatus',
# Bridge Port Table: Dot1dBasePortEntry
'bp_index' => 'dot1dBasePortIfIndex',
'bp_port' => 'dot1dBasePortCircuit ',
'bp_port' => 'dot1dBasePortCircuit',
# Bridge Static (Destination-Address Filtering) Database
'bs_mac' => 'dot1dStaticAddress',
'bs_mac' => 'dot1dStaticAddress',
'bs_port' => 'dot1dStaticReceivePort',
'bs_to' => 'dot1dStaticAllowedToGoTo',
'bs_status' => 'dot1dStaticStatus',
@@ -82,11 +83,23 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'stp_p_root' => 'dot1dStpPortDesignatedRoot',
'stp_p_bridge' => 'dot1dStpPortDesignatedBridge',
'stp_p_port' => 'dot1dStpPortDesignatedPort',
# Q-BRIDGE-MIB :
'qb_i_vlan' => 'dot1qPvid',
'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes',
'qb_v_name' => 'dot1qVlanStaticName',
'qb_v_stat' => 'dot1qVlanStaticRowStatus',
# Q-BRIDGE-MIB : dot1qPortVlanTable
'qb_i_vlan' => 'dot1qPvid',
'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes',
'qb_i_vlan_in_flt' => 'dot1qPortIngressFiltering',
# Q-BRIDGE-MIB : dot1qVlanCurrentTable
'qb_cv_egress' => 'dot1qVlanCurrentEgressPorts',
'qb_cv_untagged' => 'dot1qVlanCurrentUntaggedPorts',
'qb_cv_stat' => 'dot1qVlanStatus',
# Q-BRIDGE-MIB : dot1qVlanStaticTable
'v_name' => 'dot1qVlanStaticName',
'qb_v_egress' => 'dot1qVlanStaticEgressPorts',
'qb_v_fbdn_egress' => 'dot1qVlanForbiddenEgressPorts',
'qb_v_untagged' => 'dot1qVlanStaticUntaggedPorts',
'qb_v_stat' => 'dot1qVlanStaticRowStatus',
# VLAN Forwarding Table: Dot1qTpFdbEntry
'qb_fw_port' => 'dot1qTpFdbPort',
'qb_fw_status' => 'dot1qTpFdbStatus',
);
%MUNGE = (
@@ -102,11 +115,33 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'stp_p_port' => \&SNMP::Info::munge_mac
);
# break up the Dot1qTpFdbEntry INDEX into FDB ID and MAC Address.
sub _qb_fdbtable_index {
my $idx = shift;
my @values = split(/\./, $idx);
my $fdb_id = shift(@values);
return ($fdb_id, join(':',map { sprintf "%02x",$_ } @values));
}
sub qb_fw_mac {
my $bridge = shift;
my $partial = shift;
my $qb_fw_port = $bridge->qb_fw_port($partial);
my $qb_fw_mac = {};
foreach my $idx (keys %$qb_fw_port) {
my($fdb_id, $mac) = _qb_fdbtable_index($idx);
$qb_fw_mac->{$idx} = $mac;
}
$qb_fw_mac;
}
sub qb_i_vlan_t {
my $bridge = shift;
my $partial = shift;
my $qb_i_vlan = $bridge->qb_i_vlan();
my $qb_i_vlan_type = $bridge->qb_i_vlan_type();
my $qb_i_vlan = $bridge->qb_i_vlan($partial);
my $qb_i_vlan_type = $bridge->qb_i_vlan_type($partial);
my $i_vlan = {};
@@ -121,8 +156,10 @@ sub qb_i_vlan_t {
sub i_stp_state {
my $bridge = shift;
my $bp_index = $bridge->bp_index();
my $stp_p_state = $bridge->stp_p_state();
my $partial = shift;
my $bp_index = $bridge->bp_index($partial);
my $stp_p_state = $bridge->stp_p_state($partial);
my %i_stp_state;
@@ -137,11 +174,12 @@ sub i_stp_state {
return \%i_stp_state;
}
sub i_stp_port {
my $bridge = shift;
my $bp_index = $bridge->bp_index();
my $stp_p_port = $bridge->stp_p_port();
my $partial = shift;
my $bp_index = $bridge->bp_index($partial);
my $stp_p_port = $bridge->stp_p_port($partial);
my %i_stp_port;
@@ -157,8 +195,10 @@ sub i_stp_port {
sub i_stp_id {
my $bridge = shift;
my $bp_index = $bridge->bp_index();
my $stp_p_id = $bridge->stp_p_id();
my $partial = shift;
my $bp_index = $bridge->bp_index($partial);
my $stp_p_id = $bridge->stp_p_id($partial);
my %i_stp_id;
@@ -174,8 +214,10 @@ sub i_stp_id {
sub i_stp_bridge {
my $bridge = shift;
my $bp_index = $bridge->bp_index();
my $stp_p_bridge = $bridge->stp_p_bridge();
my $partial = shift;
my $bp_index = $bridge->bp_index($partial);
my $stp_p_bridge = $bridge->stp_p_bridge($partial);
my %i_stp_bridge;
@@ -189,6 +231,369 @@ sub i_stp_bridge {
return \%i_stp_bridge;
}
# Non-accessible, but needed for consistency with other classes
sub v_index {
my $bridge = shift;
my $partial = shift;
my $v_name = $bridge->v_name($partial);
my %v_index;
foreach my $idx (keys %$v_name) {
$v_index{$idx} = $idx;
}
return \%v_index;
}
sub i_vlan {
my $bridge = shift;
my $partial = shift;
my $index = $bridge->bp_index();
# If given a partial it will be an ifIndex, we need to use dot1dBasePort
if ($partial) {
my %r_index = reverse %$index;
$partial = $r_index{$partial};
}
my $i_pvid = $bridge->qb_i_vlan($partial) || {};
my $i_vlan = {};
foreach my $bport (keys %$i_pvid) {
my $vlan = $i_pvid->{$bport};
my $ifindex = $index->{$bport};
unless (defined $ifindex) {
print " Port $bport has no bp_index mapping. Skipping\n"
if $DEBUG;
next;
}
$i_vlan->{$ifindex} = $vlan;
}
return $i_vlan;
}
sub i_vlan_membership {
my $bridge = shift;
my $partial = shift;
my $index = $bridge->bp_index();
# Use VlanCurrentTable if available since it will include dynamic
# VLANs. However, some devices do not populate the table.
# 11/07 - Todo: Issue with some devices trying to query VlanCurrentTable
# as table may grow very large with frequent VLAN changes.
#my $v_ports = $bridge->qb_cv_egress() || $bridge->qb_v_egress();
my $v_ports = $bridge->qb_v_egress() || {};
my $i_vlan_membership = {};
foreach my $idx (keys %$v_ports) {
next unless (defined $v_ports->{$idx});
my $portlist = [split(//, unpack("B*", $v_ports->{$idx}))];
my $ret = [];
my $vlan;
# Strip TimeFilter if we're using VlanCurrentTable
($vlan = $idx) =~ s/^\d+\.//;
# Convert portlist bit array to bp_index array
for (my $i = 0; $i <= $#$portlist; $i++) {
push(@{$ret}, $i+1) if (@$portlist[$i]);
}
#Create HoA ifIndex -> VLAN array
foreach my $port (@{$ret}) {
my $ifindex = $index->{$port};
next unless (defined($ifindex)); # shouldn't happen
next if (defined $partial and $ifindex !~ /^$partial$/);
push(@{$i_vlan_membership->{$ifindex}}, $vlan);
}
}
return $i_vlan_membership;
}
sub set_i_pvid {
my $bridge = shift;
my ($vlan_id, $ifindex) = @_;
return undef unless ($bridge->_validate_vlan_param ($vlan_id, $ifindex));
my $index = $bridge->bp_index();
my %r_index = reverse %$index;
my $bport = $r_index{$ifindex};
unless ( $bridge->set_qb_i_vlan($vlan_id, $bport) ) {
$bridge->error_throw("Unable to change PVID to $vlan_id on
IfIndex: $ifindex");
return undef;
}
return 1;
}
sub set_i_vlan {
my $bridge = shift;
my ($new_vlan_id, $ifindex) = @_;
return undef unless ($bridge->_validate_vlan_param ($new_vlan_id, $ifindex));
my $index = $bridge->bp_index();
my %r_index = reverse %$index;
my $bport = $r_index{$ifindex};
my $vlan_p_type = $bridge->qb_i_vlan_type($bport);
unless ( $vlan_p_type->{$bport} =~ /admitAll/ ) {
$bridge->error_throw("Not an access port");
return undef;
}
my $i_pvid = $bridge->qb_i_vlan($bport);
# Store current untagged VLAN to remove it from the egress port list later
my $old_vlan_id = $i_pvid->{$bport};
print "Changing VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n"
if $bridge->debug();
# Check if port in forbidden list for the VLAN, haven't seen this used,
# but we'll check anyway
return undef unless
($bridge->_check_forbidden_ports($new_vlan_id, $bport));
# Remove port from any untagged list
return undef unless
($bridge->_remove_from_untagged_lists($bport));
# Remove port from old VLAN from egress list
return undef unless
($bridge->_remove_from_egress_portlist($old_vlan_id, $bport));
# Add port to egress list for VLAN
return undef unless
($bridge->_add_to_egress_portlist($new_vlan_id, $bport));
# Add port to untagged egress list for VLAN
return undef unless
($bridge->_add_to_untagged_portlist($new_vlan_id, $bport));
# Set new untagged / native VLAN
# Some models/versions do this for us also, so check to see if we need
$i_pvid = $bridge->qb_i_vlan($bport);
my $cur_i_pvid = $i_pvid->{$bport};
print "Current PVID: $cur_i_pvid\n" if $bridge->debug();
unless ($cur_i_pvid eq $new_vlan_id) {
return undef unless ($bridge->set_i_pvid($new_vlan_id, $ifindex));
}
print "Successfully changed VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" if $bridge->debug();
return 1;
}
sub set_add_i_vlan_tagged {
my $bridge = shift;
my ($vlan_id, $ifindex) = @_;
my $index = $bridge->bp_index();
my %r_index = reverse %$index;
my $bport = $r_index{$ifindex};
return undef unless ( $bridge->_validate_vlan_param ($vlan_id, $ifindex) );
print "Adding VLAN: $vlan_id to IfIndex: $ifindex\n" if $bridge->debug();
# Check if port in forbidden list for the VLAN, haven't seen this used,
# but we'll check anyway
return undef unless ($bridge->_check_forbidden_ports($vlan_id, $bport));
# Add port to egress list for VLAN
return undef unless ($bridge->_add_to_egress_portlist($vlan_id, $bport));
print "Successfully added IfIndex: $ifindex to VLAN: $vlan_id egress list\n" if $bridge->debug();
return 1;
}
sub set_remove_i_vlan_tagged {
my $bridge = shift;
my ($vlan_id, $ifindex) = @_;
my $index = $bridge->bp_index();
my %r_index = reverse %$index;
my $bport = $r_index{$ifindex};
return undef unless ( $bridge->_validate_vlan_param ($vlan_id, $ifindex) );
print "Removing VLAN: $vlan_id from IfIndex: $ifindex\n" if $bridge->debug();
# Remove port from egress list for VLAN
return undef unless ($bridge->_remove_from_egress_portlist($vlan_id, $bport));
print "Successfully removed IfIndex: $ifindex from VLAN: $vlan_id egress list\n" if $bridge->debug();
return 1;
}
#
# These are internal methods and are not documented. Do not use directly.
#
sub _check_forbidden_ports {
my $bridge = shift;
my ($vlan_id, $index) = @_;
return undef unless ($vlan_id =~ /\d+/ and $index =~ /\d+/);
my $iv_forbidden = $bridge->qb_v_fbdn_egress($vlan_id);
my @forbidden_ports = split(//, unpack("B*", $iv_forbidden->{$vlan_id}));
print "Forbidden ports: @forbidden_ports\n" if $bridge->debug();
if ( defined($forbidden_ports[$index-1]) and ($forbidden_ports[$index-1] eq "1")) {
print "Error: Index: $index in forbidden list for VLAN: $vlan_id unable to add\n" if $bridge->debug();
return undef;
}
return 1;
}
sub _add_to_untagged_portlist {
my $bridge = shift;
my ($vlan_id, $index) = @_;
return undef unless ($vlan_id =~ /\d+/ and $index =~ /\d+/);
my $iv_members = $bridge->qb_v_untagged($vlan_id);
my @untagged_list = split(//, unpack("B*", $iv_members->{$vlan_id}));
print "Original untagged list for VLAN: $vlan_id: @untagged_list \n" if $bridge->debug();
$untagged_list[$index-1] = '1';
# Some devices do not populate the portlist with all possible ports.
# If we have lengthened the list fill all undefined elements with zero.
foreach my $item (@untagged_list) {
$item = '0' unless (defined($item));
}
print "Modified untagged list for VLAN: $vlan_id: @untagged_list \n" if $bridge->debug();
my $new_untagged = pack("B*", join('', @untagged_list));
my $untagged_rv = $bridge->set_qb_v_untagged($new_untagged, $vlan_id);
unless ($untagged_rv) {
print "Error: Unable to add VLAN: $vlan_id to Index: $index untagged list\n" if $bridge->debug();
return undef;
}
return 1;
}
sub _remove_from_untagged_lists {
my $bridge = shift;
my ($index) = @_;
return undef unless ($index =~ /\d+/);
my $iv_members = $bridge->qb_v_untagged();
foreach my $vlan (keys %$iv_members) {
my @untagged_list = split(//, unpack("B*", $iv_members->{$vlan}));
print "Original untagged list for VLAN: $vlan: @untagged_list \n" if $bridge->debug();
if ( defined($untagged_list[$index-1]) and ($untagged_list[$index-1] eq "1")) {
$untagged_list[$index-1] = '0';
print "Modified untagged list for VLAN: $vlan: @untagged_list \n" if $bridge->debug();
my $new_untagged = pack("B*", join('', @untagged_list));
my $untagged_rv = $bridge->set_qb_v_untagged($new_untagged, $vlan);
unless ($untagged_rv) {
print "Warning: Unable to remove Index: $index from VLAN: $vlan untagged list\n" if $bridge->debug();
return undef;
}
}
}
return 1;
}
sub _add_to_egress_portlist {
my $bridge = shift;
my ($vlan_id, $index) = @_;
return undef unless ($vlan_id =~ /\d+/ and $index =~ /\d+/);
my $iv_members = $bridge->qb_v_egress($vlan_id);
my @egress_list = split(//, unpack("B*", $iv_members->{$vlan_id}));
print "Original egress list for VLAN: $vlan_id: @egress_list \n" if $bridge->debug();
$egress_list[$index-1] = '1';
# Some devices do not populate the portlist with all possible ports.
# If we have lengthened the list fill all undefined elements with zero.
foreach my $item (@egress_list) {
$item = '0' unless (defined($item));
}
print "Modified egress list for VLAN: $vlan_id: @egress_list \n" if $bridge->debug();
my $new_egress = pack("B*", join('', @egress_list));
my $egress_rv = $bridge->set_qb_v_egress($new_egress, $vlan_id);
unless ($egress_rv) {
print "Error: Unable to add VLAN: $vlan_id to Index: $index egress list\n" if $bridge->debug();
return undef;
}
return 1;
}
sub _remove_from_egress_portlist {
my $bridge = shift;
my ($vlan_id, $index) = @_;
return undef unless ($vlan_id =~ /\d+/ and $index =~ /\d+/);
my $iv_members = $bridge->qb_v_egress($vlan_id);
my @egress_list = split(//, unpack("B*", $iv_members->{$vlan_id}));
print "Original egress list for VLAN: $vlan_id: @egress_list \n" if $bridge->debug();
# Some devices may remove automatically, so check state before set
if ( defined($egress_list[$index-1]) and ($egress_list[$index-1] eq "1")) {
$egress_list[$index-1] = '0';
print "Modified egress list for VLAN: $vlan_id: @egress_list \n" if $bridge->debug();
my $new_egress = pack("B*", join('', @egress_list));
my $egress_rv = $bridge->set_qb_v_egress($new_egress, $vlan_id);
unless ($egress_rv) {
print "Warning: Unable to remove Index: $index from VLAN: $vlan_id egress list\n" if $bridge->debug();
return undef;
}
}
return 1;
}
sub _validate_vlan_param {
my $bridge = 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+$/ ) {
$bridge->error_throw("Invalid parameter");
return undef;
}
# Check that ifIndex exists on device
my $index = $bridge->interfaces($ifindex);
unless ( exists $index->{$ifindex} ) {
$bridge->error_throw("ifIndex $ifindex does not exist");
return undef;
}
#Check that VLAN exists on device
my $vtp_vlans = $bridge->load_qb_cv_stat() || $bridge->load_qb_v_stat();
my $vlan_exists = 0;
foreach my $iid (keys %$vtp_vlans) {
my $vlan = 0;
my $state = $vtp_vlans->{$iid};
next unless defined $state;
if ($iid =~ /(\d+)$/ ) {
$vlan = $1;
}
$vlan_exists = 1 if ( $vlan_id eq $vlan );
}
unless ( $vlan_exists ) {
$bridge->error_throw("VLAN $vlan_id does not exist or is not
operational");
return undef;
}
return 1;
}
1;
__END__
@@ -196,7 +601,8 @@ __END__
=head1 NAME
SNMP::Info::Bridge - Perl5 Interface to SNMP data available through the BRIDGE-MIB (RFC1493)
SNMP::Info::Bridge - SNMP Interface to SNMP data available through the
BRIDGE-MIB (RFC1493)
=head1 AUTHOR
@@ -212,7 +618,7 @@ Max Baker
Version => 2
);
my $class = $cdp->class();
my $class = $bridge->class();
print " Using device sub class : $class\n";
# Grab Forwarding Tables
@@ -232,12 +638,15 @@ Max Baker
=head1 DESCRIPTION
BRIDGE-MIB is used by most Layer 2 devices, and holds information like the MAC Forwarding Table and Spanning Tree Protocol info.
BRIDGE-MIB is used by most Layer 2 devices, and holds information like the
MAC Forwarding Table and Spanning Tree Protocol info.
Q-BRIDGE-MIB holds 802.11q information -- VLANs and Trunking. Cisco tends not to use this MIB, but some
proprietary ones. HP and some nicer vendors use this. This is from C<RFC2674_q>.
Q-BRIDGE-MIB holds 802.1q information -- VLANs and Trunking. Cisco tends not
to use this MIB, but some proprietary ones. HP and some nicer vendors use
this. This is from C<RFC2674_q>.
Create or use a subclass of SNMP::Info that inherits this class. Do not use directly.
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
@@ -281,13 +690,15 @@ Returns the number of ports in device
=item $bridge->b_type()
Returns the type? of the device
Returns the type of bridging this bridge can perform, transparent and/or
sourceroute.
(B<dot1dBaseType>)
=item $bridge->stp_ver()
Returns what version of STP the device is running. Either decLb100 or ieee8021d.
Returns what version of STP the device is running. Either decLb100 or
ieee8021d.
(B<dot1dStpProtocolSpecification>)
@@ -303,16 +714,25 @@ Returns root of STP.
(B<dot1dStpDesignatedRoot>)
=item $bridge->qb_vlans_max()
=item $bridge->qb_vlans_max()
Maximum number of VLANS supported on this device.
(B<dot1qMaxSupportedVlans>)
=item $bridge->qb_vlans()
Number of VLANS on this device.
Current number of VLANs that are configured in this device.
(B<dot1qNumVlans>)
=item $bridge->qb_next_vlan_index()
The next available value for B<dot1qVlanIndex> of a local VLAN entry in
B<dot1qVlanStaticTable>
(B<dot1qNextFreeLocalVlanIndex>)
=back
=head1 TABLE METHODS
@@ -320,6 +740,29 @@ Number of VLANS on this device.
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $bridge->i_vlan()
Returns a mapping between ifIndex and the PVID or default VLAN.
=item $bridge->i_vlan_membership()
Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs.
These are the VLANs which are members of the egress list for the port.
Example:
my $interfaces = $bridge->interfaces();
my $vlans = $bridge->i_vlan_membership();
foreach my $iid (sort keys %$interfaces) {
my $port = $interfaces->{$iid};
my $vlan = join(',', sort(@{$vlans->{$iid}}));
print "Port: $port VLAN: $vlan\n";
}
=back
=head2 Forwarding Table (dot1dTpFdbEntry)
=over
@@ -332,7 +775,8 @@ Returns reference to hash of forwarding table MAC Addresses
=item $bridge->fw_port()
Returns reference to hash of forwarding table entries port interface identifier (iid)
Returns reference to hash of forwarding table entries port interface
identifier (iid)
(B<dot1dTpFdbPort>)
@@ -350,13 +794,17 @@ Returns reference to hash of forwading table entries status
=item $bridge->bp_index()
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
Returns reference to hash of bridge port table entries map back to interface
identifier (iid)
(B<dot1dBasePortIfIndex>)
=item $bridge->bp_port()
Returns reference to hash of bridge port table entries physical port name.
Returns reference to hash of bridge port table entries for a port which
(potentially) has the same value of B<dot1dBasePortIfIndex> as another port
on the same bridge, this object contains the name of an object instance unique
to this port.
(B<dot1dBasePortCircuit>)
@@ -370,25 +818,26 @@ Descriptions are lifted straight from F<BRIDGE-MIB.my>
=item $bridge->stp_p_id()
"The port number of the port for which this entry contains Spanning Tree Protocol management
information."
"The port number of the port for which this entry contains Spanning Tree
Protocol management information."
(B<dot1dStpPort>)
=item $bridge->stp_p_priority()
"The value of the priority field which is contained in the first (in network byte order)
octet of the (2 octet long) Port ID. The other octet of the Port ID is given by the value of
dot1dStpPort."
"The value of the priority field which is contained in the first
(in network byte order) octet of the (2 octet long) Port ID. The other octet
of the Port ID is given by the value of dot1dStpPort."
(B<dot1dStpPortPriority>)
=item $bridge->stp_p_state()
"The port's current state as defined by application of the Spanning Tree Protocol. This
state controls what action a port takes on reception of a frame. If the bridge has detected
a port that is malfunctioning it will place that port into the broken(6) state. For ports which
are disabled (see dot1dStpPortEnable), this object will have a value of disabled(1)."
"The port's current state as defined by application of the Spanning Tree
Protocol. This state controls what action a port takes on reception of a
frame. If the bridge has detected a port that is malfunctioning it will place
that port into the broken(6) state. For ports which are disabled
(see dot1dStpPortEnable), this object will have a value of disabled(1)."
disabled(1)
blocking(2)
@@ -401,23 +850,25 @@ are disabled (see dot1dStpPortEnable), this object will have a value of disabled
=item $bridge->stp_p_cost()
"The contribution of this port to the path cost of paths towards the spanning tree root which include
this port. 802.1D-1990 recommends that the default value of this parameter be in inverse
proportion to the speed of the attached LAN."
"The contribution of this port to the path cost of paths towards the spanning
tree root which include this port. 802.1D-1990 recommends that the default
value of this parameter be in inverse proportion to the speed of the attached
LAN."
(B<dot1dStpPortPathCost>)
=item $bridge->stp_p_root()
"The unique Bridge Identifier of the Bridge recorded as the Root in the Configuration BPDUs
transmitted by the Designated Bridge for the segment to which the port is attached."
"The unique Bridge Identifier of the Bridge recorded as the Root in the
Configuration BPDUs transmitted by the Designated Bridge for the segment to
which the port is attached."
(B<dot1dStpPortDesignatedRoot>)
=item $bridge->stp_p_bridge()
"The Bridge Identifier of the bridge which this port considers to be the Designated Bridge for
this port's segment."
"The Bridge Identifier of the bridge which this port considers to be the
Designated Bridge for this port's segment."
(B<dot1dStpPortDesignatedBridge>)
@@ -425,11 +876,13 @@ this port's segment."
(B<dot1dStpPortDesignatedPort>)
"The Port Identifier of the port on the Designated Bridge for this port's segment."
"The Port Identifier of the port on the Designated Bridge for this port's
segment."
=item $bridge->i_stp_port()
Returns the mapping of (B<dot1dStpPortDesignatedPort>) to the interface index (iid).
Returns the mapping of (B<dot1dStpPortDesignatedPort>) to the interface
index (iid).
=item $bridge->i_stp_id()
@@ -437,17 +890,19 @@ Returns the mapping of (B<dot1dStpPort>) to the interface index (iid).
=item $bridge->i_stp_bridge()
Returns the mapping of (B<dot1dStpPortDesignatedBridge>) to the interface index (iid).
Returns the mapping of (B<dot1dStpPortDesignatedBridge>) to the interface
index (iid).
=back
=head2 Q-BRIDGE Data
=head2 Q-BRIDGE Port VLAN Table (dot1qPortVlanTable)
=over
=item $bridge->qb_i_vlan()
Gives the vlan used by interfaces
The PVID, the VLAN ID assigned to untagged frames or Priority-Tagged frames
received on this port.
(B<dot1qPvid>)
@@ -458,12 +913,71 @@ trunk ports.
(B<dot1qPortAcceptableFrameTypes>)
=item $bridge->qb_i_vlan_in_flt()
When this is C<true> the device will discard incoming frames for VLANs which
do not include this Port in its Member set. When C<false>, the port will
accept all incoming frames.
(B<dot1qPortIngressFiltering>)
=back
=head2 Q-BRIDGE VLAN Current Table (dot1qVlanCurrentTable)
=over
=item $bridge->qb_cv_egress()
The set of ports which are assigned to the egress list for this VLAN.
(B<dot1qVlanCurrentEgressPorts>)
=item $bridge->qb_cv_untagged()
The set of ports which should transmit egress packets for this VLAN as
untagged.
(B<dot1qVlanCurrentUntaggedPorts>)
=item $bridge->qb_cv_stat()
Status of the VLAN, other, permanent, or dynamicGvrp.
(B<dot1qVlanStatus>)
=back
=head2 Q-BRIDGE VLAN Static Table (dot1qVlanStaticTable)
=over
=item $bridge->qb_v_name()
Human-entered name for vlans.
(B<dot1qVlanStaticName>)
=item $bridge->qb_v_egress()
The set of ports which are assigned to the egress list for this VLAN.
(B<dot1qVlanStaticEgressPorts>)
=item $bridge->qb_v_fbdn_egress()
The set of ports which are prohibited from being included in the egress list
for this VLAN.
(B<dot1qVlanForbiddenEgressPorts>)
=item $bridge->qb_v_untagged()
The set of ports which should transmit egress packets for this VLAN as
untagged.
(B<dot1qVlanStaticUntaggedPorts>)
=item $bridge->qb_v_stat()
uhh. C<active> !
@@ -472,4 +986,80 @@ uhh. C<active> !
=back
=head2 Q-BRIDGE Filtering Database Table (dot1qFdbTable)
=over
=item $bridge->qb_fw_mac()
Returns reference to hash of forwarding table MAC Addresses
(B<dot1qTpFdbAddress>)
=item $bridge->qb_fw_port()
Returns reference to hash of forwarding table entries port interface
identifier (iid)
(B<dot1qTpFdbPort>)
=item $bridge->qb_fw_status()
Returns reference to hash of forwading table entries status
(B<dot1qTpFdbStatus>)
=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 $bridge->set_i_vlan(vlan, ifIndex)
Changes an access (untagged) port VLAN, must be supplied with the numeric VLAN
ID and port ifIndex. This method will modify the port's VLAN membership and
PVID (default VLAN). This method should only be used on end station
(non-trunk) ports.
Example:
my %if_map = reverse %{$bridge->interfaces()};
$bridge->set_i_vlan('2', $if_map{'1.1'})
or die "Couldn't change port VLAN. ",$bridge->error(1);
=item $bridge->set_i_pvid(pvid, ifIndex)
Sets port PVID or default VLAN, must be supplied with the numeric VLAN ID and
port ifIndex. This method only changes the PVID, to modify an access (untagged)
port use set_i_vlan() instead.
Example:
my %if_map = reverse %{$bridge->interfaces()};
$bridge->set_i_pvid('2', $if_map{'1.1'})
or die "Couldn't change port PVID. ",$bridge->error(1);
=item $bridge->set_add_i_vlan_tagged(vlan, ifIndex)
Adds the port to the egress list of the VLAN, must be supplied with the numeric
VLAN ID and port ifIndex.
Example:
my %if_map = reverse %{$bridge->interfaces()};
$bridge->set_add_i_vlan_tagged('2', $if_map{'1.1'})
or die "Couldn't add port to egress list. ",$bridge->error(1);
=item $bridge->set_remove_i_vlan_tagged(vlan, ifIndex)
Removes the port from the egress list of the VLAN, must be supplied with the
numeric VLAN ID and port ifIndex.
Example:
my %if_map = reverse %{$bridge->interfaces()};
$bridge->set_remove_i_vlan_tagged('2', $if_map{'1.1'})
or die "Couldn't add port to egress list. ",$bridge->error(1);
=cut

View File

@@ -31,7 +31,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CDP;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -59,7 +59,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
%FUNCS = (
'c_index' => 'cdpCacheIfIndex',
'c_proto' => 'cdpCacheAddressType',
'c_ip' => 'cdpCacheAddress',
'c_addr' => 'cdpCacheAddress',
'c_ver' => 'cdpCacheVersion',
'c_id' => 'cdpCacheDeviceId',
'c_port' => 'cdpCacheDevicePort',
@@ -67,7 +67,8 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'c_capabilities' => 'cdpCacheCapabilities',
'c_domain' => 'cdpCacheVTPMgmtDomain',
'c_vlan' => 'cdpCacheNativeVLAN',
'c_duplex' => 'cdpCacheDuplex'
'c_duplex' => 'cdpCacheDuplex',
'c_power' => 'cdpCachePowerConsumption',
);
%MUNGE = (
@@ -77,7 +78,9 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'c_port' => \&munge_null,
'c_id' => \&munge_null,
'c_ver' => \&munge_null,
'c_ip' => \&SNMP::Info::munge_ip
'c_ip' => \&SNMP::Info::munge_ip,
'c_power' => \&munge_power,
);
# munge_null() - removes nulls (\0)
@@ -94,9 +97,15 @@ sub munge_caps {
my $bits = substr(unpack("B*",$caps),-7);
return $bits;
}
sub munge_power {
my $power = shift;
my $decimal = substr($power, -3);
$power =~ s/$decimal$/\.$decimal/;
return $power;
}
sub hasCDP {
my $cdp = shift;
@@ -140,12 +149,32 @@ sub c_if {
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 - Perl5 Interface to Cisco Discovery Protocol (CDP) using SNMP
SNMP::Info::CDP - SNMP Interface to Cisco Discovery Protocol (CDP) using SNMP
=head1 AUTHOR
@@ -347,7 +376,14 @@ See c_if() entry.
=item $cdp->c_ip()
Returns remote IP address
If $cdp->c_proto() is supported, returns remote IPV4 address only. Otherwise
it will return all addresses.
(B<cdpCacheAddress>)
=item $cdp->c_addr()
Returns remote address
(B<cdpCacheAddress>)

446
Info/CiscoConfig.pm Normal file
View File

@@ -0,0 +1,446 @@
# SNMP::Info::CiscoConfig
# Justin Hunter, Eric Miller
# $Id$
#
# 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;
$VERSION = '1.07';
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/;
%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 undef;
}
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 undef;
}
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 undef;
}
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 undef;
}
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 undef;
}
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 undef;
}
}
print "Using old method\n" if $ciscoconfig->debug();
unless ( $ciscoconfig->set_old_write_net( $tftpfile, $tftphost ) ) {
$ciscoconfig->error_throw("Save operation failed");
return undef;
}
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 undef;
}
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 undef;
}
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 undef;
}
}
print "Using old method\n" if $ciscoconfig->debug();
unless ( $ciscoconfig->set_old_write_mem( 1 ) ) {
$ciscoconfig->error_throw("Save operation failed");
return undef;
}
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 C<CISCO-CONFIG-COPY-MIB>, C<CISCO-FLASH-MIB>, and C<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 CISCO-CONFIG-COPY-MIB
=item CISCO-FLASH-MIB
=item OLD-CISCO-SYS-MIB
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $ciscoconfig->old_write_mem()
(B<writeMem>)
=item $ciscoconfig->old_write_net()
(B<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 (B<ccCopyTable>)
=over
=item $ciscoconfig->config_protocol()
(B<ccCopyProtocol>)
=item $ciscoconfig->config_source_type()
(B<ccCopySourceFileType>)
=item $ciscoconfig->config_dest_type()
(B<ccCopyDestFileType>)
=item $ciscoconfig->config_server_addr()
(B<ccCopyServerAddress>)
=item $ciscoconfig->config_filename()
(B<ccCopyFileName>)
=item $ciscoconfig->config_username()
(B<ccCopyUserName>)
=item $ciscoconfig->config_password()
(B<ccCopyUserPassword>)
=item $ciscoconfig->config_notify_complete()
(B<ccCopyNotificationOnCompletion>)
=item $ciscoconfig->config_copy_state()
(B<ccCopyState>)
=item $ciscoconfig->config_copy_start_time()
(B<ccCopyTimeStarted>)
=item $ciscoconfig->config_copy_complete_time()
(B<ccCopyTimeCompleted>)
=item $ciscoconfig->config_fail_cause()
(B<ccCopyFailCause>)
=item $ciscoconfig->config_row_status()
(B<ccCopyEntryRowStatus>)
=back
=head2 Flash Copy Table (B<ciscoFlashCopyTable>)
Table of Flash copy operation entries.
=over
=item $ciscoconfig->flash_copy_cmd()
(B<ciscoFlashCopyCommand>)
=item $ciscoconfig->flash_copy_protocol()
(B<ciscoFlashCopyProtocol>)
=item $ciscoconfig->flash_copy_address()
(B<ciscoFlashCopyServerAddress>)
=item $ciscoconfig->flash_copy_source()
(B<ciscoFlashCopySourceName>)
=item $ciscoconfig->flash_copy_dest()
(B<ciscoFlashCopyDestinationName>)
=item $ciscoconfig->flash_copy_row_status()
(B<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 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 startup configuration. Equivalent to
the CLI command "copy running-config startup-config" or "write mem".
This method attempts to use newer "copy running-config startup-config"
procedure first and then the older "write mem" procedure if that fails. The
newer procedure is supported Cisco devices with the 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);
=cut

View File

@@ -3,27 +3,27 @@ package SNMP::Info::CiscoImage;
# Copyright (c) 2005 Matt Tuttle
#
# 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
# * 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
# 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;
# (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
# 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.
use strict;
@@ -31,8 +31,8 @@ use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
$VERSION = '1.03';
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.07';
@SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoImage::EXPORT_OK = qw//;
@@ -56,7 +56,7 @@ __END__
=head1 NAME
SNMP::Info::CiscoImage - Perl5 Interface to image strings for Cisco Devices
SNMP::Info::CiscoImage - SNMP Interface to image strings for Cisco Devices
=head1 AUTHOR
@@ -64,7 +64,7 @@ Matt Tuttle (C<mtuttle@americanhebrewacademy.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
# Let SNMP::Info determine the correct subclass for you.
my $ci = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
@@ -72,22 +72,22 @@ Matt Tuttle (C<mtuttle@americanhebrewacademy.org>)
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
)
or die "Can't connect to DestHost.\n";
my $class = $ci->class();
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.
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.
None.
=head2 Required MIBs

328
Info/CiscoPortSecurity.pm Normal file
View File

@@ -0,0 +1,328 @@
# SNMP::Info::CiscoPortSecurity
# Eric Miller
#
# Copyright (c) 2006 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 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::CiscoPortSecurity;
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
@SNMP::Info::CiscoPortSecurity::ISA = qw/Exporter/;
@SNMP::Info::CiscoPortSecurity::EXPORT_OK = qw//;
%MIBS = (
'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB',
);
%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',
);
%MUNGE = (
'cps_i_mac' => \&SNMP::Info::munge_mac,
'cps_m_mac' => \&SNMP::Info::munge_mac,
'cps_i_v_mac' => \&SNMP::Info::munge_mac,
);
1;
__END__
=head1 NAME
SNMP::Info::CiscoPortSecurity - SNMP Interface to data from
CISCO-PORT-SECURITY-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,
# 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 = $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 C<CISCO-PORT-SECURITY-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 CISCO-PORT-SECURITY-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz or from
Netdisco-mib package at netdisco.org.
=head1 GLOBALS
These are methods that return scalar values from SNMP
=over
=back
=head2 CISCO-PORT-SECURITY-MIB globals
=over
=item $stack->cps_clear()
(B<cpsGlobalClearSecureMacAddresses>)
=item $stack->cps_notify()
(B<cpsGlobalSNMPNotifControl>)
=item $stack->cps_rate()
(B<cpsGlobalSNMPNotifRate>)
=item $stack->cps_enable()
(B<cpsGlobalPortSecurityEnable>)
=item $stack->cps_mac_count()
(B<cpsGlobalTotalSecureAddress>)
=item $stack->cps_mac_max()
(B<cpsGlobalMaxSecureAddress>)
=back
=head1 TABLE METHODS
=head2 CISCO-PORT-SECURITY-MIB - Interface Config Table
=over
=item $stack->cps_i_limit_val()
(B<cpsIfInvalidSrcRateLimitValue>)
=item $stack->cps_i_limit()
(B<cpsIfInvalidSrcRateLimitEnable>)
=item $stack->cps_i_sticky()
(B<cpsIfStickyEnable>)
=item $stack->cps_i_clear_type()
(B<cpsIfClearSecureMacAddresses>)
=item $stack->cps_i_shutdown()
(B<cpsIfShutdownTimeout>)
=item $stack->cps_i_flood()
(B<cpsIfUnicastFloodingEnable>)
=item $stack->cps_i_clear()
(B<cpsIfClearSecureAddresses>)
=item $stack->cps_i_mac()
(B<cpsIfSecureLastMacAddress>)
=item $stack->cps_i_count()
(B<cpsIfViolationCount>)
=item $stack->cps_i_action()
(B<cpsIfViolationAction>)
=item $stack->cps_i_mac_static()
(B<cpsIfStaticMacAddrAgingEnable>)
=item $stack->cps_i_mac_type()
(B<cpsIfSecureMacAddrAgingType>)
=item $stack->cps_i_mac_age()
(B<cpsIfSecureMacAddrAgingTime>)
=item $stack->cps_i_mac_count()
(B<cpsIfCurrentSecureMacAddrCount>)
=item $stack->cps_i_mac_max()
(B<cpsIfMaxSecureMacAddr>)
=item $stack->cps_i_status()
(B<cpsIfPortSecurityStatus>)
=item $stack->cps_i_enable()
(B<cpsIfPortSecurityEnable>)
=back
=head2 CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
=over
=item $stack->cps_i_v_mac_count()
(B<cpsIfVlanCurSecureMacAddrCount>)
=item $stack->cps_i_v_mac_max()
(B<cpsIfVlanMaxSecureMacAddr>)
=item $stack->cps_i_v()
(B<cpsIfVlanIndex>)
=back
=head2 CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
=over
=item $stack->cps_i_v_mac_status()
(B<cpsIfVlanSecureMacAddrRowStatus>)
=item $stack->cps_i_v_mac_age()
(B<cpsIfVlanSecureMacAddrRemainAge>)
=item $stack->cps_i_v_mac_type()
(B<cpsIfVlanSecureMacAddrType>)
=item $stack->cps_i_v_vlan()
(B<cpsIfVlanSecureVlanIndex>)
=item $stack->cps_i_v_mac()
(B<cpsIfVlanSecureMacAddress>)
=back
=head2 CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
=over
=item $stack->cps_m_status()
(B<cpsSecureMacAddrRowStatus>)
=item $stack->cps_m_age()
(B<cpsSecureMacAddrRemainingAge>)
=item $stack->cps_m_type()
(B<cpsSecureMacAddrType>)
=item $stack->cps_m_mac()
(B<cpsSecureMacAddress>)
=back
=cut

147
Info/CiscoPower.pm Normal file
View File

@@ -0,0 +1,147 @@
# SNMP::Info::CiscoPower
# Bill Fenner
#
# Copyright (c) 2007 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::CiscoPower;
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::CiscoPower::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoPower::EXPORT_OK = qw//;
%MIBS = ('CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex');
%GLOBALS = (
);
%FUNCS = (
'cpeth_ent_phy' => 'cpeExtPsePortEntPhyIndex',
);
%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;
}
1;
=head1 NAME
SNMP::Info::CiscoPower - SNMP Interface to data stored in 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,
# 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 = $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 pethPsePortTable to ifIndex values. This class
provides that helper, using 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 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 pethPsePortTable to ifIndex by way of the ENTITY-MIB.
=back
=cut

View File

@@ -1,6 +1,5 @@
# SNMP::Info::CiscoQOS
# Alexander Hartmaier <alexander.hartmaier@t-systems.at>
# $Id$
#
# Copyright (c) 2005 Alexander Hartmaier
#
@@ -30,7 +29,9 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoQOS;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
@@ -39,7 +40,7 @@ use SNMP::Info;
@SNMP::Info::CiscoQOS::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoQOS::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
%MIBS = (
'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex',
@@ -49,18 +50,24 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
);
%FUNCS = (
# CISCO-CLASS-BASED-QOS-MIB
# CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable
'qos_i_index' => 'cbQosIfIndex',
'qos_i_type' => 'cbQosIfType',
'qos_pol_direction' => 'cbQosPolicyDirection',
'qos_obj_index' => 'cbQosConfigIndex',
# 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 = (
@@ -71,11 +78,11 @@ __END__
=head1 NAME
SNMP::Info::CiscoQOS - Perl5 Interface to Cisco's Quality of Service MIBs
SNMP::Info::CiscoQOS - SNMP Interface to Cisco's Quality of Service MIBs
=head1 AUTHOR
Alexander Hartmaier (C<alexander.hartmaier@t-systems.at>)
Alexander Hartmaier
=head1 SYNOPSIS
@@ -90,7 +97,7 @@ Alexander Hartmaier (C<alexander.hartmaier@t-systems.at>)
)
or die "Can't connect to DestHost.\n";
my $class = $qos->class();
my $class = $qos->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -118,17 +125,16 @@ MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=over
none
=item none
=back
=head1 TABLE METHODS
=head2 ServicePolicy Table
=head2 ServicePolicy Table (B<cbQosServicePolicyTable>)
This table is from CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable
This table describes the interfaces/media types and the policymap that are attached to it.
This table describes the interfaces/media types and the policymap that are
attached to it.
=over
@@ -140,12 +146,72 @@ This table describes the interfaces/media types and the policymap that are attac
(B<cbQosIfType>)
=head2 ClassMap configuration Table
=item $qos->qos_pol_direction()
This table is from CISCO-CLASS-BASED-QOS-MIB::cbQosCMCfgTable
=over
(B<cbQosPolicyDirection>)
=back
=head2 ClassMap Objects Table (B<cbQosObjectsTable>)
=over
=item $qos->qos_obj_index()
(B<cbQosConfigIndex>)
=item $qos->qos_obj_type()
(B<cbQosObjectsType>)
=item $qos->qos_obj_parent()
(B<cbQosParentObjectsIndex>)
=back
=head2 ClassMap Configuration Table (B<cbQosCMCfgTable>)
=over
=item $qos->qos_cm_name()
(B<cbQosCMName>)
=item $qos->qos_cm_desc()
(B<cbQosCMDesc>)
=item $qos->qos_cm_info()
(B<cbQosCMInfo>)
=back
=head2 ClassMap Stats Table (B<cbQosCMStatsTable>)
=over
=item $qos->qos_octet_pre()
(B<cbQosCMPrePolicyByte>)
=item $qos->qos_octet_post()
(B<cbQosCMPostPolicyByte>)
=back
=head2 Queueing Configuration Table (B<cbQosQueueingCfgTable>)
=over
=item $qos->qos_queueingcfg_bw()
(B<cbQosQueueingCfgBandwidth>)
=item $qos->qos_queueingcfg_bw_units()
(B<cbQosQueueingCfgBandwidthUnits>)
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoRTT;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
@@ -40,7 +40,7 @@ use SNMP::Info;
@SNMP::Info::CiscoRTT::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoRTT::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
%MIBS = (
'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner',
@@ -63,11 +63,11 @@ __END__
=head1 NAME
SNMP::Info::CiscoRTT - Perl5 Interface to Cisco's Round Trip Time MIBs
SNMP::Info::CiscoRTT - SNMP Interface to Cisco's Round Trip Time MIBs
=head1 AUTHOR
Alexander Hartmaier (C<alexander.hartmaier@t-systems.at>)
Alexander Hartmaier
=head1 SYNOPSIS
@@ -82,7 +82,7 @@ Alexander Hartmaier (C<alexander.hartmaier@t-systems.at>)
)
or die "Can't connect to DestHost.\n";
my $class = $rtt->class();
my $class = $rtt->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -110,7 +110,7 @@ MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=over
none
None
=back

View File

@@ -1,7 +1,7 @@
# SNMP::Info::CiscoStack
# Max Baker
#
# Copyright (c)2003,2004 Max Baker
# Copyright (c)2003,2004,2006 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoStack;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -42,7 +42,6 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/;
%MIBS = (
'CISCO-STACK-MIB' => 'ciscoStackMIB',
'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB',
);
%GLOBALS = (
@@ -58,17 +57,9 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/;
'ps2_status' => 'chassisPs2Status',
'slots' => 'chassisNumSlots',
'fan' => 'chassisFanStatus',
# 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 = (
'i_type2' => 'ifType',
# CISCO-STACK-MIB::moduleEntry
# These are blades in a catalyst device
'm_type' => 'moduleType',
@@ -101,47 +92,11 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/;
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
# 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',
);
%MUNGE = (
'm_ports_status' => \&munge_port_status,
'p_duplex_admin' => \&SNMP::Info::munge_bits,
'cps_i_mac' => \&SNMP::Info::munge_mac,
'cps_m_mac' => \&SNMP::Info::munge_mac,
'cps_i_v_mac' => \&SNMP::Info::munge_mac,
);
%PORTSTAT = (1 => 'other',
@@ -167,81 +122,104 @@ sub serial {
return undef;
}
sub i_type {
my $stack = shift;
my $p_port = $stack->p_port();
my $p_type = $stack->p_type();
# Get more generic port types from IF-MIB
my $i_type = $stack->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;
}
# p_* functions are indexed to physical port. let's index these
# to snmp iid
sub i_name {
my $stack = shift;
my $p_port = $stack->p_port();
my $p_name = $stack->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;
}
# 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 $i_duplex = $stack->SUPER::i_duplex();
my $p_port = $stack->p_port();
my $p_duplex = $stack->p_duplex();
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};
$i_duplex->{$iid} = $p_duplex->{$port};
next unless defined $iid;
next if (defined $partial and $iid !~ /^$partial$/);
# Test for gigabit
if ($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_admin = $stack->p_duplex_admin();
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_admin) {
my $i_duplex_admin = {};
foreach my $port (keys %$p_duplex) {
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;
next if (defined $partial and $iid !~ /^$partial$/);
# Test for gigabit
if ($p_duplex_cap->{$port} == 0) {
$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;
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 {
@@ -250,7 +228,7 @@ sub set_i_speed_admin {
my $stack = shift;
my ($speed, $iid) = @_;
my $p_port = $stack->p_port();
my $p_port = $stack->p_port() || {};
my %reverse_p_port = reverse %$p_port;
$speed = lc($speed);
@@ -259,7 +237,7 @@ sub set_i_speed_admin {
$iid = $reverse_p_port{$iid};
return $stack->set_p_speed($speeds{$speed}, $iid);
return $stack->set_p_speed_admin($speeds{$speed}, $iid);
}
sub set_i_duplex_admin {
@@ -268,7 +246,15 @@ sub set_i_duplex_admin {
my $stack = shift;
my ($duplex, $iid) = @_;
my $p_port = $stack->p_port();
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);
@@ -280,30 +266,14 @@ sub set_i_duplex_admin {
return $stack->set_p_duplex($duplexes{$duplex}, $iid);
}
# $stack->interfaces() - Maps the ifIndex table to a physical port
sub interfaces {
my $self = shift;
my $i_index = $self->i_index();
my $portnames = $self->p_port();
my %portmap = reverse %$portnames;
my %interfaces = ();
foreach my $iid (keys %$i_index) {
my $if = $i_index->{$iid};
my $port = $portmap{$iid};
$interfaces{$iid} = $port || $if;
}
return \%interfaces;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoStack - Intefaces to data from CISCO-STACK-MIB and CISCO-PORT-SECURITY-MIB
SNMP::Info::CiscoStack - SNMP Inteface to data from CISCO-STACK-MIB and
CISCO-PORT-SECURITY-MIB
=head1 AUTHOR
@@ -322,7 +292,7 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $ciscostats->class();
my $class = $ciscostats->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -343,8 +313,6 @@ none.
=item CISCO-STACK-MIB
=item CISCO-PORT-SECURITY-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz or from
@@ -396,48 +364,12 @@ Netdisco-mib package at netdisco.org.
=back
=head2 CISCO-PORT-SECURITY-MIB globals
See CISCO-PORT-SECURITY-MIB for details.
=over
=item $stack->cps_clear()
B<cpsGlobalClearSecureMacAddresses>
=item $stack->cps_notify()
B<cpsGlobalSNMPNotifControl>
=item $stack->cps_rate()
B<cpsGlobalSNMPNotifRate>
=item $stack->cps_enable()
B<cpsGlobalPortSecurityEnable>
=item $stack->cps_mac_count()
B<cpsGlobalTotalSecureAddress>
=item $stack->cps_mac_max()
B<cpsGlobalMaxSecureAddress>
=back
=head1 TABLE METHODS
=head2 Interface Tables
=over
=item $stack->interfaces()
Crosses p_port() with i_index() to get physical names.
=item $stack->i_physical()
Returns a map to IID for ports that are physical ports, not vlans, etc.
@@ -448,19 +380,23 @@ Crosses p_port() with p_type() and returns the results.
Overrides with ifType if p_type() isn't available.
=item $stack->i_name()
Crosses p_name with p_port and returns results.
=item $stack->i_duplex()
Crosses p_duplex with p_port and returns results.
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 (B<portDuplex>) is auto
then the operational duplex can not be determined. Otherwise it uses the
reported port duplex (B<portDuplex>).
=item $stack->i_duplex_admin()
Crosses p_duplex_admin with p_port.
Returns reference to hash of iid to administrative duplex setting.
Munges bit_string returned from p_duplex_admin to get duplex settings.
First checks for fixed gigabit ports which are always full duplex. Next checks
the port administrative speed (B<portAdminSpeed>) which if set to
autonegotiate then the duplex will also autonegotiate, otherwise it uses the
reported port duplex (B<portDuplex>).
=item $stack->set_i_speed_admin(speed, ifIndex)
@@ -670,147 +606,4 @@ B<portAdminTxFlowControl>
=back
=head2 CISCO-PORT-SECURITY-MIB - Interface Config Table
See CISCO-PORT-SECURITY-MIB for details.
=over
=item $stack->cps_i_limit_val()
B<cpsIfInvalidSrcRateLimitValue>
=item $stack->cps_i_limit()
B<cpsIfInvalidSrcRateLimitEnable>
=item $stack->cps_i_sticky()
B<cpsIfStickyEnable>
=item $stack->cps_i_clear_type()
B<cpsIfClearSecureMacAddresses>
=item $stack->cps_i_shutdown()
B<cpsIfShutdownTimeout>
=item $stack->cps_i_flood()
B<cpsIfUnicastFloodingEnable>
=item $stack->cps_i_clear()
B<cpsIfClearSecureAddresses>
=item $stack->cps_i_mac()
B<cpsIfSecureLastMacAddress>
=item $stack->cps_i_count()
B<cpsIfViolationCount>
=item $stack->cps_i_action()
B<cpsIfViolationAction>
=item $stack->cps_i_mac_static()
B<cpsIfStaticMacAddrAgingEnable>
=item $stack->cps_i_mac_type()
B<cpsIfSecureMacAddrAgingType>
=item $stack->cps_i_mac_age()
B<cpsIfSecureMacAddrAgingTime>
=item $stack->cps_i_mac_count()
B<cpsIfCurrentSecureMacAddrCount>
=item $stack->cps_i_mac_max()
B<cpsIfMaxSecureMacAddr>
=item $stack->cps_i_status()
B<cpsIfPortSecurityStatus>
=item $stack->cps_i_enable()
B<cpsIfPortSecurityEnable>
=back
=head2 CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
=over
=item $stack->cps_i_v_mac_count()
B<cpsIfVlanCurSecureMacAddrCount>
=item $stack->cps_i_v_mac_max()
B<cpsIfVlanMaxSecureMacAddr>
=item $stack->cps_i_v()
B<cpsIfVlanIndex>
=back
=head2 CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
=over
=item $stack->cps_i_v_mac_status()
B<cpsIfVlanSecureMacAddrRowStatus>
=item $stack->cps_i_v_mac_age()
B<cpsIfVlanSecureMacAddrRemainAge>
=item $stack->cps_i_v_mac_type()
B<cpsIfVlanSecureMacAddrType>
=item $stack->cps_i_v_vlan()
B<cpsIfVlanSecureVlanIndex>
=item $stack->cps_i_v_mac()
B<cpsIfVlanSecureMacAddress>
=back
=head2 CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
=over
=item $stack->cps_m_status()
B<cpsSecureMacAddrRowStatus>
=item $stack->cps_m_age()
B<cpsSecureMacAddrRemainingAge>
=item $stack->cps_m_type()
B<cpsSecureMacAddrType>
=item $stack->cps_m_mac()
B<cpsSecureMacAddress>
=back
=cut

View File

@@ -31,7 +31,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoStats;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -44,13 +44,15 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::CiscoStats::EXPORT_OK = qw//;
%MIBS = (
'SNMPv2-MIB' => 'sysDescr',
'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec',
'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed',
'OLD-CISCO-SYSTEM-MIB' => 'writeMem',
'CISCO-PRODUCTS-MIB' => 'sysName',
'CISCO-STACK-MIB' => 'wsc1900sysID', # some older catalysts live here
'SNMPv2-MIB' => 'sysDescr',
'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec',
'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed',
'OLD-CISCO-SYSTEM-MIB' => 'writeMem',
'CISCO-PRODUCTS-MIB' => 'sysName',
# some older catalysts live here
'CISCO-STACK-MIB' => 'wsc1900sysID',
'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis',
'CISCO-FLASH-MIB' => 'ciscoFlashDeviceSize',
);
%GLOBALS = (
@@ -65,14 +67,16 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'cat_cpu' => 'cpmCPUTotal5sec.9',
'cat_cpu_1min' => 'cpmCPUTotal1min.9',
'cat_cpu_5min' => 'cpmCPUTotal5min.9',
# CISCO-MEMORY-POOL-MIB
'mem_free' => 'ciscoMemoryPoolFree.1',
'mem_used' => 'ciscoMemoryPoolUsed.1',
# OLD-CISCO-SYSTEM-MIB
'write_mem' => 'writeMem',
);
%FUNCS = (
# CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolTable
'cisco_mem_free' => 'ciscoMemoryPoolFree',
'cisco_mem_used' => 'ciscoMemoryPoolUsed',
# CISCO-FLASH-MIB::ciscoFlashDeviceTable
'cisco_flash_size' => 'ciscoFlashDeviceSize',
);
%MUNGE = (
@@ -129,12 +133,62 @@ sub 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_free = $self->mem_free();
my $mem_used = $self->mem_used();
return undef unless defined $mem_free and defined $mem_used;
return $mem_free + $mem_used;
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;
@@ -173,7 +227,7 @@ Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
None.
=head2 Required MIBs
@@ -193,6 +247,8 @@ none.
=item CISCO-ENTITY-VENDORTYPE-OID-MIB
=item CISCO-FLASH-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
@@ -227,57 +283,98 @@ Trys to parse device operating system version from description()
=item $ciscostats->ios_cpu()
Current CPU usage in percents of device.
Current CPU usage in percent.
B<1.3.6.1.4.1.9.2.1.56.0> =
B<OLD-CISCO-CPU-MIB:avgBusyPer>
=item $ciscostats->ios_cpu_1min()
Average CPU Usage in percents of device over last minute.
Average CPU Usage in percent over the last minute.
B<1.3.6.1.4.1.9.2.1.57.0>
=item $ciscostats->ios_cpu_5min()
Average CPU Usage in percents of device over last 5 minutes.
Average CPU Usage in percent over the last 5 minutes.
B<1.3.6.1.4.1.9.2.1.58.0>
=item $ciscostats->cat_cpu()
Current CPU usage in percents of device.
Current CPU usage in percent.
B<CISCO-PROCESS-MIB::cpmCPUTotal5sec.9>
=item $ciscostats->cat_cpu_1min()
Average CPU Usage in percents of device over last minute.
Average CPU Usage in percent over the last minute.
B<CISCO-PROCESS-MIB::cpmCPUTotal1min.9>
=item $ciscostats->cat_cpu_5min()
Average CPU Usage in percents of device over last 5 minutes.
Average CPU Usage in percent over the last 5 minutes.
B<CISCO-PROCESS-MIB::cpmCPUTotal5min.9>
=item $ciscostats->mem_free()
Main DRAM free in device. In bytes.
Main DRAM free of the device in bytes.
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree.1>
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree>
=item $ciscostats->mem_used()
Main DRAM used in device. In bytes.
Main DRAM used of the device in bytes.
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed.1>
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed>
=item $ciscostats->mem_total()
Main DRAM of the device in bytes.
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree> + B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed>
=item $ciscostats->flashmem_total()
Flash memory of the device in bytes.
B<CISCO-FLASH-MIB::ciscoFlashDeviceSize>
=back
=head1 TABLE METHODS
None.
=head2 Cisco Memory Pool Table (B<ciscoMemoryPoolTable>)
=over
=item $ciscostats->cisco_mem_free()
The number of bytes from the memory pool that are currently unused on the
managed device.
(B<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.
(B<ciscoMemoryPoolUsed>)
=back
=head2 Cisco Flash Device Table (B<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.
(B<ciscoFlashDeviceSize>)
=cut

View File

@@ -30,15 +30,15 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoVTP;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoVTP::EXPORT_OK = qw//;
@@ -54,10 +54,11 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'vtp_notify' => 'vtpNotificationsEnabled',
'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled',
'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled',
'vtp_trunk_set_serial' => 'vlanTrunkPortSetSerialNo',
);
%FUNCS = (
# Management Domain Table
# CISCO-VTP-MIB::managementDomainTable
'vtp_d_index' => 'managementDomainIndex',
'vtp_d_name' => 'managementDomainName',
'vtp_d_mode' => 'managementDomainLocalMode',
@@ -69,8 +70,7 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'vtp_d_tftp_path' => 'managementDomainTftpPathname',
'vtp_d_pruning' => 'managementDomainPruningState',
'vtp_d_ver' => 'managementDomainVersionInUse',
# VLAN Table
'v_index' => 'vtpVlanIndex',
# CISCO-VTP-MIB::vtpVlanTable
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
@@ -88,9 +88,7 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'v_crf' => 'vtpVlanIsCRFBackup',
'v_type_ext' => 'vtpVlanTypeExt',
'v_if' => 'vtpVlanIfIndex',
# CISCO-VLAN-MEMBERSHIP-MIB
# VmMembershipTable
# CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable
'i_vlan_type' => 'vmVlanType',
'i_vlan2' => 'vmVlan',
'i_vlan_stat' => 'vmPortStatus',
@@ -98,12 +96,24 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'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',
# vlanTrunkPortTable
# 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
@@ -113,49 +123,305 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
%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;
# Check for CISCO-VLAN-MIB
my $i_vlan = $vtp->i_vlan2();
return $i_vlan if defined $i_vlan;
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) || {};
# Check in CISCO-VLAN-IFTABLE-RELATION-MIB
my $v_cvi_if = $vtp->v_cvi_if();
return undef unless defined $v_cvi_if;
# Translate vlan.physical_interface -> iid
# to iid -> vlan
$i_vlan = {};
foreach my $i (keys %$v_cvi_if){
my ($vlan,$phys) = split(/\./,$i);
my $iid = $v_cvi_if->{$i};
$i_vlan->{$iid}=$vlan;
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;
}
return $i_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 $voice_vlans = $vtp->i_voice_vlan($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 special voice VLANs (0 and 4096)
foreach my $port (keys %$voice_vlans) {
my $vlan = $voice_vlans->{$port};
next unless defined $vlan;
# Going to assume we would catch regular VLANs with the other methods
next unless ($vlan == 0 or $vlan == 4096);
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;
foreach my $list ("$ports_vlans->{$port}", "$ports_vlans_2k->{$port}",
"$ports_vlans_3k->{$port}", "$ports_vlans_4k->{$port}") {
my $vlanlist = [split(//, unpack("B*", $list))];
my $offset = 1024 * $k;
foreach my $vlan (keys %oper_vlans) {
push(@{$i_vlan_membership->{$port}}, $vlan) if (@$vlanlist[$vlan]-$offset);
}
$k++;
}
}
}
return $i_vlan_membership;
}
sub set_i_pvid {
my $vtp = shift;
my ($vlan_id, $ifindex) = @_;
return undef 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 undef;
}
return $rv;
}
$vtp->error_throw("Can't find ifIndex: $ifindex - Is it a trunk port?");
return undef;
}
sub set_i_vlan {
my $vtp = shift;
my ($vlan_id, $ifindex) = @_;
# Check for CISCO-VLAN-MIB
my $i_vlan = $vtp->i_vlan2();
return undef unless ( $vtp->validate_vlan_param ($vlan_id, $ifindex) );
my $i_vlan = $vtp->i_vlan2($ifindex);
if (defined $i_vlan) {
return $vtp->set_i_vlan2(@_);
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 undef;
}
return $rv;
}
# only support the first case for now.
$vtp->error_throw("Can't find ifIndex: $ifindex - Is it an access port?");
return undef;
}
sub set_add_i_vlan_tagged {
my $vtp = shift;
my ($vlan_id, $ifindex) = @_;
return undef 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 undef;
}
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 undef;
}
#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 undef;
}
return 1;
}
sub set_remove_i_vlan_tagged {
my $vtp = shift;
my ($vlan_id, $ifindex) = @_;
return undef 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 undef;
}
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 undef;
}
#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 undef;
}
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 undef;
}
# Check that ifIndex exists on device
my $index = $vtp->interfaces($ifindex);
unless ( exists $index->{$ifindex} ) {
$vtp->error_throw("ifIndex $ifindex does not exist");
return undef;
}
#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 undef;
}
return 1;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoVTP - Perl5 Interface to Cisco's VLAN Management MIBs
SNMP::Info::CiscoVTP - SNMP Interface to Cisco's VLAN Management MIBs
=head1 AUTHOR
@@ -174,19 +440,19 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $vtp->class();
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 memebership.
information about a Cisco device's VLAN and VTP Domain memebership.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
None.
=head2 Required MIBs
@@ -208,116 +474,140 @@ MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=item $vtp->vtp_version()
C<vtpVersion>
(B<vtpVersion>)
=item $vtp->vtp_maxstore()
C<vtpMaxVlanStorage>
(B<vtpMaxVlanStorage>)
=item $vtp->vtp_notify()
C<vtpNotificationsEnabled>
(B<vtpNotificationsEnabled>)
=item $vtp->vtp_notify_create()
C<vtpVlanCreatedNotifEnabled>
(B<vtpVlanCreatedNotifEnabled>)
=item $vtp->vtp_notify_delete()
C<vtpVlanDeletedNotifEnabled>
(B<vtpVlanDeletedNotifEnabled>)
=item $vtp->vtp_trunk_set_serial()
(B<vlanTrunkPortSetSerialNo>)
=back
=head1 TABLE METHODS
You device will only implement a subset of these methods.
Your device will only implement a subset of these methods.
=head2 VLAN Table
=over
=item $vtp->i_vlan()
Returns a mapping between 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 = 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 (B<CISCO-VTP-MIB::vtpVlanTable>)
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
for a good treaty of how to connect to the VLANs
This table is from CISCO-VTP-MIB::vtpVlanTable
=over
=item $vtp->v_index()
C<vtpVlanIndex>
(B<vtpVlanIndex>)
=item $vtp->v_state()
C<vtpVlanState>
(B<vtpVlanState>)
=item $vtp->v_type()
C<vtpVlanType>
(B<vtpVlanType>)
=item $vtp->v_name()
C<vtpVlanName>
(B<vtpVlanName>)
=item $vtp->v_mtu()
C<vtpVlanMtu>
(B<vtpVlanMtu>)
=item $vtp->v_said()
C<vtpVlanDot10Said>
(B<vtpVlanDot10Said>)
=item $vtp->v_ring()
C<vtpVlanRingNumber>
(B<vtpVlanRingNumber>)
=item $vtp->v_bridge()
C<vtpVlanBridgeNumber>
(B<vtpVlanBridgeNumber>)
=item $vtp->v_stp()
C<vtpVlanStpType>
(B<vtpVlanStpType>)
=item $vtp->v_parent()
C<vtpVlanParentVlan>
(B<vtpVlanParentVlan>)
=item $vtp->v_trans1()
C<vtpVlanTranslationalVlan1>
(B<vtpVlanTranslationalVlan1>)
=item $vtp->v_trans2()
C<vtpVlanTranslationalVlan2>
(B<vtpVlanTranslationalVlan2>)
=item $vtp->v_btype()
C<vtpVlanBridgeType>
(B<vtpVlanBridgeType>)
=item $vtp->v_hop_are()
C<vtpVlanAreHopCount>
(B<vtpVlanAreHopCount>)
=item $vtp->v_hop_ste()
C<vtpVlanSteHopCount>
(B<vtpVlanSteHopCount>)
=item $vtp->v_crf()
C<vtpVlanIsCRFBackup>
(B<vtpVlanIsCRFBackup>)
=item $vtp->v_type_ext()
C<vtpVlanTypeExt>
(B<vtpVlanTypeExt>)
=item $vtp->v_if()
C<vtpVlanIfIndex>
(B<vtpVlanIfIndex>)
=back
=head2 VLAN Interface Table
This table is from CISCO-VLAN-MEMBERSHIP-MIB::VmMembershipTable
=head2 VLAN Membership Table (B<CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable>)
=over
@@ -325,96 +615,211 @@ This table is from CISCO-VLAN-MEMBERSHIP-MIB::VmMembershipTable
Static, Dynamic, or multiVlan.
C<vmVlanType>
(B<vmVlanType>)
=item $vtp->i_vlan()
=item $vtp->i_vlan2()
The VLAN that a port is assigned to.
The VLAN that an access port is assigned to.
0 for no VLAN assigned.
C<vmVlan>
(B<vmVlan>)
=item $vtp->i_vlan_stat()
Inactive, active, shutdown.
C<vmPortStatus>
(B<vmPortStatus>)
=item $vtp->i_vlan_1()
Each bit represents a VLAN. This is 0 through 1023
C<vmVlans>
(B<vmVlans>)
=item $vtp->i_vlan_2()
Each bit represents a VLAN. This is 1024 through 2047
C<vmVlans2k>
(B<vmVlans2k>)
=item $vtp->i_vlan_3()
Each bit represents a VLAN. This is 2048 through 3071
C<vmVlans3k>
(B<vmVlans3k>)
=item $vtp->i_vlan_4()
Each bit represents a VLAN. This is 3072 through 4095
C<vmVlans4k>
(B<vmVlans4k>)
=back
=head2 Managment Domain Table
=head2 VLAN Membership Voice VLAN Table (B<CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable>)
=over
=item $vtp->i_voice_vlan()
(B<vmVoiceVlanId>)
=back
=head2 Managment Domain Table (B<CISCO-VTP-MIB::managementDomainTable>)
=over
=item $vtp->vtp_d_index()
C<managementDomainIndex>
(B<managementDomainIndex>)
=item $vtp->vtp_d_name()
C<managementDomainName>
(B<managementDomainName>)
=item $vtp->vtp_d_mode()
C<managementDomainLocalMode>
(B<managementDomainLocalMode>)
=item $vtp->vtp_d_rev()
C<managementDomainConfigRevNumber>
(B<managementDomainConfigRevNumber>)
=item $vtp->vtp_d_updater()
C<managementDomainLastUpdater>
(B<managementDomainLastUpdater>)
=item $vtp->vtp_d_last()
C<managementDomainLastChange>
(B<managementDomainLastChange>)
=item $vtp->vtp_d_status()
C<managementDomainRowStatus>
(B<managementDomainRowStatus>)
=item $vtp->vtp_d_tftp()
C<managementDomainTftpServer>
(B<managementDomainTftpServer>)
=item $vtp->vtp_d_tftp_path()
C<managementDomainTftpPathname>
(B<managementDomainTftpPathname>)
=item $vtp->vtp_d_pruning()
C<managementDomainPruningState>
(B<managementDomainPruningState>)
=item $vtp->vtp_d_ver()
C<managementDomainVersionInUse>
(B<managementDomainVersionInUse>)
=back
=head2 VLAN Trunk Port Table (B<CISCO-VTP-MIB::vlanTrunkPortTable>)
=over
=item $vtp->vtp_trunk_mgmt_dom()
(B<vlanTrunkPortManagementDomain>)
=item $vtp->vtp_trunk_encaps_t()
(B<vlanTrunkPortEncapsulationType>)
=item $vtp->vtp_trunk_vlans()
(B<vlanTrunkPortVlansEnabled>)
=item $vtp->vtp_trunk_vlans_2k()
(B<vlanTrunkPortVlansEnabled2k>)
=item $vtp->vtp_trunk_vlans_3k()
(B<vlanTrunkPortVlansEnabled3k>)
=item $vtp->vtp_trunk_vlans_4k()
(B<vlanTrunkPortVlansEnabled4k>)
=item $vtp->vtp_trunk_native()
(B<vlanTrunkPortNativeVlan>)
=item $vtp->i_pvid()
(B<vlanTrunkPortNativeVlan>)
=item $vtp->vtp_trunk_rstat()
(B<vlanTrunkPortRowStatus>)
=item $vtp->vtp_trunk_dyn()
(B<vlanTrunkPortDynamicState>)
=item $vtp->vtp_trunk_dyn_stat()
(B<vlanTrunkPortDynamicStatus>)
=item $vtp->vtp_trunk_vtp()
(B<vlanTrunkPortVtpEnabled>)
=item $vtp->vtp_trunk_encaps()
(B<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 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 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 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 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);
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Entity;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -48,7 +48,6 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
);
%FUNCS = (
'e_index' => 'entPhysicalIndex',
'e_alias' => 'entPhysicalAlias',
'e_class' => 'entPhysicalClass',
'e_descr' => 'entPhysicalDescr',
@@ -60,7 +59,7 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'e_model' => 'entPhysicalModelName',
'e_name' => 'entPhysicalName',
'e_parent' => 'entPhysicalContainedIn',
'e_pos' => 'entParentRelPos',
'e_pos' => 'entPhysicalParentRelPos',
'e_serial' => 'entPhysicalSerialNum',
'e_swver' => 'entPhysicalSoftwareRev',
'e_type' => 'entPhysicalVendorType',
@@ -68,11 +67,34 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
);
%MUNGE = (
'e_type' => \&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 undef 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 $e_map = $entity->e_map();
my $partial = shift;
my $e_map = $entity->e_map($partial);
my %e_port;
@@ -88,11 +110,19 @@ sub e_port {
return \%e_port;
}
sub munge_e_type {
my $oid = shift;
my $name = &SNMP::translateObj($oid);
return $name if defined($name);
return $oid;
}
1;
=head1 NAME
SNMP::Info::Entity - Perl5 Interface to SNMP data stored in ENTITY-MIB. RFC 2737
SNMP::Info::Entity - SNMP Interface to data stored in ENTITY-MIB. RFC 2737
=head1 AUTHOR
@@ -155,7 +185,7 @@ to a hash.
=item $entity->e_index()
Not normally implemented
Index
(C<entPhysicalIndex>)
@@ -226,6 +256,12 @@ More computer friendly name of entity. Parse me.
Maps EntityTable entries to the Interface Table (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>)

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::EtherLike;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -42,7 +42,9 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::EtherLike::EXPORT_OK = qw//;
%MIBS = ('ETHERLIKE-MIB' => 'etherMIB' );
%MIBS = (
'ETHERLIKE-MIB' => 'etherMIB'
);
%GLOBALS = ();
@@ -69,8 +71,9 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
'el_coll_freq' => 'dot3CollFrequencies'
);
%MUNGE = ( %SNMP::Info::MUNGE,
'el_duplex' => \&munge_el_duplex,
%MUNGE = (
%SNMP::Info::MUNGE,
'el_duplex' => \&munge_el_duplex,
);
sub munge_el_duplex {
@@ -88,7 +91,7 @@ __END__
=head1 NAME
SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB RFC 1398
SNMP::Info::EtherLike - SNMP Interface to SNMP ETHERLIKE-MIB RFC 1398
=head1 AUTHOR

View File

@@ -42,9 +42,11 @@ use SNMP::Info;
@SNMP::Info::FDP::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
$VERSION = '1.03';
$VERSION = '1.07';
%MIBS = ( 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' );
%MIBS = (
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun'
);
%GLOBALS = (
# CDP-Compatibility
@@ -84,8 +86,6 @@ sub munge_caps {
my $bits = substr(unpack("B*",$caps),-7);
return $bits;
}
sub cdp_run {
@@ -103,8 +103,6 @@ sub hasFDP {
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();
@@ -147,7 +145,7 @@ __END__
=head1 NAME
SNMP::Info::FDP - Perl5 Interface to Foundry Discovery Protocol (FDP) using SNMP
SNMP::Info::FDP - SNMP Interface to Foundry Discovery Protocol (FDP) using SNMP
=head1 AUTHOR

397
Info/IEEE802dot11.pm Normal file
View File

@@ -0,0 +1,397 @@
# SNMP::Info::IEEE802dot11
# Eric Miller
# $Id$
#
# Copyright (c) 2006 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::IEEE802dot11;
$VERSION = '1.07';
use strict;
use Exporter;
@SNMP::Info::IEEE802dot11::ISA = qw/Exporter/;
@SNMP::Info::IEEE802dot11::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
%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 undef;
}
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 undef;
}
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 undef;
}
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) {
my $mw = eval "\$dot11->dot11_tx_pwr_level_$pwr(\$idx)";
$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 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 C<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 IEEE802dot11-MIB
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $dot11->vendor()
Trys to discover the vendor from dot11_man_name() - returns lower case
of the first word in the first instance found.
=item $dot11->model()
Trys to discover the model from dot11_prod_name() - returns lower case
of the first instance found.
=item $dot11->os_ver()
Trys 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.
(B<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 milliwats, of the radio
interface.
=back
=head2 Dot11 Phy OFDM Table (B<dot11PhyOFDMTable>)
=over
=item $dot11->dot11_cur_freq()
(B<dot11CurrentFrequency>)
=back
=head2 Dot11 Phy DSSS Table (B<dot11PhyDSSSTable>)
=over
=item $dot11->dot11_cur_ch()
(B<dot11CurrentChannel>)
=back
=head2 Dot11 Phy Operation Table (B<dot11PhyOperationTable>)
=over
=item $dot11->dot11_phy_type()
(B<dot11PHYType>)
=item $dot11->dot11_reg_dom()
(B<dot11CurrentRegDomain>)
=back
=head2 Dot11 Resource Information Table (B<dot11ResourceInfoTable>)
=over
=item $dot11->dot11_prod_ver()
(B<dot11manufacturerProductVersion>)
=item $dot11->dot11_prod_name()
(B<dot11manufacturerProductName>)
=item $dot11->dot11_man_name()
(B<dot11manufacturerName>)
=back
=head2 Dot11 Operation Table (B<dot11OperationTable>)
=over
=item $dot11->dot11_mac()
(B<dot11MACAddress>)
=back
=head2 Dot11 Station Configuration Table (B<dot11StationConfigTable>)
=over
=item $dot11->dot11_bss_type()
(B<dot11DesiredBSSType>)
=item $dot11->dot11_pwr_mode()
(B<dot11PowerManagementMode>)
=item $dot11->dot11_sta_id()
(B<dot11StationID>)
=back
=head2 Dot11 Transmission Power Table (B<dot11PhyTxPowerTable>)
=over
=item $dot11->dot11_cur_tx_pwr()
(B<dot11CurrentTxPowerLevel>)
=item $dot11->dot11_tx_pwr_level_1()
(B<dot11TxPowerLevel1>)
=item $dot11->dot11_tx_pwr_level_2()
(B<dot11TxPowerLevel2>)
=item $dot11->dot11_tx_pwr_level_3()
(B<dot11TxPowerLevel3>)
=item $dot11->dot11_tx_pwr_level_4()
(B<dot11TxPowerLevel4>)
=item $dot11->dot11_tx_pwr_level_5()
(B<dot11TxPowerLevel5>)
=item $dot11->dot11_tx_pwr_level_6()
(B<dot11TxPowerLevel6>)
=item $dot11->dot11_tx_pwr_level_7()
(B<dot11TxPowerLevel7>)
=item $dot11->dot11_tx_pwr_level_8()
(B<dot11TxPowerLevel8>)
=back
=cut

508
Info/LLDP.pm Normal file
View File

@@ -0,0 +1,508 @@
# SNMP::Info::LLDP
#
# Eric Miller
#
# Copyright (c) 2007 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.
#
# 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;
$VERSION = '1.07';
# $Id$
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 $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
%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' => \&munge_null,
'lldp_sysname' => \&munge_null,
'lldp_rem_sysname' => \&munge_null,
'lldp_rem_sysdesc' => \&munge_null,
'lldp_rem_port_desc' => \&munge_null,
'lldp_sys_cap' => \&munge_caps,
'lldp_rem_sys_cap' => \&munge_caps,
);
sub munge_null {
my $text = shift || return;
$text =~ s/\0//g;
return $text;
}
sub munge_caps {
my $caps = shift;
return undef unless defined $caps;
my $bits = unpack("b*",$caps);
return $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 undef;
}
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));
}
$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 undef;
#}
# 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 undef;
}
}
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 LLDP-MIB
=item LLDP-EXT-DOT1-MIB
=item 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 B<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, B<lldpLocSysName> object should have the
same value of B<sysName> object.
Nulls are removed before the value is returned.
(B<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, B<lldpLocSysDesc> object should have
the same value of B<sysDesc> object.
Nulls are removed before the value is returned.
(B<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
(B<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.
(B<lldpRemChassisId>)
=item $lldp->lldp_if()
Returns the mapping to the SNMP Interface Table.
=item $lldp->lldp_ip()
Returns remote IPv4 address. Returns undef 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 (B<lldpRemTable>)
=over
=item $lldp->lldp_rem_id_type()
Returns the type of encoding used to identify the chassis associated with
the remote system.
(B<lldpRemChassisIdSubtype>)
=item $lldp->lldp_rem_id()
Returns the string value used to identify the chassis component associated
with the remote system.
(B<lldpRemChassisId>)
=item $lldp->lldp_rem_pid_type()
Returns the type of port identifier encoding used in the associated
B<lldpRemPortId> object.
(B<lldpRemPortIdSubtype>)
=item $lldp->lldp_rem_pid()
Returns the string value used to identify the port component associated with
the remote system.
(B<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.
(B<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.
(B<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.
(B<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
(B<lldpRemSysCapEnabled>)
=back
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -38,7 +38,7 @@ use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/;
@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Layer1::EXPORT_OK = qw//;
@@ -56,18 +56,18 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
%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',
'rptr_last_src' => 'rptrAddrTrackNewLastSrcAddress',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
'rptr_last_src'=> \&SNMP::Info::munge_mac,
);
# Method OverRides
@@ -116,8 +116,10 @@ sub vendor {
# By Default we'll use the description field
sub interfaces {
my $l1 = shift;
my $interfaces = $l1->i_index();
my $rptr_port = $l1->rptr_port();
my $partial = shift;
my $interfaces = $l1->i_index($partial) || {};
my $rptr_port = $l1->rptr_port($partial) || {};
foreach my $port (keys %$rptr_port){
$interfaces->{$port} = $port;
@@ -127,9 +129,10 @@ sub interfaces {
sub i_up_admin {
my $l1 = shift;
my $partial = shift;
my $i_up_admin = $l1->i_up_admin2();
my $rptr_up_admin = $l1->rptr_up_admin();
my $i_up_admin = $l1->SUPER::i_up_admin($partial) || {};
my $rptr_up_admin = $l1->rptr_up_admin($partial) || {};
foreach my $key (keys %$rptr_up_admin){
my $up = $rptr_up_admin->{$key};
@@ -142,8 +145,10 @@ sub i_up_admin {
sub i_up {
my $l1 = shift;
my $i_up = $l1->i_up2();
my $rptr_up = $l1->rptr_up();
my $partial = shift;
my $i_up = $l1->SUPER::i_up($partial) || {};
my $rptr_up = $l1->rptr_up($partial) || {};
foreach my $key (keys %$rptr_up){
my $up = $rptr_up->{$key};
@@ -151,14 +156,14 @@ sub i_up {
}
return $i_up;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1 - Perl5 Interface to network devices serving Layer1 only.
SNMP::Info::Layer1 - SNMP Interface to network devices serving Layer1 only.
=head1 AUTHOR
@@ -177,7 +182,7 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $l1->class();
my $class = $l1->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
@@ -194,14 +199,15 @@ Max Baker
=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.
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.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $l1 = new SNMP::Info::Layer1(...);
@@ -219,13 +225,14 @@ a more specific class using the method above.
=item SNMP-REPEATER-MIB
=item Inherited Classes
MIBs required for SNMP::Info
=back
SNMP-REPEATER-MIB needs to be extracted from ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
MIBs required for L<SNMP::Info/"Required MIBs">
See L<SNMP::Info/"Required MIBs"> for its MIB requirements.
SNMP-REPEATER-MIB needs to be extracted from
ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
=head1 GLOBALS
@@ -261,11 +268,11 @@ Number of 'groups' in the Repeater MIB
=back
=head2 Globals imported from SNMP::Info
=head2 Global Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -312,10 +319,14 @@ Group (slot) Number for given port.
(B<rptrPortOperStatus>)
=item $l1->rptr_last_src()
(B<rptrAddrTrackNewLastSrcAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Allied;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -49,7 +49,6 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%FUNCS = (%SNMP::Info::Layer1::FUNCS,
'i_name2' => 'ifName',
'ati_p_name' => 'portName',
'ati_up' => 'linkTestLED',
);
@@ -92,10 +91,10 @@ sub model {
sub i_name{
my $allied = shift;
my $partial = shift;
my $i_name = $allied->i_name2();
my $ati_p_name = $allied->ati_p_name();
my $i_name = $allied->orig_i_name($partial) || {};
my $ati_p_name = $allied->ati_p_name($partial) || {};
foreach my $port (keys %$ati_p_name){
my $name = $ati_p_name->{$port};
@@ -107,9 +106,10 @@ sub i_name{
sub i_up {
my $allied = shift;
my $partial = shift;
my $i_up = SNMP::Info::Layer1::i_up($allied);
my $ati_up = $allied->ati_up();
my $i_up = SNMP::Info::Layer1::i_up($allied, $partial);
my $ati_up = $allied->ati_up($partial) || {};
foreach my $port (keys %$ati_up){
my $up = $ati_up->{$port};
@@ -143,7 +143,7 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $l1->class();
my $class = $allied->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -168,12 +168,12 @@ inherited methods.
Download for your device from http://www.allied-telesyn.com/allied/support/
=item Inherited Classes
MIBs listed in SNMP::Info::Layer1 and its inherited classes.
=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
@@ -208,9 +208,9 @@ Trys to cull out AT-nnnnX out of the description field.
=head2 Global Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
=head2 Overrides
@@ -243,6 +243,6 @@ the values of ati_up() to 'up' and 'down'.
=head2 Table Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Asante;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -48,10 +48,6 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%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',
@@ -63,15 +59,15 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
'ASANTE-HUB1012-MIB' => 'asante'
);
%MUNGE = (%SNMP::Info::Layer1::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'i_speed2' => \&SNMP::Info::munge_speed,
%MUNGE = (
%SNMP::Info::Layer1::MUNGE,
);
sub interfaces {
my $asante = shift;
my $partial = shift;
my $rptr_port = $asante->rptr_port();
my $rptr_port = $asante->rptr_port($partial) || {};
my %interfaces;
@@ -110,8 +106,9 @@ sub model {
sub i_up {
my $asante = shift;
my $partial = shift;
my $asante_up = $asante->asante_up();
my $asante_up = $asante->asante_up($partial) || {};
my $i_up = {};
foreach my $port (keys %$asante_up){
@@ -125,8 +122,9 @@ sub i_up {
sub i_speed {
my $asante = shift;
my $partial = shift;
my $i_speed = $asante->i_speed2();
my $i_speed = $asante->orig_i_speed($partial) || {};
my %i_speed;
@@ -137,8 +135,9 @@ sub i_speed {
sub i_mac {
my $asante = shift;
my $partial = shift;
my $i_mac = $asante->i_mac2();
my $i_mac = $asante->orig_i_mac($partial) || {};
my %i_mac;
@@ -153,8 +152,9 @@ sub i_description {
sub i_name {
my $asante = shift;
my $partial = shift;
my $i_name = $asante->i_descr2();
my $i_name = $asante->orig_i_descr($partial) || {};
my %i_name;
@@ -186,7 +186,7 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $asante->class();
my $class = $asante->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -210,10 +210,12 @@ Asante device through SNMP.
Download from http://www.mibdepot.com
=item MIBs listed in SNMP::Info::Layer1
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
=head2 Overrides
@@ -234,15 +236,16 @@ Returns 'asante' :)
=item $asante->model()
Trys to cull out AT-nnnnX out of the description field.
Cross references $asante->id() to the ASANTE-HUB1012-MIB and returns
the results.
=back
=head2 Globals inherited from SNMP::Info::Layer1
=head2 Global Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
=head2 Overrides
@@ -255,7 +258,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 ati_up() to 'up' and 'down'.
the values of asante_up() to 'up' and 'down'.
=back
@@ -275,6 +278,6 @@ the values of ati_up() to 'up' and 'down'.
=head2 Table Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -2,7 +2,7 @@
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 Eric Miller, Max Baker
# Copyright (c) 2004 Eric Miller, Max Baker
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -28,23 +28,21 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Bayhub;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::NortelStack;
use SNMP::Info::SONMP;
use SNMP::Info::NortelStack;
use SNMP::Info::Layer2;
@SNMP::Info::Layer1::Bayhub::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/;
@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 $AUTOLOAD $INIT $DEBUG/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS,
'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable',
@@ -52,15 +50,13 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::SONMP::FUNCS,
# S5-ETHERNET-COMMON-MIB::s5EnPortTable
@@ -68,6 +64,10 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
'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',
@@ -75,8 +75,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
@@ -101,19 +100,22 @@ sub model {
return $id unless defined $model;
$model =~ s/^sreg-//i;
return 'Baystack Hub' if ($model =~ /BayStackEth/);
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
# and port status
sub i_index {
my $bayhub = shift;
my $b_index = $bayhub->bayhub_pb_index();
my $p_index = $bayhub->bayhub_pp_index();
my $model = $bayhub->model();
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){
@@ -141,14 +143,20 @@ sub i_index {
return \%i_index;
}
# Partials don't really help in this class, but implemented
# for consistency
sub interfaces {
my $bayhub = shift;
my $i_index = $bayhub->i_index();
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;
@@ -164,12 +172,15 @@ sub interfaces {
sub i_duplex {
my $bayhub = shift;
my $port_index = $bayhub->i_index();
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;
@@ -179,12 +190,15 @@ sub i_duplex {
sub i_duplex_admin {
my $bayhub = shift;
my $port_index = $bayhub->i_index();
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;
@@ -194,14 +208,20 @@ sub i_duplex_admin {
sub i_speed {
my $bayhub = shift;
my $port_index = $bayhub->i_index();
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;
my $speed = '10 Mbps';
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;
@@ -209,13 +229,16 @@ sub i_speed {
sub i_up {
my $bayhub = shift;
my $port_index = $bayhub->i_index();
my $link_stat = $bayhub->bayhub_up();
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;
@@ -229,13 +252,16 @@ sub i_up {
sub i_up_admin {
my $bayhub = shift;
my $i_index = $bayhub->i_index();
my $link_stat = $bayhub->bayhub_up_admin();
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;
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;
@@ -265,10 +291,12 @@ sub set_i_up_admin {
# Hubs do not support the standard Bridge MIB
sub bp_index {
my $bayhub = shift;
my $b_index = $bayhub->bayhub_nb_index();
my $p_index = $bayhub->bayhub_np_index();
my $model = $bayhub->model();
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){
@@ -290,6 +318,7 @@ sub bp_index {
}
my $index = ($board*256)+$port;
next if (defined $partial and $index !~ /^$partial$/);
$bp_index{$index} = $index;
}
@@ -298,9 +327,11 @@ sub bp_index {
sub fw_port {
my $bayhub = shift;
my $b_index = $bayhub->bayhub_nb_index();
my $p_index = $bayhub->bayhub_np_index();
my $model = $bayhub->model();
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){
@@ -336,6 +367,93 @@ 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__
@@ -368,7 +486,7 @@ Eric Miller
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bayhub device through SNMP. Also provides device MAC to port mapping through the propietary MIB.
Bayhub 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.
@@ -379,9 +497,7 @@ my $bayhub = new SNMP::Info::Layer1::Bayhub(...);
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::Layer2
=item SNMP::Info::NortelStack
@@ -397,18 +513,16 @@ my $bayhub = new SNMP::Info::Layer1::Bayhub(...);
=item S5-COMMON-STATS-MIB
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See SNMP::Info::NortelStack for its own MIB requirements.
See SNMP::Info::SONMP for its own MIB requirements.
=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
@@ -428,7 +542,7 @@ Returns 'bay_hub'
Cross references $bayhub->id() to the SYNOPTICS-MIB and returns
the results.
Removes sreg- from the model name
Removes either Baystack Hub, 5000, or 5005 depending on the model.
=back
@@ -452,23 +566,19 @@ start at 0. Returns 0.
=back
=head2 Globals imported from SNMP::Info
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::NortelStack
See documentation in SNMP::Info::NortelStack for details.
See L<SNMP::Info::NortelStack/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -498,7 +608,7 @@ Returns half, hubs do not support full duplex.
=item $bayhub->i_speed()
Currently returns 10 Mbps. The class does not currently support 100 Mbps hubs.
Returns interface speed.
=item $bayhub->i_up()
@@ -535,20 +645,70 @@ to the Interface index.
=back
=head2 Table Methods imported from SNMP::Info
=head2 Pseudo ENTITY-MIB Information
See documentation in SNMP::Info for details.
These devices do not support ENTITY-MIB. These methods emulate Physical Table
methods using S5-CHASSIS-MIB. See L<SNMP::Info::NortelStack/"TABLE METHODS">
for details.
=head2 Table Methods imported from SNMP::Info::Bridge
=over
See documentation in SNMP::Info::Bridge for details.
=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_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 documentation in SNMP::Info::NortelStack for details.
See L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=cut

441
Info/Layer1/Cyclades.pm Normal file
View File

@@ -0,0 +1,441 @@
# SNMP::Info::Layer1::Cyclades
# Eric Miller
# $Id$
#
# Copyright (c) 2006 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::Layer1::Cyclades;
$VERSION = '1.07';
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/;
%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 undef 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 CYCLADES-ACS-SYS-MIB
=item CYCLADES-ACS-CONF-MIB
=item 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()
(B<cyACSversion>)
=item $cyclades->serial()
(B<cyACSDevId>)
=item $cyclades->root_ip()
(B<cyEthIPaddr>)
=item $cyclades->ps1_status()
(B<cyACSPw1>)
=item $cyclades->ps2_status()
(B<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 (B<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
B<cySPortSocketPort> to avoid conflicts with B<ifIndex>.
=item $cyclades->interfaces()
Returns reference to map of IIDs to physical ports. Extended to include
serial ports, B<cyISPortTty>.
=item $cyclades->i_speed()
Returns interface speed. Extended to include serial ports, B<cyISPortSpeed>.
=item $cyclades->i_up()
Returns link status for each port. Extended to include serial ports,
B<cyISPortSigCD>.
=item $cyclades->i_description()
Returns description of each port. Extended to include serial ports,
B<cyISPortName>.
=item $cyclades->i_name()
Returns name of each port. Extended to include serial ports, B<cyISPortName>.
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -28,28 +28,25 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::S3000;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info::Layer1;
use SNMP::Info::Bridge;
use SNMP::Info::Layer2;
@SNMP::Info::Layer1::S3000::ISA = qw/SNMP::Info::Layer1 SNMP::Info::Bridge/;
@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 $AUTOLOAD $INIT $DEBUG/;
%MIBS = (
%SNMP::Info::Layer1::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Layer2::MIBS,
'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable',
'SYNOPTICS-COMMON-MIB' => 's3AgentType',
);
%GLOBALS = (
%SNMP::Info::Layer1::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Layer2::GLOBALS,
# From SYNOPTICS-COMMON-MIB
'os_bin' => 's3AgentFwVer',
's3000_major_ver' => 's3AgentSwMajorVer',
@@ -58,8 +55,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Layer2::FUNCS,
# SYNOPTICS-ETHERNET-MIB::s3EnetPortTable
's3000_pb_index' => 's3EnetPortBoardIndex',
's3000_pp_index' => 's3EnetPortIndex',
@@ -75,8 +71,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%MUNGE = (
%SNMP::Info::Layer1::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Layer2::MUNGE,
's3000_topo_mac' => \&SNMP::Info::munge_mac
);
@@ -130,11 +125,14 @@ sub mac {
}
# Hubs do not support ifMIB requirements for get MAC
# and port status
# and port status
sub i_index {
my $s3000 = shift;
my $b_index = $s3000->s3000_pb_index();
my $p_index = $s3000->s3000_pp_index();
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){
@@ -150,14 +148,20 @@ sub i_index {
return \%i_index;
}
# Partials don't really help in this class, but implemented
# for consistency
sub interfaces {
my $s3000 = shift;
my $i_index = $s3000->i_index();
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;
@@ -173,12 +177,15 @@ sub interfaces {
sub i_duplex {
my $s3000 = shift;
my $port_index = $s3000->i_index();
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';
@@ -189,12 +196,15 @@ sub i_duplex {
sub i_duplex_admin {
my $s3000 = shift;
my $port_index = $s3000->i_index();
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';
@@ -205,12 +215,15 @@ sub i_duplex_admin {
sub i_speed {
my $s3000 = shift;
my $port_index = $s3000->i_index();
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 10Mbs
my $speed = '10000000';
@@ -221,13 +234,16 @@ sub i_speed {
sub i_up {
my $s3000 = shift;
my $port_index = $s3000->i_index();
my $link_stat = $s3000->s3000_up();
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;
@@ -241,13 +257,16 @@ sub i_up {
sub i_up_admin {
my $s3000 = shift;
my $i_index = $s3000->i_index();
my $link_stat = $s3000->s3000_up_admin();
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;
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;
@@ -263,7 +282,7 @@ sub set_i_up_admin {
my $s3000 = shift;
my ($setting, $iid) = @_;
my $i_index = $s3000->i_index();
my $i_index = $s3000->i_index() || {};
my %reverse_i_index = reverse %$i_index;
$setting = lc($setting);
@@ -277,9 +296,11 @@ sub set_i_up_admin {
# Hubs do not support the standard Bridge MIB
sub bp_index {
my $s3000 = shift;
my $b_index = $s3000->s3000_nb_index();
my $p_index = $s3000->s3000_np_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;
@@ -289,6 +310,7 @@ sub bp_index {
my $port = $p_index->{$iid}||0;
my $index = ($board*256)+$port;
next if (defined $partial and $index !~ /^$partial$/);
$bp_index{$index} = $index;
}
@@ -297,8 +319,10 @@ sub bp_index {
sub fw_port {
my $s3000 = shift;
my $b_index = $s3000->s3000_nb_index();
my $p_index = $s3000->s3000_np_index();
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;
@@ -346,7 +370,7 @@ Eric Miller
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bayhub device through SNMP. Also provides device MAC to port mapping through the propietary MIB.
Bayhub 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.
@@ -357,9 +381,7 @@ my $s3000 = new SNMP::Info::Layer1::S3000(...);
=over
=item SNMP::Info::Layer1
=item SNMP::Info::Bridge
=item SNMP::Info::Layer2
=back
@@ -371,14 +393,12 @@ my $s3000 = new SNMP::Info::Layer1::S3000(...);
=item SYNOPTICS-ETHERNET-MIB
=item Inherited Classes' MIBs
See SNMP::Info::Layer1 for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
=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
@@ -426,15 +446,11 @@ Returns 00000011. Class emulates Layer 2 functionality through proprietary MIBs
=back
=head2 Globals imported from SNMP::Info::Layer1
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer1 for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -513,12 +529,8 @@ Returns reference to hash. Key: Table entry, Value:Remote MAC address
=back
=head2 Table Methods imported from SNMP::Info::Layer1
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer1 for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -39,21 +39,24 @@ use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::Entity;
use SNMP::Info::PowerEthernet;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity SNMP::Info::PowerEthernet Exporter/;
@SNMP::Info::Layer2::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Entity::MIBS,
%SNMP::Info::PowerEthernet::MIBS,
);
%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
);
@@ -61,6 +64,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Entity::FUNCS,
%SNMP::Info::PowerEthernet::FUNCS,
);
%MUNGE = (
@@ -68,6 +72,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE,
);
# Method OverRides
@@ -77,7 +82,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
sub model {
my $l2 = shift;
my $id = $l2->id();
my $model = &SNMP::translateObj($id);
my $model = &SNMP::translateObj($id) || $id || '';
# HP
$model =~ s/^hpswitch//i;
@@ -126,15 +131,16 @@ sub serial {
sub i_ignore {
my $l2 = shift;
my $partial = shift;
my $i_type = $l2->i_type();
my $i_type = $l2->i_type($partial) || {};
my %i_ignore = ();
foreach my $if (keys %$i_type){
my $type = $i_type->{$if};
$i_ignore{$if}++
if $type =~ /(loopback|propvirtual|other|cpu)/i;
if $type =~ /(loopback|other|cpu)/i;
}
return \%i_ignore;
@@ -142,8 +148,10 @@ sub i_ignore {
sub interfaces {
my $l2 = shift;
my $interfaces = $l2->i_index();
my $i_descr = $l2->i_description();
my $partial = shift;
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){
@@ -159,7 +167,7 @@ __END__
=head1 NAME
SNMP::Info::Layer2 - Perl5 Interface to network devices serving Layer2 only.
SNMP::Info::Layer2 - SNMP Interface to network devices serving Layer2 only.
=head1 AUTHOR
@@ -194,14 +202,15 @@ Max Baker
=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.
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.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $l2 = new SNMP::Info::Layer2(...);
@@ -254,15 +263,15 @@ Trys to discover the vendor from $l2->model() and $l2->description()
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
=head1 TABLE METHODS
@@ -289,14 +298,14 @@ Ignores ports with B<ifType> of loopback,propvirtual,other, and cpu
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=cut

211
Info/Layer2/Airespace.pm Normal file
View File

@@ -0,0 +1,211 @@
# SNMP::Info::Layer2::Airespace
# Eric Miller
# $Id$
#
# Copyright (c) 2007 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;
$VERSION = '1.07';
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/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::Airespace::MIBS,
);
%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,
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::Airespace::MUNGE,
);
sub os {
return 'cisco';
}
sub vendor {
return 'cisco';
}
sub model {
my $airespace = shift;
my $model = $airespace->airespace_model();
return undef unless defined $model;
return $model;
}
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,
# 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 = $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()
(B<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.
=head2 Overrides
=over
=item None
=back
=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.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Aironet;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -96,7 +96,9 @@ sub vendor {
sub interfaces {
my $aironet = shift;
my $i_description = $aironet->i_description();
my $partial = shift;
my $i_description = $aironet->i_description($partial);
return $i_description;
}
@@ -115,7 +117,9 @@ sub description {
# Fetch duplex from EtherLike
sub i_duplex {
my $aironet = shift;
my $el_duplex = $aironet->el_duplex();
my $partial = shift;
my $el_duplex = $aironet->el_duplex($partial);
my %i_duplex;
foreach my $d (keys %$el_duplex){
@@ -220,17 +224,17 @@ Adds info from method e_descr() from SNMP::Info::Entity
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
See documentation in L<SNMP::Info::EtherLike/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
=head2 Overrides
@@ -248,14 +252,14 @@ Crosses information from SNMP::Info::EtherLike to get duplex info for interfaces
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
See documentation in L<SNMP::Info::EtherLike/"TABLE METHODS"> for details.
=cut

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Allied;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -45,11 +45,10 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
%SNMP::Info::Layer2::GLOBALS
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
'ip_adresses'=> 'atNetAddress',
'ip_mac' => 'atPhysAddress',
'i_name' => 'ifName',
'i_up2' => 'ifOperStatus',
);
%MIBS = (
@@ -58,7 +57,8 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking',
);
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
%MUNGE = (
%SNMP::Info::Layer2::MUNGE,
);
sub vendor {
@@ -89,7 +89,7 @@ sub model {
return undef;
}
sub ip {
sub root_ip {
my $allied = shift;
my $ip_hash = $allied->ip_addresses();
my $ip;
@@ -117,9 +117,9 @@ sub mac{
sub i_up {
my $allied = shift;
my $partial = shift;
my $i_up = SNMP::Info::Layer1::i_up($allied);
#my $i_up2 = $allied->i_up2() || {};
my $i_up = SNMP::Info::Layer1::i_up($allied, $partial);
foreach my $port (keys %$i_up){
my $up = $i_up->{$port};
@@ -153,7 +153,7 @@ Max Baker, Dmitry Sergienko <dmitry@trifle.net>
)
or die "Can't connect to DestHost.\n";
my $class = $l1->class();
my $class = $allied->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -166,7 +166,7 @@ inherited methods.
=over
=item SNMP::Info::Layer1
=item SNMP::Info::Layer2
=back
@@ -174,16 +174,18 @@ inherited methods.
=over
=item ATI-MIB
=item AtiSwitch-MIB
Download for your device from http://www.allied-telesyn.com/allied/support/
=item AtiStackInfo-MIB
=item Inherited Classes
MIBs listed in SNMP::Info::Layer1 and its inherited classes.
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
@@ -206,7 +208,7 @@ Culls Version from description()
=item $allied->root_ip()
Returns IP Address of Managed Hub.
Returns IP Address of Managed Device.
(B<actualIpAddr>)
@@ -216,20 +218,16 @@ Trys to cull out AT-nnnnX out of the description field.
=back
=head2 Global Methods imported from SNMP::Info::Layer1
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer1 for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
=head2 Overrides
=over
=item $allied->i_name()
Returns reference to map of IIDs to human-set port name.
=item $allied->i_up()
Returns reference to map of IIDs to link status. Changes
@@ -237,10 +235,8 @@ the values of ati_up() to 'up' and 'down'.
=back
=head2 Allied MIB
=head2 Table Methods imported from SNMP::Info::Layer2
=over
=back
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -28,41 +28,39 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Aruba;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Aruba::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Layer2::MIBS,
'WLSX-SWITCH-MIB' => 'wlsxHostname',
'WLSR-AP-MIB' => 'wlsrHideSSID',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Layer2::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'i_index2' => 'ifIndex',
'i_name2' => 'ifName',
%SNMP::Info::Layer2::FUNCS,
# WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable
# Table index leafs do not return information
# therefore unable to use apESSID. We extract
# therefore unable to use apBSSID. We extract
# the information from the IID instead.
#'aruba_ap_essid' => 'apESSID',
'aruba_ap_name' => 'apLocation',
'aruba_ap_ip' => 'apIpAddress',
'aruba_ap_name' => 'apLocation',
'aruba_ap_ip' => 'apIpAddress',
'aruba_ap_essid' => 'apESSID',
'aruba_ap_ssidbcast' => 'wlsrHideSSID',
# WLSR-AP-MIB::wlsrConfigTable
'aruba_ap_channel' => 'apCurrentChannel',
# WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable
# Table index leafs do not return information
# therefore unable to use staAccessPointBSSID
@@ -74,8 +72,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Layer2::MUNGE,
);
sub layers {
@@ -116,8 +113,10 @@ sub model {
sub i_index {
my $aruba = shift;
my $i_index = $aruba->i_index2();
my $ap_index = $aruba->aruba_ap_name();
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){
@@ -139,8 +138,10 @@ sub i_index {
sub interfaces {
my $aruba = shift;
my $i_index = $aruba->i_index();
my $i_descr = $aruba->i_description();
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){
@@ -167,9 +168,11 @@ sub interfaces {
sub i_name {
my $aruba = shift;
my $i_index = $aruba->i_index();
my $i_name2 = $aruba->i_name2();
my $ap_name = $aruba->aruba_ap_name();
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 %i_name;
foreach my $iid (keys %$i_index){
@@ -193,12 +196,88 @@ sub i_name {
}
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 $i_index = $aruba->i_index2();
my $ap_index = $aruba->aruba_ap_name();
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){
@@ -220,7 +299,9 @@ sub bp_index {
sub fw_port {
my $aruba = shift;
my $fw_idx = $aruba->fw_user();
my $partial = shift;
my $fw_idx = $aruba->fw_user($partial) || {};
my %fw_port;
foreach my $iid (keys %$fw_idx){
@@ -237,7 +318,9 @@ sub fw_port {
sub fw_mac {
my $aruba = shift;
my $fw_idx = $aruba->fw_user();
my $partial = shift;
my $fw_idx = $aruba->fw_user($partial) || {};
my %fw_mac;
foreach my $iid (keys %$fw_idx){
@@ -299,9 +382,7 @@ determining a more specific class using the method above.
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::Layer2
=back
@@ -311,14 +392,14 @@ determining a more specific class using the method above.
=item WLSX-SWITCH-MIB
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
=item WLSR-AP-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
@@ -355,7 +436,11 @@ proprietary MIBs.
=back
=head1 TABLE ENTRIES
=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.
@@ -393,6 +478,25 @@ both the keys and values.
(B<staPhyAddress>) as extracted from the IID.
=item $aruba->i_ssidlist()
Returns reference to hash. SSID's recognized by the radio interface.
(B<apESSID>)
=item $aruba->i_ssidbcast()
Returns reference to hash. Indicates whether the SSID is broadcast, true or false.
(B<wlsrHideSSID>)
=item $aruba->i_80211channel()
Returns reference to hash. Current operating frequency channel of the radio
interface.
(B<apCurrentChannel>)
=back
=head2 Aruba Switch AP Table (B<wlsxSwitchAccessPointTable>)
@@ -407,6 +511,14 @@ both the keys and values.
(B<apIpAddress>)
=item $aruba->aruba_ap_essid()
(B<apESSID>)
=item $aruba->aruba_ap_ssidbcast()
(B<wlsrHideSSID>)
=back
=head2 Aruba Switch Station Management Table (B<wlsxSwitchStationMgmtTable>)
@@ -417,4 +529,20 @@ both the keys and values.
(B<staUserName>)
=back
=head2 Aruba Wireless AP Configuration Table (B<wlsrConfigTable>)
=over
=item $aruba->aruba_ap_channel()
(B<apCurrentChannel>)
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -31,7 +31,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Bay;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -307,7 +307,7 @@ a more specific class using the method above.
=item Inherited classes
MIBs required by SNMP::Info::Layer2 and its superclasses.
MIBs required by L<SNMP::Info::Layer2/"Required MIBs"> and its superclasses.
=back
@@ -354,9 +354,9 @@ Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -469,6 +469,6 @@ Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg() i
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -1,6 +1,5 @@
# SNMP::Info::Layer2::Baystack
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 Max Baker changes from version 0.8 and beyond.
# All rights reserved.
@@ -29,49 +28,47 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Baystack;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
use SNMP::Info::RapidCity;
use SNMP::Info::NortelStack;
use SNMP::Info::RapidCity;
use SNMP::Info::LLDP;
use SNMP::Info::Layer3;
@SNMP::Info::Layer2::Baystack::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::RapidCity SNMP::Info::NortelStack Exporter/;
@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 $AUTOLOAD $INIT $DEBUG/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::SONMP::MIBS,
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS,
%SNMP::Info::RapidCity::MIBS,
%SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::RapidCity::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::SONMP::FUNCS,
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS,
%SNMP::Info::RapidCity::FUNCS,
%SNMP::Info::NortelStack::FUNCS,
'i_name2' => 'ifName',
'i_mac2' => 'ifPhysAddress',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
%SNMP::Info::SONMP::FUNCS,
);
# 450's report full duplex as speed = 20mbps?!
@@ -80,13 +77,11 @@ $SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
$SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps';
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::SONMP::MUNGE,
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::LLDP::MUNGE,
%SNMP::Info::RapidCity::MUNGE,
%SNMP::Info::NortelStack::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
%SNMP::Info::SONMP::MUNGE,
);
sub os {
@@ -94,9 +89,12 @@ sub os {
my $descr = $baystack->description();
my $model = $baystack->model();
if ((defined $model and $model =~ /(470|460|BPS|5510|5520|5530)/) and (defined $descr and $descr =~ m/SW:v[3-5]/i)) {
if ((defined $model and $model =~ /(325|420|425|470|460|BPS|2500|3510|4524|4526|4548|4550|5510|5520|5530)/) and (defined $descr and $descr =~ m/SW:v[3-5]/i)) {
return 'boss';
}
if ((defined $descr and $descr =~ /Business Ethernet Switch.*SW:v/i)) {
return 'bes';
}
return 'baystack';
}
@@ -137,27 +135,16 @@ sub model {
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 $2 if ($model =~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)-?(\d+)/);
return $model;
}
sub i_ignore {
my $baystack = shift;
my $i_type = $baystack->i_type();
my %i_ignore;
foreach my $if (keys %$i_type){
my $type = $i_type->{$if};
next unless defined $type;
$i_ignore{$if}++ if $type =~ /(54|loopback|propvirtual|cpu)/i;
}
return \%i_ignore;
}
sub interfaces {
my $baystack = shift;
my $i_index = $baystack->i_index();
my $partial = shift;
my $i_index = $baystack->i_index($partial) || {};
my $index_factor = $baystack->index_factor();
my $slot_offset = $baystack->slot_offset();
@@ -179,7 +166,9 @@ sub interfaces {
sub i_mac {
my $baystack = shift;
my $i_mac = $baystack->i_mac2();
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
@@ -194,9 +183,11 @@ sub i_mac {
sub i_name {
my $baystack = shift;
my $i_index = $baystack->i_index();
my $i_alias = $baystack->i_alias();
my $i_name2 = $baystack->i_name2();
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){
@@ -219,12 +210,228 @@ sub index_factor {
$op_mode = 'pure' unless defined $op_mode;
my $index_factor = 32;
$index_factor = 64 if ((defined $model and $model =~ /(470)/) or ($os eq 'boss') and ($op_mode eq 'pure'));
$index_factor = 64 if ((defined $model and $model =~ /(470)/) or ($os =~ m/(boss|bes)/) and ($op_mode eq 'pure'));
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
@@ -265,36 +472,36 @@ my $baystack = new SNMP::Info::Layer2::Baystack(...);
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::SONMP
=item SNMP::Info::NortelStack
=item SNMP::Info::SONMP
=item SNMP::Info::RapidCity
=item SNMP::Info::LLDP
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See SNMP::Info::NortelStack for its own MIB requirements.
See SNMP::Info::SONMP for its own MIB requirements.
See SNMP::Info::RapidCity for its own MIB requirements.
=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
@@ -343,27 +550,27 @@ Returns either 32 or 64 based upon the formula.
=back
=head2 Globals imported from SNMP::Info
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::NortelStack
See documentation in SNMP::Info::NortelStack for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See L<SNMP::Info::NortelStack/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
See L<SNMP::Info::RapidCity/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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.
@@ -400,48 +607,135 @@ Crosses ifName with ifAlias and returns the human set port name if exists.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=head2 ENTITY-MIB Information
For older devices which do not support ENTITY-MIB, these methods emulate
Physical Table methods using S5-CHASSIS-MIB. See
L<SNMP::Info::NortelStack/"TABLE METHODS"> for details on ns_e_* methods.
=over
=item $baystack->at_index()
=item $baystack->e_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
If the device doesn't support B<entPhysicalDescr>, this will try ns_e_index().
Note that this is based on B<entPhysicalDescr> due to implementation
details of SNMP::Info::Entity::e_index().
(B<ipNetToMediaIfIndex>)
=item $baystack->e_class()
=item $baystack->at_paddr()
If the device doesn't support B<entPhysicalClass>, this will try ns_e_class().
Returns reference to hash. Maps ARP table entries to MAC addresses.
=item $baystack->e_descr()
(B<ipNetToMediaPhysAddress>)
If the device doesn't support B<entPhysicalDescr>, this will try ns_e_descr().
=item $baystack->at_netaddr()
=item $baystack->e_fwver()
Returns reference to hash. Maps ARP table entries to IPs
If the device doesn't support B<entPhysicalFirmwareRev>, this will try
ns_e_fwver().
(B<ipNetToMediaNetAddress>)
=item $baystack->e_hwver()
If the device doesn't support B<entPhysicalHardwareRev>, this will try
ns_e_hwver().
=item $baystack->e_parent()
If the device doesn't support B<entPhysicalContainedIn>, this will try
ns_e_parent().
=item $baystack->e_pos()
If the device doesn't support B<entPhysicalParentRelPos>, this will try
ns_e_pos().
=item $baystack->e_serial()
If the device doesn't support B<entPhysicalSerialNum>, this will try
ns_e_serial().
=item $baystack->e_swver()
If the device doesn't support B<entPhysicalSoftwareRev>, this will try
ns_e_swver().
=item $baystack->e_type()
If the device doesn't support B<entPhysicalVendorType>, this will try
ns_e_type().
=item $baystack->e_vendor()
If the device doesn't support B<entPhysicalMfgName>, this will try
ns_e_vendor().
=back
=head2 Table Methods imported from SNMP::Info
=head2 Topology information
See documentation in SNMP::Info for details.
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 de-duplicate if necessary.
=head2 Table Methods imported from SNMP::Info::Bridge
=over
See documentation in SNMP::Info::Bridge for details.
=item $baystack->hasCDP()
=head2 Table Methods imported from SNMP::Info::NortelStack
Returns true if the device is running either SONMP or LLDP.
See documentation in SNMP::Info::NortelStack for details.
=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 documentation in SNMP::Info::SONMP for details.
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 documentation in SNMP::Info::RapidCity for details.
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

@@ -5,91 +5,96 @@
#
# 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
# * 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
# 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;
# (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
# 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 = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoVTP
SNMP::Info::CDP SNMP::Info::CiscoStats Exporter/;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoConfig SNMP::Info::Layer2
Exporter/;
@SNMP::Info::Layer2::C1900::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'c1900_flash_status' => 'upgradeFlashBankStatus',
);
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'c1900_flash_status' => 'upgradeFlashBankStatus',
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
'i_type2' => 'ifType',
'i_name2' => 'ifName',
# 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',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
# 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,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::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::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE,
);
sub bulkwalk_no { 1; }
sub cisco_comm_indexing { 1; }
sub vendor {
return 'cisco';
}
sub os {
return 'catalyst';
}
@@ -100,123 +105,158 @@ sub os_ver {
# 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 undef unless defined $c1900_flash_status;
if ($c1900_flash_status =~ m/V(\d+\.\d+(\.\d+)?)/){
if ( $c1900_flash_status =~ m/V(\d+\.\d+(\.\d+)?)/ ) {
return $1;
}
}
return undef;
}
sub bulkwalk_no { 1; }
sub cisco_comm_indexing { 1; }
sub interfaces {
my $c1900 = shift;
my $i_descr = $c1900->i_description();
my $c1900 = shift;
my $partial = shift;
foreach my $iid (keys %$i_descr){
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 $interfaces = $c1900->interfaces();
my $c1900_p_index = $c1900->c1900_p_index();
my $c1900_p_duplex = $c1900->c1900_p_duplex();
my $c1900 = shift;
my $partial = shift;
my %reverse_1900 = reverse %$c1900_p_index;
my $c1900_p_duplex = $c1900->c1900_p_duplex($partial) || {};
my %i_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;
foreach my $if ( keys %$c1900_p_duplex ) {
my $duplex = $c1900_p_duplex->{$if};
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 $interfaces = $c1900->interfaces();
my $c1900_p_index = $c1900->c1900_p_index();
my $c1900_p_admin = $c1900->c1900_p_duplex_admin();
my $c1900 = shift;
my $partial = shift;
my %reverse_1900 = reverse %$c1900_p_index;
my $c1900_p_admin = $c1900->c1900_p_duplex_admin($partial) || {};
my %i_duplex_admin;
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;
foreach my $if ( keys %$c1900_p_admin ) {
my $duplex = $c1900_p_admin->{$if};
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_type {
my $c1900 = shift;
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();
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};
next unless defined $port;
next unless defined $type;
next unless defined $media;
$i_type->{$port} = "$type $media";
}
return $i_type;
}
sub i_name {
my $c1900 = shift;
my $i_name = $c1900->i_name2();
my $c1900_p_name = $c1900->c1900_p_name();
foreach my $port (keys %$c1900_p_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 {
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 $iid = $c1900->c1900_p_ifindex($port);
$duplex = lc($duplex);
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 undef;
}
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;
}
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;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::C1900 - Perl5 Interface to SNMP data from Cisco Catlyst 1900 Network Switches running CatOS
SNMP::Info::Layer2::C1900 - SNMP Interface to data from Cisco Catlyst 1900
Network Switches running CatOS
=head1 AUTHOR
@@ -240,13 +280,13 @@ Max Baker
=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
Catalyst 1900 device through SNMP. See SNMP::Info for full documentation
Note that most of these devices only talk SNMP version 1, but not all.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $c1900 = new SNMP::Info::Layer2::C1900(...);
@@ -254,6 +294,12 @@ a more specific class using the method above.
=over
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoConfig
=item SNMP::Info::Layer2
=back
@@ -268,22 +314,24 @@ 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
=item Inherited Classes' MIBs
MIBs listed in SNMP::Info::Layer2
=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->bulkwalk_no
Return C<1>. Bulkwalk is turned off for this class.
=item $c1900->c1900_flash_status()
Usually contains the version of the software loaded in flash.
@@ -308,11 +356,36 @@ Returns 'cisco' :)
=back
=head2 Overrides
=over
=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 documentation in SNMP::Info::Layer2 for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
@@ -322,25 +395,34 @@ See documentation in SNMP::Info::Layer2 for details.
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
Crosses $c1900->c1900_p_index() with $c1900->c1900_p_duplex_admin;
=item $c1900->i_name()
Crosses ifName with c1900_p_name() and returns the human set port name if exists.
Crosses 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()
c1900_p_type() and c1900_p_media() if they exist.
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";
}
=back
@@ -358,42 +440,72 @@ B<swPortIfIndex>
Gives Port Duplex Info
B<swPortDuplexStatus>
(B<swPortDuplexStatus>)
=item $c1900->c1900_p_duplex_admin()
Gives admin setting for Duplex Info
B<swPortFullDuplex>
(B<swPortFullDuplex>)
=item $c1900->c1900_p_name()
Gives human set name for port
B<swPortName>
(B<swPortName>)
=item $c1900->c1900_p_up_admin()
Gives Admin status of port enabled.
B<swPortAdminStatus>
(B<swPortAdminStatus>)
=item $c1900->c1900_p_type()
Gives Type of port, ie. "general-ethernet"
B<swPortMediaCapability>
(B<swPortMediaCapability>)
=item $c1900->c1900_p_media()
Gives the media of the port , ie "fiber-sc"
B<swPortConnectorType>
(B<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 documentation in SNMP::Info::Layer2 for details.
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 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);
=cut

View File

@@ -30,34 +30,38 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C2900;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
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::Layer2 SNMP::Info::CiscoVTP
SNMP::Info::CDP SNMP::Info::CiscoStats Exporter/;
@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::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
# Set for No CDP
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
'i_name' => 'ifAlias',
# C2900PortEntry
'c2900_p_index' => 'c2900PortIfIndex',
@@ -66,17 +70,21 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
);
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
%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::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
%MUNGE = (
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
sub vendor {
@@ -89,11 +97,11 @@ sub cisco_comm_indexing {
sub i_duplex {
my $c2900 = shift;
my $partial = shift;
my $interfaces = $c2900->interfaces();
my $interfaces = $c2900->interfaces($partial);
my $c2900_p_index = $c2900->c2900_p_index();
my $c2900_p_duplex = $c2900->c2900_p_duplex();
my %reverse_2900 = reverse %$c2900_p_index;
@@ -113,11 +121,11 @@ sub i_duplex {
sub i_duplex_admin {
my $c2900 = shift;
my $partial = shift;
my $interfaces = $c2900->interfaces();
my $interfaces = $c2900->interfaces($partial);
my $c2900_p_index = $c2900->c2900_p_index();
my $c2900_p_admin = $c2900->c2900_p_duplex_admin();
my %reverse_2900 = reverse %$c2900_p_index;
@@ -136,23 +144,19 @@ sub i_duplex_admin {
return \%i_duplex_admin;
}
### we want to be able to set speed on 2900 class switches
###
### $info->set_i_speed_admin("100", ifIndex);
### speed choices are 'auto', '10', '100'
###
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 = shift;
my ($speed, $iid) = @_;
my $c2900_p_index = $c2900->c2900_p_index();
my %reverse_2900 = reverse %$c2900_p_index;
$speed = lc($speed);
return 0 unless defined $speeds{$speed};
return undef unless defined $speeds{$speed};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
@@ -160,23 +164,19 @@ sub set_i_speed_admin {
return $c2900->set_c2900_p_speed_admin($speeds{$speed}, $iid);
}
### we want to be able to set duplex on 2900 class switches
###
### $info->set_i_duplex_admin("half", ifIndex);
### duplex choices are 'auto', 'half', 'full'
###
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 = shift;
my ($duplex, $iid) = @_;
my $c2900_p_index = $c2900->c2900_p_index();
my %reverse_2900 = reverse %$c2900_p_index;
$duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex};
return undef unless defined $duplexes{$duplex};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
@@ -187,8 +187,10 @@ sub set_i_duplex_admin {
# Use i_descritption for port key, cuz i_name can be manually entered.
sub interfaces {
my $c2900 = shift;
my $interfaces = $c2900->i_index();
my $i_descr = $c2900->i_description();
my $partial = shift;
my $interfaces = $c2900->i_index($partial) || {};
my $i_descr = $c2900->i_description($partial) || {};
my %if;
foreach my $iid (keys %$interfaces){
@@ -219,16 +221,16 @@ Max Baker
# Let SNMP::Info determine the correct subclass for you.
my $c2900 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
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();
my $class = $c2900->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -236,8 +238,8 @@ Max Baker
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.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $c2900 = new SNMP::Info::Layer2::C2900(...);
@@ -245,10 +247,16 @@ a more specific class using the method above.
=over
=item SNMP::Info::Layer2
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoConfig
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
@@ -259,14 +267,20 @@ a more specific class using the method above.
Part of the v2 MIBs from Cisco.
=item Inherited Classes' MIBs
See SNMP::Info::Layer2 for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
=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
@@ -277,19 +291,31 @@ These are methods that return scalar value from SNMP
=item $c2900->vendor()
Returns 'cisco' :)
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 documentation in SNMP::Info::Layer2 for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -300,55 +326,27 @@ 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 broadcasted 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
=item $c2900->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port ifIndex
Speed choices are 'auto', '10', '100'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin to
utilize port 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 ifIndex
Speed choices are 'auto', 'half', 'full'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin to
utilize port 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);
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin()
=back
@@ -358,37 +356,84 @@ to a hash.
=item $c2900->c2900_p_index()
Maps the Switch Port Table to the IID
Maps the Switch Port Table to the IID
B<c2900PortIfIndex>
(B<c2900PortIfIndex>)
=item $c2900->c2900_p_duplex()
Gives Port Duplex Info
Gives Port Duplex Info
B<c2900PortDuplexStatus>
(B<c2900PortDuplexStatus>)
=item $c2900->c2900_p_duplex_admin()
Gives admin setting for Duplex Info
B<c2900PortDuplexState>
Gives admin setting for Duplex Info
(B<c2900PortDuplexState>)
=item $c2900->c2900_p_speed_admin()
Gives Admin speed of port
Gives Admin speed of port
B<c2900PortAdminSpeed>
(B<c2900PortAdminSpeed>)
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
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 ifIndex
Speed choices are 'auto', '10', '100'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_speed_admin() to utilize
port 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 ifIndex
Speed choices are 'auto', 'half', 'full'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin() to utilize
port 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);
=cut

View File

@@ -29,61 +29,61 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Catalyst;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CiscoStack;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::Layer2;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoStack
SNMP::Info::CiscoVTP SNMP::Info::CDP SNMP::Info::CiscoStats Exporter/;
@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/;
@SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
);
%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,
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
);
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
);
%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,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
);
# Need to specify this or it might grab the ones out of L2 instead of CiscoStack
*SNMP::Info::Layer2::Catalyst::serial = \&SNMP::Info::CiscoStack::serial;
*SNMP::Info::Layer2::Catalyst::interfaces = \&SNMP::Info::CiscoStack::interfaces;
*SNMP::Info::Layer2::Catalyst::i_duplex = \&SNMP::Info::CiscoStack::i_duplex;
*SNMP::Info::Layer2::Catalyst::i_type = \&SNMP::Info::CiscoStack::i_type;
*SNMP::Info::Layer2::Catalyst::i_name = \&SNMP::Info::CiscoStack::i_name;
*SNMP::Info::Layer2::Catalyst::i_duplex_admin = \&SNMP::Info::CiscoStack::i_duplex_admin;
);
# Overidden Methods
@@ -124,7 +124,7 @@ sub os_ver {
# Workaround for incomplete bp_index
sub bp_index {
my $cat = shift;
my $cat = shift;
my $p_index = $cat->p_port();
my $b_index = $cat->p_oidx();
@@ -143,12 +143,48 @@ sub cisco_comm_indexing {
1;
}
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 %interfaces = ();
foreach my $iid (keys %$i_index) {
next unless defined $iid;
my $if = $i_index->{$iid};
my $port = $portmap{$iid};
$interfaces{$iid} = $port || $if;
}
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;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco Catalyst devices running Catalyst OS.
SNMP::Info::Layer2::Catalyst - SNMP Interface to Cisco Catalyst devices
running Catalyst OS.
=head1 AUTHOR
@@ -172,22 +208,24 @@ Max Baker
=head1 DESCRIPTION
SNMP::Info subclass to provide information for Cisco Catalyst series switches running CatOS.
SNMP::Info subclass to provide information for Cisco Catalyst series switches
running CatOS.
This class includes the Catalyst 2920, 4000, 5000, 6000 (hybrid mode) families.
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.
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.
See SNMP::Info::device_type() for specifics.
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.
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.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
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(...);
@@ -195,11 +233,17 @@ a more specific class using the method above.
=over
=item SNMP::Info::Layer2
=item SNMP::Info::CiscoStack
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoPortSecurity
=item SNMP::Info::Layer2
=back
@@ -209,11 +253,17 @@ a more specific class using the method above.
=item Inherited Classes' MIBs
See SNMP::Info::Layer2 for its own MIB requirements.
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStack 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::CiscoPortSecurity/"Required MIBs"> for its own MIB requirements.
See L<SNMP::Info::Layer2/"Required MIBs"> for its own MIB requirements.
=back
@@ -240,19 +290,31 @@ Returns 'cisco'
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
See documentation in L<SNMP::Info::CiscoStack/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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.
@@ -261,25 +323,49 @@ to a hash.
=over
=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.
B<portName>
=item $cat->bp_index()
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
Returns reference to hash of bridge port table entries map back to interface
identifier (iid)
Crosses (B<portCrossIndex>) to (B<portIfIndex>) since some devices seem to have
problems with BRIDGE-MIB
=back
=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::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
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::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"TABLE METHODS"> for
details.
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Table Methods imported from SNMP::Info::Layer2::CiscoStack
See documentation in SNMP::Info::Layer2::CiscoStack for details.
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Centillion;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
@@ -307,13 +307,13 @@ than bridge group based.
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::NortelStack for its own MIB requirements.
See L<SNMP::Info::NortelStack/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::SONMP for its own MIB requirements.
See L<SNMP::Info::SONMP/"Required MIBs"> for its own MIB requirements.
=back
@@ -391,21 +391,21 @@ start at 0. Returns 0.
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::NortelStack
See documentation in SNMP::Info::NortelStack for details.
See documentation in L<SNMP::Info::NortelStack/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See documentation in L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -504,18 +504,18 @@ Returns reference to hash. Key: Table entry, Value: VLAN Type
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::NortelStack
See documentation in SNMP::Info::NortelStack for details.
See documentation in L<SNMP::Info::NortelStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See documentation in L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=cut

256
Info/Layer2/Cisco.pm Normal file
View File

@@ -0,0 +1,256 @@
# SNMP::Info::Layer2::Cisco
# Max Baker
#
# Copyright (c) 2006 Max Baker
#
# 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;
# $Id$
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;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = '1.07';
@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//;
%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

@@ -26,7 +26,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Foundry;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -209,7 +209,7 @@ __END__
=head1 NAME
SNMP::Info::Layer2::Foundry - Perl5 Interface to Foundry FastIron Network Devices
SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry FastIron Network Devices
=head1 AUTHOR
@@ -217,19 +217,7 @@ Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $foundry = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
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";
This module is Deprecated. Please use Layer3::Foundry instead.
=head1 DESCRIPTION
@@ -269,13 +257,13 @@ These are methods that return scalar value from SNMP
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::FDP
See documentation in SNMP::Info::FDP for details.
See documentation in L<SNMP::Info::FDP/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -290,10 +278,10 @@ to a hash.
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::FDP
See documentation in SNMP::Info::FDP for details.
See documentation in L<SNMP::Info::FDP/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::HP;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -38,30 +38,31 @@ use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::MAU;
use SNMP::Info::Entity;
use SNMP::Info::LLDP;
use SNMP::Info::CDP;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $INIT/ ;
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer2 SNMP::Info::MAU SNMP::Info::Entity
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer2 SNMP::Info::MAU SNMP::Info::LLDP
SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::HP::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::MAU::MIBS,
%SNMP::Info::Entity::MIBS,
%SNMP::Info::LLDP::MIBS,
%SNMP::Info::CDP::MIBS,
'RFC1271-MIB' => 'logDescription',
'HP-ICF-OID' => 'hpSwitch4000',
'HP-VLAN' => 'hpVlanMemberIndex',
'RFC1271-MIB' => 'logDescription',
'HP-ICF-OID' => 'hpSwitch4000',
'HP-VLAN' => 'hpVlanMemberIndex',
'STATISTICS-MIB' => 'hpSwitchCpuStat',
'NETSWITCH-MIB' => 'hpMsgBufFree',
'NETSWITCH-MIB' => 'hpMsgBufFree',
'CONFIG-MIB' => 'hpSwitchConfig',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'serial1' => 'entPhysicalSerialNum.1',
'hp_cpu' => 'hpSwitchCpuStat.0',
@@ -77,7 +78,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $I
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::MAU::FUNCS,
%SNMP::Info::Entity::FUNCS,
%SNMP::Info::LLDP::FUNCS,
%SNMP::Info::CDP::FUNCS,
'bp_index2' => 'dot1dBasePortIfIndex',
'i_type2' => 'ifType',
@@ -92,13 +93,16 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $I
'hp_v_mac' => 'hpVlanAddrPhysAddress',
'hp_v_if_index'=> 'hpVlanMemberIndex',
'hp_v_if_tag' => 'hpVlanMemberTagged2',
# CONFIG-MIB::hpSwitchPortTable
'hp_duplex' => 'hpSwitchPortEtherMode',
'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::MAU::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::LLDP::MUNGE,
%SNMP::Info::CDP::MUNGE
);
@@ -137,15 +141,20 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $I
'J8165A' => '2650-PWR',
'J8433A' => 'CX4-6400cl-6XG',
'J8474A' => 'MF-6400cl-6XG',
'J8697A' => '5406zl',
'J8698A' => '5412zl',
'J8718A' => '5404yl',
'J8719A' => '5408yl',
'J8770A' => '4204vl',
'J8773A' => '4208vl',
'J8680A' => '9608sl',
'J8762A' => '2600-8-PWR',
'J8692A' => '3500yl-24G-PWR',
'J8693A' => '3500yl-48G-PWR',
);
# Method Overrides
*SNMP::Info::Layer2::HP::i_duplex = \&SNMP::Info::MAU::mau_i_duplex;
*SNMP::Info::Layer2::HP::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin;
sub cpu {
my $hp = shift;
return $hp->hp_cpu();
@@ -214,27 +223,6 @@ sub interfaces {
}
sub i_type {
my $hp = shift;
my $e_descr = $hp->e_descr();
my $e_port = $hp->e_port();
# Grab default values to pass through
my $i_type = $hp->i_type2();
# Now Stuff in the entity-table values
foreach my $port (keys %$e_descr){
my $iid = $e_port->{$port};
next unless defined $iid;
my $type = $e_descr->{$port};
$type =~ s/^HP ?//;
$i_type->{$iid} = $type;
}
return $i_type;
}
sub i_name {
my $hp = shift;
my $i_alias = $hp->i_alias();
@@ -257,6 +245,37 @@ sub i_name {
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';
}
@@ -300,11 +319,62 @@ sub slots {
#
#}
# Bridge MIB does not map Bridge Port to ifIndex correctly on all models
sub bp_index {
my $hp = shift;
my $partial = shift;
my $if_index = $hp->i_index($partial);
my $model = $hp->model();
my $bp_index = $hp->bp_index2($partial);
unless (defined $model and $model =~ /(1600|2424|4000|8000)/) {
return $bp_index;
}
my %mod_bp_index;
foreach my $iid (keys %$if_index){
$mod_bp_index{$iid} = $iid;
}
return \%mod_bp_index;
}
# VLAN methods. Newer HPs use Q-BRIDGE, older use proprietary MIB. Use
# Q-BRIDGE if available.
sub v_index {
my $hp = shift;
my $partial = shift;
# Newer devices
my $q_index = $hp->SUPER::v_index($partial);
if (defined $q_index and scalar(keys %$q_index)){
return $q_index;
}
# Older devices
return $hp->hp_v_index($partial);
}
sub v_name {
my $hp = shift;
my $partial = shift;
# Newer devices
my $q_name = $hp->SUPER::v_name($partial);
if (defined $q_name and scalar(keys %$q_name)){
return $q_name;
}
# Older devices
return $hp->hp_v_name($partial);
}
sub i_vlan {
my $hp = shift;
# Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->qb_i_vlan_t();
my $qb_i_vlan = $hp->SUPER::i_vlan();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
return $qb_i_vlan;
}
@@ -321,34 +391,329 @@ sub i_vlan {
my $tag = $hp_v_if_tag->{$row};
my $vlan = $hp_v_index->{$index};
next unless defined $tag;
$vlan = 'Trunk' if $tag eq 'tagged';
$vlan = 'Auto' if $tag eq 'auto';
undef $vlan if $tag eq 'no';
next unless (defined $tag and $tag =~ /untagged/);
$i_vlan->{$if} = $vlan if defined $vlan;
}
return $i_vlan;
}
# Bridge MIB does not map Bridge Port to ifIndex correctly on all models
sub bp_index {
sub i_vlan_membership {
my $hp = shift;
my $if_index = $hp->i_index();
my $model = $hp->model();
my $bp_index = $hp->bp_index2();
unless (defined $model and $model =~ /(1600|2424|4000|8000)/) {
return $bp_index;
# Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->SUPER::i_vlan_membership();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
return $qb_i_vlan;
}
my %mod_bp_index;
foreach my $iid (keys %$if_index){
$mod_bp_index{$iid} = $iid;
# Older get it from HP-VLAN
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 \%mod_bp_index;
return $i_vlan_membership;
}
sub set_i_vlan {
my $hp = shift;
my ($vlan, $ifindex) = @_;
unless ( defined $vlan and defined $ifindex and
$vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) {
$hp->error_throw("Invalid parameter");
return undef;
}
# Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->qb_i_vlan_t();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
return $hp->SUPER::set_i_vlan($vlan, $ifindex);
} # We're done here if the device supports the Q-BRIDGE-MIB
# Older HP switches use the HP-VLAN MIB
# Thanks to Jeroen van Ingen
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 $old_untagged;
# Hash to lookup VLAN index of the VID (dot1q tag)
my %vl_trans = reverse %$hp_v_index;
foreach my $row (keys %$hp_v_if_tag){
# Loop through table to determine current untagged vlan for the port we're about to change
my ($index,$if) = split(/\./,$row);
if ($if == $ifindex 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;
my $rv = $hp->set_hp_v_if_tag(1, $row);
warn "Unexpected error changing native/untagged VLAN into tagged.\n" unless $rv;
last;
}
}
# 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 untagged in the desired VLAN
my $rv = $hp->set_hp_v_if_tag(2, "$vlan_index.$ifindex");
if ($rv) {
# If port change is successful, remove VLAN that used to be untagged from the port
$hp->set_hp_v_if_tag(3, $old_untagged) if defined $old_untagged;
return $rv;
} else {
# If not, try to revert to the old situation.
$hp->set_hp_v_if_tag(2, $old_untagged) if defined $old_untagged;
}
}
else {
warn "Requested VLAN (VLAN ID: $vlan) not found!\n";
}
}
print "Error: Unable to change VLAN: $vlan on IfIndex: $ifindex list\n" if $hp->debug();
return undef;
}
sub set_i_pvid {
my $hp = shift;
my ($vlan, $ifindex) = @_;
unless ( defined $vlan and defined $ifindex and
$vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) {
$hp->error_throw("Invalid parameter");
return undef;
}
# Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->qb_i_vlan_t();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
return $hp->SUPER::set_i_pvid($vlan, $ifindex);
}
# HP method same as set_i_vlan()
return $hp->set_i_vlan($vlan, $ifindex);
}
sub set_add_i_vlan_tagged {
my $hp = shift;
my ($vlan, $ifindex) = @_;
unless ( defined $vlan and defined $ifindex and
$vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) {
$hp->error_throw("Invalid parameter");
return undef;
}
# Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->qb_i_vlan();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
return $hp->SUPER::set_add_i_vlan_tagged($vlan, $ifindex);
} # We're done here if the device supports the Q-BRIDGE-MIB
# Older HP switches use the HP-VLAN MIB
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)){
# 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) {
# Add port to egress list for VLAN
my $rv = ($hp->set_hp_v_if_tag(1, "$vlan_index.$ifindex"));
if ($rv) {
print "Successfully added IfIndex: $ifindex to VLAN: $vlan list\n" if $hp->debug();
return 1;
}
}
else {
$hp->error_throw("Requested VLAN (VLAN ID: $vlan) not found!\n");
}
}
print "Error: Unable to add VLAN: $vlan to IfIndex: $ifindex list\n" if $hp->debug();
return undef;
}
sub set_remove_i_vlan_tagged {
my $hp = shift;
my ($vlan, $ifindex) = @_;
unless ( defined $vlan and defined $ifindex and
$vlan =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) {
$hp->error_throw("Invalid parameter");
return undef;
}
# Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->qb_i_vlan();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
return $hp->SUPER::set_remove_i_vlan_tagged($vlan, $ifindex);
} # We're done here if the device supports the Q-BRIDGE-MIB
# Older HP switches use the HP-VLAN MIB
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)){
# 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) {
# Add port to egress list for VLAN
my $rv = ($hp->set_hp_v_if_tag(3, "$vlan_index.$ifindex"));
if ($rv) {
print "Successfully added IfIndex: $ifindex to VLAN: $vlan list\n" if $hp->debug();
return 1;
}
}
else {
$hp->error_throw("Requested VLAN (VLAN ID: $vlan) not found!\n");
}
}
print "Error: Unable to remove VLAN: $vlan to IfIndex: $ifindex list\n" if $hp->debug();
return undef;
}
# Use CDP and/or LLDP
sub hasCDP {
my $hp = shift;
return $hp->hasLLDP() || $hp->SUPER::hasCDP();
}
sub c_ip {
my $hp = shift;
my $partial = shift;
my $cdp = $hp->SUPER::c_ip($partial) || {};
my $lldp = $hp->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 $hp = shift;
my $partial = shift;
my $lldp = $hp->lldp_if($partial) || {};;
my $cdp = $hp->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 $hp = shift;
my $partial = shift;
my $lldp = $hp->lldp_port($partial) || {};
my $cdp = $hp->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 $hp = shift;
my $partial = shift;
my $lldp = $hp->lldp_id($partial) || {};
my $cdp = $hp->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 $hp = shift;
my $partial = shift;
my $lldp = $hp->lldp_rem_sysdesc($partial) || {};
my $cdp = $hp->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;
@@ -398,7 +763,7 @@ a more specific class using the method above.
=item SNMP::Info::Layer2
=item SNMP::Info::Entity
=item SNMP::Info::LLDP
=item SNMP::Info::MAU
@@ -422,9 +787,11 @@ Included in V2 mibs from Cisco
=item NETSWITCH-MIB
=item CONFIG-MIB
=back
The last three MIBs listed are from HP and can be found at L<http://www.hp.com/rnd/software>
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 ChangeLog
@@ -497,10 +864,17 @@ the common model number with this map :
'J8165A' => '2650-PWR',
'J8433A' => 'CX4-6400cl-6XG',
'J8474A' => 'MF-6400cl-6XG',
'J8697A' => '5406zl',
'J8698A' => '5412zl',
'J8718A' => '5404yl',
'J8719A' => '5408yl',
);
'J8770A' => '4204vl',
'J8773A' => '4208vl',
'J8680A' => '9608sl',
'J8762A' => '2600-8-PWR',
'J8692A' => '3500yl-24G-PWR',
'J8693A' => '3500yl-48G-PWR',
);
=item $hp->os()
@@ -535,15 +909,15 @@ hp
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
=head2 Globals imported from SNMP::Info::LLDP
See documentation in SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::LLDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head1 TABLE METHODS
@@ -560,28 +934,42 @@ Uses $hp->i_description()
=item $hp->i_duplex()
Maps $hp->mau_index() with $hp->mau_link(). Methods inherited from
SNMP::Info::MAU.
Returns reference to map of IIDs to current link duplex.
=item $hp->i_duplex_admin()
Maps $hp->mau_index() with $hp->mau_auto(), $hp->mau_autostat(),
$hp->typeadmin(), and $mau_autosent(). Methods inherited from
SNMP::Info::MAU.
Returns reference to hash of IIDs to admin duplex setting.
=item $hp->i_name()
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
=item $hp->i_type()
Crosses i_type() with $hp->e_descr() using $hp->e_port()
=item $hp->i_vlan()
Looks in Q-BRIDGE-MIB -- see SNMP::Info::Bridge
Returns a mapping between ifIndex and the PVID (default VLAN) or untagged
port when using HP-VLAN.
and for older devices looks in HP-VLAN.
Looks in Q-BRIDGE-MIB first (L<SNMP::Info::Bridge/"TABLE METHODS">) and for
older devices looks in HP-VLAN.
=item $hp->i_vlan_membership()
Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs.
These are the VLANs which are members of the egress list for the port. It
is the union of tagged, untagged, and auto ports when using HP-VLAN.
Looks in Q-BRIDGE-MIB first (L<SNMP::Info::Bridge/"TABLE METHODS">) and for
older devices looks in HP-VLAN.
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->bp_index()
@@ -592,16 +980,113 @@ since they seem to have problems with BRIDGE-MIB
=back
=head2 Topology information
Based upon the firmware version HP devices may support Cisco Discovery
Protocol (CDP), Link Layer Discovery Protocol (LLDP), or both. 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 de-duplicate if necessary.
=over
=item $hp->hasCDP()
Returns true if the device is running either CDP or LLDP.
=item $hp->c_if()
Returns reference to hash. Key: iid Value: local device port (interfaces)
=item $hp->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 $hp->c_port()
Returns reference to hash. Key: iid Value: remote port (interfaces)
=item $hp->c_id()
Returns reference to hash. Key: iid Value: string value used to identify the
chassis component associated with the remote system.
=item $hp->c_platform()
Returns reference to hash. Key: iid Value: Remote Device Type
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
=head2 Table Methods imported from SNMP::Info::LLDP
See documentation in SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::LLDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
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 $hp->set_i_vlan(vlan, ifIndex)
Changes an untagged port VLAN, must be supplied with the numeric VLAN
ID and port ifIndex. This method will modify the port's VLAN membership.
This method should only be used on end station (non-trunk) ports.
Example:
my %if_map = reverse %{$hp->interfaces()};
$hp->set_i_vlan('2', $if_map{'1.1'})
or die "Couldn't change port VLAN. ",$hp->error(1);
=item $hp->set_i_pvid(pvid, ifIndex)
Sets port PVID or default VLAN, must be supplied with the numeric VLAN ID and
port ifIndex. This method only changes the PVID, to modify an access (untagged)
port use set_i_vlan() instead.
Example:
my %if_map = reverse %{$hp->interfaces()};
$hp->set_i_pvid('2', $if_map{'1.1'})
or die "Couldn't change port PVID. ",$hp->error(1);
=item $hp->set_add_i_vlan_tagged(vlan, ifIndex)
Adds the port to the egress list of the VLAN, must be supplied with the numeric
VLAN ID and port ifIndex.
Example:
my %if_map = reverse %{$hp->interfaces()};
$hp->set_add_i_vlan_tagged('2', $if_map{'1.1'})
or die "Couldn't add port to egress list. ",$hp->error(1);
=item $hp->set_remove_i_vlan_tagged(vlan, ifIndex)
Removes the port from the egress list of the VLAN, must be supplied with the
numeric VLAN ID and port ifIndex.
Example:
my %if_map = reverse %{$hp->interfaces()};
$hp->set_remove_i_vlan_tagged('2', $if_map{'1.1'})
or die "Couldn't add port to egress list. ",$hp->error(1);
=cut

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::N2270;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
@@ -156,13 +156,13 @@ my $n2270 = new SNMP::Info::Layer2::N2270(...);
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::SONMP for its own MIB requirements.
See L<SNMP::Info::SONMP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::Airespace for its own MIB requirements.
See L<SNMP::Info::Airespace/"Required MIBs"> for its own MIB requirements.
=back
@@ -207,21 +207,21 @@ start at 0. Returns 0.
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See documentation in L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::Airespace
See documentation in SNMP::Info::Airespace for details.
See documentation in L<SNMP::Info::Airespace/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -236,18 +236,18 @@ to a hash.
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See documentation in L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Airespace
See documentation in SNMP::Info::Airespace for details.
See documentation in L<SNMP::Info::Airespace/"TABLE METHODS"> for details.
=cut

View File

@@ -28,29 +28,29 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::NAP222x;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
use SNMP::Info::IEEE802dot11;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::NAP222x::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP Exporter/;
@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 $AUTOLOAD $INIT $DEBUG/;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::IEEE802dot11::MIBS,
%SNMP::Info::SONMP::MIBS,
'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::IEEE802dot11::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
'nt_hw_ver' => 'ntWlanSwHardwareVer',
'nt_fw_ver' => 'ntWlanSwBootRomVer',
@@ -68,21 +68,23 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::IEEE802dot11::FUNCS,
%SNMP::Info::SONMP::FUNCS,
'i_name2' => 'ifName',
'bp_index_2' => 'dot1dTpFdbPort',
# From ntWlanPortTable
'nt_prt_name' => 'ntWlanPortName',
'nt_dpx_admin' => 'ntWlanPortCapabilities',
'nt_auto' => 'ntWlanPortAutonegotiation',
'nt_dpx' => 'ntWlanPortSpeedDpxStatus',
'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::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::IEEE802dot11::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
@@ -90,17 +92,6 @@ sub os {
return 'nortel';
}
sub os_ver {
my $nap222x = shift;
my $ver = $nap222x->nt_sw_ver();
return undef unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub os_bin {
my $nap222x = shift;
my $bin = $nap222x->nt_fw_ver();
@@ -112,10 +103,6 @@ sub os_bin {
return undef;
}
sub vendor {
return 'nortel';
}
sub model {
my $nap222x = shift;
my $descr = $nap222x->description();
@@ -123,7 +110,6 @@ sub model {
return 'AP-2220' if ($descr =~ /2220/);
return 'AP-2221' if ($descr =~ /2221/);
return 'AP-2225' if ($descr =~ /2225/);
return undef;
}
@@ -153,23 +139,12 @@ sub serial {
return undef;
}
sub i_ignore {
my $nap222x = shift;
my $descr = $nap222x->i_description();
my %i_ignore;
foreach my $if (keys %$descr){
my $type = $descr->{$if};
# Skip virtual interfaces
$i_ignore{$if}++ if $type =~ /(loopback|lo|other)/i;
}
return \%i_ignore;
}
sub interfaces {
my $nap222x = shift;
my $interfaces = $nap222x->i_index();
my $description = $nap222x->i_description();
my $partial = shift;
my $interfaces = $nap222x->i_index($partial) || {};
my $description = $nap222x->i_description($partial) || {};
my %interfaces = ();
foreach my $iid (keys %$interfaces){
@@ -184,10 +159,11 @@ sub interfaces {
sub i_duplex {
my $nap222x = shift;
my $partial = shift;
my $mode = $nap222x->nt_dpx();
my $port_name = $nap222x->nt_prt_name();
my $interfaces = $nap222x->interfaces();
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){
@@ -210,11 +186,12 @@ sub i_duplex {
sub i_duplex_admin {
my $nap222x = shift;
my $dpx_admin = $nap222x->nt_dpx_admin();
my $nt_auto = $nap222x->nt_auto();
my $interfaces = $nap222x->interfaces();
my $port_name = $nap222x->nt_prt_name();
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){
@@ -239,12 +216,14 @@ sub i_duplex_admin {
sub i_name {
my $nap222x = shift;
my $interfaces = $nap222x->interfaces();
my $partial = shift;
my $interfaces = $nap222x->interfaces($partial) || {};
my %i_name;
foreach my $if (keys %$interfaces){
my $desc = $interfaces->{$if};
next unless defined $desc;
next unless defined $desc;
my $name = 'unknown';
$name = 'Ethernet Interface' if $desc =~ /dp/i;
@@ -259,7 +238,9 @@ sub i_name {
# dot1dBasePortTable does not exist and dot1dTpFdbPort does not map to ifIndex
sub bp_index {
my $nap222x = shift;
my $interfaces = $nap222x->interfaces();
my $partial = shift;
my $interfaces = $nap222x->interfaces($partial) || {};
my %bp_index;
foreach my $iid (keys %$interfaces){
@@ -275,12 +256,112 @@ sub bp_index {
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
SNMP::Info::Layer2::NAP222x - SNMP Interface to Nortel 2220 Series Access Points
=head1 AUTHOR
@@ -299,7 +380,7 @@ Eric Miller
)
or die "Can't connect to DestHost.\n";
my $class = $nap222x->class();
my $class = $nap222x->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -310,18 +391,18 @@ Provides abstraction to the configuration information obtainable from a Nortel
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(...);
my $nap222x = new SNMP::Info::Layer2::NAP222x(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::SONMP
=item SNMP::Info::IEEE802dot11
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
@@ -330,24 +411,16 @@ a more specific class using the method above.
=item NORTEL-WLAN-AP-MIB
=item Inherited classes
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See SNMP::Info::SONMP for its own MIB requirements.
=back
MIBs can be found on the CD that came with your product.
=head2 Inherited MIBs
Or, they can be downloaded directly from Nortel Networks regardless of support
contract status.
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.
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
Select by Product Families, Wireless LAN, WLAN - Access Point 2220, Software.
Filter on mibs and download the latest version's archive.
=head1 GLOBALS
@@ -355,21 +428,13 @@ These are methods that return scalar value from SNMP
=over
=item $nap222x->vendor()
Returns 'Nortel'
=item $nap222x->model()
Returns the model extracted from B<sysDescr>.
=item $nap222x->os()
Returns 'Nortel'
=item $nap222x->os_ver()
Returns the software version extracted from B<ntWlanSwOpCodeVer>.
Returns 'nortel'
=item $nap222x->os_bin()
@@ -387,65 +452,65 @@ Returns the MAC address of the first Ethernet Interface.
Returns the hardware version.
B<ntWlanSwHardwareVer>
(B<ntWlanSwHardwareVer>)
=item $nap222x->nt_cc()
Returns the country code of the AP.
B<ntWlanSwHardwareVer>
(B<ntWlanSwHardwareVer>)
=item $nap222x->tftp_action()
B<ntWlanTransferStart>
(B<ntWlanTransferStart>)
=item $nap222x->tftp_host()
B<ntWlanFileServer>
(B<ntWlanFileServer>)
=item $nap222x->tftp_file()
B<ntWlanDestFile>
(B<ntWlanDestFile>)
=item $nap222x->tftp_type()
B<ntWlanFileType>
(B<ntWlanFileType>)
=item $nap222x->tftp_result()
B<ntWlanFileTransferStatus>
(B<ntWlanFileTransferStatus>)
=item $nap222x->tftp_xtype()
B<ntWlanTransferType>
(B<ntWlanTransferType>)
=item $nap222x->tftp_src_file()
B<ntWlanSrcFile>
(B<ntWlanSrcFile>)
=item $nap222x->ftp_user()
B<ntWlanUserName>
(B<ntWlanUserName>)
=item $nap222x->ftp_pass()
B<ntWlanPassword>
(B<ntWlanPassword>)
=back
=head2 Globals imported from SNMP::Info
=head2 Globals imported from SNMP::Info::SONMP
See documentation in SNMP::Info for details.
See L<SNMP::Info::SONMP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
=head2 Global Methods imported from SNMP::Info::IEEE802dot11
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::IEEE802dot11/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::SONMP
=head2 Global Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::SONMP for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -458,21 +523,17 @@ to a hash.
Returns reference to map of IIDs to physical ports.
=item $nap222x->i_ignore()
Returns reference to hash of IIDs to ignore.
=item $nap222x->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs.
B<ntWlanPortSpeedDpxStatus>
(B<ntWlanPortSpeedDpxStatus>)
=item $nap222x->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs.
B<ntWlanPortCapabilities>
(B<ntWlanPortCapabilities>)
=item $nap222x->i_name()
@@ -483,18 +544,37 @@ Returns a human name based upon port description.
Returns a mapping between ifIndex and the Bridge Table. This does not exist in
the MIB and bridge port index is not the same as 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 VID of the radio interfaces.
(B<ntWlanApVlanDefaultVid>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
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

183
Info/Layer2/Netgear.pm Normal file
View File

@@ -0,0 +1,183 @@
# SNMP::Info::Layer2::Netgear
# Bill Fenner and Zoltan Erszenyi
#
#
# 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;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/;
$VERSION = '1.07';
@SNMP::Info::Layer2::Netgear::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Netgear::EXPORT_OK = qw//;
%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,
# 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 = $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 Table Methods imported from SNMP::Info::Layer2
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -2,7 +2,7 @@
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 Eric Miller
# Copyright (c) 2004 Eric Miller
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -28,36 +28,42 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Orinoco;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::IEEE802dot11;
use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Orinoco::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@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 $AUTOLOAD $INIT $DEBUG/;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::IEEE802dot11::MIBS,
#'ORiNOCO-MIB' => 'orinoco',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::IEEE802dot11::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::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::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::IEEE802dot11::MUNGE,
);
sub os {
@@ -66,6 +72,7 @@ sub os {
sub os_ver {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
@@ -81,6 +88,7 @@ sub os_ver {
sub os_bin {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
@@ -100,6 +108,7 @@ sub vendor {
sub model {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
@@ -110,6 +119,7 @@ sub model {
sub serial {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
@@ -119,7 +129,9 @@ sub serial {
sub i_ignore {
my $orinoco = shift;
my $descr = $orinoco->i_description();
my $partial = shift;
my $descr = $orinoco->i_description($partial) || {};
my %i_ignore;
foreach my $if (keys %$descr){
@@ -132,8 +144,10 @@ sub i_ignore {
sub interfaces {
my $orinoco = shift;
my $interfaces = $orinoco->i_index();
my $descriptions = $orinoco->i_description();
my $partial = shift;
my $interfaces = $orinoco->i_index($partial) || {};
my $descriptions = $orinoco->i_description($partial) || {};
my %interfaces = ();
foreach my $iid (keys %$interfaces){
@@ -148,6 +162,22 @@ sub interfaces {
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__
@@ -172,13 +202,14 @@ Eric Miller
)
or die "Can't connect to DestHost.\n";
my $class = $orinoco->class();
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 a Orinoco
Access Point through SNMP.
Access Point through SNMP. Orinoco devices have been maufactured 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.
@@ -189,9 +220,9 @@ determining a more specific class using the method above.
=over
=item SNMP::Info
=item SNMP::Info::Layer2
=item SNMP::Info::Bridge
=item SNMP::Info::IEEE802dot11
=back
@@ -199,14 +230,16 @@ determining a more specific class using the method above.
=over
=item Inherited classes
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
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
@@ -215,7 +248,7 @@ These are methods that return scalar value from SNMP
=item $orinoco->vendor()
Returns 'Proxim' :)
Returns 'proxim'
=item $orinoco->model()
@@ -239,15 +272,15 @@ Returns the serial number extracted from B<sysDescr>.
=back
=head2 Globals imported from SNMP::Info
=head2 Global Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info for details.
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
=head2 Global Methods imported from SNMP::Info::IEEE802dot11
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::IEEE802dot11/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -266,12 +299,12 @@ Returns reference to hash of IIDs to ignore.
=back
=head2 Table Methods imported from SNMP::Info
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info for details.
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
=head2 Table Methods imported from SNMP::Info::IEEE802dot11
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::IEEE802dot11/"TABLE METHODS"> for details.
=cut

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::ZyXEL_DSLAM;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -161,7 +161,7 @@ This MIB assumedly obtainable through ZyXEL or possibly included with your devic
=item Inherited Classes
MIBs listed in SNMP::Info::Layer2 and their inherited classes.
MIBs listed in L<SNMP::Info::Layer2/"Required MIBs"> and their inherited classes.
=back
@@ -199,9 +199,9 @@ Trys to cull out model out of the description field.
=head2 Global Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
=head2 Overrides
@@ -219,6 +219,6 @@ Returns reference to map of IIDs to human-set port description (profile name).
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
See documentation in L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -40,17 +40,20 @@ use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::EtherLike;
use SNMP::Info::Entity;
use SNMP::Info::PowerEthernet;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
@SNMP::Info::Layer3::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::EtherLike
SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::ISA = qw/SNMP::Info::PowerEthernet
SNMP::Info::Entity SNMP::Info::EtherLike
SNMP::Info::Bridge SNMP::Info Exporter/;
@SNMP::Info::Layer3::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::EtherLike::MIBS,
%SNMP::Info::Entity::MIBS,
%SNMP::Info::PowerEthernet::MIBS,
'IP-MIB' => 'ipNetToMediaIfIndex',
'OSPF-MIB' => 'ospfRouterId',
'BGP4-MIB' => 'bgpIdentifier',
@@ -62,6 +65,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::PowerEthernet::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',
@@ -74,8 +78,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::Entity::FUNCS,
# IFMIB
'i_name2' => 'ifName',
%SNMP::Info::PowerEthernet::FUNCS,
# Obsolete Address Translation Table (ARP Cache)
'old_at_index' => 'atIfIndex',
'old_at_paddr' => 'atPhysAddress',
@@ -84,9 +87,20 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# OSPF
'ospf_ip' => 'ospfHostIpAddress',
# BGP Peer Table
# 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',
@@ -106,8 +120,9 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE,
'old_at_paddr' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
);
@@ -136,8 +151,9 @@ sub root_ip {
sub i_ignore {
my $l3 = shift;
my $partial = shift;
my $interfaces = $l3->interfaces();
my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore;
foreach my $if (keys %$interfaces) {
@@ -191,9 +207,11 @@ sub model {
sub i_name {
my $l3 = shift;
my $i_index = $l3->i_index();
my $i_alias = $l3->i_alias();
my $i_name2 = $l3->i_name2();
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 %i_name;
foreach my $iid (keys %$i_name2){
@@ -209,9 +227,10 @@ sub i_name {
sub i_duplex {
my $l3 = shift;
my $el_index = $l3->el_index();
my $el_duplex = $l3->el_duplex();
my $partial = shift;
my $el_index = $l3->el_index($partial);
my $el_duplex = $l3->el_duplex($partial);
my %i_index;
foreach my $el_port (keys %$el_duplex){
@@ -231,8 +250,10 @@ sub i_duplex {
# $l3->interfaces() - Map the Interfaces to their physical names
sub interfaces {
my $l3 = shift;
my $interfaces = $l3->i_index();
my $descriptions = $l3->i_description();
my $partial = shift;
my $interfaces = $l3->i_index($partial);
my $descriptions = $l3->i_description($partial);
my %interfaces = ();
foreach my $iid (keys %$interfaces){
@@ -257,30 +278,33 @@ sub vendor {
sub at_index {
my $l3 = shift;
my $partial = shift;
return $l3->orig_at_index() || $l3->old_at_index();
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() || $l3->old_at_paddr();
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() || $l3->old_at_netaddr();
return $l3->orig_at_netaddr($partial) || $l3->old_at_netaddr($partial);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3 - Perl5 Interface to network devices serving Layer3 or Layers 2 & 3
SNMP::Info::Layer3 - SNMP Interface to network devices serving Layer3 or
Layers 2 & 3
=head1 AUTHOR
@@ -299,7 +323,7 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $l3->class();
my $class = $l3->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
@@ -315,14 +339,15 @@ Max Baker
=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.
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.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $l3 = new SNMP::Info::Layer3(...);
@@ -332,28 +357,36 @@ a more specific class using the method above.
=item SNMP::Info
=item SNMP::Info::Bridge
For L2/L3 devices.
=item SNMP::Info::Bridge (For L2/L3 devices)
=item SNMP::Info::EtherLike
=item SNMP::Info::Entity
=back
=head2 Required MIBs
=over
=item IP-MIB
=item OSPF-MIB
=item BGP4-MIB
=item Inherited Classes
MIBs required by the inherited classes listed above.
=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.
MIBs can be found in the netdisco-mibs package.
=head1 GLOBALS
@@ -404,25 +437,31 @@ Trys to cull a serial number from ENTITY-MIB, description, and OLD-CISCO-... mib
Trys to cull a Vendor name from B<sysDescr>
=item $l3->root_ip()
Returns the primary IP used to communicate with the device. Returns the first
found: OSPF Router ID (B<ospfRouterId>) or any OSPF Host IP Address
(B<ospfHostIpAddress>).
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
See L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
=head2 Global Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::EtherLike
=head2 Global Methods imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
See L<SNMP::Info::EtherLike/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Entity
=head2 Global Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
See L<SNMP::Info::Entity/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -456,7 +495,7 @@ 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 SNMP::Info::Etherlike for the el_index() and el_duplex() methods.
See L<SNMP::Info::Etherlike> for the el_index() and el_duplex() methods.
=back
@@ -520,7 +559,7 @@ Returns reference to hash of Arp Cache Entries to IP Address
=back
=head2 BGP Peer Table
=head2 BGP Peer Table (B<bgpPeerTable>)
=over
@@ -598,20 +637,94 @@ transmitted on this connection
=back
=head2 OSPF Interface Table (B<ospfIfTable>)
=over
=item $l3->ospf_if_ip()
Returns reference to hash of OSPF interface IP addresses
(B<ospfIfIpAddress>)
=item $l3->ospf_if_area()
Returns reference to hash of the OSPF area to which the interfaces connect
(B<ospfIfAreaId>)
=item $l3->ospf_if_type()
Returns reference to hash of the OSPF interfaces' type
(B<ospfIfType>)
=item $l3->ospf_if_hello()
Returns reference to hash of the OSPF interfaces' hello interval
(B<ospfIfHelloInterval>)
=item $l3->ospf_if_dead()
Returns reference to hash of the OSPF interfaces' dead interval
(B<ospfIfRtrDeadInterval>)
=item $l3->ospf_if_admin()
Returns reference to hash of the OSPF interfaces' administrative status
(B<ospfIfAdminStat>)
=item $l3->ospf_if_state()
Returns reference to hash of the OSPF interfaces' state
(B<ospfIfState>)
=back
=head2 OSPF Neighbor Table (B<ospfNbrTable>)
=over
=item $l3->ospf_peers()
Returns reference to hash of IP addresses the neighbor is using in its
IP Source Addresses
(B<ospfNbrIpAddr>)
=item $l3->ospf_peer_id()
Returns reference to hash of neighbor Router IDs
(B<ospfNbrRtrId>)
=item $l3->ospf_peer_state()
Returns reference to hash of state of the relationship with the neighbor
routers
(B<ospfNbrState>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
See L<SNMP::Info::EtherLike/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
See L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Aironet;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -313,9 +313,9 @@ Returns 'cisco'.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -389,6 +389,6 @@ B<awcIfMSDUMaxLength>
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -29,21 +29,23 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::AlteonAD;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Layer3;
use SNMP::Info::Bridge;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE /;
@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::Bridge::MIBS,
'ALTEON-TIGON-SWITCH-MIB' => 'agSoftwareVersion',
'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt',
@@ -52,6 +54,7 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE /;
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
'sw_ver' => 'agSoftwareVersion',
'tftp_action' => 'agTftpAction',
@@ -62,13 +65,8 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE /;
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'bp_index_2' => 'dot1dBasePortIfIndex',
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# From agPortCurCfgTable
'ag_p_cfg_idx' => 'agPortCurCfgIndx',
'ag_p_cfg_pref' => 'agPortCurCfgPrefLink',
@@ -86,8 +84,8 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE /;
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::Bridge::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub model {
@@ -236,7 +234,7 @@ sub i_name {
# Bridge MIB does not map Bridge Port to ifIndex correctly
sub bp_index {
my $alteon = shift;
my $b_index = $alteon->bp_index_2();
my $b_index = $alteon->orig_bp_index();
my %bp_index;
foreach my $iid (keys %$b_index){
@@ -317,9 +315,9 @@ the latest version's archive.
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See L<SNMP::Info::Bridge/"Required MIBs"> for its own MIB requirements.
=back
@@ -365,13 +363,13 @@ Returns the software version reported by B<agSoftwareVersion>
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -409,36 +407,12 @@ Returns a mapping between ifIndex and the Bridge Table.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $alteon->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $alteon->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $alteon->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
See documentation in L<SNMP::Info::Bridge/"TABLE METHODS"> for details.
=cut

File diff suppressed because it is too large Load Diff

View File

@@ -29,72 +29,76 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C3550;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CiscoStack;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoImage;
use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
@SNMP::Info::Layer3::C3550::ISA = qw/SNMP::Info::Layer3 SNMP::Info::CiscoStack SNMP::Info::CiscoVTP
SNMP::Info::CiscoStats SNMP::Info::CDP Exporter
SNMP::Info::CiscoImage/;
@SNMP::Info::Layer3::C3550::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack
SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoImage SNMP::Info::CiscoPower
SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::C3550::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
'ports2' => 'ifNumber',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoImage::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
# Pick and choose
*SNMP::Info::Layer3::C3550::serial = \&SNMP::Info::CiscoStack::serial;
*SNMP::Info::Layer3::C3550::interfaces = \&SNMP::Info::Layer3::interfaces;
*SNMP::Info::Layer3::C3550::i_duplex = \&SNMP::Info::CiscoStack::i_duplex;
*SNMP::Info::Layer3::C3550::i_duplex_admin = \&SNMP::Info::CiscoStack::i_duplex_admin;
*SNMP::Info::Layer3::C3550::i_name = \&SNMP::Info::Layer3::i_name;
*SNMP::Info::Layer3::C3550::i_type = \&SNMP::Info::CiscoStack::i_type;
sub vendor {
return 'cisco';
}
@@ -126,17 +130,101 @@ sub 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 {
$c3550->SUPER::set_i_duplex_admin;
}
}
sub cisco_comm_indexing {
1;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::C3550 - Perl5 Interface to Cisco Catalyst 3550 Layer 2/3 Switches running IOS
SNMP::Info::Layer3::C3550 - SNMP Interface to Cisco Catalyst 3550 Layer 2/3
Switches running IOS
=head1 AUTHOR
@@ -146,12 +234,12 @@ Max Baker
# Let SNMP::Info determine the correct subclass for you.
my $c3550 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
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";
@@ -162,12 +250,12 @@ Max Baker
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 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.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $c3550 = new SNMP::Info::Layer3::C3550(...);
@@ -177,6 +265,10 @@ a more specific class using the method above.
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoPower
=item SNMP::Info::CiscoPortSecurity
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
@@ -195,17 +287,21 @@ a more specific class using the method above.
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See L<SNMP::Info::CiscoPower/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStack for its own MIB requirements.
See L<SNMP::Info::CiscoPortSecurity/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoImage for its own MIB requirements.
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CDP 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::CDP/"Required MIBs"> for its own MIB requirements.
=back
@@ -234,55 +330,111 @@ Trys to cull the number of ports from the model number.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"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 SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
See documentation in L<SNMP::Info::CiscoStack/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=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.
=item $c3550->i_duplex_admin()
Returns reference to hash of iid to administrative duplex setting.
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 ifIndex.
Speed choices are 'auto', 'half', 'full'.
Crosses $c3550->p_port() with $c3550->p_duplex() to utilize port 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);
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"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::CiscoPortSecurity
See documentation in L<SNMP::Info::CiscoPortSecurity/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
See documentation in L<SNMP::Info::CiscoStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
See documentation in L<SNMP::Info::CiscoImage/"TABLE METHODS"> for details.
=cut

View File

@@ -33,37 +33,46 @@ package SNMP::Info::Layer3::C4000;
use strict;
use Exporter;
use SNMP::Info::Layer3;
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;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = '1.03';
@SNMP::Info::Layer3::C4000::ISA = qw/ SNMP::Info::Layer3 SNMP::Info::CiscoStack SNMP::Info::CiscoVTP
SNMP::Info::CiscoStats SNMP::Info::CDP
SNMP::Info::CiscoImage SNMP::Info::MAU Exporter/;
$VERSION = '1.07';
@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//;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoImage::MIBS,
%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::CiscoVTP::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoImage::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',
@@ -72,24 +81,29 @@ $VERSION = '1.03';
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoImage::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::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoImage::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;
@@ -115,7 +129,8 @@ __END__
=head1 NAME
SNMP::Info::Layer3::C4000 - Perl5 Interface to Cisco Catalyst 4000 Layer 2/3 Switches running IOS
SNMP::Info::Layer3::C4000 - SNMP Interface to Cisco Catalyst 4000 Layer 2/3
Switches running IOS
=head1 AUTHOR
@@ -125,12 +140,12 @@ Bill Fenner
# Let SNMP::Info determine the correct subclass for you.
my $c4000 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
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";
@@ -141,8 +156,8 @@ Bill Fenner
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.
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(...);
@@ -150,18 +165,22 @@ a more specific class using the method above.
=over
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStats
=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
@@ -170,17 +189,21 @@ a more specific class using the method above.
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CDP for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoImage for its own MIB requirements.
See L<SNMP::Info::CiscoPortSecurity/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::MAU 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
@@ -188,58 +211,73 @@ See SNMP::Info::MAU for its own MIB requirements.
These are methods that return scalar value from SNMP
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
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 SNMP::Info::MAU for details.
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
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 SNMP::Info::MAU for details.
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

@@ -33,79 +33,171 @@ package SNMP::Info::Layer3::C6500;
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::CiscoVTP;
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 vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = '1.03';
@SNMP::Info::Layer3::C6500::ISA = qw/ SNMP::Info::Layer3 SNMP::Info::CiscoStack SNMP::Info::CiscoVTP
SNMP::Info::CiscoStats SNMP::Info::CDP Exporter
SNMP::Info::CiscoImage/;
$VERSION = '1.07';
@SNMP::Info::Layer3::C6500::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack
SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoImage
SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoConfig
SNMP::Info::CiscoPower
SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::C6500::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStats::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::CiscoVTP::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::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::CiscoVTP::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStats::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::CiscoVTP::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::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::CiscoVTP::MUNGE,
);
# Pick and choose
*SNMP::Info::Layer3::C6500::serial = \&SNMP::Info::CiscoStack::serial;
*SNMP::Info::Layer3::C6500::interfaces = \&SNMP::Info::Layer3::interfaces;
*SNMP::Info::Layer3::C6500::i_duplex = \&SNMP::Info::CiscoStack::i_duplex;
#*SNMP::Info::Layer3::C6500::i_duplex_admin = \&SNMP::Info::Layer3::i_duplex_admin;
*SNMP::Info::Layer3::C6500::i_name = \&SNMP::Info::Layer3::i_name;
*SNMP::Info::Layer3::C6500::i_type = \&SNMP::Info::CiscoStack::i_type;
sub vendor {
return 'cisco';
}
# There are some buggy 6509's out there.
sub bulkwalk_no { 1; }
sub cisco_comm_indexing { 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 {
$c6500->SUPER::set_i_duplex_admin;
}
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::C6500 - Perl5 Interface to Cisco Catalyst 6500 Layer 2/3 Switches running IOS and/or CatOS
SNMP::Info::Layer3::C6500 - SNMP Interface to Cisco Catalyst 6500 Layer 2/3
Switches running IOS and/or CatOS
=head1 AUTHOR
@@ -115,12 +207,12 @@ Max Baker
# Let SNMP::Info determine the correct subclass for you.
my $c6500 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
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";
@@ -131,12 +223,12 @@ Max Baker
Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches.
These devices run IOS but have some of the same charactersitics as the Catalyst WS-C family (5xxx).
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 charactersitics as the Catalyst
WS-C family (5xxx). For example, forwarding tables are held in VLANs, and
extended interface information is gleened from 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.
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(...);
@@ -144,18 +236,24 @@ a more specific class using the method above.
=over
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
=item SNMP::Info::CiscoStats
=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
=back
=head2 Required MIBs
@@ -164,17 +262,23 @@ a more specific class using the method above.
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See L<SNMP::Info::CiscoStack/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStack for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CDP for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoImage 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.
=back
@@ -184,69 +288,128 @@ These are methods that return scalar value from SNMP
=over
=item $c6500->bulkwalk_no
Return C<1>. There are some buggy 6509's out there, so bulkwalk
is turned off for this class.
=item $c6500->vendor()
Returns 'cisco'
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
See documentation in L<SNMP::Info::CiscoStack/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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.
=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
=head2 Overrides
See documentation in SNMP::Info::Layer3 for details.
=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 ifIndex.
Speed choices are 'auto', 'half', 'full'.
Crosses $c6500->p_port() with $c6500->p_duplex() to utilize port 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 SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
See documentation in L<SNMP::Info::CiscoStack/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
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::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,7 +1,7 @@
# SNMP::Info::Layer3::Cisco
# Max Baker
#
# Copyright (c) 2004-6 Max Baker
# Copyright (c) 2004 Max Baker
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -32,68 +32,103 @@ package SNMP::Info::Layer3::Cisco;
use strict;
use Exporter;
use SNMP::Info::Layer3;
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;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = '1.03';
@SNMP::Info::Layer3::Cisco::ISA = qw/SNMP::Info::Layer3 SNMP::Info::CiscoVTP
SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoImage SNMP::Info::CiscoRTT
SNMP::Info::CiscoQOS Exporter/;
$VERSION = '1.07';
@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//;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoRTT::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::CiscoVTP::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoRTT::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::CiscoVTP::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoRTT::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::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoImage::MUNGE,
%SNMP::Info::CiscoRTT::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;
}
}
}
\%i_vlan;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Cisco - Perl5 Interface to L3 and L2+L3 IOS Cisco Device
SNMP::Info::Layer3::Cisco - SNMP Interface to L3 and L2+L3 IOS Cisco Device
that are not covered in other classes.
=head1 AUTHOR
@@ -104,12 +139,12 @@ Max Baker
# Let SNMP::Info determine the correct subclass for you.
my $cisco = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
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";
@@ -124,8 +159,6 @@ Subclass for Generic Cisco Routers running IOS
=over
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CDP
@@ -134,23 +167,43 @@ Subclass for Generic Cisco Routers running IOS
=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 CISCO-EIGRP-MIB
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See L<SNMP::Info::CiscoVTP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See L<SNMP::Info::CDP/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CDP for its own MIB requirements.
See L<SNMP::Info::CiscoImage/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::CiscoImage 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
@@ -164,51 +217,97 @@ These are methods that return scalar value from SNMP
Returns 'cisco'
=item $cisco->eigrp_id()
(B<cEigrpAsRouterId>)
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head2 Global Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
See documentation in L<SNMP::Info::CiscoImage/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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.
=head2 Table Methods imported from SNMP::Info::Layer3
=over
See documentation in SNMP::Info::Layer3 for details.
=item $cisco->eigrp_peers()
Returns EIGRP peer IP addresses
(B<cEigrpPeerAddr>)
=back
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
See documentation in L<SNMP::Info::CiscoVTP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
See documentation in L<SNMP::Info::CDP/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
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

@@ -29,43 +29,42 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Contivity;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Layer3;
use SNMP::Info::Entity;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::Contivity::ISA = qw/SNMP::Info SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::Contivity::ISA = qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//;
%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,
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::Entity::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub layers {
@@ -127,7 +126,9 @@ sub serial {
sub interfaces {
my $contivity = shift;
my $description = $contivity->i_description();
my $partial = shift;
my $description = $contivity->i_description($partial) || {};
my %interfaces = ();
foreach my $iid (keys %$description){
@@ -142,7 +143,9 @@ sub interfaces {
sub i_name {
my $contivity = shift;
my $i_name2 = $contivity->i_name2();
my $partial = shift;
my $i_name2 = $contivity->orig_i_name($partial) || {};
my %i_name;
foreach my $iid (keys %$i_name2){
@@ -162,8 +165,8 @@ __END__
=head1 NAME
SNMP::Info::Layer3::Contivity - Perl5 Interface to Nortel Networks' Contivity
Extranet Switches (CES).
SNMP::Info::Layer3::Contivity - SNMP Interface to Nortel VPN Routers (Contivity
Extranet Switches).
=head1 AUTHOR
@@ -182,15 +185,15 @@ Eric Miller
)
or die "Can't connect to DestHost.\n";
my $class = $contivity->class();
my $class = $contivity->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Nortel Networks' Contivity Extranet Switch (CES).
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.
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(...);
@@ -200,6 +203,8 @@ a more specific class using the method above.
=item SNMP::Info
=item SNMP::Info::Layer3
=item SNMP::Info::Entity
=back
@@ -210,9 +215,11 @@ a more specific class using the method above.
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See L<SNMP::Info/"Required MIBs"> for its own MIB requirements.
See SNMP::Info::Entity 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
@@ -265,13 +272,17 @@ layers.
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
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 SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -287,36 +298,16 @@ tunnel interfaces.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $contivity->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $contivity->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $contivity->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
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 SNMP::Info::Entity for details.
See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
=cut

374
Info/Layer3/Dell.pm Normal file
View File

@@ -0,0 +1,374 @@
# SNMP::Info::Layer3::Dell - SNMP Interface to Dell devices
# Eric Miller
#
# Copyright (c) 2006 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::Layer3::Dell;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '1.07';
@SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Dell::EXPORT_OK = qw//;
%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 bulkwalk_no { 1; }
sub model {
my $dell = shift;
my $name = $dell->dell_id_name();
if ($name =~ m/(\d+)/){
return $1;
}
return undef;
}
sub vendor {
return 'dell';
}
sub os {
return 'dell';
}
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;
}
return undef;
}
# Descriptions are all the same, so use name instead
sub interfaces {
my $dell = shift;
my $partial = shift;
my $interfaces = $dell->i_index($partial) || {};
my $names = $dell->orig_i_name($partial) || {};
my %interfaces = ();
foreach my $iid (keys %$interfaces){
my $name = $names->{$iid};
next unless defined $name;
$interfaces{$iid} = $name;
}
return \%interfaces;
}
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;
}
# Normal BRIDGE-MIB not working? Use Q-BRIDGE-MIB for macsuck
sub fw_mac {
my $dell = shift;
my $partial = shift;
return $dell->qb_fw_mac($partial);
}
sub fw_port {
my $dell = shift;
my $partial = shift;
return $dell->qb_fw_port($partial);
}
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,
# These arguments are passed directly on to SNMP::Session
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.
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 Dell-Vendor-MIB
=item RADLAN-Physicaldescription-MIB
=item RADLAN-rlInterfaces
=item 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()
(B<productIdentificationVersion>)
=item $dell->dell_id_name()
(B<productIdentificationDisplayName>)
=item $dell->model()
Returns model type. Returns numeric from (B<productIdentificationDisplayName>).
=item $dell->vendor()
Returns dell
=item $dell->os()
Returns dell
=back
=head2 Overrides
=over
=item $dell->bulkwalk_no
Return C<1>. Bulkwalk is currently turned off for this class.
=item $dell->serial()
Returns serial number. (B<rlPhdUnitGenParamSerialNum>)
=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 (B<swIfTable>)
=over
=item $dell->dell_duplex_admin()
(B<swIfDuplexAdminMode>)
=item $dell->dell_duplex()
(B<swIfDuplexOperMode>)
=item $dell->dell_tag_mode()
(B<swIfTaggedMode>)
=item $dell->dell_i_type()
(B<swIfType>)
=item $dell->dell_fc_admin()
(B<swIfFlowControlMode>)
=item $dell->dell_speed_admin()
(B<swIfSpeedAdminMode>)
=item $dell->dell_auto()
(B<swIfSpeedDuplexAutoNegotiation>)
=item $dell->dell_fc()
(B<swIfOperFlowControlMode>)
=back
=head2 Overrides
=over
=item $dell->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port name.
Uses name instead of description since descriptions are not unique.
Only returns those iids that have a name listed in $l3->i_name()
=item $dell->i_duplex_admin()
Returns reference to hash of iid to current link administrative duplex setting.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

506
Info/Layer3/Enterasys.pm Normal file
View File

@@ -0,0 +1,506 @@
# SNMP::Info::Layer3::Enterasys - SNMP Interface to Enterasys devices
# Eric Miller
#
# Copyright (c) 2007 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.
#
# 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;
# $Id$
use strict;
use Exporter;
use SNMP::Info::MAU;
use SNMP::Info::LLDP;
use SNMP::Info::CDP;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '1.07';
@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//;
%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 undef;
}
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 undef unless defined $descr;
if ($descr =~ m/\bRev ([\d.]*)/){
return $1;
}
return undef;
}
# 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
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($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 $enterasys = shift;
my $partial = shift;
my $lldp = $enterasys->lldp_if($partial) || {};;
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($partial) || {};
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($partial) || {};
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($partial) || {};
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,
# These arguments are passed directly on to SNMP::Session
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 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 ENTERASYS-OIDS-MIB.
=item $enterasys->vendor()
Returns enterasys
=item $enterasys->os()
Returns enterasys
=item $enterasys->mac()
Returns base mac
(B<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->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">.
=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 de-duplicate 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,5 +1,6 @@
# SNMP::Info::Layer3::Extreme - SNMP Interface to Extreme devices
# Eric Miller
# Bill Fenner
#
# Copyright (c) 2005 Eric Miller
#
@@ -40,7 +41,7 @@ use SNMP::Info::MAU;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '1.03';
$VERSION = '1.07';
@SNMP::Info::Layer3::Extreme::ISA = qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//;
@@ -50,37 +51,50 @@ $VERSION = '1.03';
'EXTREME-BASE-MIB' => 'extremeAgent',
'EXTREME-SYSTEM-MIB' => 'extremeSystem',
'EXTREME-FDB-MIB' => 'extremeSystem',
'EXTREME-VLAN-MIB' => 'extremeVlan',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
'serial' => 'extremeSystemID',
'temp' => 'extremeCurrentTemperature',
'ps1_status' => 'extremePowerSupplyStatus.1',
'fan' => 'extremeFanOperational.1',
'mac' => 'dot1dBaseBridgeAddress',
'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
'fw_mac' => 'extremeFdbMacFdbMacAddress',
'fw_port' => 'extremeFdbMacFdbPortIfIndex',
'fw_status' => 'extremeFdbMacFdbStatus',
'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',
);
%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
sub bulkwalk_no { 1; }
*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;
@@ -120,7 +134,48 @@ sub os_ver {
return undef;
}
# We're not using BRIDGE-MIB
#
# 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();
@@ -132,28 +187,301 @@ sub bp_index {
return \%bp_index;
}
# Index values in the Q-BRIDGE-MIB are the same
# as in the BRIDGE-MIB and do not match ifIndex.
sub munge_true_ok {
my $val = shift;
return undef 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 undef 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 undef if ($s eq "");
$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}));
}
}
\%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 $qb_i_vlan = $extreme->qb_i_vlan();
my $bp_index = $extreme->bp_index();
my %i_vlan;
foreach my $v_index (keys %$qb_i_vlan){
my $vlan = $qb_i_vlan->{$v_index};
my $iid = $bp_index->{$v_index};
unless (defined $iid) {
print " Port $v_index has no bp_index mapping. Skipping\n"
if $DEBUG;
next;
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};
}
$i_vlan{$iid}=$vlan;
}
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 undef;
}
# 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 undef;
}
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 undef;
}
}
# 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 undef;
}
# 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 undef;
}
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 undef;
}
# 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 undef;
}
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 undef;
}
# invalidate cache of ifstack?
return $rv;
}
1;
__END__
@@ -163,7 +491,7 @@ SNMP::Info::Layer3::Extreme - Perl5 Interface to Extreme Network Devices
=head1 AUTHOR
Eric Miller
Eric Miller, Bill Fenner
=head1 SYNOPSIS
@@ -212,6 +540,8 @@ my $extreme = new SNMP::Info::Layer3::Extreme(...);
=item EXTREME-FDB-MIB
=item EXTREME-VLAN-MIB
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
@@ -224,9 +554,9 @@ These are methods that return scalar value from SNMP
=over
=item $extreme->bulkwalk_no
Return C<1>. Bulkwalk is currently turned off for this class.
#=item $extreme->bulkwalk_no
#
#Return C<1>. Bulkwalk is currently turned off for this class.
=item $extreme->model()
@@ -280,13 +610,13 @@ Returns base mac
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
See documentation in L<SNMP::Info::MAU/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -322,10 +652,51 @@ rather than BRIDGE-MIB.
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
See documentation in L<SNMP::Info::MAU/"TABLE METHODS"> for details.
=item $extreme->set_i_vlan ( vlan, ifIndex )
Changes an access (untagged) port VLAN, must be supplied with the numeric
VLAN ID and port 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 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 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 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);
=cut

View File

@@ -37,48 +37,43 @@ use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::FDP;
use SNMP::Info::LLDP;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '1.03';
$VERSION = '1.07';
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::Layer3 SNMP::Info::FDP Exporter/;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS,
%SNMP::Info::FDP::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
# IP-FORWARD-MIB
# ETHERLIKE-MIB
# RFC1398-MIB
# RMON-MIB
# IF-MIB
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::FDP::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,
'i_name2' => 'ifName',
# FOUNDRY-MIB
# snSwPortInfoTable - Switch Port Information Group
# FOUNDRY-SN-SWITCH-GROUP-MIB
# snSwPortInfoTable - Switch Port Information Group
'sw_index' => 'snSwPortIfIndex',
'sw_duplex' => 'snSwPortInfoChnMode',
'sw_type' => 'snSwPortInfoMediaType',
@@ -86,44 +81,20 @@ $VERSION = '1.03';
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::LLDP::MUNGE,
%SNMP::Info::FDP::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
# Method OverRides
sub bulkwalk_no { 1; }
# 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 $interfaces = $foundry->interfaces();
my $i_descr = $foundry->i_descr();
my $partial = shift;
my $interfaces = $foundry->interfaces($partial) || {};
my %i_ignore;
foreach my $if (keys %$interfaces) {
# lo -> cisco aironet 350 loopback
if ($interfaces->{$if} =~ /(tunnel|loopback|lo|lb|null)/i){
if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i){
$i_ignore{$if}++;
}
}
@@ -132,8 +103,10 @@ sub i_ignore {
sub i_duplex {
my $foundry = shift;
my $sw_index = $foundry->sw_index();
my $sw_duplex= $foundry->sw_duplex();
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();
@@ -150,104 +123,273 @@ sub i_duplex {
return \%i_duplex;
}
sub i_type {
my $foundry = shift;
my $sw_index = $foundry->sw_index();
my $sw_type= $foundry->sw_type();
unless (defined $sw_index and defined $sw_type){
return $foundry->SUPER::i_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();
unless (defined $sw_index and defined $sw_speed){
return $foundry->SUPER::i_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 $desc = $foundry->description();
my $model = &SNMP::translateObj($id);
$model = $1 if $desc =~ /\s+([a-z]{2}\d{4})\D/i;
$model = $1 if $desc =~ /\b(FW[A-Z\d]+)/;
# 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//;
return $model;
}
sub os {
my $foundry = shift;
my $descr = $foundry->description();
if ($descr =~ m/IronWare/i) {
return 'IronWare';
}
sub os {
return 'foundry';
}
sub vendor {
return 'foundry';
}
sub os_ver {
my $foundry = shift;
my $os_version = $foundry->os_version();
return $os_version if defined $os_version;
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;
}
return undef;
# 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();
}
# $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 $partial = shift;
my %ifs = ();
foreach my $iid (keys %$interfaces){
$ifs{$iid} = $descriptions->{$iid};
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 \%ifs;
return $i_descr;
}
sub vendor {
return 'foundry';
# 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 undef;
}
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;
@@ -255,7 +397,7 @@ __END__
=head1 NAME
SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry FastIron Network Devices
SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry Network Devices
=head1 AUTHOR
@@ -274,18 +416,16 @@ Max Baker
)
or die "Can't connect to DestHost.\n";
my $class = $foundry->class();
my $class = $foundry->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
This module provides limited functionality from some L2+L3 and L3 Foundry devices.
Abstraction subclass for Foundry Networks devices.
Specifically designed for a FI4802. Works on a FWSX424.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above. Turn off the AutoSpecify flag.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $foundry = new SNMP::Info::Layer3::Foundry(...);
@@ -293,8 +433,11 @@ a more specific class using the method above. Turn off the AutoSpecify flag.
=over
=item SNMP::Info
=item SNMP::Info::Layer3;
=item SNMP::Info::FDP;
=item SNMP::Info::LLDP;
=back
@@ -304,14 +447,20 @@ a more specific class using the method above. Turn off the AutoSpecify flag.
=item FOUNDRY-SN-ROOT-MIB
=item FOUNDRY-SN-AGENT-MIB
=item FOUNDRY-SN-SWITCH-GROUP-MIB
=item Inherited Classes' MIBs
See classes listed above for their required 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
The Foundry MIBS can be downloaded from www.mibdepot.com and ??
=head1 GLOBALS
These are methods that return scalar value from SNMP
@@ -320,12 +469,20 @@ These are methods that return scalar value from SNMP
=item $foundry->model()
Returns model type. Checks $foundry->id() against the
FOUNDRY-SN-ROOT-MIB and then parses out xxNNNN
Returns model type. Checks $foundry->id() against the FOUNDRY-SN-ROOT-MIB
and removes 'sn'. EdgeIron models determined through ENTITY-MIB.
=item $foundry->vendor()
Returns 'foundry' :)
Returns 'foundry'
=item $foundry->os()
Returns 'foundry'
=item $foundry->os_ver()
Returns the software version
=item $foundry->mac()
@@ -343,8 +500,6 @@ Returns Chassis type.
Returns serial number of device.
(B<snChasSerNum>)
=item $foundry->temp()
Returns the chassis temperature
@@ -371,11 +526,19 @@ Returns the status of the chassis fan.
=back
=head2 Globals imported from SNMP::Info
=head2 Global Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info for details.
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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.
@@ -388,13 +551,6 @@ to a hash.
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.
@@ -407,43 +563,6 @@ Returns reference to hash of interface link duplex status.
Crosses $foundry->sw_duplex() with $foundry->sw_index()
=item $foundry->i_type()
Returns reference to hash of interface types.
Crosses $foundry->sw_type() with $foundry->sw_index()
=item $foundry->i_speed()
Returns reference to hash of interface speeds .
Crosses $foundry->sw_speeD() with $foundry->sw_index() and
does a little munging.
=back
=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>)
@@ -476,8 +595,63 @@ Returns reference to hash. Current Port Speed.
=back
=head2 Table Methods imported from SNMP::Info
=head2 Topology information
See documentation in SNMP::Info for details.
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 de-duplicate 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

@@ -32,7 +32,7 @@ use Exporter;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = '1.03';
$VERSION = '1.07';
@SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Juniper::EXPORT_OK = qw//;
@@ -91,12 +91,36 @@ sub model {
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;
}
}
}
\%i_vlan;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Juniper - Perl5 Interface to L3 Juniper Devices
SNMP::Info::Layer3::Juniper - SNMP Interface to L3 Juniper Devices
=head1 AUTHOR
@@ -136,7 +160,7 @@ Subclass for Generic Juniper Routers running JUNOS
=item Inherited Classes' MIBs
See L<SNMP::Info::Layer3> for its own MIB requirements.
See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
=back
@@ -167,15 +191,24 @@ These are methods that return scalar value from SNMP
=head2 Globals imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
=head1 TABLE ENTRIES
=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 ifType is l2vlan(135), and
the VLAN ID extracted from the interface description.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3> for details.
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

179
Info/Layer3/Microsoft.pm Normal file
View File

@@ -0,0 +1,179 @@
# SNMP::Info::Layer3::Microsoft
#
# 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;
$VERSION = '1.07';
# $Id$
use Exporter;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
@SNMP::Info::Layer3::Microsoft::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Microsoft::EXPORT_OK = qw//;
%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,
# These arguments are passed directly on to SNMP::Session
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
=over
=item $router->vendor()
Returns 'microsoft'
=item $router->os()
Returns 'windows'
=item $router->os_ver()
Returns nothing.
=item $router->model()
Returns 'Windows Router'
=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 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -1,10 +1,7 @@
# SNMP::Info::Layer3::N1600 - SNMP Interface to Nortel N16XX devices
# Eric Miller
#
# Copyright (c) 2004,2005 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
# Copyright (c) 2005 Eric Miller
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -14,9 +11,6 @@
# * 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
@@ -40,7 +34,7 @@ use SNMP::Info::SONMP;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '1.03';
$VERSION = '1.07';
@SNMP::Info::Layer3::N1600::ISA = qw/SNMP::Info::Layer3 SNMP::Info::SONMP Exporter/;
@SNMP::Info::Layer3::N1600::EXPORT_OK = qw//;
@@ -115,7 +109,9 @@ sub os_ver {
sub interfaces {
my $n1600 = shift;
my $i_index = $n1600->i_index();
my $partial = shift;
my $i_index = $n1600->i_index($partial) || {};
my %if;
foreach my $iid (keys %$i_index){
@@ -130,7 +126,9 @@ sub interfaces {
sub i_duplex {
my $n1600 = shift;
my $nway_status = $n1600->n1600_nway_status();
my $partial = shift;
my $nway_status = $n1600->n1600_nway_status($partial) || {};
my %i_duplex;
foreach my $iid (keys %$nway_status){
@@ -145,7 +143,9 @@ sub i_duplex {
sub i_duplex_admin {
my $n1600 = shift;
my $nway_state = $n1600->n1600_nway_state();
my $partial = shift;
my $nway_state = $n1600->n1600_nway_state($partial) || {};
my %i_duplex;
foreach my $iid (keys %$nway_state){
@@ -169,7 +169,7 @@ __END__
=head1 NAME
SNMP::Info::Layer3::N1600 - Perl5 Interface to Nortel 16XX Network Devices
SNMP::Info::Layer3::N1600 - SNMP Interface to Nortel 16XX Network Devices
=head1 AUTHOR
@@ -197,8 +197,8 @@ Eric Miller
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.
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(...);
@@ -277,13 +277,13 @@ not stack, the only requirment to reserve more than the max number of ports.
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
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 ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
@@ -311,10 +311,10 @@ Returns reference to hash of interface administrative link duplex status.
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
See documentation in L<SNMP::Info::SONMP/"TABLE METHODS"> for details.
=cut

236
Info/Layer3/NetSNMP.pm Normal file
View File

@@ -0,0 +1,236 @@
# SNMP::Info::Layer3::NetSNMP
# Bradley Baetz and 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::NetSNMP;
# $Id$
use Exporter;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = '1.07';
@SNMP::Info::Layer3::NetSNMP::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::NetSNMP::EXPORT_OK = qw//;
%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 undef;
}
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,
# These arguments are passed directly on to SNMP::Session
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 UCD-SNMP-MIB
=item NET-SNMP-TC
=item 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 sysDescr.
=item $netsnmp->os_ver()
Returns the software version extracted from sysDescr, along
with the Net-SNMP version.
=item $netsnmp->uptime()
Returns the system uptime instead of the agent uptime.
NOTE: discontinuity timers and other TimeStamp-based objects
are based on agent uptime, so use orig_uptime().
=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 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 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

211
Info/Layer3/Netscreen.pm Normal file
View File

@@ -0,0 +1,211 @@
# SNMP::Info::Layer3::Netscreen
# Kent Hamilton
# $Id$
#
# 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;
$VERSION = '1.07';
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 $AUTOLOAD $INIT $DEBUG/;
%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 undef;
}
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 undef;
}
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,
# 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 = $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 NETSCREEN-SMI
=item NETSCREEN-PRODUCTS-MIB
=item NETSCREEN-INTERFACE-MIB
=item 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 '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

File diff suppressed because it is too large Load Diff

187
Info/Layer3/Sun.pm Normal file
View File

@@ -0,0 +1,187 @@
# SNMP::Info::Layer3::Sun
#
# 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;
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer3;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
@SNMP::Info::Layer3::Sun::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Sun::EXPORT_OK = qw//;
%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 undef unless defined $descr;
if ($descr =~ m/SunOS (\S+)/) {
return $1;
}
return undef;
}
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,
# These arguments are passed directly on to SNMP::Session
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 motd.
=item $sun->model()
Returns 'Solaris Router'
=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 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
=cut

View File

@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::MAU;
$VERSION = '1.03';
$VERSION = '1.07';
# $Id$
use strict;
@@ -161,10 +161,12 @@ sub mau_i_duplex {
sub mau_i_duplex_admin {
my $mau = shift;
my $partial = shift;
my $mau_index = $mau->mau_index();
my $mau_autostat = $mau->mau_autostat();
my $mau_type_admin = $mau->mau_type_admin();
my %rev_mau_index = reverse %$mau_index;
my $mau_autostat = defined $partial ? $mau->mau_autostat($rev_mau_index{$partial}) : $mau->mau_autostat();
my $mau_type_admin = defined $partial ? $mau->mau_type_admin($rev_mau_index{$partial}) : $mau->mau_type_admin();
# Older HP4000's don't implement ifMauDefaultType, but we can
# figure out from ifMauAutoNegCapAdvertised what we'd like.
@@ -197,6 +199,8 @@ sub mau_i_duplex_admin {
$duplex = 'full';
} elsif ($type_admin =~ /hd$/i){
$duplex = 'half';
} elsif ($type_admin eq 'zeroDotZero') {
$duplex = 'auto';
}
$i_duplex_admin{$iid} = $duplex if defined $duplex;
@@ -255,7 +259,8 @@ __END__
=head1 NAME
SNMP::Info::MAU - Perl5 Interface to Medium Access Unit (MAU) MIB (RFC 2668) via SNMP
SNMP::Info::MAU - SNMP Interface to Medium Access Unit (MAU) MIB (RFC 2668)
via SNMP
=head1 AUTHOR
@@ -277,13 +282,14 @@ Max Baker
=head1 DESCRIPTION
SNMP::Info::MAU is a sublcass of SNMP::Info that supplies access to the
MAU-MIB (RFC 2668). This MIB is sometimes implemented on Layer 2 network devices like HP Switches.
MAU = Media Access Unit.
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
connected to that port.
Normally you use or create a subclass of SNMP::Info that inherits this one. Do not use directly.
Normally you use or create a subclass of SNMP::Info that inherits this one. Do
not use directly.
For debugging purposes call the class directly as you would SNMP::Info
@@ -341,7 +347,7 @@ Returns either (auto,none,full,half).
=back
=head2 MAU INTERFACE TABLE ENTRIES
=head2 MAU INTERFACE TABLE METHODS
=over

View File

@@ -2,7 +2,7 @@
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 Eric Miller, Max Baker
# Copyright (c) 2004 Eric Miller, Max Baker
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::NortelStack;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
@@ -44,6 +44,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
# 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 = (
@@ -57,7 +58,8 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'tftp_result' => 's5AgInfoFileStatus',
'vlan' => 's5AgSysManagementVlanId',
# From S5-CHASSIS-MIB
'serial' => 's5ChasSerNum',
'ns_serial' => 's5ChasSerNum',
'ns_ch_type' => 's5ChasType',
'ns_cfg_chg' => 's5ChasGblConfChngs',
'ns_cfg_time' => 's5ChasGblConfLstChng',
);
@@ -66,9 +68,11 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
# 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_ns_com_idx'=> 's5ChasComIndx',
'ns_com_idx' => 's5ChasComIndx',
'ns_com_sub_idx' => 's5ChasComSubIndx',
'ns_com_type' => 's5ChasComType',
'ns_com_descr' => 's5ChasComDescr',
@@ -76,7 +80,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'ns_com_serial' => 's5ChasComSerNum',
# From S5-CHASSIS-MIB::s5ChasStoreTable
'ns_store_grp_idx' => 's5ChasStoreGrpIndx',
'ns_store_ns_com_idx' => 's5ChasStoreComIndx',
'ns_store_com_idx' => 's5ChasStoreComIndx',
'ns_store_sub_idx' => 's5ChasStoreSubIndx',
'ns_store_idx' => 's5ChasStoreIndx',
'ns_store_type' => 's5ChasStoreType',
@@ -85,12 +89,16 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
);
%MUNGE = (
'ns_ch_type' => \&munge_ns_com_type,
'ns_grp_type' => \&munge_ns_grp_type,
'ns_com_type' => \&munge_ns_com_type,
'ns_store_type' => \&munge_ns_store_type,
);
sub os_ver {
my $bayhub = shift;
my $ver = $bayhub->ns_ag_ver();
my $stack = shift;
my $ver = $stack->ns_ag_ver();
return undef unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){
@@ -103,8 +111,9 @@ sub os_ver {
}
sub os_bin {
my $bayhub = shift;
my $ver = $bayhub->ns_ag_ver();
my $stack = shift;
my $ver = $stack->ns_ag_ver();
return undef unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/i){
@@ -116,12 +125,436 @@ sub os_bin {
return undef;
}
# 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 undef;
}
# Psuedo 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_com_type {
my $oid = shift;
my $name = &SNMP::translateObj($oid);
return $name if defined($name);
return $oid;
}
sub munge_ns_store_type {
my $oid = shift;
my $name = &SNMP::translateObj($oid);
return $name if defined($name);
return $oid;
}
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 - Perl5 Interface to Nortel Stack information using SNMP
SNMP::Info::NortelStack - SNMP Interface to the Nortel S5-AGENT-MIB and S5-CHASSIS-MIB
=head1 AUTHOR
@@ -131,13 +564,13 @@ Eric Miller
# 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
)
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();
@@ -174,10 +607,6 @@ These are methods that return scalar values from SNMP
=over
=item $baystack->serial()
Returns (B<s5ChasSerNum>)
=item $stack->os_ver()
Returns the software version extracted from (B<s5AgInfoVer>)
@@ -186,6 +615,12 @@ Returns the software version extracted from (B<s5AgInfoVer>)
Returns the firmware version extracted from (B<s5AgInfoVer>)
=item $stack->serial()
Returns serial number of the chassis
(B<s5ChasSerNum>)
=item $stack->ns_ag_ver()
Returns the version of the agent in the form 'major.minor.maintenance[letters]'.
@@ -294,7 +729,7 @@ group which contains this component.
(B<s5ChasComGrpIndx>)
=item $stack->ns_com_ns_com_idx()
=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.
@@ -345,7 +780,7 @@ group.
(B<s5ChasStoreGrpIndx>)
=item $stack->ns_store_ns_com_idx()
=item $stack->ns_store_idx()
Returns reference to hash. Key: Table entry, Value: Index of the group.
@@ -383,4 +818,77 @@ Returns reference to hash. Key: Table entry, Value: Version
=back
=head2 Psuedo ENTITY-MIB information
These methods emulate ENTITY-MIB Physical Table methods using S5-CHASSIS-MIB.
=over
=item $stack->ns_e_index()
Returns reference to hash. Key: IID, Value: Integer, Indicies 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
(B<s5ChasGrpDescr>).
Group is stripped from the string. Values may be Supervisory Module,
Backplane, Board, Power Supply, Sensor, Fan, Clock, Unit.
=item $stack->ns_e_descr()
Returns reference to hash. Key: IID, Value: Human friendly name
(B<s5ChasComDescr>)
=item $stack->ns_e_hwver()
Returns reference to hash. Key: IID, Value: Hardware version
(B<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
(B<s5ChasComSerNum>)
=item $stack->ns_e_pos()
Returns reference to hash. Key: IID, Value: The relative position among all
entities sharing the same parent.
(B<s5ChasComSubIndx>)
=item $stack->ns_e_type()
Returns reference to hash. Key: IID, Value: Type of component/sub-component
as defined under B<s5ChasComTypeVal> in S5-REG-MIB.
=item $stack->ns_e_fwver()
Returns reference to hash. Key: IID, Value: Firmware revision.
Value of B<s5ChasStoreCntntVer> for entries with rom, boot, or fw in
B<s5ChasStoreType>.
=item $stack->ns_e_fwver()
Returns reference to hash. Key: IID, Value: Software revision.
Value of B<s5ChasStoreCntntVer> for entries with "flash" in B<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.
=cut

219
Info/PowerEthernet.pm Normal file
View File

@@ -0,0 +1,219 @@
# SNMP::Info::PowerEthernet
# Bill Fenner
#
# Copyright (c) 2007 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::PowerEthernet;
$VERSION = '1.07';
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::PowerEthernet::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::PowerEthernet::EXPORT_OK = qw//;
%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 undef;
}
$peth_port_ifindex->{$i} = $port;
}
return $peth_port_ifindex;
}
1;
=head1 NAME
SNMP::Info::PowerEthernet - SNMP Interface to data stored in 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,
# 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 = $poe->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
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 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 deliveringPower, this represents the 802.3af
class of the device being powered.
C<pethPsePortPowerClassifications>
=item $poe->peth_port_ifindex()
A mapping function from the pethPsePortTable INDEX of
module.port to an 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).
=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 milliwats,
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

View File

@@ -1,7 +1,7 @@
# SNMP::Info::RapidCity
# $Id$
#
# Copyright (c) 2004-6 Eric Miller, Max Baker
# Copyright (c) 2004 Eric Miller, Max Baker
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -27,24 +27,23 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::RapidCity;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use Carp;
@SNMP::Info::RapidCity::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::RapidCity::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
%MIBS = (
'RAPID-CITY' => 'rapidCity',
);
%GLOBALS = (
'serial' => 'rcChasSerialNumber',
'rc_serial' => 'rcChasSerialNumber',
'chassis' => 'rcChasType',
'slots' => 'rcChasNumSlots',
'tftp_host' => 'rcTftpHost',
@@ -54,6 +53,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'rc_ch_rev' => 'rcChasHardwareRevision',
'rc_base_mac' => 'rc2kChassisBaseMacAddr',
'rc_virt_ip' => 'rcSysVirtualIpAddr',
'rc_virt_mask' => 'rcSysVirtualNetMask',
);
%FUNCS = (
@@ -69,6 +69,7 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus',
'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus',
'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr',
'rc_cpu_mask' => 'rc2kCpuEthernetPortMask',
'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate',
'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex',
'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex',
@@ -84,13 +85,15 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
'rc_i_vlan_tag' => 'rcVlanPortPerformTagging',
# From RAPID-CITY::rcVlanTable
'rc_vlan_id' => 'rcVlanId',
'rc_vlan_name' => 'rcVlanName',
'v_name' => 'rcVlanName',
'rc_vlan_color' => 'rcVlanColor',
'rc_vlan_if' => 'rcVlanIfIndex',
'rc_vlan_stg' => 'rcVlanStgId',
'rc_vlan_type' => 'rcVlanType',
'rc_vlan_members' => 'rcVlanPortMembers',
'rc_vlan_no_join' => 'rcVlanNotAllowToJoin',
'rc_vlan_mac' => 'rcVlanMacAddress',
'rc_vlan_rstatus' => 'rcVlanRowStatus',
# From RAPID-CITY::rcIpAddrTable
'rc_ip_index' => 'rcIpAdEntIfIndex',
'rc_ip_addr' => 'rcIpAdEntAddr',
@@ -138,20 +141,28 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
%MUNGE = (
'rc_base_mac' => \&SNMP::Info::munge_mac,
'rc_vlan_mac' => \&SNMP::Info::munge_mac,
'rc_cpu_mac' => \&SNMP::Info::munge_mac,
'rc_cpu_mac' => \&SNMP::Info::munge_mac,
);
# Need to override here since overridden in Layer2 and Layer3 classes
sub serial {
my $rapidcity = shift;
my $ver = $rapidcity->rc_serial();
return $ver unless !defined $ver;
return undef;
}
sub i_duplex {
my $rapidcity = shift;
my $partial = shift;
my $interfaces = $rapidcity->interfaces();
my $rc_index = $rapidcity->rc_index();
my $rc_duplex = $rapidcity->rc_duplex();
my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex();
my $rc_duplex = $rapidcity->rc_duplex($partial) || {};
my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex($partial) || {};
my %i_duplex;
foreach my $if (keys %$interfaces){
foreach my $if (keys %$rc_duplex){
my $duplex = $rc_duplex->{$if};
next unless defined $duplex;
@@ -173,16 +184,15 @@ sub i_duplex {
sub i_duplex_admin {
my $rapidcity = shift;
my $partial = shift;
my $interfaces = $rapidcity->interfaces();
my $rc_index = $rapidcity->rc_index();
my $rc_duplex_admin = $rapidcity->rc_duplex_admin();
my $rc_auto = $rapidcity->rc_auto();
my $rc_cpu_auto = $rapidcity->rc_cpu_auto();
my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin();
my $rc_duplex_admin = $rapidcity->rc_duplex_admin() || {};
my $rc_auto = $rapidcity->rc_auto($partial) || {};
my $rc_cpu_auto = $rapidcity->rc_cpu_auto($partial) || {};
my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin($partial) || {};
my %i_duplex_admin;
foreach my $if (keys %$interfaces){
foreach my $if (keys %$rc_duplex_admin){
my $duplex = $rc_duplex_admin->{$if};
next unless defined $duplex;
my $auto = $rc_auto->{$if}||'false';
@@ -212,36 +222,301 @@ sub i_duplex_admin {
return \%i_duplex_admin;
}
sub set_i_duplex_admin {
my $rapidcity = shift;
my ($duplex, $iid) = @_;
$duplex = lc($duplex);
return undef unless ($duplex =~ /(half|full|auto)/ and $iid =~ /\d+/);
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/full 2 half 1/;
my $i_auto = $rapidcity->rc_auto($iid);
if ($duplex eq "auto") {
return $rapidcity->set_rc_auto('1', $iid);
}
elsif (($duplex ne "auto") and ($i_auto->{$iid} eq "1")) {
return undef unless ($rapidcity->set_rc_auto('2', $iid));
return $rapidcity->set_rc_duplex_admin($duplexes{$duplex}, $iid);
}
else {
return $rapidcity->set_rc_duplex_admin($duplexes{$duplex}, $iid);
}
return undef;
}
sub set_i_speed_admin {
my $rapidcity = shift;
my ($speed, $iid) = @_;
return undef unless ($speed =~ /(10|100|1000|auto)/i and $iid =~ /\d+/);
# map a textual duplex to an integer one the switch understands
my %speeds = qw/10 1 100 2 1000 3/;
my $i_auto = $rapidcity->rc_auto($iid);
if ($speed eq "auto") {
return $rapidcity->set_rc_auto('1', $iid);
}
elsif (($speed ne "auto") and ($i_auto->{$iid} eq "1")) {
return undef unless ($rapidcity->set_rc_auto('2', $iid));
return $rapidcity->set_rc_speed_admin($speeds{$speed}, $iid);
}
else {
return $rapidcity->set_rc_speed_admin($speeds{$speed}, $iid);
}
return undef;
}
sub v_index {
my $rapidcity = shift;
my $partial = shift;
return $rapidcity->rc_vlan_id($partial);
}
sub i_vlan {
my $rapidcity = shift;
my $partial = shift;
my $rc_vlans = $rapidcity->rc_i_vlan();
my $rc_vlan_id = $rapidcity->rc_vlan_id();
my $rc_vlan_if = $rapidcity->rc_vlan_if();
my $i_pvid = $rapidcity->rc_i_vlan_pvid($partial) || {};
my %i_vlan;
foreach my $if (keys %$rc_vlans){
my $rc_vlanid = $rc_vlans->{$if};
next unless defined $rc_vlanid;
my @vlanids = map { sprintf "%02x",$_ } unpack('C*',$rc_vlanid);
return $i_pvid;
}
my @vlans = ();
sub i_vlan_membership {
my $rapidcity = shift;
while($#vlanids > 0) {
my $h = join('', splice(@vlanids,0,2));
push(@vlans, hex($h));
}
my $vlans = join (',', @vlans);
$i_vlan{$if}=$vlans;
my $rc_v_ports = $rapidcity->rc_vlan_members();
my $i_vlan_membership = {};
foreach my $vlan (keys %$rc_v_ports) {
my $portlist = [split(//, unpack("B*", $rc_v_ports->{$vlan}))];
my $ret = [];
# Convert portlist bit array to ifIndex array
for (my $i = 0; $i <= scalar(@$portlist); $i++) {
push(@{$ret}, $i) if (@$portlist[$i]);
}
#Create HoA ifIndex -> VLAN array
foreach my $port (@{$ret}) {
push(@{$i_vlan_membership->{$port}}, $vlan);
}
}
foreach my $if (keys %$rc_vlan_if){
my $vlan_if = $rc_vlan_if->{$if};
next unless defined $vlan_if;
my $vlan = $rc_vlan_id->{$if};
return $i_vlan_membership;
}
$i_vlan{$vlan_if}=$vlan;
sub set_i_pvid {
my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_;
return undef unless ( $rapidcity->validate_vlan_param ($vlan_id, $ifindex) );
unless ( $rapidcity->set_rc_i_vlan_pvid($vlan_id, $ifindex) ) {
$rapidcity->error_throw("Unable to change PVID to $vlan_id on IfIndex: $ifindex");
return undef;
}
return \%i_vlan;
return 1;
}
sub set_i_vlan {
my $rapidcity = shift;
my ($new_vlan_id, $ifindex) = @_;
return undef unless ( $rapidcity->validate_vlan_param ($new_vlan_id, $ifindex) );
my $vlan_p_type = $rapidcity->rc_i_vlan_type($ifindex);
unless ( $vlan_p_type->{$ifindex} =~ /access/ ) {
$rapidcity->error_throw("Not an access port");
return undef;
}
my $i_pvid = $rapidcity->rc_i_vlan_pvid($ifindex);
# Store current untagged VLAN to remove it from the port list later
my $old_vlan_id = $i_pvid->{$ifindex};
print "Changing VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" if $rapidcity->debug();
# Check if port in forbidden list for the VLAN, haven't seen this used, but we'll check anyway
return undef unless ($rapidcity->check_forbidden_ports($new_vlan_id, $ifindex));
# Remove port from old VLAN from egress list
return undef unless ($rapidcity->remove_from_egress_portlist($old_vlan_id, $ifindex));
# Add port to egress list for VLAN
return undef unless ($rapidcity->add_to_egress_portlist($new_vlan_id, $ifindex));
# Set new untagged / native VLAN
# Some models/versions do this for us also, so check to see if we need to set
$i_pvid = $rapidcity->rc_i_vlan_pvid($ifindex);
my $cur_i_pvid = $i_pvid->{$ifindex};
print "Current PVID: $cur_i_pvid\n" if $rapidcity->debug();
unless ($cur_i_pvid eq $new_vlan_id) {
return undef unless ($rapidcity->set_i_pvid($new_vlan_id, $ifindex));
}
print "Successfully changed VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" if $rapidcity->debug();
return 1;
}
sub set_add_i_vlan_tagged {
my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_;
return undef unless ( $rapidcity->validate_vlan_param ($vlan_id, $ifindex) );
print "Adding VLAN: $vlan_id to IfIndex: $ifindex\n" if $rapidcity->debug();
# Check if port in forbidden list for the VLAN, haven't seen this used, but we'll check anyway
return undef unless ($rapidcity->check_forbidden_ports($vlan_id, $ifindex));
# Add port to egress list for VLAN
return undef unless ($rapidcity->add_to_egress_portlist($vlan_id, $ifindex));
print "Successfully added IfIndex: $ifindex to VLAN: $vlan_id egress list\n" if $rapidcity->debug();
return 1;
}
sub set_remove_i_vlan_tagged {
my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_;
return undef unless ( $rapidcity->validate_vlan_param ($vlan_id, $ifindex) );
print "Removing VLAN: $vlan_id from IfIndex: $ifindex\n" if $rapidcity->debug();
# Remove port from egress list for VLAN
return undef unless ($rapidcity->remove_from_egress_portlist($vlan_id, $ifindex));
print "Successfully removed IfIndex: $ifindex from VLAN: $vlan_id egress list\n" if $rapidcity->debug();
return 1;
}
#
# Need to be able to construct a single set with multiple oids
#
#sub set_create_vlan {
# my $rapidcity = shift;
# my ($name, $vlan_id) = @_;
# return undef unless ($vlan_id =~ /\d+/);
#
# my $activate_rv = $rapidcity->set_rc_vlan_rstatus(4, $vlan_id);
# unless ($activate_rv) {
# print "Error: Unable to activate VLAN: $vlan_id\n" if $rapidcity->debug();
# return undef;
# }
# my $rv = $rapidcity->set_v_name($name, $vlan_id);
# unless ($rv) {
# print "Error: Unable to create VLAN: $vlan_id\n" if $rapidcity->debug();
# return undef;
# }
# return 1;
#}
sub set_delete_vlan {
my $rapidcity = shift;
my ($vlan_id) = shift;
return undef unless ($vlan_id =~ /^\d+$/);
unless ( $rapidcity->set_rc_vlan_rstatus('6', $vlan_id) ) {
$rapidcity->error_throw("Unable to delete VLAN: $vlan_id");
return undef;
}
return 1;
}
#
# These are internal methods and are not documented. Do not use directly.
#
sub check_forbidden_ports {
my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_;
my $iv_forbidden = $rapidcity->rc_vlan_no_join($vlan_id);
my @forbidden_ports = split(//, unpack("B*", $iv_forbidden->{$vlan_id}));
print "Forbidden ports: @forbidden_ports\n" if $rapidcity->debug();
if ( defined($forbidden_ports[$ifindex]) and ($forbidden_ports[$ifindex] eq "1")) {
$rapidcity->error_throw("IfIndex: $ifindex in forbidden list for VLAN: $vlan_id unable to add");
return undef;
}
return 1;
}
sub add_to_egress_portlist {
my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_;
my $iv_members = $rapidcity->rc_vlan_members($vlan_id);
my @egress_list = split(//, unpack("B*", $iv_members->{$vlan_id}));
print "Original egress list for VLAN: $vlan_id: @egress_list \n" if $rapidcity->debug();
$egress_list[$ifindex] = '1';
# Some devices do not populate the portlist with all possible ports.
# If we have lengthened the list fill all undefined elements with zero.
foreach my $item (@egress_list) {
$item = '0' unless (defined($item));
}
print "Modified egress list for VLAN: $vlan_id: @egress_list \n" if $rapidcity->debug();
my $new_egress = pack("B*", join('', @egress_list));
unless ( $rapidcity->set_rc_vlan_members($new_egress, $vlan_id) ) {
$rapidcity->error_throw("Unable to add VLAN: $vlan_id to IfIndex: $ifindex egress list");
return undef;
}
return 1;
}
sub remove_from_egress_portlist {
my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_;
my $iv_members = $rapidcity->rc_vlan_members($vlan_id);
my @egress_list = split(//, unpack("B*", $iv_members->{$vlan_id}));
print "Original egress list for VLAN: $vlan_id: @egress_list \n" if $rapidcity->debug();
# Some devices may remove automatically, so check state before set
if ( defined($egress_list[$ifindex]) and ($egress_list[$ifindex] eq "1")) {
$egress_list[$ifindex] = '0';
print "Modified egress list for VLAN: $vlan_id: @egress_list \n" if $rapidcity->debug();
my $new_egress = pack("B*", join('', @egress_list));
unless ( $rapidcity->set_rc_vlan_members($new_egress, $vlan_id) ) {
$rapidcity->error_throw("Unable to remove IfIndex: $ifindex from VLAN: $vlan_id egress list");
return undef;
}
}
return 1;
}
sub validate_vlan_param {
my $rapidcity = 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+$/ ) {
$rapidcity->error_throw("Invalid parameter");
return undef;
}
# Check that ifIndex exists on device
my $index = $rapidcity->interfaces($ifindex);
unless ( exists $index->{$ifindex} ) {
$rapidcity->error_throw("ifIndex $ifindex does not exist");
return undef;
}
#Check that VLAN exists on device
unless ( $rapidcity->rc_vlan_id($vlan_id) ) {
$rapidcity->error_throw("VLAN $vlan_id does not exist or is not operational");
return undef;
}
return 1;
}
1;
@@ -250,7 +525,7 @@ __END__
=head1 NAME
SNMP::Info::Layer2::RapidCity - SNMP Interface to the Nortel RapidCity MIB
SNMP::Info::RapidCity - SNMP Interface to the Nortel RapidCity MIB
=head1 AUTHOR
@@ -269,7 +544,7 @@ Eric Miller
)
or die "Can't connect to DestHost.\n";
my $class = $rapidcity->class();
my $class = $rapidcity->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
@@ -299,11 +574,11 @@ These are methods that return scalar values from SNMP
=over
=item $rapidcity->chassis_base_mac()
=item $rapidcity->rc_base_mac()
(B<rc2kChassisBaseMacAddr>)
=item $rapidcity->ch_serial()
=item $rapidcity->rc_serial()
(B<rcChasSerialNumber>)
@@ -323,6 +598,10 @@ These are methods that return scalar values from SNMP
(B<rcSysVirtualIpAddr>)
=item $rapidcity->rc_virt_mask()
(B<rcSysVirtualNetMask>)
=item $rapidcity->tftp_host()
(B<rcTftpHost>)
@@ -341,6 +620,16 @@ These are methods that return scalar values from SNMP
=back
=head2 Overrides
=over
=item $rapidcity->serial()
Returns serial number of the chassis
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
@@ -358,7 +647,22 @@ Returns reference to hash of IIDs to admin duplex setting.
=item $rapidcity->i_vlan()
Returns a mapping between ifIndex and the VLAN.
Returns a mapping between ifIndex and the PVID or default VLAN.
=item $rapidcity->i_vlan_membership()
Returns reference to hash of arrays: key = ifIndex, value = array of VLAN IDs.
These are the VLANs which are members of the egress list for the port.
Example:
my $interfaces = $rapidcity->interfaces();
my $vlans = $rapidcity->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
@@ -412,6 +716,10 @@ Returns a mapping between ifIndex and the VLAN.
(B<rc2kCpuEthernetPortAddr>)
=item $rapidcity->rc_cpu_mask()
(B<rc2kCpuEthernetPortMask>)
=item $rapidcity->rc_cpu_auto()
(B<rc2kCpuEthernetPortAutoNegotiate>)
@@ -476,7 +784,7 @@ Returns a mapping between ifIndex and the VLAN.
(B<rcVlanId>)
=item $rapidcity->rc_vlan_name()
=item $rapidcity->v_name()
(B<rcVlanName>)
@@ -686,4 +994,80 @@ Returns a mapping between ifIndex and the VLAN.
(B<rc2kMdaCardDeviations>)
=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 $rapidcity->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port ifIndex. Speed choices
are 'auto', '10', '100', '1000'.
Example:
my %if_map = reverse %{$rapidcity->interfaces()};
$rapidcity->set_i_speed_admin('auto', $if_map{'1.1'})
or die "Couldn't change port speed. ",$rapidcity->error(1);
=item $rapidcity->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port ifIndex. Speed choices
are 'auto', 'half', 'full'.
Example:
my %if_map = reverse %{$rapidcity->interfaces()};
$rapidcity->set_i_duplex_admin('auto', $if_map{'1.1'})
or die "Couldn't change port duplex. ",$rapidcity->error(1);
=item $rapidcity->set_i_vlan(vlan, ifIndex)
Changes an access (untagged) port VLAN, must be supplied with the numeric VLAN ID
and port ifIndex. This method will modify the port's VLAN membership and PVID
(default VLAN). This method should only be used on end station (non-trunk) ports.
Example:
my %if_map = reverse %{$rapidcity->interfaces()};
$rapidcity->set_i_vlan('2', $if_map{'1.1'})
or die "Couldn't change port VLAN. ",$rapidcity->error(1);
=item $rapidcity->set_i_pvid(pvid, ifIndex)
Sets port PVID or default VLAN, must be supplied with the numeric VLAN ID and
port ifIndex. This method only changes the PVID, to modify an access (untagged)
port use set_i_vlan() instead.
Example:
my %if_map = reverse %{$rapidcity->interfaces()};
$rapidcity->set_i_pvid('2', $if_map{'1.1'})
or die "Couldn't change port PVID. ",$rapidcity->error(1);
=item $rapidcity->set_add_i_vlan_tagged(vlan, ifIndex)
Adds the port to the egress list of the VLAN, must be supplied with the numeric
VLAN ID and port ifIndex.
Example:
my %if_map = reverse %{$rapidcity->interfaces()};
$rapidcity->set_add_i_vlan_tagged('2', $if_map{'1.1'})
or die "Couldn't add port to egress list. ",$rapidcity->error(1);
=item $rapidcity->set_remove_i_vlan_tagged(vlan, ifIndex)
Removes the port from the egress list of the VLAN, must be supplied with the
numeric VLAN ID and port ifIndex.
Example:
my %if_map = reverse %{$rapidcity->interfaces()};
$rapidcity->set_remove_i_vlan_tagged('2', $if_map{'1.1'})
or die "Couldn't add port to egress list. ",$rapidcity->error(1);
=item $rapidcity->set_delete_vlan(vlan)
Deletes the specified VLAN from the device.
=cut

View File

@@ -28,13 +28,12 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::SONMP;
$VERSION = '1.03';
$VERSION = '1.07';
use strict;
use Exporter;
use SNMP::Info;
use Carp;
@SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::SONMP::EXPORT_OK = qw//;
@@ -83,11 +82,12 @@ sub hasCDP {
return $sonmp->cdp_run();
}
sub c_if {
my $sonmp = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
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();
@@ -98,7 +98,7 @@ sub c_if {
my $port = $sonmp_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
my $slot = $sonmp_topo_slot->{$entry}||0;
my $slot = $sonmp_topo_slot->{$entry} || 0;
if ($model eq 'Baystack Hub') {
my $comidx = $slot;
@@ -115,117 +115,60 @@ sub c_if {
my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset);
$c_if{"$index.1"} = $index;
$c_if{$entry} = $index;
}
return \%c_if;
}
sub c_ip {
my $sonmp = shift;
my $sonmp_topo_ip = $sonmp->sonmp_topo_ip();
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
my $ip = $sonmp->cdp_id();
my $index_factor = $sonmp->index_factor();
my $slot_offset = $sonmp->slot_offset();
my $port_offset = $sonmp->port_offset();
my $model = $sonmp->model();
my $partial = shift;
# Count the number of devices seen on each port.
# more than one device seen means connected to a non-sonmp
# device, but other sonmp devices are squawking further away.
my %ip_port;
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 =~ /^[\d\.]+$/ and $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);
next if $port == 0;
my $ip = $sonmp_topo_ip->{$entry};
push(@{$ip_port{$index}},$ip);
}
my %c_ip;
foreach my $port (keys %ip_port){
my $ips = $ip_port{$port};
if (scalar @$ips == 1) {
$c_ip{"$port.1"} = $ips->[0];
} else {
$c_ip{"$port.1"} = $ips;
}
$c_ip{$entry} = $ip;
}
return \%c_ip;
}
sub c_port {
my $sonmp = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
my $sonmp_topo_seg = $sonmp->sonmp_topo_seg();
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
my $index_factor = $sonmp->index_factor();
my $slot_offset = $sonmp->slot_offset();
my $port_offset = $sonmp->port_offset();
my $model = $sonmp->model();
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform();
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 $slot = $sonmp_topo_slot->{$entry};
$slot = 0 unless defined $slot;
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);
# For fake remotes (multiple IPs for a c_ip), use first found
next if defined $c_port{"$index.1"};
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{"$index.1"} = 'dp0';
$c_port{$entry} = 'dp0';
}
# BayHubs send the lower three bytes of the MAC not the slot/port
elsif ($seg > 4000) {
$c_port{"$index.1"} = 'unknown';
$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{"$index.1"} = "$remote_slot.$remote_port";
$c_port{$entry} = "$remote_slot.$remote_port";
}
}
return \%c_port;
@@ -233,48 +176,27 @@ sub c_port {
sub c_platform {
my $sonmp = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform();
my $index_factor = $sonmp->index_factor();
my $slot_offset = $sonmp->slot_offset();
my $port_offset = $sonmp->port_offset();
my $model = $sonmp->model();
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}||0;
my $port = $sonmp_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
my $slot = $sonmp_topo_slot->{$entry};
$slot = 0 unless defined $slot;
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);
# For fake remotes (multiple IPs for a c_ip), use first found
next if defined $c_platform{"$index.1"};
my $platform = $sonmp_topo_platform->{$entry};
$c_platform{"$index.1"} = $platform;
$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();
@@ -293,7 +215,7 @@ __END__
=head1 NAME
SNMP::Info::SONMP - Perl5 Interface to SynOptics Network Management Protocol (SONMP) using SNMP
SNMP::Info::SONMP - SNMP Interface to SynOptics Network Management Protocol (SONMP)
=head1 AUTHOR
@@ -334,10 +256,10 @@ 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 Networks devices.
SONMP has been rebranded by Bay then Nortel Networks and is know by several different
names.
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.
@@ -358,19 +280,6 @@ None.
=back
MIBs can be found on the CD that came with your product.
Or, they can be downloaded directly from Nortel Networks regardless of support
contract status.
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
Select by product, Java Device Manager, Software. Download the latest version.
After installation, all mibs are located under the install directory under mibs
and the repspective product line.
Note: Required version of SYNOPTICS-ROOT-MIB, must be version 199 or higher,
for example synro199.mib.
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
@@ -392,7 +301,7 @@ Returns the offset if port numbering does not start at 0. Defaults to 0.
=item $cdp->hasCDP()
Is CDP is active in this device?
Is SONMP is active in this device?
=item $sonmp->cdp_id()
@@ -402,7 +311,7 @@ Returns the IP that the device is sending out for its Nmm topology info.
=item $sonmp->cdp_run()
Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
Returns true if SONMP is on for this device.
(B<s5EnMsTopStatus>)
@@ -417,7 +326,7 @@ Returns MAC of the advertised IP address of the device.
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Layer2 Topology info (s5EnMsTopNmmTable)
=head2 Layer2 Topology info (B<s5EnMsTopNmmTable>)
=over
@@ -445,7 +354,7 @@ Returns reference to hash. Key: Table entry, Value:Remote Segment ID
(B<s5EnMsTopNmmSegId>)
=item $sonmp->sonmp_topo_mac
=item $sonmp->sonmp_topo_mac()
(B<s5EnMsTopNmmMacAddr>)
@@ -459,7 +368,8 @@ Returns reference to hash. Key: Table entry, Value:Remote Device Type
=item $sonmp->sonmp_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.
(B<s5EnMsTopNmmLocalSeg>)
@@ -473,28 +383,25 @@ All entries with port=0 are local and ignored.
=item $sonmp->c_if()
Returns reference to hash. Key: ifIndex.1 Value: port (iid)
Returns reference to hash. Key: IID, Value: Local port (interfaces)
=item $sonmp->c_ip()
Returns referenece to hash. Key: ifIndex.1
Returns reference to hash. Key: IID, Value: Remote IP address
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-SONMP 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-SONMP device in between two or more devices.
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: ifIndex.1 Value: remote port
Returns reference to hash. Key: IID, Value: Remote port (interfaces)
=item $sonmp->c_platform()
Returns reference to hash. Key: ifIndex.1 Value: Remote Device Type
Returns reference to hash. Key: IID, Value: Remote device type
=back

View File

@@ -5,7 +5,10 @@ Info.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
@@ -14,12 +17,15 @@ Info/CiscoVTP.pm
Info/Entity.pm
Info/EtherLike.pm
Info/FDP.pm
Info/IEEE802dot11.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/Aruba.pm
@@ -29,10 +35,12 @@ 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/N2270.pm
Info/Layer2/NAP222x.pm
Info/Layer2/Netgear.pm
Info/Layer2/Orinoco.pm
Info/Layer2/ZyXEL_DSLAM.pm
Info/Layer3.pm
@@ -44,18 +52,27 @@ Info/Layer3/C4000.pm
Info/Layer3/C6500.pm
Info/Layer3/Cisco.pm
Info/Layer3/Contivity.pm
Info/Layer3/Dell.pm
Info/Layer3/Enterasys.pm
Info/Layer3/Extreme.pm
Info/Layer3/Foundry.pm
Info/Layer3/Juniper.pm
Info/Layer3/Microsoft.pm
Info/Layer3/N1600.pm
Info/Layer3/Netscreen.pm
Info/Layer3/NetSNMP.pm
Info/Layer3/Passport.pm
Info/Layer3/Sun.pm
Info/LLDP.pm
Info/MAU.pm
Info/NortelStack.pm
Info/PowerEthernet.pm
Info/RapidCity.pm
Info/SONMP.pm
Makefile.PL
MANIFEST This list of files
README
t/docmunge
t/make_dev_matrix.pl
t/prereq.t
t/test_class.pl

204
README
View File

@@ -5,7 +5,7 @@ NAME
VERSION
SNMP::Info - Version 1.01
SNMP::Info - Version 1.07
AUTHOR
@@ -130,8 +130,11 @@ REQUIREMENTS
Various version 4's and 5.0 and 5.1 series will work. 5.0.1 is kinda
flaky on the Perl side.
Redhat Users: Certain versions that comes with certain versions of
Redhat/Fedora doesn't have the Perl library installed. Uninstall the
Versions 5.0301 and 5.0203 have issues with bulkwalk, turn off
bulkwalk.
Redhat Users: Some versions that come with certain versions of
Redhat/Fedora don't have the Perl library installed. Uninstall the
RPM and install by hand.
2. MIBS
@@ -199,10 +202,17 @@ SUBCLASSES
CISCO-CDP-MIB. Cisco Discovery Protocol (CDP) Support. Inherited by
Cisco and HP devices.
SNMP::Info::CiscoConfig
CISCO-CONFIG-COPY-MIB, CISCO-FLASH-MIB, and OLD-CISCO-SYS-MIB. These
OIDs facilitate the writing of configuration files.
SNMP::Info::CiscoImage
CISCO-IMAGE-MIB. A collection of OIDs providing IOS image
characteristics.
SNMP::Info::CiscoPortSecurity
CISCO-PORT-SECURITY-MIB.
SNMP::Info::CiscoQOS
CISCO-CLASS-BASED-QOS-MIB. A collection of OIDs providing
information about a Cisco device's QOS config.
@@ -212,12 +222,12 @@ SUBCLASSES
Cisco device's RTT values.
SNMP::Info::CiscoStack
CISCO-STACK-MIB and CISCO-PORT-SECURITY-MIB
CISCO-STACK-MIB.
SNMP::Info::CiscoStats
OLD-CISCO-CPU-MIB, CISCO-PROCESS-MIB, and CISCO-MEMORY-POOL-MIB.
Provides common interfaces for memory, cpu, and os statistics for
Cisco devices. Provides methods for information in :
OLD-CISCO-CPU-MIB, CISCO-PROCESS-MIB and CISCO-MEMORY-POOL-MIB
Cisco devices.
SNMP::Info::CiscoVTP
CISCO-VTP-MIB, CISCO-VLAN-MEMBERSHIP-MIB,
@@ -233,6 +243,14 @@ SUBCLASSES
SNMP::Info::FDP
Foundry Discovery Protocol. FOUNDRY-SN-SWITCH-GROUP-MIB
SNMP::Info::IEEE802dot11
IEEE802dot11-MIB. A collection of OIDs providing information about
standards based 802.11 wireless devices.
SNMP::Info::LLDP
LLDP-MIB, LLDP-EXT-DOT1-MIB, and LLDP-EXT-DOT3-MIB. Link Layer
Discovery Protocol (LLDP) Support.
SNMP::Info::MAU
MAU-MIB (RFC2668). Some Layer2 devices use this for extended
Ethernet (Media Access Unit) interface information.
@@ -274,6 +292,9 @@ SUBCLASSES
Subclass for Nortel/Bay hubs. This includes System 5000, 100
series, 200 series, and probably more.
SNMP::Info::Layer1::Cyclades
Subclass for Cyclades terminal servers.
SNMP::Info::Layer1::S3000
Subclass for Bay/Synoptics hubs. This includes System 3000,
281X, and probably more.
@@ -281,6 +302,9 @@ SUBCLASSES
SNMP::Info::Layer2
Generic Layer2 Device subclass.
SNMP::Info::Layer2::Airespace
Subclass for Cisco (Airespace) wireless controllers.
SNMP::Info::Layer2::Aironet
Class for Cisco Aironet wireless devices that run IOS. See also
Layer3::Aironet for Aironet devices that don't run IOS.
@@ -316,8 +340,12 @@ SUBCLASSES
SNMP::Info::Layer2::Centillion
Subclass for Nortel/Bay Centillion and 5000BH ATM switches.
SNMP::Info::Layer2::Cisco
Generic Cisco subclass for layer2 devices that are not yet
supported in more specific subclasses.
SNMP::Info::Layer2::Foundry
Subclass for Foundry Switches. Tested on EdgeIron 24G.
Depreciated. Use SNMP::Info::Layer3::Foundry.
SNMP::Info::Layer2::HP
Subclass for HP Procurve Switches
@@ -366,7 +394,7 @@ SUBCLASSES
SNMP::Info::Layer3::C6500
This class covers Catalyst 6500s in native mode, hybrid mode.
Catalyst 4000's, 3750's, 2970's and probably others.
Catalyst 3750's, 2970's and probably others.
SNMP::Info::Layer3::Cisco
This is a simple wrapper around Layer3 for IOS devices. It adds
@@ -375,29 +403,45 @@ SUBCLASSES
SNMP::Info::Layer3::Contivity
Subclass for Nortel Contivity/VPN Routers.
SNMP::Info::Layer3::Dell
Subclass for Dell PowerConnect switches.
SNMP::Info::Layer3::Enterasys
Subclass for Enterasys devices.
SNMP::Info::Layer3::Extreme
Subclass for Extreme Networks switches.
See SNMP::Info::Layer3::Extreme for more info.
SNMP::Info::Layer3::Foundry
Subclass for older Foundry Network devices. Outdated, but being
updated for newer devices.
Requires FOUNDRY-SN-ROOT-MIB.
Subclass for Foundry Network devices.
See SNMP::Info::Layer3::Foundry for more info.
SNMP::Info::Layer3::Juniper
Subclass for Juniper devices.
Subclass for Juniper devices
SNMP::Info::Layer3::Microsoft
Subclass for Generic Microsoft Routers running Microsoft Windows
OS.
SNMP::Info::Layer3::N1600
Subclass for Nortel Ethernet Routing Switch 1600 series.
SNMP::Info::Layer3::NetSNMP
Subclass for host systems running Net-SNMP.
SNMP::Info::Layer3::Netscreen
Subclass for Juniper NetScreen.
SNMP::Info::Layer3::Passport
Subclass for Nortel Ethernet Routing Switch/Passport 8000 series
and Accelar series switches.
SNMP::Info::Layer3::Sun
Subclass for Generic Sun Routers running SunOS.
Thanks
Thanks for testing and coding help (in no particular order) to : Andy
@@ -412,15 +456,16 @@ USAGE
new()
Creates a new object and connects via SNMP::Session.
my $info = new SNMP::Info( 'Debug' => 1,
'AutoSpecify' => 1,
'BigInt' => 1,
'BulkWalk' => 1,
'BulkRepeaters'=> 20,
'DestHost' => 'myrouter',
'Community' => 'public',
'Version' => 2,
'MibDirs' => ['dir1','dir2','dir3'],
my $info = new SNMP::Info( 'Debug' => 1,
'AutoSpecify' => 1,
'BigInt' => 1,
'BulkWalk' => 1,
'BulkRepeaters' => 20,
'LoopDetect' => 1,
'DestHost' => 'myrouter',
'Community' => 'public',
'Version' => 2,
'MibDirs' => ['dir1','dir2','dir3'],
) or die;
SNMP::Info Specific Arguments :
@@ -450,8 +495,20 @@ USAGE
(default 20)
LoopDetect
Detects looping during getnext table column walks by comparing
IIDs for each instance. A loop is detected if the same IID is
seen more than once and the walk is aborted. Note: This will not
detect loops during a bulkwalk operation, Net-SNMP's internal
bulkwalk function must detect the loop.
Set to 0 to turn off loop detection.
(default on)
Debug
Prints Lots of debugging messages
Prints Lots of debugging messages. Pass 2 to print even more
debugging messages.
(default off)
@@ -510,7 +567,7 @@ USAGE
data once, and then return cached versions of that data.
Run $info->load_METHOD() where method is something like 'i_name' to
reload data from a table method.
reload data from a method.
Run $info->clear_cache() to clear the cache to allow reload of both
globals and table methods.
@@ -532,12 +589,17 @@ USAGE
Optionally sets the bulkwalk parameter.
$info->loopdetect([1|0])
Returns if loopdetect is currently turned on for this object.
Optionally sets the loopdetect parameter.
$info->device_type()
Returns the Subclass name for this device. "SNMP::Info" is returned
if no more specific class is available.
First the device is checked for Layer 3 support and a specific
subclass, then Layer 2 support and subclasses are checked for.
subclass, then Layer 2 support and subclasses are checked.
This means that Layer 2 / 3 switches and routers will fall under the
SNMP::Info::Layer3 subclasses.
@@ -552,28 +614,42 @@ USAGE
AP4800... All Non IOS
Catalyst 3550,3548,3560 -> SNMP::Info::Layer3::C3550
Catalyst 4000,4500 -> SNMP::Info::Layer3::C4000
Catalyst 6500, 3750 -> SNMP::Info::Layer3::C6500
Catalyst 6500,3750 -> SNMP::Info::Layer3::C6500
Cisco Generic L3 IOS device -> SNMP::Info::Layer3::Cisco
Cyclades terminal server -> SNMP::Info::Layer1::Cyclades
Dell PowerConnect -> SNMP::Info::Layer3::Dell
Enterasys -> SNMP::Info::Layer3::Enterasys
Extreme -> SNMP::Info::Layer3::Extreme
Foundry -> SNMP::Info::Layer3::Foundry
Juniper -> SNMP::Info::Layer3::Juniper
Microsoft -> SNMP::Info::Layer3::Microsoft
Net-SNMP -> SNMP::Info::Layer3::NetSNMP
Nortel Passport/Accelar LAN -> SNMP::Info::Layer3::Passport
Nortel/Bay Baystack -> SNMP::Info::Layer2::Baystack
Alteon Ace Director -> SNMP::Info::Layer3::AlteonAD
Nortel Contivity -> SNMP::Info::Layer3::Contivity
Nortel BayRS Router -> SNMP::Info::Layer3::BayRS
Elsif Layer2 (no Layer3) -> SNMP::Info::Layer2
Sun Router -> SNMP::Info::Layer3::Sun
Elsif Layer2 (no Layer3) -> SNMP::Info::Layer2
Aironet - IOS Devices -> SNMP::Info::Layer2::Aironet
Catalyst 1900 -> SNMP::Info::Layer2::C1900
Catalyst 2900XL,2950,3500XL -> SNMP::Info::Layer2::C2900
Catalyst 2970 -> SNMP::Info::Layer3::C6500
Catalyst 2900XL,2940,2950,
3500XL -> SNMP::Info::Layer2::C2900
Catalyst 2960, 2970 -> SNMP::Info::Layer3::C6500
Catalyst 3550/3548 -> SNMP::Info::Layer3::C3550
Cisco 3400 w/ MetroBase -> SNMP::Info::Layer3::C3550
Catalyst WS-C 2926,5xxx -> SNMP::Info::Layer2::Catalyst
Cisco (Airespace) Wireless -> SNMP::Info::Layer2::Airespace
Cisco (not covered by above) -> SNMP::Info::Layer2::Cisco
Cyclades terminal server -> SNMP::Info::Layer1::Cyclades
Dell PowerConnect -> SNMP::Info::Layer3::Dell
Enterasys -> SNMP::Info::Layer3::Enterasys
Extreme -> SNMP::Info::Layer3::Extreme
Foundry (EdgeIron,????) -> SNMP::Info::Layer2::Foundry
Foundry -> SNMP::Info::Layer3::Foundry
HP Procurve -> SNMP::Info::Layer2::HP
Nortel/Bay Centillion ATM -> SNMP::Info::Layer2::Centillion
Nortel/Bay Baystack -> SNMP::Info::Layer2::Baystack
Nortel Business Ethernet Switch-> SNMP::Info::Layer2::Baystack
Nortel Passport/Accelar 8100 -> SNMP::Info::Layer3::Passport
Nortel AP 222x -> SNMP::Info::Layer2::NAP222x
Orinco AP -> SNMP::Info::Layer2::Orinoco
@@ -586,6 +662,7 @@ USAGE
Else -> SNMP::Info
ZyXEL_DSLAM -> SNMP::Info::Layer2::ZyXEL_DSLAM
Aruba wireless -> SNMP::Info::Layer2::Aruba
Juniper NetScreen -> SNMP::Info::Layer3::Netscreen
$info->error(no_clear)
Returns Error message if there is an error, or undef if there is
@@ -691,8 +768,9 @@ USAGE
Partial Table Fetches
If you want to get only a part of an SNMP table and you know the IID for
the part of the table that you want, you can specify it in the call:
If you want to get only a part of an SNMP table or a single instance
from the table and you know the IID for the part of the table that you
want, you can specify it in the call:
$local_routes = $info->ipr_route('192.168.0');
@@ -845,6 +923,36 @@ USAGE
(ifInBroadcastPkts) (ifOutBroadcastPkts) (ifHCInBroadcastPkts)
(ifHCOutBroadcastPkts)
$info->i_discards_in() $info->i_discards_out()
"The number of inbound packets which were chosen to be discarded
even though no errors had been detected to prevent their being
deliverable to a higher-layer protocol. One possible reason for
discarding such a packet could be to free up buffer space." (IF-MIB)
(ifInDiscards) (ifOutDiscards)
$info->i_bad_proto_in()
"For packet-oriented interfaces, the number of packets received via
the interface which were discarded because of an unknown or
unsupported protocol. For character-oriented or fixed-length
interfaces that support protocol multiplexing the number of
transmission units received via the interface which were discarded
because of an unknown or unsupported protocol. For any interface
that does not support protocol multiplexing, this counter will
always be 0."
(ifInUnknownProtos)
$info->i_qlen_out()
"The length of the output packet queue (in packets)."
(ifOutQLen)
$info->i_specific()
See IF-MIB for full description
(ifSpecific)
IP Address Table
Each entry in this table is an IP address in use on this device. Usually
@@ -1242,6 +1350,7 @@ SNMP::INFO INTERNALS
'622000000' => 'OC-12',
'622080000' => 'OC-12',
'1000000000' => '1.0 Gbps',
'2488000000' => 'OC-48',
)
munge_highspeed()
@@ -1325,7 +1434,8 @@ SNMP::INFO INTERNALS
$info->_set(attr,val,iid)
Used internally by AUTOLOAD to run an SNMP set command for dynamic
methods listed in either %GLOBALS or %FUNCS.
methods listed in either %GLOBALS or %FUNCS or a valid mib leaf from
a loaded MIB. Clears attr cache on sucessful set.
Example: $info->set_name('dog',3) uses autoload to resolve to
$info->_set('name','dog',3);
@@ -1349,7 +1459,10 @@ SNMP::INFO INTERNALS
$info->_load_attr()
Used internally by AUTOLOAD to fetch data called from methods listed
in %FUNCS.
in %FUNCS or a MIB Leaf node name.
Supports partial table fetches and single instance table fetches.
See "Partial Table Fetches" in SNMP::Info.
Called from $info->load_METHOD();
@@ -1367,20 +1480,27 @@ SNMP::INFO INTERNALS
AUTOLOAD
Each entry in either %FUNCS or %GLOBALS is used by AUTOLOAD() to create
dynamic methods.
Each entry in either %FUNCS, %GLOBALS, or MIB Leaf node names present in
loaded MIBs are used by AUTOLOAD() to create dynamic methods.
Note that this AUTOLOAD is going to be run for all the classes listed in
the @ISA array in a subclass, so will be called with a variety of
package names. We check the %FUNCS and %GLOBALS of the package that is
doing the calling at this given instant.
1. Returns unless method is listed in %FUNCS or %GLOBALS for given class
2. If the method exists in %GLOBALS it runs $info->_global(method)
unless already cached.
3. Method is in %FUNCS
4. Run $info->_load_attr(method) if not cached
5. Return $info->_show_attr(method).
1. Returns unless method is listed in %FUNCS, %GLOBALS, or is MIB Leaf
node name in a loaded MIB for given class.
2. Checks for load_ prefix and if present runs $info->_global(method)
for methods which exist in %GLOBALS or are a single instance MIB Leaf
node name, otherwise runs $info->_load_attr(method) for methods which
exist in %FUNCS or are MIB Leaf node name contained within a table. This
always forces reloading and does not use cached data.
3. Check for set_ prefix and if present runs $info->_set(method).
4. If the method exists in %GLOBALS or is a single instance MIB Leaf
node name it runs $info->_global(method) unless already cached.
5. If the method exists in %FUNCS or is MIB Leaf node name contained
within a table it runs $info->_load_attr(method) if not cached.
6. Otherwise return $info->_show_attr(method).
Override any dynamic method listed in one of these hashes by creating a
subroutine with the same name.

35
t/docmunge Executable file
View File

@@ -0,0 +1,35 @@
#!/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

@@ -295,6 +295,10 @@ be assumed working.
</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

View File

@@ -13,7 +13,7 @@ use lib '/usr/local/netdisco';
use SNMP::Info;
use Getopt::Long;
use strict;
use vars qw/$Class $Dev $Comm $Ver @Dump %Dumped/;
use vars qw/$Class $Dev $Comm $Ver @Dump %Dumped $Debug %args $NoBulk/;
# Default Values
$Class = '';
@@ -21,13 +21,17 @@ $Dev = '';
$Comm = '';
$Ver = 2;
@Dump = ();
$Debug = 0;
$NoBulk = 0;
GetOptions ('c|class=s' => \$Class,
'd|dev=s' => \$Dev,
's|comm=s' => \$Comm,
'v|ver=i' => \$Ver,
'h|help' => \&usage,
'p|print=s' => \@Dump,
GetOptions ('c|class=s' => \$Class,
'd|dev=s' => \$Dev,
's|comm=s' => \$Comm,
'v|ver=i' => \$Ver,
'h|help' => \&usage,
'p|print=s' => \@Dump,
'x|debug+' => \$Debug,
'n|nobulk' => \$NoBulk,
);
&usage unless ($Dev and $Comm);
@@ -42,12 +46,18 @@ print "Class $Class loaded.\n";
print "Dumping : ",join(',',@Dump),"\n" if scalar @Dump;
%args = ();
if ($NoBulk) {
$args{BulkWalk} = 0;
}
my $dev = new $Class( 'AutoSpecify' => 0,
'AutoVerBack' => 0,
'Version' => $Ver,
'Debug' => 0,
'Debug' => $Debug,
'DestHost' => $Dev,
'Community' => $Comm
'Community' => $Comm,
%args
) or die "\n";
print "Connected to $Dev.\n";
@@ -135,6 +145,10 @@ sub test_fn {
return 0;
}
# If accidentally called on a global, pass it along nicely.
if (defined($results) and !ref($results)) {
return test_global($dev, $method);
}
unless (defined $results and scalar keys %$results) {
printf "%-20s Empty Results.\n",$method;
return 0;
@@ -144,7 +158,13 @@ sub test_fn {
if (grep(/^$method$/,@Dump)) {
$Dumped{$method} = 1;
foreach my $iid (keys %$results){
print " $iid : $results->{$iid}\n";
print " $iid : ";
if (ref($results->{$iid}) eq 'ARRAY') {
print "[ ", join(", ", @{$results->{$iid}}), " ]";
} else {
print $results->{$iid};
}
print "\n";
}
}
return 1;
@@ -154,12 +174,14 @@ sub usage {
print << "end_usage";
test_class - Test a device against an SNMP::Info class
-c --class Layer2::Catalyst
-d --dev myswitch
-s --comm public
-v --ver 2
-p --print i_blah
-p --print i_blah2
-c --class Layer2::Catalyst
-d --dev myswitch
-s --comm public
-v --ver 2
-p --print i_blah
-p --print i_blah2
-x --debug debugging flag
-n --nobulk disable bulkwalk
end_usage
exit;