Compare commits

...

315 Commits

Author SHA1 Message Date
Eric Miller
8aee915872 make update 2006-04-07 03:25:06 +00:00
Eric Miller
eeac8fd9a2 fix namespace snmp_connect_ip() 2006-04-07 02:46:04 +00:00
Eric Miller
07db467827 doc updates, fix namespace snmp_connect_ip() 2006-04-07 02:44:14 +00:00
Eric Miller
8bed2081b9 doc updates, fix namespace snmp_connect_ip() 2006-04-07 02:31:20 +00:00
Eric Miller
f0e0b9063c doc 2006-04-06 21:41:43 +00:00
Bill Fenner
41907297f8 Commit in the directory I thought I was in before, and add
Juniper to the DeviceMatrix.
While I'm fixing mistakes, add the .0 to jnxBoxSerialNo.0
2006-04-06 21:31:48 +00:00
Eric Miller
2e0392a6db Note Sup720-3B and NativeIOS 12.2 (17d)SXB10 problem (Ralf Gross) and misc updates 2006-04-06 21:14:38 +00:00
Bill Fenner
3c4b8911f5 Add i_speed_high(), which i_speed() uses if needed to support
interfaces >4Gbps
2006-04-06 20:50:46 +00:00
Bill Fenner
3db7164f9f Add Juniper.pm and C4000.pm 2006-04-06 20:46:17 +00:00
Bill Fenner
cfe3c34ab6 Add Juniper. 2006-04-06 20:45:07 +00:00
Bill Fenner
ceac50e33e Use CISCO-DOT11-IF-MIB to get SSID and channel info per radio port. 2006-04-05 06:11:18 +00:00
Bill Fenner
b71ba01d32 Create and use a duplex_munge to remove the string "Duplex" from the
return value of el_duplex().

Submitted by:	Justin Hunter (arcanez)
2006-04-05 05:43:36 +00:00
Bill Fenner
5cc00d443c Use SNMP::Info::MAU for mau_i_speed_admin.
Update documentation to note that we use SNMP::Info::MAU and
 remove some bits accidentally copied from another Cisco class.
2006-04-05 05:11:55 +00:00
Bill Fenner
4edb3115e5 Add [the beginning of] a Layer3::Juniper class.
Junipers worked with SNMP::Info::Layer3; this class's main purpose
 is to get the device inventory a bit nicer.
2006-04-05 04:16:36 +00:00
Bill Fenner
33435d89e4 Allow calls to orig_foo, load_orig_foo, set_orig_foo
to be able to call a FUNC that you've overloaded with a function.
2006-04-05 03:59:58 +00:00
Eric Miller
f5c93b3413 updates 2006-04-05 03:58:11 +00:00
Eric Miller
59fbe71c56 fix for models not returning complete bp_index() 2006-04-05 03:42:10 +00:00
Eric Miller
4f6b5f0883 root ip check 2006-04-05 02:38:40 +00:00
Eric Miller
23eb3b596d remove root_ip() 2006-04-05 02:34:19 +00:00
Eric Miller
55b2a27f40 check for unreachable root ip before assignment 2006-04-05 02:30:17 +00:00
Eric Miller
5e46120b52 not really 2006-04-05 02:15:51 +00:00
Eric Miller
4b70bfa7c8 check for unreachable root ip before assignment 2006-04-05 02:09:06 +00:00
Eric Miller
c530e25e02 check for unreachable root ip before assignment 2006-04-05 01:57:12 +00:00
Eric Miller
409065375e add sub _snmp_connect_ip 2006-04-05 01:45:53 +00:00
Bill Fenner
32ccc2857f Implement mau_i_speed_admin based on the strings in the middle of
ifMauDefaultType
2006-03-29 21:46:55 +00:00
Bill Fenner
c1025cb76f Use SNMPv2-MIB instead of RFC1213-MIB for sysDescr 2006-03-29 21:45:30 +00:00
Bill Fenner
1f6a738cda Updated MODEL_MAP from HP-ICF-OID MIB, partly based on email from
Robert Kerr.
2006-03-29 00:33:59 +00:00
Bill Fenner
8f10a4f16e Add a new class for Cisco Catalyst 4000/4500 and move 4000 support to use it. 2006-03-28 22:14:37 +00:00
Bill Fenner
50d9fdefb3 Rewrite mau_i_duplex_admin in terms of mau_type_admin (ifMauDefaultType).
Call the old one (mau_i_duplex_admin_old) if mau_type_admin is empty.

Most modern devices support ifMauDefaultType but not everything
 supports ifMauAutoNegCapAdvertised.
2006-03-28 22:11:44 +00:00
Bill Fenner
d777d98396 Inherit CiscoStats to get the products MIB in scope so that the product
ID gets translated.
Enable CDP.  In bridge mode it's possible that there's something to
 learn from it.
2006-03-28 22:06:48 +00:00
Bill Fenner
75e7b0c6b0 Print the result of device_type().
If you ask for a dump with -p, and it's not in the list of things we're
 already grabbing, grab it at the end.
2006-03-28 22:02:00 +00:00
Eric Miller
9fc965d095 try to capture all the names 2006-02-21 03:25:41 +00:00
Eric Miller
10b4611e81 update for duplex, vlan properties 2006-02-21 02:26:54 +00:00
Eric Miller
f416f7cc49 duplex write, vlan properties 2006-02-21 02:25:14 +00:00
Eric Miller
50d9070f36 updates for 1.0 2006-02-21 01:07:02 +00:00
Eric Miller
14db80441c doc update 2006-02-18 04:33:02 +00:00
Eric Miller
6193e661f5 remove e-mail 2006-02-18 04:31:24 +00:00
Eric Miller
3e69394cca updates 2006-02-18 04:08:59 +00:00
Eric Miller
88cdcebe2d use EXTREME-FDB-MIB instead of BRIDGE-MIB since BRIDGE-MIB must be explicitly enabled on these devices and does not respond by default. Fix duplex status reporting. 2006-02-18 04:03:34 +00:00
Eric Miller
20024f8c50 add set_i_duplex_admin() and set_i_speed_admin() methods, add portCrossIndex in %FUNCS to support bp_index() patch in Catalyst class 2006-02-18 03:55:36 +00:00
Eric Miller
40caf6cc0e use CISCO-STACK-MIB for bridge port mapping rather than BRIDGE-MIB due to some devices not returning complete index 2006-02-18 03:49:55 +00:00
Eric Miller
2d3b28b973 Carlos Vicente's ipforwarding patch - SF 1431212 and doc updates 2006-02-16 04:58:42 +00:00
Eric Miller
325b087bd1 Carlos Vicente's BGP patch - SF 1431212 2006-02-16 03:42:20 +00:00
Eric Miller
0703a5f777 Alexander Barthel's STP patches SF 1424342 2006-02-16 02:35:28 +00:00
Eric Miller
c4a4749bcf new features 2006-02-02 04:22:48 +00:00
Eric Miller
1fd0facbe0 cisco qos, cisco rtt, synoptics 2006-02-02 04:21:56 +00:00
Eric Miller
bc9ab17f2d update supported lists with new models 2006-02-02 04:20:35 +00:00
Eric Miller
22fd4f73a9 Alexander Hartmaier's patch - SF 1369007 2006-02-02 03:37:06 +00:00
Eric Miller
4de346fa39 synoptics hub support 2006-02-01 22:30:42 +00:00
Eric Miller
e14c749f66 Alexander Hartmaier's patch, Cisco RTT - SF 1369007 2006-02-01 22:27:32 +00:00
Eric Miller
c0f1872f04 Alexander Hartmaier's patch, Cisco QOS - SF 1369007 2006-02-01 22:26:08 +00:00
Eric Miller
70944f0589 Aruba os name change - Brian Chow 2006-01-31 13:10:58 +00:00
Eric Miller
d2b4c85d37 doc updates 2006-01-26 04:46:18 +00:00
Eric Miller
a4cc2f5514 Nortel arpnip support for stackable layer 3 models 2006-01-26 04:41:07 +00:00
Eric Miller
fa8f91d508 Nortel name changes and arpnip support for Layer 3 models 2006-01-26 04:39:06 +00:00
Eric Miller
7966400cf2 Nortel name changes 2006-01-25 19:35:11 +00:00
Eric Miller
3227540322 capture more models 2006-01-25 19:30:18 +00:00
Eric Miller
183f8bde3a Extreme Summit fix 2006-01-25 17:57:24 +00:00
Eric Miller
62133dfedf Nortel 2270, Extreme, Aruba 2006-01-25 03:19:22 +00:00
Eric Miller
eb833c69e3 add support for disabling/enabling ports 2006-01-24 21:47:39 +00:00
Eric Miller
53d96a2e32 documentation changes 2006-01-24 21:19:06 +00:00
Eric Miller
efc1682877 documentation 2006-01-24 20:56:01 +00:00
Eric Miller
8846bb2f0f documentation 2006-01-24 20:47:58 +00:00
Eric Miller
558c80aa84 Aruba wireless support 2006-01-24 20:15:16 +00:00
Eric Miller
f905638e5b 2270 wireless switch (airespace) support 2006-01-24 19:58:27 +00:00
Max Baker
d1636f0fe9 fix a small warning 2006-01-17 04:18:10 +00:00
Max Baker
1d1193c459 Fixed manifest with changes from Benny Kj�rgaard <benny@catpipe.net>
and other recent additions
2006-01-17 04:17:15 +00:00
Eric Miller
4a2e62be2d aruba wireless switch support 2005-11-16 21:41:23 +00:00
Eric Miller
137cc84ca6 nortel 2270 wireless switch support 2005-11-16 21:28:02 +00:00
Eric Miller
e744df1dca airespace wireless switch support 2005-11-16 21:23:32 +00:00
Eric Miller
378dc6bc19 doc again 2005-11-14 04:16:24 +00:00
Eric Miller
3f2f722dab doc correction 2005-11-14 04:08:07 +00:00
Eric Miller
25f57d65a5 Justin Hunter's patch, SF ID 1341140 2005-11-14 03:38:26 +00:00
Eric Miller
f5dba96839 Justin Hunter's patch, SF ID 1341140, add set_i_duplex_admin and set_i_speed_admin methods 2005-11-13 04:18:33 +00:00
Eric Miller
3a1d04eb38 bp_index fix - some 8600's not working properly 2005-11-11 21:34:15 +00:00
Eric Miller
adac25b3dd extreme networks support 2005-09-29 02:50:36 +00:00
Eric Miller
9b2229e3eb remove root_ip() 2005-09-29 02:48:45 +00:00
Eric Miller
bf040dffa9 add extreme networks support 2005-09-29 02:06:32 +00:00
Eric Miller
86a12cd2a6 Initial Import 2005-09-22 19:15:24 +00:00
Eric Miller
bfcb56f06d correct Nortel 1600 definition 2005-06-03 18:12:32 +00:00
Eric Miller
9a4a336c78 add support for Nortel 1600 and 8100 series 2005-06-03 04:27:20 +00:00
Eric Miller
6696eeeb9d add support for Nortel 1600 and 8100 series 2005-06-03 04:20:22 +00:00
Eric Miller
4da90c4f9b add support for Nortel 1600 and 8100 series 2005-06-03 04:14:55 +00:00
Eric Miller
88f31110a7 doc cleanup 2005-06-03 04:01:48 +00:00
Eric Miller
afab6191b2 add support for Nortel N16XX series 2005-06-03 03:46:47 +00:00
Eric Miller
7ce87ebd3d add support for 8100 series, doc cleanup 2005-06-03 03:39:56 +00:00
Eric Miller
d8e1e932ae fix for mac() when topology off 2005-06-03 03:02:36 +00:00
Max Baker
089430de17 Added basic i_set_vlan() 2005-04-27 04:31:11 +00:00
Max Baker
dce0a40ebb some device isn't returning a description? 2005-04-27 04:30:37 +00:00
Eric Miller
2347edad82 add support for Accelar Layer 3 2005-04-07 04:09:03 +00:00
Eric Miller
0ab5eb2bf1 add support for Accelar Layer 3 2005-04-07 04:03:17 +00:00
Eric Miller
d314ffe897 add support for Accelar Layer 3 2005-04-07 03:54:40 +00:00
Eric Miller
1162dc3a7b add endofmibview exception handling 2005-03-28 00:52:17 +00:00
Eric Miller
0967634043 change vendor to be consistent 2005-03-10 03:54:04 +00:00
Eric Miller
133355bc9d only use OSPF router ID if IP interface exists 2005-03-10 03:42:16 +00:00
Eric Miller
76c734dc01 restrict Passport class to 8600 2005-03-10 03:14:55 +00:00
Eric Miller
3128e3e5f6 correct vlan port id, typo 2005-03-09 22:06:28 +00:00
Eric Miller
c9ebd5ae28 correct vlan port id 2005-03-09 22:02:12 +00:00
Max Baker
b6efcd86dd vi typo too :-| 2005-02-21 05:16:20 +00:00
Max Baker
a0323aacd2 oops forgot a comma 2005-02-21 05:14:51 +00:00
Max Baker
258b7551ff still trying to get interfaces() right for l2/* 2005-02-18 18:32:41 +00:00
Max Baker
7a023554eb Added CDP back to HP 2005-02-18 03:52:10 +00:00
Max Baker
b557c9d890 removed all cisco stuff from l2 and readded it to L2::C* classes 2005-02-18 03:50:42 +00:00
Max Baker
8dae0aad96 took out some kludy cisco-specific stuff from interfaces() 2005-02-18 03:34:23 +00:00
Max Baker
902383cab7 oops 2005-02-17 06:11:14 +00:00
Max Baker
a1eb6e5831 added interface flowcontrol stuff to ciscostack (n. petri) 2005-02-17 02:02:24 +00:00
Max Baker
3656d4c514 *** empty log message *** 2005-02-17 01:50:47 +00:00
Max Baker
e899f76249 aesthetic.. remove sn from the beg. of model names 2005-02-17 01:45:46 +00:00
Max Baker
d38bfcbbf7 removed Carp and changed to error_throw(). 2005-02-17 01:45:21 +00:00
Max Baker
0f654f5aaa - removed some MIB documentation. expect ppl to use my mib package or suffer.
- added bulkwalk() method so it can be changed dynamically.
- added support for L2::Foundry
- removed rfc1213-mib -- net-snmp does this for us
- fixed some typos in _load_attr()
2005-02-17 01:44:22 +00:00
Max Baker
6cab3ad6b3 *** empty log message *** 2005-02-17 01:41:34 +00:00
Max Baker
6685e4dd77 brought this thing back to life 2005-02-17 01:31:49 +00:00
Max Baker
2b42f25d1e added CiscoImage class 2005-02-17 01:30:26 +00:00
Max Baker
85359ddf59 *** empty log message *** 2005-02-17 01:16:49 +00:00
Max Baker
1e198a8d8e turned off bulkwalk 2005-02-16 23:24:46 +00:00
Max Baker
6bd545d307 foundry fixes 2005-01-28 09:26:53 +00:00
Max Baker
bc53167731 *** empty log message *** 2005-01-28 08:56:27 +00:00
Max Baker
9a5135b9e1 Prep for 1.0:
- removed all references to $DEBUG, $INIT and $SNMP::debugging
- rev'd version number
- doc updates
- added cdp_run() to FDP.pm
- removed my email addr from all over the place
2005-01-28 08:55:51 +00:00
Max Baker
8193143459 doc improvements 2005-01-28 08:54:04 +00:00
Max Baker
61ac00d7fb - Moved i_duplex and i_duplex_admin routines over from L2::HP so they could
be used by other classes (foundry...)
- removed DEBUG and INIT references.
- rev'd to 1.0
2005-01-28 08:44:26 +00:00
Max Baker
7944613d42 1.0 prep :
- whitespace changes
    - remove email
    - rev vers no.
2005-01-28 08:41:19 +00:00
Max Baker
ff07325a05 Prepped for 1.0 :
- some minor white space changes (\t -> spaces)
    - removed email
    - removed $DEBUG, $INIT and $SNMP::debugging references
    - rev'd version
2005-01-28 08:39:35 +00:00
Max Baker
afe5436749 preped for 1.0 :
- removed INIT and DEBUG specific stuff
    - removed SNMP::debugging stuff
    - removed my email addr
    - set VERSION
2005-01-28 08:38:00 +00:00
Max Baker
ade9d7ef32 moved i_duplex and i_duplex_admin to MAU
moved i_vlan code to BRIDGE-MIB
preped for 1.0
2005-01-28 08:37:26 +00:00
Max Baker
6a397d7c72 moved i_vlan() from l2::hp over here as qb_i_vlan_t(). rev'd to 1.0 2005-01-28 08:34:50 +00:00
Max Baker
933bbaf00b - Rev'd to 1.0
- Added DebugSNMP option
- fixed [ 1111284 ] Parameters not being set with AutoSpecify
  by changing around arg passing in new() and specify()
- took out the bulkwalk_no for net-snmp 5.1 thing
- fixed up the check for $INIT and $DEBUG so they don't have to be explicitly
   set in every subclass.
- Fixed error detection when creating a new SNMP Session
+ Added L2::Foundry to device_type()
+ Added munge_i_up() to account for bug where IF-MIB and RFC1213-MIB data collide
2005-01-28 08:33:16 +00:00
Max Baker
1bd53dda51 added all methods from mib and expanded docs 2005-01-28 03:56:57 +00:00
Max Baker
5595fea427 documentation catch up 2005-01-26 19:22:02 +00:00
Max Baker
31661b1374 added ciscostats and cdp back into 3550 and 6500 classes. rev'd to 1.0 2005-01-26 19:05:28 +00:00
Max Baker
780965728e added net-snmp 2005-01-21 00:12:57 +00:00
Max Baker
a7570d9e58 cleanup 2005-01-18 02:42:19 +00:00
Max Baker
b6989e8ada added entity-mib to l2 and l3 classes. abstracted non cisco stuff from L3 to L3::Cisco and CiscoStats 2005-01-18 01:59:19 +00:00
Max Baker
f9f4daea94 minor fix in os_ver() to remove warning 2005-01-17 06:16:43 +00:00
Max Baker
ab175a747c change 0.1 to 0.10. doh. 2005-01-06 02:35:46 +00:00
Max Baker
2a10991980 heh, nice catch 2004-11-20 05:18:24 +00:00
Max Baker
95d3d45e66 oops 2004-11-20 05:11:13 +00:00
Max Baker
d808fc1e6f typo found by diabolic_mdog 2004-11-20 05:10:42 +00:00
Max Baker
e8f81b17fa *** empty log message *** 2004-11-19 01:02:54 +00:00
Max Baker
db871c590c added bulkwalk and bulkrepeaters options 2004-11-19 01:01:27 +00:00
Max Baker
de464b2e6a prep 2004-11-16 01:42:32 +00:00
Max Baker
e0acc5ce90 doc upgrades 2004-11-16 01:40:56 +00:00
Max Baker
a1f913d91e doc upgrades for 0.9 2004-11-16 01:32:10 +00:00
Max Baker
d19b71073d Added L3::Cisco class, added method check to _set() 2004-11-15 23:31:20 +00:00
Max Baker
ed66350c27 added cisco-vlan-iftable vlan info 2004-11-15 23:30:07 +00:00
Max Baker
51d57b39f5 Added ciscovtp 2004-11-15 23:28:40 +00:00
Max Baker
68524eb337 *** empty log message *** 2004-11-15 23:28:00 +00:00
Max Baker
58f8ed29c7 added CISCO-PORT-SECURITY-MIB in its entirety 2004-11-14 23:07:53 +00:00
Eric Miller
3b96232e13 fix for serial and index_factor 2004-11-04 18:17:55 +00:00
Eric Miller
19b5d34c10 fix bayrs match, rcs tag 2004-11-04 17:46:28 +00:00
Max Baker
5bb4252cf0 pod error 2004-11-01 20:33:33 +00:00
Max Baker
8191d5f957 bruce roger's foundry changes 2004-11-01 19:19:38 +00:00
Max Baker
1c458c9ca9 missed this one 2004-10-28 21:57:32 +00:00
Max Baker
36f84e357e added RCS id tag and rev'd all version numbers to 0.9 2004-10-28 21:53:15 +00:00
Max Baker
c1b7d7dfc0 +jeneric's massive Nortel functionality patch. L2::Bay depricated 2004-10-28 21:45:00 +00:00
Max Baker
bbd45f82ab + MibDir addition to allow for specifying mib dirs.
* _global() change so that failed data is cached and not
            attempted to be retrieved.
            This includes NOSUCH* type returns
+ All of jerneric's kick-ass Nortel additions and typo fixes.
2004-10-28 21:43:53 +00:00
Max Baker
02f3e91c5d added null string removal in CDP info 2004-10-28 21:40:11 +00:00
Max Baker
d5afa9f592 got rid of some warnings for undef models 2004-10-28 21:37:36 +00:00
Max Baker
dceec4f537 added c3560 to c3550 class 2004-10-13 16:38:30 +00:00
Max Baker
51b09605df added dump 2004-09-27 14:48:42 +00:00
Max Baker
dc00c7d907 Added BULKWALK patch from b.baetz 2004-09-27 14:48:19 +00:00
Max Baker
c6df2928a1 *** empty log message *** 2004-06-29 17:35:17 +00:00
Max Baker
86bf9fd360 *** empty log message *** 2004-06-29 02:00:17 +00:00
Max Baker
505de8c6dc *** empty log message *** 2004-06-29 01:58:51 +00:00
Max Baker
70744f3df2 added i_lastchange() 2004-06-21 15:33:12 +00:00
Max Baker
96393d5781 added check for root_ip() addresses of all zeros 2004-06-19 23:21:01 +00:00
Max Baker
598c075670 *** empty log message *** 2004-06-19 23:20:34 +00:00
Max Baker
ac8eef8f73 typo 2004-06-19 23:20:19 +00:00
Max Baker
f5eb4e8bb6 doc info found by IAN@CPAN 2004-06-19 23:14:09 +00:00
Max Baker
abb7fe7f3c removed small warning if no bay_topo_platform() entry was found in c_platform() 2004-04-23 20:18:08 +00:00
Max Baker
440bb002b6 doc changes 2004-03-22 04:22:00 +00:00
Max Baker
6dd3f4b21a a little undef checking gets rid of warnings 2004-03-14 17:31:20 +00:00
Max Baker
1278117b05 added c6sup1 to l3:c6500 2004-03-14 17:30:26 +00:00
Max Baker
5c6c75b42e Fixed Bug [ 911235 ] -- added sub os() by accident.. Cut and paste happy.
Reported by Bradley Baetz - bbaetz
2004-03-07 19:53:34 +00:00
Max Baker
d78e5d6656 added cisco_comm_indexing() method for clarification/customization purposed. 2004-03-02 05:46:14 +00:00
Max Baker
094c2d548d added device_type() debugging info. 2004-03-02 05:22:35 +00:00
Max Baker
4913ac6cdd added q-bridge-mib stuff. and some docs 2004-03-02 05:15:40 +00:00
Max Baker
ac9efcf8ba added q-bridge mib stuff 2004-03-02 04:57:04 +00:00
Max Baker
6b4444d97a version and copyright change for 0.8 prep 2004-02-13 06:30:31 +00:00
Max Baker
607d5f04bd graph changes 2004-02-13 06:19:20 +00:00
Max Baker
b46aa416a0 order of precedence on serial no. entry 2004-02-13 06:18:57 +00:00
Max Baker
800aa0b4f0 Added device matrix graphing fun 2004-02-13 05:15:32 +00:00
Max Baker
a0e0be2d68 added more serial() support for L2 and L3 2004-02-12 21:16:37 +00:00
Max Baker
3fa47dc2e6 added HP-VLAN 2004-02-10 17:29:26 +00:00
Max Baker
25141d3c8e Added C1900 to ::CiscoVTP 2004-02-10 17:28:34 +00:00
Max Baker
1f02aeaec4 added support for CISCO-VLAN-MEMBERSHIP and all the i_vlan* funcs. 2004-02-10 17:24:22 +00:00
Max Baker
5d4aada8f5 added Q-BRIDGE 2004-02-10 17:23:45 +00:00
Max Baker
3bd7f78277 added weird description for c6500's 2004-02-10 17:23:11 +00:00
Max Baker
3994706465 fix by dana watanabe to support C3500xl in description string. Added new T3 to speed map 2004-02-06 03:25:10 +00:00
Max Baker
12bf18ac02 added more devices to model map 2004-01-28 06:41:40 +00:00
Max Baker
5c6a8f3c45 checked for empty id in model() 2004-01-28 06:41:19 +00:00
Max Baker
ddddb703aa *** empty log message *** 2004-01-28 06:19:56 +00:00
Max Baker
5ef4c78f8a Added ap4800 to l3:aironet class 2004-01-28 06:14:18 +00:00
Max Baker
05a7f104a4 *** empty log message *** 2004-01-28 06:13:58 +00:00
Max Baker
da1183b4fa fixed up os_ver to parse old AP4800's 2004-01-28 06:13:23 +00:00
Max Baker
a51ad7ee88 added Cisco 2970 to l3:c6500 class 2004-01-28 06:06:03 +00:00
Max Baker
df3e0e3b3a *** empty log message *** 2004-01-21 07:13:39 +00:00
Max Baker
c156584417 *** empty log message *** 2004-01-20 16:47:48 +00:00
Max Baker
74e649a033 removed warning about non numeric port line 199 2004-01-20 16:44:20 +00:00
Max Baker
342a45a424 added check for os() and descr() in model() 2004-01-20 16:39:23 +00:00
Max Baker
7076c236ea *** empty log message *** 2004-01-07 00:11:39 +00:00
Max Baker
0d90383ea3 case on model/os 2004-01-07 00:10:26 +00:00
Max Baker
fe59f88dd3 added older aironet, l2:allied, l2:zyxel 2004-01-06 23:56:17 +00:00
Max Baker
2f4704b18d *** empty log message *** 2004-01-06 23:55:47 +00:00
Max Baker
c8c94bbd8b added cat4000 and 3750s to l3:c6500 class 2004-01-05 00:16:07 +00:00
Max Baker
054e27e827 added C3500XL support 2003-09-23 02:56:51 +00:00
Max Baker
766f14d2bf ver 0.7 prep 2003-08-14 18:24:56 +00:00
Max Baker
4e52756a41 *** empty log message *** 2003-08-05 19:16:38 +00:00
Max Baker
55fc398ddf added classes, snmp_ver 2003-08-05 19:11:17 +00:00
Max Baker
a5e8e6c7cd *** empty log message *** 2003-08-05 19:10:57 +00:00
Max Baker
bb8762835f *** empty log message *** 2003-08-05 18:37:38 +00:00
Max Baker
7c8b1a8853 *** empty log message *** 2003-08-05 16:41:12 +00:00
Max Baker
be8140a142 *** empty log message *** 2003-08-05 01:49:04 +00:00
Max Baker
f7c57860b7 *** empty log message *** 2003-08-04 21:50:25 +00:00
Max Baker
c44fc3ddbe added v_name and v_port tests 2003-08-04 21:49:43 +00:00
Max Baker
c2fd3bd3a4 fixed os() for IOS Catalyst devices to report IOS and not CatOS 2003-08-04 21:49:14 +00:00
Max Baker
dfff2624ac added support for AP1200 2003-08-04 21:48:14 +00:00
Max Baker
91c40fddb6 *** empty log message *** 2003-08-04 21:47:43 +00:00
Max Baker
cafeb36418 *** empty log message *** 2003-08-04 19:56:25 +00:00
Max Baker
fa56c7b332 extracted CiscoStack stuff, included new class 2003-07-29 19:31:03 +00:00
Max Baker
a52f1f3d37 added serial, fixed i_duplex(), interfaces 2003-07-29 19:30:28 +00:00
Max Baker
476053c539 added C6500 class. Added dual t1 to speed map 2003-07-29 19:29:38 +00:00
Max Baker
0530c5d9e9 *** empty log message *** 2003-07-29 19:27:12 +00:00
Max Baker
b982e95c42 Extracted CISCO-STACK-MIB to SNMP::Info::CiscoStack 2003-07-29 18:03:24 +00:00
Max Baker
de286cbfa0 extracted from l2::catalyst 2003-07-29 18:03:02 +00:00
Max Baker
a94c685c6d changed speed_map 2003-07-29 15:43:50 +00:00
Max Baker
58feb21dec made static table entries appear in same format as cam table entries 2003-07-29 15:33:03 +00:00
Max Baker
81f0b821e3 changed speedmap 2003-07-29 15:32:07 +00:00
Max Baker
ea8275677b changed device_type() to not falsepositive for Bay and HP classes. Changed error_throw to not give line feeds. 2003-07-28 16:22:36 +00:00
Max Baker
c0891ec8c0 re-added cisco-stack-mib -- needed to id old catalysts 2003-07-28 16:01:10 +00:00
Max Baker
9dd38845a6 kept model numbers and added a dash 2003-07-28 15:49:14 +00:00
Max Baker
0d8aa25e63 added defaults and thanks 2003-07-24 00:25:36 +00:00
Max Baker
f57c9333da removed dependency on CISCO-STACK-MIB 2003-07-03 18:49:45 +00:00
Max Baker
f060b67b4a switched over to CiscoVTP subclass for vlan processing 2003-07-03 17:18:26 +00:00
Max Baker
c59e13ac35 *** empty log message *** 2003-07-03 17:04:57 +00:00
Max Baker
a49d1522b0 added t1s to speed_map and added l2 c3550's to device_type() 2003-07-02 20:51:48 +00:00
Max Baker
39e618f761 escaped all control characters, not just line feed 2003-07-02 19:24:49 +00:00
Max Baker
3d812e0eae added test_class.pl 2003-06-30 18:27:51 +00:00
Max Baker
4f1ac32865 *** empty log message *** 2003-06-30 18:27:13 +00:00
Max Baker
d176570b1d case sensitive for 2900s and 2950s in device_type() 2003-06-27 23:54:15 +00:00
Max Baker
393fb71b1a added 2950s to the C2900 class 2003-06-27 23:09:35 +00:00
Max Baker
bd1be7e258 added vlans 2003-06-27 22:03:29 +00:00
Max Baker
e296e93b23 push ver_0_6 2003-06-18 16:26:39 +00:00
Max Baker
bd457307ff Module did not return 1 and failed to load under specify() 2003-06-18 16:25:08 +00:00
Max Baker
f988cecc4d version 0.5 prep 2003-06-10 16:50:44 +00:00
Max Baker
d2f67b2db2 Added partial table lookup capabilities 2003-05-30 21:04:56 +00:00
Max Baker
c4a4c3d5e6 *** empty log message *** 2003-05-30 21:04:06 +00:00
Max Baker
fa38fdbc2b Added IP Route Table 2003-05-30 19:22:15 +00:00
Max Baker
2e03e3faca added undef checking in os_*() 2003-05-27 15:38:59 +00:00
Max Baker
e448915e0b Added SUPPORT section 2003-05-14 01:07:28 +00:00
Max Baker
37836bedac minor undef warnings 2003-05-12 21:20:48 +00:00
Max Baker
a60663b238 doc change 2003-04-29 18:24:23 +00:00
Max Baker
5e879b6822 Version 4 2003-04-29 18:15:47 +00:00
Max Baker
c672b914db Version 4 readme 2003-04-29 18:15:31 +00:00
Max Baker
f703bdc910 doc change 2003-04-29 18:13:58 +00:00
Max Baker
0752a2403c doc change to 0.4 2003-04-29 18:13:34 +00:00
Max Baker
f0dc4c4b31 added CiscoStats as superclass; doc style to 0.4; removed HP mibs are requirement 2003-04-29 18:12:52 +00:00
Max Baker
7269476bad added CiscoStats as superclass and doc style to 0.4 2003-04-29 18:12:11 +00:00
Max Baker
42d56e62e1 ver 0.4 doc change 2003-04-29 18:11:16 +00:00
Max Baker
873fd257cd added all documentation
fixed regex in os_ver()
added RFC1213-MIB as requirement
2003-04-29 18:10:21 +00:00
Max Baker
43d01c5060 added full information from mib and ver 0.4 documentation style 2003-04-29 18:09:10 +00:00
Max Baker
1d45ab5522 doc change 2003-04-29 18:08:30 +00:00
Max Baker
2674536a55 added b_mac to MUNGE, 0.4 doc change 2003-04-29 18:06:20 +00:00
Max Baker
cc13a0f850 added ciscostats,entity and t/prereq.t 2003-04-29 18:04:59 +00:00
Max Baker
f9a97d7a3b fixed clear_cache() 2003-04-29 18:00:11 +00:00
Max Baker
d5f1a1ae95 doc change 2003-04-29 17:45:40 +00:00
Max Baker
466c0daec0 doc change 2003-04-29 17:42:58 +00:00
Max Baker
e127beb2d7 doc change 2003-04-29 17:42:07 +00:00
Max Baker
ff9cab9fe7 v4 doc changes 2003-04-29 17:32:32 +00:00
Max Baker
6d9ce57032 doc change to 0.4 2003-04-29 17:17:55 +00:00
Max Baker
77d854f58f - version 0.4 call and doc upgrade
- Added os_ver() os()
2003-04-29 17:10:11 +00:00
Max Baker
9e2ac2d880 - added STATISTICS and NETSWITCH mibs for CPU and memory stats
- added hp_cpu(), hp_mem_total(), mem_free(), mem_used(), os_version(),
  os_bin(), mac(), cpu(), os(), os_ver() methods
- changed to 0.4 doc style
2003-04-29 16:56:17 +00:00
Max Baker
4a52fccc20 small doc change 2003-04-29 16:54:12 +00:00
Max Baker
d7e524b4a3 - added os() , os_ver, and os_bin()
- doc change to 0.4 style
2003-04-29 16:53:46 +00:00
Max Baker
6da7d340a9 - Doc changes for 0.4
- added os() and os_ver()
- Got rid of %MYMIBS -> %MIBS indirection
2003-04-29 16:40:43 +00:00
Max Baker
e9fa153e45 doc changes for 0.4 2003-04-29 16:24:48 +00:00
Max Baker
fa99cb39ae - Added interfaces() to only use ifDescr
- Added os and os_ver to cull out oldddddddd catalyst versions
- Added i_name() to use c1900_p_name()
- doc changes for 0.4
2003-04-29 16:18:30 +00:00
Max Baker
622a35de01 doc changes for 0.4 2003-04-29 15:58:17 +00:00
Max Baker
74c85cae9e * added os() and os_ver()
* Documentation revamp
* prep for 0.4
2003-04-29 02:40:53 +00:00
Max Baker
3eba4c6c79 * Added os() and os_ver()
* Rev to 0.4
* Documentation revamp
2003-04-29 02:40:18 +00:00
Max Baker
3f179aa21a * Added NOSUCH support to fix bug with Version 1 data collection
* Major Documentation (pod) rewrite
* Changed debuging to object scope
* Added error throwing and checking
* clear_cache()
2003-04-29 02:22:45 +00:00
Max Baker
a6a8ed4c55 - Exported code from netdisco to c_if() to fake the interface table.
- Updated documentation to reflect autospecify methods of v0.4
2003-04-24 18:50:22 +00:00
Max Baker
d7b6fa2179 *** empty log message *** 2003-04-22 23:12:59 +00:00
Max Baker
69645321cd Major Changes.
1. Changed internal storage of function data from iid -> attr -> val to attr -> iid -> val
2. Changed object name space :
    $info{name}  is a object variable
    $info{_name} is a cached entry or flag for cached entry
3. Added error reporting for silent usage of class with $self->error()
4. Added more object instance methods for instance data for more OO like behavior
5. API HAS CHANGED -- load_all() and all() return new data structure.  These were internal functions,
   but listed in example (groan)
2003-04-21 21:43:39 +00:00
Max Baker
f2754b80bb - Removed ENTITY-MIB methods to SNMP::Info::Entity
- Removed %MY* crap
2003-04-17 21:23:53 +00:00
Max Baker
1f1ba32c1b *** empty log message *** 2003-04-17 21:22:59 +00:00
Max Baker
39ed601300 Added bigint req 2003-04-17 21:21:17 +00:00
Max Baker
c2bbd03c2f Lots of Changes.
- Added auto-specify code in new() and specify()
    - Added BigInt / 64 Bit Counter code
    - Added SNMP::Info::Layer2::Aironet
    - GLOBALs (scalar SNMP data) are now cached
    - Added Interface Statistics methods (i_pkts_*, i_octet_*)
2003-04-17 21:20:26 +00:00
Max Baker
3c3c040471 added check for undef port in fw_mac 2003-03-26 20:34:40 +00:00
Max Baker
af51ee7ea4 added check for undef port in c_ip() 2003-03-26 20:33:39 +00:00
Max Baker
e4e039e2e1 ver_03 2003-03-06 21:56:22 +00:00
Max Baker
6dac5dffb3 new 2003-03-06 21:47:37 +00:00
Max Baker
ddeb705f13 ver_03 2003-03-06 21:41:07 +00:00
Max Baker
b86cf86fa6 ver_03 2003-03-06 21:12:46 +00:00
Max Baker
0cd3ba27c0 removed snmp requirement 2003-03-06 21:02:56 +00:00
Max Baker
fe6157f900 changed to t/* 2003-03-06 21:01:44 +00:00
Max Baker
b4c1bf0900 error check 2003-03-05 19:29:22 +00:00
Max Baker
7f2e79c634 error check in serial() 2003-03-05 19:29:07 +00:00
Max Baker
947c8679c8 Added check in _global() for NOSUCHOBJECT response from SNMP 2003-03-04 20:18:19 +00:00
Max Baker
919906516d Speedup in device_type() and more debugging info for GET operations and new() 2003-02-21 18:23:08 +00:00
Max Baker
ad70c2345e *** empty log message *** 2003-02-19 23:46:18 +00:00
Max Baker
3035a9df7a *** empty log message *** 2003-02-19 17:53:59 +00:00
Max Baker
556441ba09 ver_02_prep 2003-02-19 17:50:56 +00:00
Max Baker
97eeeb4ae4 prep for v0.2 2003-02-19 17:38:30 +00:00
Max Baker
e0c1c79ce8 *** empty log message *** 2003-02-19 17:36:48 +00:00
Max Baker
c5fe50aa67 added 450 exclusion in model() 2003-02-13 19:47:11 +00:00
Max Baker
7d29cf4c13 removed cat/catalyst from model() 2003-02-13 19:43:53 +00:00
Max Baker
7a8967d924 Added cvs id string 2003-02-13 18:47:21 +00:00
Max Baker
c5b1b3c3d2 Added STP table entries and functions 2003-02-13 18:46:42 +00:00
Max Baker
95912047f7 docs 2003-02-13 18:46:20 +00:00
Max Baker
a1286a02f9 Added set() capabilities 2003-02-12 20:49:54 +00:00
Max Baker
543fc51d2f Added layer3/c3550.pm 2003-02-11 20:58:44 +00:00
Max Baker
e2b0f18b28 initial add 2003-02-11 20:58:22 +00:00
Max Baker
2b56fdbb85 removed HP MIBs and HP specific stuff in model() 2003-01-17 18:51:36 +00:00
Max Baker
3371ef7727 Added model() and MODEL_MAP 2003-01-17 18:51:04 +00:00
Max Baker
fd7cf06a07 Changed HP detection in device_type() 2003-01-17 18:49:38 +00:00
62 changed files with 20078 additions and 2371 deletions

View File

@@ -1,4 +1,9 @@
Copyright (c) 2002, Regents of the University of California
All code from version 0.7 on
Copyright (c) 2003,2004 Max Baker
All rights reserved.
Original Code
Copyright (c) 2002,2003 Regents of the University of California
All rights reserved.
Redistribution and use in source and binary forms, with or without

182
ChangeLog Normal file
View File

@@ -0,0 +1,182 @@
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
ChangeLog $Id$
version 1.0 ()
+ Added Interface FlowControl status to CiscoStack (Nicolai Petri)
+ Added CiscoImage class (Matthew Tuttle)
+ Added C1200 and C350 IOS devices to L2::Aironet (Matthew Tuttle)
+ Added support for Foundry IronWare and gave L3::Foundry CPR
+ Added support for Foundry EdgeIrons as new class L2::Foundry
+ Added BulkWalk and BulkRepeaters options to new()
+ Added DebugSNMP option to new()
+ Added CISCO-ENTITY-VENDORTYPE-OID-MIB,CISCO-PRODUCTS-MIB,CISCO-STACK-MIB
to CiscoStats.pm for model()
+ Check for bulkwalk_no() method
+ Added Entity.pm to L3 and L2 classes per N. Petri's suggestion.
+ Added support for Passport/Accelar 1100 and 1200 series in L3::Passport
+ Added support for Passport/Accelar 8100 series in L3::Passport
+ Added support for Passport 1600 series as new class, L3::N1600
+ Added support for Extreme Alpine and Summit switches as new class
L3:Extreme (Mike Hunter and Eric Miller)
+ Added support for Aruba wireless switches (Eric Miller and Brian Chow)
+ Added support for Nortel 2700 series (Airespace) wireless switches
+ Added support for Synoptics hubs as new class L1:S3000
+ Added Cisco QOS and RTT classes (Alexander Hartmaier)
+ Added BGP Peer Table to L3 class (Carlos Vicente)
+ Added ipforwarding status to Info base class (Carlos Vicente)
+ Added STP port state to Bridge class (Alexander Barthel)
+ Added L3 support (arpnip) to Baystack class for routing capable switches
+ Added set_i_duplex_admin() and set_i_speed_admin() to C2900 class (Justin Hunter)
+ Added set_i_duplex_admin() and set_i_speed_admin() to CiscoStack class
+ CDP added to Aironet class
+ Added Juniper class
+ Added support for Catalyst 4000 and 4500, get admin. duplex
and speed properly
+ Added i_speed_high(), which i_speed() uses if needed to support
interfaces >4Gbps
* More error checking in _load_attr() around bulkwalk code
* Minor warning fix in L3::Aironet::os_ver()
* Abstracted remaining Cisco stuff from L3 to L3::Cisco
* Removed all Cisco stuff from L2
* Expanded Entity.pm to cover the whole ENTITY-MIB and improved docs.
* changed all refs to $DEBUG to $self->debug() for reentrant code
* [ 1111284 ] Parameters not being set with AutoSpecify - fixed.
* Turned off BULKWALK for C1900 and C6500 classes.
* Added exception handling for V2 ENDOFMIBVIEW
* Fix in SONMP when topology not enabled
* Fix in L3::Passport root_ip()
* Fix in L3::Passport bp_index() some devices not returning complete index.
* Enable set_i_up_admin() in Bayhub
* Recognize new Nortel model names in Baystack and Passport classes
* Orinoco class should now recognize more models
* Cleanup model recognition in Baystack class, recognize more models
* Modify Catalyst class to use CISCO-STACK-MIB for brige port index mapping
some devices having problems returning complete index from BRIDGE-MIB
* Check root ip for reachability before assignment
* HP class should recognize more models
* Fix in HP class for models not returning full bp_index
* [ 1436103 ] L2::Aironet devices weren't getting their model
translated properly
verison 0.9 (11/15/04)
+ ** Added full Nortel/Bay/BayStack support
by new developer Eric Miller.
L2::Bay now depricated.
+ Added Alteon Ace support (Eric Miller)
+ Added Nortel Cotivity support (Eric Miller)
+ Added Nortel BayRS support (Eric Miller)
+ Added Nortel Centillion support (Eric Miller)
+ Added Nortel AP 222x support (Eric Miller)
+ Added Orinco AP support (Eric Miller)
+ Added i_lastchange() per suggestion of Nicolai Petri
+ Added BULKWALK patch by Bradley Baetz - This should
greatly speed up requests on SNMPv2c devices.
+ Added MibDirs option to new() to allow specifying non-system MIB directories.
* Added C3560s to the C3550 class. Thanks to Nicolai.
* Fixed Bug where older Cisco's would append nulls to certain
CDP information. Would come up a 'DBD::Pg parser' error in Netdisco
* Changed so a failed _global() call is cached so it won't retry
an error over and over again if the same global is used.
* Added check in _set() to see if data came from sub or FUNCS/GLOBALS
Fails if came from sub.
version 0.8 (03/21/04)
+ Added Q-BRIDGE-MIB support to SNMP::Info::Bridge
+ Added Aironet AP4800 to Layer3::Aironet class
+ Added C3500XL devices to the Layer2::C2900 class
+ Added Cisco 3750 (37xxstack) to Layer3::C6500 class
+ Added Cisco Catalyst 4000 to Layer3::C6500 class
+ Added Cisco Catalyst 2970 to Layer3::C6500 Class
* Made Cisco Commuinty string indexing a boolean method for clarification
* Added VLAN info for HP devices using Q-BRIDGE-MIB
* Fixed warning about uninitialized value in CiscoStats line 92
* Added for more serial# checking for L2 and L3
* Fixed warning in Layer2::Bay about non numeric port line 199
Contributions from Dmitry Sergienko:
+ Added Cisco Aironet BR500 and AP1200 to L2::Aironet Class
* Fixed the Port name alias for Catalyst 2900 devices
+ Added Support For ZyXEL DSLAMs and Allied Telesys Switches
version 0.7 (08/14/03)
* Added Class for Catalyst 6500 Series - Layer3::C6500
* Added CiscoVTP support to 3550,2900, and Catalyst classes
* Extracted VLAN stuff from Layer2::Catalyst to SNMP::Info::CiscoVTP
* Extracted CISCO-STACK-MIB from Layer2::Catalyst to SNMP::Info::CiscoStack
* Added 2950's to the Layer2::C2900 class
* Added 3548's and 350x's to the Layer3::C3550 class
* Broke out 3550's into separate device types (3550-24, 3550-48)
* Added T1,dual T1, and T3 , ATM over OC-12 ... to the SPEED_MAP
* Fixed speed map -- OC-1 -> OC-3
* Fixed Bug where Catalyst Switch running IOS would report CatOS as os()
version 0.6 (06/18/03)
* Minor Bug Fix. SNMP::Info::Layer2::Bay and SNMP::Info::Layer2::C1900
didn't return 1 and failed to load on some versions of Perl.
version 0.5 (06/10/03)
* Added ability to get paritial tables. For example to get the
IP routing table for 128.114.* you can do
$ipr = $dev->ipr_dest('128.114');
* Added IP Routing Table entries from RFC1213 to SNMP::Info
* minor bug fixes
version 0.4 (04/29/03)
* BIG CHANGE ! Internal Data structure has changed.
* Added clear_cache() method
* Added NO_SUCH support for snmpget (TABLE) calls to get SNMP MIB II data
from SNMP Version 1 devices.
* Methods load_all() and all() have changed their return value. Sorry but the API had to change.
* New object methods snmp_comm(), snmp_ver(), store(), class(), nosuch() to make it more OO happy.
* Globals are now cached
* Added new argument 'AutoSpecify' to new() to auto-connect with subclass
detected in device_type()
* New method specify() returns a new subclass object
* Subclasses are automatically loaded when specify or autospecify is used!
* Added methods for Interface statistics (ifInOctets ...)
* Added methods for Memory and CPU statistics
* Added SNMP::Info::Entity, moved out of L2-HP
* Added SNMP::Info::Layer2::Aironet
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 more debugging
* Added info and munging for c_capabilities in SNMP::Info::CD
Thanks to Martin Lorensen <martin /at- lorensen.dk>
* Removed requirement for SNMP in the Makefile.PL and moved it to t/prereq.t
so that the Module will install via CPAN without trying to install the old
4.2.0 version of SNMP on CPAN. Will now fail in the test phase.
Thanks again to Martin Lorensen <martin /at- lorensen.dk>
* Moved tests from test.pl to t/*
version 0.2 (02/19/03)
* Added put_() methods and support for SNMP put commands
* Added SNMP::Info::Layer3::C3550 class for Cisco Catalyst 3550
* Fixed HP Detection in device_type()
* 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
version 0.1 (12/30/02)
* Initial Release
* SubClasses Included:
* SNMP::Info::Bridge
* SNMP::Info::CDP
* SNMP::Info::EtherLike
* SNMP::Info::MAU
* SNMP::Info::Layer1
o SNMP::Info::Layer1::Allied
o SNMP::Info::Layer1::Asante
* SNMP::Info::Layer2
o SNMP::Info::Layer2::Bay
o SNMP::Info::Layer2::C1900
o SNMP::Info::Layer2::C2900
o SNMP::Info::Layer2::Catalyst
o SNMP::Info::Layer2::HP
* SNMP::Info::Layer3
o SNMP::Info::Layer3::Aironet
o SNMP::Info::Layer3::Foundry

654
DeviceMatrix.txt Normal file
View File

@@ -0,0 +1,654 @@
# SNMP Device Compatibility Matrix
# SNMP::Info - (C) 2004 Max Baker
# This file is meant to detail the cababilities
# of network devices to supply data via SNMP.
# $Id$
# Allied
device-vendor: Allied Telesyn
cdp:no
device-family: Allied Hubs
class: Layer1::Allied
ver: 1
arpnip: no
macsuck: no
duplex: no
device: AT-3624T
device-family: AT-8000 Switches
class: Layer2::Allied
ver: 2
macsuck: yes
# Aruba
device-vendor: Aruba
device-family: Aruba Wireless Controllers
arpnip: no
macsuck: yes
portmac: yes
duplex: no
class: Layer2::Aruba
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
device: 5000
# Asante
device-vendor: Asante
device-family: Asante Hubs
class: Layer1::Asante
ver: 1
arpnip: no
macsuck: no
duplex: no
device: 1012
# Bay
device-vendor: Bay
note: See Nortel
# CISCO
device-vendor: Cisco
cdp: yes
ver: 2
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
note: IOS based device
class: Layer2::Aironet
device: BR500
note: Aironet based device
device: AP350, AP340, CAP350, CAP340, 1200, AP4800
note: Aironet based device
device-family: 1000
duplex: no
ver: 1
class: Layer3
device: 1003
device-family: 1700
class: Layer3
device: 1710
duplex: link
device-family: 2500
duplex: no
macsuck: yes
arpnip: yes
ver: 1
class: Layer3
device: 2501
device: 2503
device: AS2509RJ
device: AS2511RJ
device: 2511
device: 2514
device-family: 2600
duplex: link
arpnip: yes
macsuck: yes
class: Layer3
device:2610,2610XM,2611,2620,2620XM,2621
device:2621XM
device:2651XM
device:2691
device-family: 3600
class: Layer3
device: 3620
device: 3640
duplex: no
device-family: 7500
class: Layer3
device: 7507
duplex: no
note: !Duplex settings are falsely reported in older IOS versions
device-family: AS5000
duplex: no
class: Layer3
device: AS5300
#
# Cisco - Catalyst
#
device-family: Catalyst 1900
note: !Upgrade older (pre 9.0) versions of CatOS
note: !CatOS ver 9.00.03 through 9.00.06 have problems when trunking. Upgrade to 9.00.07 or higher.
ver: 1
duplex: both
vlan: write
class: Layer2::C1900
device: wsc1900c
device-family: Catalyst 1900
device: wsc1900
device-family: Catalyst 1900
device-family: Catalyst 2900
note: IOS
macsuck: vlan
duplex: write
vlan: write
class: Layer2::C2900
portmac: yes
note: !Pre IOS 11.2 (8) SA3 - PortMAC shows up in CAM table.
device: 2908xl
note: !Pre IOS 11.2 (8.6) some features (duplex...) aren't present.
device: 2912MfXL
device: 2924MXL
ver: 1
device: 2924CXL
device: 2924CXLv
device-family: Catalyst 2940
note: IOS
macsuck: vlan
duplex: write
vlan: write
class: Layer2::C2900
portmac: yes
device: 2940-8TT
device-family: Catalyst 2950
note: IOS
macsuck: vlan
duplex: write
vlan: write
class: Layer2::C2900
portmac: yes
device: 2950-t24
device-family: Catalyst 2970
macsuck:vlan
duplex: write
vlan: write
note: Acts just like IOS Catalyst 6500 series
class: Layer3::C6500
device: 2970G-24T-E
device-family: Catalyst 3500 XL
portmac: yes
macsuck: vlan
duplex: write
vlan: write
note: L2 only IOS devices - Just like Catalyst 2900 series from SNMP
note: IOS Version 12.0(5)XP is buggy and doesn't do VLAN Community indexing correctly.
class: Layer2::C2900
device: 3508GXL
device: 3524XL
device: 3548XL
device-family: Catalyst 3550
macsuck: vlan
duplex: write
vlan: write
class: Layer3::C3550
note: Run IOS
note: Has VLANs that don't accept SNMP connections. Don't know if they are standard (by name or number).
note: Uses CISCO-STACK-MIB like Catalyst 5000 series for serial,duplex,type but not name
note: Comes in flavors that support L2, L3 or combo.
device: 3550-12T
device: 3550
note: L2/L3 Switch
arpnip: yes
device: 3550-24, 3550-48
macsuck: vlan
device-family: Catalyst 3750
class: Layer3::C6500
device-family: Catalyst 4000
duplex: both
macsuck: vlan
vlan: write
class: Layer3::C4000
note: Comes in IOS and CatOS versions like the 6k series.
note: CatOS versions like L2::Catalyst just fine.
note: !Reported problems with SNMP taking up all the CPU. Requests take significantly longer.
note: !IOS Version 12.1.8a reported not to respond to BRIDGE-MIB calls.
device: wsc4006
device: 4507
class: Layer3::C6500
note: !Has serious slowdown/timeout problems with SNMP
device: wsc4912g
note: Dedicated 12 port gig-e switch
device-family: Catalyst 5000
duplex: write
vlan: write
class: Layer2::Catalyst
note: Port info in CISCO-STACK-MIB
device: wsc2926
note: !Can give false information over SNMP at times.
device: wsc2948g
device: wsc2980g
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: wsx5302
arpnip: yes
class: Layer3
note: Router blade that runs IOS
device-family: Catalyst 6500
macsuck:vlan
duplex: write
vlan: write
class: Layer3::C6500
note: Runs in two possible modes, native (IOS) and hybrid (IOS with CatOS on top).
note: Switch running Hybrid has WS-C in description field and loves L2::Catalyst class
note: Native Mode (IOS) versions seem to have SNMP problems with L2 data.
note: !Problem with IOS 12.2.17d-SXB ... upgrade to -SXB1 or higher.
note: !Sup720-3B and NativeIOS 12.2 (17d)SXB10 may report 127.0.0.51 as CDP neighbor address.
device: 6503
macsuck:no
note: !Macsuck failing even under vlan mode
note: Native mode (IOS) reports L2+L3
device: 6509
duplex: link
macsuck:no
note: Native mode (IOS) reports L2+L3
note: !Macsuck failing even under vlan mode
device: wsc6509
duplex: write
class: Layer2::Catalyst
note: Hybrid Mode (Catalyst) reports L2 only
device: 6kMsfc
class: Layer3
duplex: no
vlan: no
note: IOS portion of Hybrid mode. VLAN and other L3 Services.
device: 6kMsfc2
class: Layer3
duplex: no
vlan: no
note: IOS portion of Hybrid mode. VLAN and other L3 Services.
device-family: Voice Gateway
class: Layer3
duplex: no
device: VG200
# Extreme
device-vendor: Extreme Networks
device-family: Alpine and Summit
arpnip: yes
macsuck: yes
duplex: both
vlan: yes
cdp: no
class: Layer3::Extreme
device: Alpine 3808
device: Summit 7i, 48si
# Foundry
device-vendor: Foundry Networks
note: CDP --> FDP.
device-family: FastIron
class: Layer3::Foundry
ver: 1
note: Support very limited
device: FastIron 4802
device-family: EdgeIron
ver: 2
class: Layer2::Foundry
cdp: yes
duplex: yes
macsuck: yes
device: EdgeIron 24G
note: Bug where spanning tree stuff loops forever when polled by SNMP.
device-family: IronWare
class: Layer3::Foundry
ver: 2
cdp: yes
note: FDP enabled.
duplex: yes
macsuck: yes
arpnip: yes
device:FWSX424
device:SI400 Router
# HP
device-vendor: HP
class: Layer2::HP
ver: 2
device-family: HP ProCurve
duplex: both
macsuck: yes
arpnip: no
cdp: yes
vlan: yes
note: CDP only available with newer ROM versions.
device: 2512
ver: 1
device: 2524
ver: 1
device: 4000
note: duplex issues?
device: 4104GL
duplex: link
device: 4108GL,8000,2626,2650,8000
note: VLAN info in Q-BRIDGE-MIB
# Net-SNMP
device-vendor: Net-SNMP
class: Layer3
ver: 2
device-family: Linux
note: net-snmp 4.x agent and 5.x agent.
device-family: BSD
# Juniper
device-vendor: Juniper
device-family: M-series router
arpnip: yes
# NORTEL
device-vendor: Nortel
note: CDP --> SONMP.
device-family: BayStack Hub
macsuck: yes
duplex: both
cdp: proprietary
ver: 1
class: Layer1::Bayhub
note: Uses proprietary MIBs to provide MAC to port mapping.
note: !Requires Advanced or Advanced Analyzer NMM
device: 102
device: System 5000
device-family: Ethernet Switch/Baystack Switch
arpnip: no
macsuck: yes
duplex: both
vlan: yes
cdp: proprietary
class: Layer2::Baystack
device: 303,304
device: 350
device: 380
device: 410
device: 420,425
device: 450
note: !Some versions > 4.X in stacked configuration have SNMP timeout issues.
note: Labels full duplex as 20Mbit connection.
device: 460,470
device: BPS
device-family: Ethernet Routing Switch/Baystack Switch
arpnip: yes
macsuck: yes
duplex: both
vlan: yes
cdp: proprietary
class: Layer2::Baystack
device: 3510
device: 5510,5520,5530
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.
device: 5000BH
device: 5005BH
device: C100
device: C50
device-family: AP222x
macsuck: yes
duplex: both
cdp: proprietary
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-family: Alteon AD
arpnip: yes
macsuck: yes
duplex: both
cdp: no
vlan: yes
class: Layer3::AlteonAD
note: !Some versions have issues with continuous SNMP polling. Upgrade to 10.0.30.7 or higher.
device: AD2
device: AD3
device: AD4
device: 180
device: 183
device: 184
device-family: Multiprotocol Router/BayRS
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
cdp: no
vlan: yes
class: Layer3::BayRS
device: AN
device: ARN
device: ASN
device: BLN
device: Passport 2430
device: Passport 5430
device-family: VPN Router/Contivity
arpnip: yes
macsuck: no
portmac: yes
duplex: no
cdp: no
class: Layer3::Contivity
device: 100,400,600
device: 1000,1010,1050
device: 1500,1600,1700,1740
device: 2500,2600,2700
device: 4500,4600,5000
device-family: Ethernet Routing Switch/Passport/Accelar LAN
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
cdp: proprietary
vlan: yes
class: Layer3::Passport
note: !8600 Code versions < 3.2 vlan based mac-suck and are unsupported. Upgrade code.
note: !8600 3.2 code versions < 3.2.2.2 have Bridge MIB loop. Upgrade code.
device: 8603,8606,8610
device: 8610co
device: 8106,8110
device: 1050,1100,1150,1200
device-family: Ethernet Routing Switch/Passport 1600
arpnip: yes
macsuck: yes
portmac: yes
duplex: both
cdp: proprietary
vlan: yes
class: Layer3::N1600
device: 1612,1624,1648
device-family: Synoptics
macsuck: yes
duplex: both
cdp: proprietary
ver: 1
class: Layer1::S3000
note: Uses proprietary MIBs to provide MAC to port mapping.
note: !Requires Advanced or Advanced Analyzer NMM
device: 281X
device: System 3000
device-family: Wireless Switch 2270
arpnip: no
macsuck: yes
portmac: yes
duplex: both
cdp: proprietary
class: Layer2::N2270
note: Uses proprietary MIBs to provide MAC to port mapping. APs appear as switch ports.
device: 2270
# Proxim
device-vendor: Proxim
device-family: Orinoco
macsuck: yes
duplex: no
cdp: no
class: Layer2::Orinoco
device: AP-1000
device: AP-2000
device: AP-4000
device: WavePOINT-II
# Synoptics
device-vendor: Synoptics
note: See Nortel
# Zyxel
device-vendor: Zyxel
class: Layer2::ZyXEL_DSLAM
note: Doesn't report sysServices (layers)
device-family: Zyxel DSLAM
device:AAM10008-61, AAM1008-63

2391
Info.pm

File diff suppressed because it is too large Load Diff

448
Info/Airespace.pm Normal file
View File

@@ -0,0 +1,448 @@
# SNMP::Info::Airespace
# Eric Miller
# $Id$
#
# 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:
#
# * 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::Airespace;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::Airespace::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Airespace::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
%MIBS = (
%SNMP::Info::MIBS,
'AIRESPACE-WIRELESS-MIB' => 'bsnAPName',
'AIRESPACE-SWITCHING-MIB' => 'agentInventorySerialNumber',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
'serial' => 'agentInventorySerialNumber',
'os_ver' => 'agentInventoryProductVersion',
);
%FUNCS = (
%SNMP::Info::FUNCS,
'i_index2' => 'ifIndex',
'i_name2' => 'ifName',
'i_description2' => 'ifDescr',
# AIRESPACE-WIRELESS-MIB::bsnAPTable
'airespace_ap_mac' => 'bsnAPDot3MacAddress',
'airespace_ap_name' => 'bsnAPName',
'airespace_ap_ip' => 'bsnApIpAddress',
'airespace_ap_loc' => 'bsnAPLocation',
'airespace_ap_model' => 'bsnAPModel',
'airespace_ap_serial' => 'bsnAPSerialNumber',
# AIRESPACE-WIRELESS-MIB::bsnMobileStationTable
'fw_port' => 'bsnMobileStationAPMacAddr',
'fw_mac' => 'bsnMobileStationMacAddress',
# AIRESPACE-SWITCHING-MIB::agentPortConfigTable
'airespace_duplex_admin' => 'agentPortPhysicalMode',
'airespace_duplex' => 'agentPortPhysicalStatus',
);
%MUNGE = (
%SNMP::Info::MUNGE,
# Add ones for our class
'airespace_ap_mac' => \&SNMP::Info::munge_mac,
'fw_port' => \&SNMP::Info::munge_mac,
);
sub layers {
return '00000011';
}
# Wirless switches do not support ifMIB requirements for get MAC
# and port status
sub i_index {
my $airespace = shift;
my $i_index = $airespace->i_index2();
my $ap_index = $airespace->airespace_ap_mac();
my %if_index;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
$if_index{$iid} = $index;
}
# Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){
my $ap_index = $ap_index->{$ap_id};
next unless defined $ap_index;
$if_index{$ap_id} = $ap_index;
}
return \%if_index;
}
sub interfaces {
my $airespace = shift;
my $i_index = $airespace->i_index();
my $ap_index = $airespace->airespace_ap_mac();
my %if;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if ($index =~ /^\d+$/ ) {
$if{$index} = "1.$index";
}
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) {
my $ap = $ap_index->{$iid};
next unless defined $ap;
$if{$index} = $ap;
}
else {
next;
}
}
return \%if;
}
sub i_name {
my $airespace = shift;
my $i_index = $airespace->i_index();
my $i_name2 = $airespace->i_name2();
my $ap_name = $airespace->airespace_ap_name();
my %i_name;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if ($index =~ /^\d+$/ ) {
my $name = $i_name2->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) {
my $name = $ap_name->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
else {
next;
}
}
return \%i_name;
}
sub i_description {
my $airespace = shift;
my $i_index = $airespace->i_index();
my $i_descr = $airespace->i_description2();
my $ap_loc = $airespace->airespace_ap_loc();
my %descr;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if ($index =~ /^\d+$/ ) {
my $descr = $i_descr->{$iid};
next unless defined $descr;
$descr{$index} = $descr;
}
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) {
my $name = $ap_loc->{$iid};
next unless defined $name;
$descr{$index} = $name;
}
else {
next;
}
}
return \%descr;
}
sub i_duplex {
my $airespace = shift;
my $interfaces = $airespace->interfaces();
my $ap_duplex = $airespace->airespace_duplex();
my %i_duplex;
foreach my $if (keys %$interfaces){
my $duplex = $ap_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;
}
sub i_duplex_admin {
my $airespace = shift;
my $interfaces = $airespace->interfaces();
my $ap_duplex_admin = $airespace->airespace_duplex_admin();
my %i_duplex_admin;
foreach my $if (keys %$interfaces){
my $duplex = $ap_duplex_admin->{$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_admin{$if}=$duplex;
}
return \%i_duplex_admin;
}
# Wireless switches do not support the standard Bridge MIB
sub bp_index {
my $airespace = shift;
my $i_index = $airespace->i_index2();
my $ap_index = $airespace->airespace_ap_mac();
my %bp_index;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
$bp_index{$iid} = $index;
}
# Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){
my $ap_index = $ap_index->{$ap_id};
next unless defined $ap_index;
$bp_index{$ap_index} = $ap_index;
}
return \%bp_index;
}
1;
__END__
=head1 NAME
SNMP::Info::Airespace - SNMP Interface to Airespace wireless switches
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
my $airespace = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $airespace->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
SNMP::Info::Airespace is a subclass of SNMP::Info that provides an interface
to C<AIRESPACE-WIRELESS-MIB> and C<AIRESPACE-SWITCHING-MIB>. These MIBs are
used in Airespace wireless switches, as well as, products from Cisco, Nortel,
and Alcatel which are based upon the Airespace platform.
The Airespace platform utilizes intelligent wireless switches which control
thin access points. The thin access points themselves are unable to be polled
for end station information.
This class emulates bridge functionality for the wireless switch. This enables
end station MAC addresses collection and correlation to the thin access point
the end station is using for communication.
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
my $airespace = new SNMP::Info::Airespace(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=back
=head2 Required MIBs
=over
=item AIRESPACE-WIRELESS-MIB
=item AIRESPACE-SWITCHING-MIB
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $airespace->serial()
(B<agentInventorySerialNumber>)
=item $airespace->os_ver()
(B<agentInventoryProductVersion>)
=back
=head2 Overrides
=over
=item $airespace->layers()
Returns 00000011. Class emulates Layer 2 functionality for Thin APs through
proprietary MIBs.
=back
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $airespace->i_index()
Returns reference to map of IIDs to Interface index.
Extends ifIndex to support thin APs as device interfaces.
=item $airespace->interfaces()
Returns reference to map of IIDs to ports. Thin APs are implemented as device
interfaces. The thin AP MAC address is used as the port identifier.
=item $airespace->i_name()
Interface name. Returns (B<ifName>) for Ethernet interfaces and (B<bsnAPName>)
for thin AP interfaces.
=item $airespace->i_description()
Description of the interface. Returns (B<ifDescr>) for Ethernet interfaces and
(B<bsnAPLocation>) for thin AP interfaces.
=item $airespace->i_duplex()
Returns reference to map of IIDs to current link duplex. Ethernet interfaces only.
=item $airespace->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting. Ethernet interfaces
only.
=item $airespace->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $airespace->fw_port()
(B<bsnMobileStationAPMacAddr>)
=item $airespace->fw_mac()
(B<bsnMobileStationMacAddress>)
=back
=head2 AIRESPACE AP Table (B<bsnAPTable>)
=over
=item $airespace->airespace_ap_mac()
(B<bsnAPDot3MacAddress>)
=item $airespace->airespace_ap_name()
(B<bsnAPName>)
=item $airespace->airespace_ap_ip()
(B<bsnApIpAddress>)
=item $airespace->airespace_ap_loc()
(B<bsnAPLocation>)
=item $airespace->airespace_ap_model()
(B<bsnAPModel>)
=item $airespace->airespace_ap_serial()
(B<bsnAPSerialNumber>)
=back
=head2 AIRESPACE Agent Port Config Table (B<agentPortConfigTable>)
=over
=item $airespace->airespace_duplex_admin()
(B<agentPortPhysicalMode>)
=item $airespace->airespace_duplex()
(B<agentPortPhysicalStatus>)
=cut

View File

@@ -1,8 +1,12 @@
# SNMP::Info::Bridge
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
# All rights reserved.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -28,7 +32,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Bridge;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
@@ -39,15 +44,21 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::Bridge::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Bridge::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
%MIBS = ('BRIDGE-MIB' => 'dot1dBaseBridgeAddress',
'Q-BRIDGE-MIB' => 'dot1qPvid',
);
$INIT = 0;
%MIBS = ('BRIDGE-MIB' => 'dot1dBaseBridgeAddress');
%GLOBALS = (
'b_mac' => 'dot1dBaseBridgeAddress',
'b_ports' => 'dot1dBaseNumPorts',
'b_type' => 'dot1dBaseType'
'b_mac' => 'dot1dBaseBridgeAddress',
'b_ports' => 'dot1dBaseNumPorts',
'b_type' => 'dot1dBaseType',
# Spanning Tree Protocol
'stp_ver' => 'dot1dStpProtocolSpecification',
'stp_time' => 'dot1dStpTimeSinceTopologyChange',
'stp_root' => 'dot1dStpDesignatedRoot',
# Q-BRIDGE-MIB
'qb_vlans_max' => 'dot1qMaxSupportedVlans',
'qb_vlans' => 'dot1qNumVlans',
);
%FUNCS = (
@@ -63,70 +74,196 @@ $INIT = 0;
'bs_port' => 'dot1dStaticReceivePort',
'bs_to' => 'dot1dStaticAllowedToGoTo',
'bs_status' => 'dot1dStaticStatus',
# Spanning Tree Protocol Table : dot1dStpPortTable
'stp_p_id' => 'dot1dStpPort',
'stp_p_priority' => 'dot1dStpPortPriority',
'stp_p_state' => 'dot1dStpPortState',
'stp_p_cost' => 'dot1dStpPortPathCost',
'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',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
# Add ones for our class
'fw_mac' => \&SNMP::Info::munge_mac,
'bs_mac' => \&SNMP::Info::munge_mac,
'b_mac' => \&SNMP::Info::munge_mac,
'fw_mac' => \&SNMP::Info::munge_mac,
'bs_mac' => \&SNMP::Info::munge_mac,
'stp_root' => \&SNMP::Info::munge_mac,
'stp_p_root' => \&SNMP::Info::munge_mac,
'stp_p_bridge' => \&SNMP::Info::munge_mac,
'stp_p_port' => \&SNMP::Info::munge_mac
);
sub qb_i_vlan_t {
my $bridge = shift;
my $qb_i_vlan = $bridge->qb_i_vlan();
my $qb_i_vlan_type = $bridge->qb_i_vlan_type();
my $i_vlan = {};
foreach my $if (keys %$qb_i_vlan){
my $vlan = $qb_i_vlan->{$if};
my $tagged = $qb_i_vlan_type->{$if} || '';
next unless defined $vlan;
$i_vlan->{$if} = $tagged eq 'admitOnlyVlanTagged' ? 'trunk' : $vlan;
}
return $i_vlan;
}
sub i_stp_state {
my $bridge = shift;
my $bp_index = $bridge->bp_index();
my $stp_p_state = $bridge->stp_p_state();
my %i_stp_state;
foreach my $index (keys %$stp_p_state){
my $state = $stp_p_state->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $state;
$i_stp_state{$iid}=$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 %i_stp_port;
foreach my $index (keys %$stp_p_port){
my $bridge = $stp_p_port->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $bridge;
$i_stp_port{$iid}=$bridge;
}
return \%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 %i_stp_id;
foreach my $index (keys %$stp_p_id){
my $bridge = $stp_p_id->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $bridge;
$i_stp_id{$iid}=$bridge;
}
return \%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 %i_stp_bridge;
foreach my $index (keys %$stp_p_bridge){
my $bridge = $stp_p_bridge->{$index};
my $iid = $bp_index->{$index};
next unless defined $iid;
next unless defined $bridge;
$i_stp_bridge{$iid}=$bridge;
}
return \%i_stp_bridge;
}
1;
__END__
=head1 NAME
SNMP::Info::Bridge - Perl5 Interface to BRIDGE-MIB
=head1 DESCRIPTION
BRIDGE-MIB is used by most Layer 2 devices like Switches
Inherits all methods from SNMP::Info
SNMP::Info::Bridge - Perl5 Interface to SNMP data available through the BRIDGE-MIB (RFC1493)
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $bridge = new SNMP::Info::Bridge(DestHost => 'myswitch',
Community => 'public');
my $mac = $bridge->mac();
my $bridge = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'switch',
Community => 'public',
Version => 2
);
=head1 CREATING AN OBJECT
my $class = $cdp->class();
print " Using device sub class : $class\n";
# Grab Forwarding Tables
my $interfaces = $bridge->interfaces();
my $fw_mac = $bridge->fw_mac();
my $fw_port = $bridge->fw_port();
my $bp_index = $bridge->bp_index();
foreach my $fw_index (keys %$fw_mac){
my $mac = $fw_mac->{$fw_index};
my $bp_id = $fw_port->{$fw_index};
my $iid = $bp_index->{$bp_id};
my $port = $interfaces->{$iid};
print "Port:$port forwarding to $mac\n";
}
=head1 DESCRIPTION
BRIDGE-MIB is used by most Layer 2 devices, and holds information like the MAC Forwarding Table and Spanning Tree Protocol info.
Q-BRIDGE-MIB holds 802.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>.
Create or use a subclass of SNMP::Info that inherits this class. Do not use directly.
For debugging you can call new() directly as you would in SNMP::Info
my $bridge = new SNMP::Info::Bridge(...);
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item new SNMP::Info::Bridge()
=item BRIDGE-MIB
Arguments passed to new() are passed on to SNMP::Session::new()
=item Q-BRIDGE-MIB
my $bridge = new SNMP::Info::Bridge(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $bridge;
=item $bridge->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $bridge->session();
# Set
my $newsession = new SNMP::Session(...);
$bridge->session($newsession);
F<rfc2674_q.mib>
=back
=head1 Bridge Global Configuration Values
BRIDGE-MIB needs to be extracted from ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
@@ -148,9 +285,40 @@ Returns the type? of the device
(B<dot1dBaseType>)
=item $bridge->stp_ver()
Returns what version of STP the device is running. Either decLb100 or ieee8021d.
(B<dot1dStpProtocolSpecification>)
=item $bridge->stp_time()
Returns time since last topology change detected. (100ths/second)
(B<dot1dStpTimeSinceTopologyChange>)
=item $bridge->stp_root()
Returns root of STP.
(B<dot1dStpDesignatedRoot>)
=item $bridge->qb_vlans_max()
(B<dot1qMaxSupportedVlans>)
=item $bridge->qb_vlans()
Number of VLANS on this device.
(B<dot1qNumVlans>)
=back
=head1 TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Forwarding Table (dot1dTpFdbEntry)
@@ -193,4 +361,115 @@ Returns reference to hash of bridge port table entries physical port name.
(B<dot1dBasePortCircuit>)
=back
=head2 Spanning Tree Protocol Table (dot1dStpPortTable)
Descriptions are lifted straight from F<BRIDGE-MIB.my>
=over
=item $bridge->stp_p_id()
"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."
(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)."
disabled(1)
blocking(2)
listening(3)
learning(4)
forwarding(5)
broken(6)
(B<dot1dStpPortState>)
=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."
(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."
(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."
(B<dot1dStpPortDesignatedBridge>)
=item $bridge->stp_p_port()
(B<dot1dStpPortDesignatedPort>)
"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).
=item $bridge->i_stp_id()
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).
=back
=head2 Q-BRIDGE Data
=over
=item $bridge->qb_i_vlan()
Gives the vlan used by interfaces
(B<dot1qPvid>)
=item $bridge->qb_i_vlan_type()
Either C<admitAll> or C<admitOnlyVlanTagged>. This is a good spot to find
trunk ports.
(B<dot1qPortAcceptableFrameTypes>)
=item $bridge->qb_v_name()
Human-entered name for vlans.
(B<dot1qVlanStaticName>)
=item $bridge->qb_v_stat()
uhh. C<active> !
(B<dot1qVlanStaticRowStatus>)
=back
=cut

View File

@@ -1,7 +1,10 @@
# SNMP::Info::CDP
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
# All rights reserved.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,26 +31,22 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CDP;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use Carp;
@SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CDP::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MIBS_V1 %MUNGE $INIT/;
# Debug
$DEBUG=0;
$SNMP::debugging=$DEBUG;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
# Five data structures required by SNMP::Info
$INIT = 0;
%MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' );
%MIBS_V1 = ( 'CISCO-CDP-MIB-V1SMI' => 'cdpGlobalRun' );
# Notice we dont inherit the default GLOBALS and FUNCS
# only the default MUNGE.
%GLOBALS = (
@@ -58,7 +57,7 @@ $INIT = 0;
);
%FUNCS = (
'c_if' => 'cdpCacheIfIndex',
'c_index' => 'cdpCacheIfIndex',
'c_proto' => 'cdpCacheAddressType',
'c_ip' => 'cdpCacheAddress',
'c_ver' => 'cdpCacheVersion',
@@ -72,11 +71,32 @@ $INIT = 0;
);
%MUNGE = (
'c_capabilities' => \&SNMP::Info::munge_octet2hex,
'c_capabilities' => \&munge_caps,
'c_platform' => \&munge_null,
'c_domain' => \&munge_null,
'c_port' => \&munge_null,
'c_id' => \&munge_null,
'c_ver' => \&munge_null,
'c_ip' => \&SNMP::Info::munge_ip
);
# munge_null() - removes nulls (\0)
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 = substr(unpack("B*",$caps),-7);
return $bits;
}
sub hasCDP {
my $cdp = shift;
@@ -93,6 +113,33 @@ sub hasCDP {
return $cdp->cdp_run();
}
sub c_if {
my $cdp = shift;
# See if by some miracle Cisco implemented the cdpCacheIfIndex entry
my $c_index = $cdp->c_index();
return $c_index if defined $c_index;
# Nope, didn't think so. Now we fake it.
my $c_ip = $cdp->c_ip();
unless (defined $c_ip){
$cdp->error_throw("SNMP::Info::CDP:c_if() - Device doesn't have cdp_ip() data. Can't fake cdp_index()");
return undef;
}
my %c_if;
foreach my $key (keys %$c_ip){
next unless defined $key;
my $iid = $key;
# Truncate .1 from cdp cache entry
$iid =~ s/\.\d+$//;
$c_if{$key} = $iid;
}
return \%c_if;
}
1;
__END__
@@ -100,56 +147,69 @@ __END__
SNMP::Info::CDP - Perl5 Interface to Cisco Discovery Protocol (CDP) using SNMP
=head1 DESCRIPTION
CDP provides Layer 2 discovery of attached devices that also
speak CDP, including switches, routers and hubs.
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $cdp = new SNMP::Info::CDP( DestHost => 'router' ,
Community => 'public' );
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
@neighbor_ips = values( %{$cdp->ip()} );
my $cdp = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
=head1 CREATING AN OBJECT
my $class = $cdp->class();
print " Using device sub class : $class\n";
=over
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
=item new SNMP::Info::CDP()
# Print out a map of device ports with CDP neighbors:
my $interfaces = $cdp->interfaces();
my $c_if = $cdp->c_if();
my $c_ip = $cdp->c_ip();
my $c_port = $cdp->c_port();
Arguments passed to new() are passed on to SNMP::Session::new()
foreach my $cdp_key (keys %$c_ip){
my $iid = $c_if->{$cdp_key};
my $port = $interfaces->{$iid};
my $neighbor = $c_ip->{$cdp_key};
my $neighbor_port = $c_port->{$cdp_key};
print "Port : $port connected to $neighbor / $neighbor_port\n";
}
my $cdp = new SNMP::Info::CDP(
DestHost => $host,
Community => 'public'
)
die "Couldn't connect.\n" unless defined $cdp;
=head1 DESCRIPTION
=item $cdp->session()
SNMP::Info::CDP is a subclass of SNMP::Info that provides an object oriented
interface to CDP information through SNMP.
Sets or returns the SNMP::Session object
CDP is a Layer 2 protocol that supplies topology information of devices that also speak CDP,
mostly switches and routers. CDP is implemented in Cisco and some HP devices.
# Get
my $sess = $cdp->session();
# Set
my $newsession = new SNMP::Session(...);
$cdp->session($newsession);
=back
=head2 Your Device May Vary
Create or use a device subclass that inherits this class. Do not use directly.
Each device implements a subset of the global and cache entries.
Check the return value to see if that data is held by the device.
=head1 CDP GLOBAL VALUES
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item CISCO-CDP-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
@@ -161,7 +221,8 @@ Accounts for SNMP version 1 devices which may have CDP but not cdp_run()
=item $cdp->cdp_run()
Is CDP enabled on this device?
Is CDP enabled on this device? Note that a lot of Cisco devices that implement
CDP don't implement this value. @#%$!
(B<cdpGlobalRun>)
@@ -187,51 +248,44 @@ This is the device id broadcast via CDP to other devices, and is what is retriev
=back
=head1 CDP CACHE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 CDP CACHE ENTRIES
=over
=item $cdp->c_proto()
Returns remote address type received. Usually IP.
(B<cdpCacheAddressType>)
=item $cdp->c_ip()
Returns remote IP address
(B<cdpCacheAddress>)
=item $cdp->c_ver()
Returns remote hardware version
(B<cdpCacheVersion>)
=item $cdp->c_id()
Returns remote device id string
(B<cdpCacheDeviceId>)
=item $cdp->c_port()
Returns remote port ID
(B<cdpDevicePort>)
=item $cdp->c_platform()
Returns remote platform id
(B<cdpCachePlatform>)
=item $cdp->c_capabilities()
Returns Device Functional Capabilities bitmap.
Returns Device Functional Capabilities. Results are munged into an ascii
binary string, 7 digits long, MSB. Each digit represents a bit from the
table below.
Anyone know where I can get info on how to decode this?
From L<http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#18843>:
(Bit) - Description
=over
=item (0x40) - Provides level 1 functionality.
=item (0x20) - The bridge or switch does not forward IGMP Report packets on nonrouter ports.
=item (0x10) - Sends and receives packets for at least one network layer protocol. If the device is routing the protocol, this bit should not be set.
=item (0x08) - Performs level 2 switching. The difference between this bit and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This device is assumed to be deployed in a physical loop-free topology.
=item (0x04) - Performs level 2 source-route bridging. A source-route bridge would set both this bit and bit 0x02.
=item (0x02) - Performs level 2 transparent bridging.
=item (0x01) - Performs level 3 routing for at least one network layer protocol.
=back
Thanks to Martin Lorensen C<martin -at- lorensen.dk> for a pointer to this information.
(B<cdpCacheCapabilities>)
@@ -241,18 +295,92 @@ Returns remote VTP Management Domain as defined in CISCO-VTP-MIB::managementDoma
(B<cdpCacheVTPMgmtDomain>)
=item $cdp->c_vlan()
Returns the remote interface native VLAN.
(B<cdpCacheNativeVLAN>)
=item $cdp->c_duplex()
Returns the port duplex status from remote devices.
(B<cdpCacheDuplex>)
=item $cdp->c_id()
Returns remote device id string
(B<cdpCacheDeviceId>)
=item $cdp->c_if()
Returns the mapping to the SNMP Interface Table.
Note that a lot devices don't implement $cdp->c_index(), So if it isn't around,
we fake it.
In order to map the cdp table entry back to the interfaces() entry, we truncate the last number
off of it :
# it exists, yay.
my $c_index = $device->c_index();
return $c_index if defined $c_index;
# if not, let's fake it
my $c_ip = $device->c_ip();
my %c_if
foreach my $key (keys %$c_ip){
$iid = $key;
## Truncate off .1 from cdp response
$iid =~ s/\.\d+$//;
$c_if{$key} = $iid;
}
return \%c_if;
=item $cdp->c_index()
Returns the mapping to the SNMP2 Interface table for CDP Cache Entries.
Most devices don't implement this, so you probably want to use $cdp->c_if() instead.
See c_if() entry.
(B<cdpCacheIfIndex>)
=item $cdp->c_ip()
Returns remote IP address
(B<cdpCacheAddress>)
=item $cdp->c_platform()
Returns remote platform id
(B<cdpCachePlatform>)
=item $cdp->c_port()
Returns remote port ID
(B<cdpDevicePort>)
=item $cdp->c_proto()
Returns remote address type received. Usually IP.
(B<cdpCacheAddressType>)
=item $cdp->c_ver()
Returns remote hardware version
(B<cdpCacheVersion>)
=item $cdp->c_vlan()
Returns the remote interface native VLAN.
(B<cdpCacheNativeVLAN>)
=back
=cut

118
Info/CiscoImage.pm Normal file
View File

@@ -0,0 +1,118 @@
package SNMP::Info::CiscoImage;
#$Id$
# Copyright (c) 2005 Matt Tuttle
#
# 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.
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
$VERSION = 1.0;
@SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoImage::EXPORT_OK = qw//;
%MIBS = (
'CISCO-IMAGE-MIB' => 'ciscoImageString',
);
%GLOBALS = (
);
%FUNCS = (
'ci_images' => 'ciscoImageString',
);
%MUNGE = (
);
1;
__END__
=head1 NAME
SNMP::Info::CiscoImage - Perl5 Interface to image strings for Cisco Devices
=head1 AUTHOR
Matt Tuttle (C<mtuttle@americanhebrewacademy.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $ci = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ci->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoImage is a subclass of SNMP::Info that provides access to
image strings embedded in an image running on Cisco Devices.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item CISCO-IMAGE-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
None.
=head1 TABLE METHODS
=over
=item $ci->ci_images()
Returns the table of image strings.
B<ciscoImageString>
=back
=cut

151
Info/CiscoQOS.pm Normal file
View File

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

143
Info/CiscoRTT.pm Normal file
View File

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

816
Info/CiscoStack.pm Normal file
View File

@@ -0,0 +1,816 @@
# SNMP::Info::CiscoStack
# Max Baker
#
# Copyright (c)2003,2004 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the 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::CiscoStack;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/;
@SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoStack::EXPORT_OK = qw//;
%MIBS = (
'CISCO-STACK-MIB' => 'ciscoStackMIB',
'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB',
);
%GLOBALS = (
'sysip' => 'sysIpAddr',
'netmask' => 'sysNetMask',
'broadcast' => 'sysBroadcast',
'serial1' => 'chassisSerialNumber',
'serial2' => 'chassisSerialNumberString',
'model1' => 'chassisModel',
'ps1_type' => 'chassisPs1Type',
'ps1_status' => 'chassisPs1Status',
'ps2_type' => 'chassisPs2Type',
'ps2_status' => 'chassisPs2Status',
'slots' => 'chassisNumSlots',
'fan' => 'chassisFanStatus',
# 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',
'm_model' => 'moduleModel',
'm_serial' => 'moduleSerialNumber',
'm_status' => 'moduleStatus',
'm_name' => 'moduleName',
'm_ports' => 'moduleNumPorts',
'm_ports_status' => 'modulePortStatus',
'm_hwver' => 'moduleHwVersion',
'm_fwver' => 'moduleFwVersion',
'm_swver' => 'moduleSwVersion',
# Router Blades :
'm_ip' => 'moduleIPAddress',
'm_sub1' => 'moduleSubType',
'm_sub2' => 'moduleSubType2',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
'p_rx_flow_control' => 'portOperRxFlowControl',
'p_tx_flow_control' => 'portOperTxFlowControl',
'p_rx_flow_control_admin' => 'portAdminRxFlowControl',
'p_tx_flow_control_admin' => 'portAdminTxFlowControl',
'p_oidx' => 'portCrossIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
# 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',
2 => 'ok',
3 => 'minorFault',
4 => 'majorFault');
# Changes binary byte describing each port into ascii, and returns
# an ascii list separated by spaces.
sub munge_port_status {
my $status = shift;
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
return join(' ',@vals);
}
sub serial {
my $stack = shift;
my $serial1 = $stack->serial1();
my $serial2 = $stack->serial2();
return $serial1 if defined $serial1;
return $serial2 if defined $serial2;
return 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;
}
sub i_duplex {
my $stack = shift;
#my $i_duplex = $stack->SUPER::i_duplex();
my $p_port = $stack->p_port();
my $p_duplex = $stack->p_duplex();
my $i_duplex = {};
foreach my $port (keys %$p_duplex) {
my $iid = $p_port->{$port};
$i_duplex->{$iid} = $p_duplex->{$port};
}
return $i_duplex;
}
sub i_duplex_admin {
my $stack = shift;
my $p_port = $stack->p_port();
my $p_duplex_admin = $stack->p_duplex_admin();
my %i_duplex_admin;
foreach my $port (keys %$p_duplex_admin) {
my $iid = $p_port->{$port};
next unless defined $iid;
my $duplex = $p_duplex_admin->{$port};
next unless defined $duplex;
my $string = 'other';
# see CISCO-STACK-MIB for a description of the bits
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
# we'll call it auto if both full and half are turned on, or if the
# specifically 'auto' flag bit is set.
$string = 'auto'
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
$i_duplex_admin{$iid} = $string;
}
return \%i_duplex_admin;
}
sub set_i_speed_admin {
# map speeds to those the switch will understand
my %speeds = qw/auto 1 10 10000000 100 100000000 1000 1000000000/;
my $stack = shift;
my ($speed, $iid) = @_;
my $p_port = $stack->p_port();
my %reverse_p_port = reverse %$p_port;
$speed = lc($speed);
return 0 unless defined $speeds{$speed};
$iid = $reverse_p_port{$iid};
return $stack->set_p_speed($speeds{$speed}, $iid);
}
sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/;
my $stack = shift;
my ($duplex, $iid) = @_;
my $p_port = $stack->p_port();
my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex};
$iid = $reverse_p_port{$iid};
return $stack->set_p_duplex($duplexes{$duplex}, $iid);
}
# $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
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $ciscostats = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ciscostats->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoStack is a subclass of SNMP::Info that provides
an interface to the C<CISCO-STACK-MIB>. This MIB is used across
the Catalyst family under CatOS and IOS.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item 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
Netdisco-mib package at netdisco.org.
=head1 GLOBALS
=over
=item $stack->broadcast()
(B<sysBroadcast>)
=item $stack->fan()
(B<chassisFanStatus>)
=item $stack->model()
(B<chassisModel>)
=item $stack->netmask()
(B<sysNetMask>)
=item $stack->ps1_type()
(B<chassisPs1Type>)
=item $stack->ps2_type()
(B<chassisPs2Type>)
=item $stack->ps1_status()
(B<chassisPs1Status>)
=item $stack->ps2_status()
(B<chassisPs2Status>)
=item $stack->serial()
(B<chassisSerialNumberString>) or (B<chassisSerialNumber>)
=item $stack->slots()
(B<chassisNumSlots>)
=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.
=item $stack->i_type()
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.
=item $stack->i_duplex_admin()
Crosses p_duplex_admin with p_port.
Munges bit_string returned from p_duplex_admin to get duplex settings.
=item $stack->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port ifIndex
Speed choices are 'auto', '10', '100', '1000'
Crosses $stack->p_port() with $stack->p_duplex() to
utilize port ifIndex.
Example:
my %if_map = reverse %{$stack->interfaces()};
$stack->set_i_speed_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port speed. ",$stack->error(1);
=item $stack->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port ifIndex
Speed choices are 'auto', 'half', 'full'
Crosses $stack->p_port() with $stack->p_duplex() to
utilize port ifIndex.
Example:
my %if_map = reverse %{$stack->interfaces()};
$stack->set_i_duplex_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port duplex. ",$stack->error(1);
=back
=head2 Module table
This table holds configuration information for each of the blades installed in
the Catalyst device.
=over
=item $stack->m_type()
(B<moduleType>)
=item $stack->m_model()
(B<moduleModel>)
=item $stack->m_serial()
(B<moduleSerialNumber>)
=item $stack->m_status()
(B<moduleStatus>)
=item $stack->m_name()
(B<moduleName>)
=item $stack->m_ports()
(B<moduleNumPorts>)
=item $stack->m_ports_status()
Returns a list of space separated status strings for the ports.
To see the status of port 4 :
@ports_status = split(' ', $stack->m_ports_status() );
$port4 = $ports_status[3];
(B<modulePortStatus>)
=item $stack->m_ports_hwver()
(B<moduleHwVersion>)
=item $stack->m_ports_fwver()
(B<moduleFwVersion>)
=item $stack->m_ports_swver()
(B<moduleSwVersion>)
=item $stack->m_ports_ip()
(B<moduleIPAddress>)
=item $stack->m_ports_sub1()
(B<moduleSubType>)
=item $stack->m_ports_sub2()
(B<moduleSubType2>)
=back
=head2 Modules - Router Blades
=over
=item $stack->m_ip()
(B<moduleIPAddress>)
=item $stack->m_sub1()
(B<moduleSubType>)
=item $stack->m_sub2()
(B<moduleSubType2>)
=back
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
=over
=item $stack->p_name()
(B<portName>)
=item $stack->p_type()
(B<portType>)
=item $stack->p_status()
(B<portOperStatus>)
=item $stack->p_status2()
(B<portAdditionalStatus>)
=item $stack->p_speed()
(B<portAdminSpeed>)
=item $stack->p_duplex()
(B<portDuplex>)
=item $stack->p_port()
(B<portIfIndex>)
=item $stack->p_rx_flow_control()
Can be either C<on> C<off> or C<disagree>
"Indicates the receive flow control operational status of the port. If the port
could not agree with the far end on a link protocol, its operational status
will be disagree(3)."
B<portOperRxFlowControl>
=item $stack->p_tx_flow_control()
Can be either C<on> C<off> or C<disagree>
"Indicates the transmit flow control operational status of the port. If the
port could not agree with the far end on a link protocol, its operational
status will be disagree(3)."
B<portOperTxFlowControl>
=item $stack->p_rx_flow_control_admin()
Can be either C<on> C<off> or C<desired>
"Indicates the receive flow control administrative status set on the port. If
the status is set to on(1), the port will require the far end to send flow
control. If the status is set to off(2), the port will not allow far end to
send flow control. If the status is set to desired(3), the port will allow the
far end to send the flow control."
B<portAdminRxFlowControl>
=item $stack->p_tx_flow_control_admin()
Can be either C<on> C<off> or C<desired>
"Indicates the transmit flow control administrative status set on the port. If
the status is set to on(1), the port will send flow control to the far end. If
the status is set to off(2), the port will not send flow control to the far
end. If the status is set to desired(3), the port will send flow control to the
far end if the far end supports it."
B<portAdminTxFlowControl>
=back
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
=over
=item $stack->p_speed_admin()
(B<portCpbSpeed>)
=item $stack->p_duplex_admin()
(B<portCpbDuplex>)
=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

283
Info/CiscoStats.pm Normal file
View File

@@ -0,0 +1,283 @@
# SNMP::Info::CiscoStats
# Max Baker
#
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
# All rights reserved.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoStats;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/;
@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
'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis',
);
%GLOBALS = (
'description' => 'sysDescr',
# We will use the numeric OID's so that we don't require people
# to install v1 MIBs, which can conflict.
# OLD-CISCO-CPU-MIB:avgBusyPer
'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0',
'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0',
'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0',
# CISCO-PROCESS-MIB
'cat_cpu' => 'cpmCPUTotal5sec.9',
'cat_cpu_1min' => 'cpmCPUTotal1min.9',
'cat_cpu_5min' => 'cpmCPUTotal5min.9',
# CISCO-MEMORY-POOL-MIB
'mem_free' => 'ciscoMemoryPoolFree.1',
'mem_used' => 'ciscoMemoryPoolUsed.1',
# OLD-CISCO-SYSTEM-MIB
'write_mem' => 'writeMem',
);
%FUNCS = (
);
%MUNGE = (
);
sub os {
my $l2 = shift;
my $descr = $l2->description() || '';
# order here matters - there are Catalysts that run IOS and have catalyst in their description field.
return 'ios' if ($descr =~ /IOS/);
return 'catalyst' if ($descr =~ /catalyst/i);
return undef;
}
sub os_ver {
my $l2 = shift;
my $os = $l2->os();
my $descr = $l2->description();
# Older Catalysts
if (defined $os and $os eq 'catalyst' and defined $descr and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/){
return $1;
}
# Newer Catalysts and IOS devices
if (defined $descr and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ ){
return $1;
}
return undef;
}
sub cpu {
my $self = shift;
my $ios_cpu = $self->ios_cpu();
return $ios_cpu if defined $ios_cpu;
my $cat_cpu = $self->cat_cpu();
return $cat_cpu;
}
sub cpu_1min {
my $self = shift;
my $ios_cpu_1min = $self->ios_cpu_1min();
return $ios_cpu_1min if defined $ios_cpu_1min;
my $cat_cpu_1min = $self->cat_cpu_1min();
return $cat_cpu_1min;
}
sub cpu_5min {
my $self = shift;
my $ios_cpu_5min = $self->ios_cpu_5min();
return $ios_cpu_5min if defined $ios_cpu_5min;
my $cat_cpu_5min = $self->cat_cpu_5min();
return $cat_cpu_5min;
}
sub mem_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;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco Devices
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $ciscostats = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $ciscostats->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::CiscoStats is a subclass of SNMP::Info that provides cpu, memory, os and
version information about Cisco Devices.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item CISCO-PRODUCTS-MIB
=item CISCO-PROCESS-MIB
=item CISCO-MEMORY-POOL-MIB
=item SNMPv2-MIB
=item OLD-CISCO-SYSTEM-MIB
=item CISCO-STACK-MIB
=item CISCO-ENTITY-VENDORTYPE-OID-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
=item $ciscostats->cpu()
Returns ios_cpu() or cat_cpu(), whichever is available.
=item $ciscostats->cpu_1min()
Returns ios_cpu_1min() or cat_cpu1min(), whichever is available.
=item $ciscostats->cpu_5min()
Returns ios_cpu_5min() or cat_cpu5min(), whichever is available.
=item $ciscostats->mem_total()
Returns mem_free() + mem_used()
=item $ciscostats->os()
Trys to parse if device is running IOS or CatOS from description()
=item $ciscostats->os_ver()
Trys to parse device operating system version from description()
=item $ciscostats->ios_cpu()
Current CPU usage in percents of device.
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.
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.
B<1.3.6.1.4.1.9.2.1.58.0>
=item $ciscostats->cat_cpu()
Current CPU usage in percents of device.
B<CISCO-PROCESS-MIB::cpmCPUTotal5sec.9>
=item $ciscostats->cat_cpu_1min()
Average CPU Usage in percents of device over last minute.
B<CISCO-PROCESS-MIB::cpmCPUTotal1min.9>
=item $ciscostats->cat_cpu_5min()
Average CPU Usage in percents of device over last 5 minutes.
B<CISCO-PROCESS-MIB::cpmCPUTotal5min.9>
=item $ciscostats->mem_free()
Main DRAM free in device. In bytes.
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree.1>
=item $ciscostats->mem_used()
Main DRAM used in device. In bytes.
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed.1>
=back
=head1 TABLE METHODS
None.
=cut

420
Info/CiscoVTP.pm Normal file
View File

@@ -0,0 +1,420 @@
# SNMP::Info::CiscoVTP
# Max Baker
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoVTP;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoVTP::EXPORT_OK = qw//;
%MIBS = (
'CISCO-VTP-MIB' => 'vtpVlanName',
'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry',
'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex',
);
%GLOBALS = (
'vtp_version' => 'vtpVersion',
'vtp_maxstore' => 'vtpMaxVlanStorage',
'vtp_notify' => 'vtpNotificationsEnabled',
'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled',
'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled',
);
%FUNCS = (
# Management Domain Table
'vtp_d_index' => 'managementDomainIndex',
'vtp_d_name' => 'managementDomainName',
'vtp_d_mode' => 'managementDomainLocalMode',
'vtp_d_rev' => 'managementDomainConfigRevNumber',
'vtp_d_updater' => 'managementDomainLastUpdater',
'vtp_d_last' => 'managementDomainLastChange',
'vtp_d_status' => 'managementDomainRowStatus',
'vtp_d_tftp' => 'managementDomainTftpServer',
'vtp_d_tftp_path' => 'managementDomainTftpPathname',
'vtp_d_pruning' => 'managementDomainPruningState',
'vtp_d_ver' => 'managementDomainVersionInUse',
# VLAN Table
'v_index' => 'vtpVlanIndex',
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
'v_said' => 'vtpVlanDot10Said',
'v_ring' => 'vtpVlanRingNumber',
'v_bridge' => 'vtpVlanBridgeNumber',
'v_stp' => 'vtpVlanStpType',
'v_parent' => 'vtpVlanParentVlan',
'v_trans1' => 'vtpVlanTranslationalVlan1',
'v_trans2' => 'vtpVlanTranslationalVlan2',
'v_btype' => 'vtpVlanBridgeType',
'v_hop_are' => 'vtpVlanAreHopCount',
'v_hop_ste' => 'vtpVlanSteHopCount',
'v_crf' => 'vtpVlanIsCRFBackup',
'v_type_ext' => 'vtpVlanTypeExt',
'v_if' => 'vtpVlanIfIndex',
# CISCO-VLAN-MEMBERSHIP-MIB
# VmMembershipTable
'i_vlan_type' => 'vmVlanType',
'i_vlan2' => 'vmVlan',
'i_vlan_stat' => 'vmPortStatus',
'i_vlan_1' => 'vmVlans',
'i_vlan_2' => 'vmVlans2k',
'i_vlan_3' => 'vmVlans3k',
'i_vlan_4' => 'vmVlans4k',
# CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB
'v_cvi_if' => 'cviRoutedVlanIfIndex',
# vlanTrunkPortTable
# TODO Add these tables if someone wants them..
# vtpEditControlTable
# vtpVlanEditTable
# vtpStatsTable
);
%MUNGE = (
);
sub i_vlan {
my $vtp = shift;
# Check for CISCO-VLAN-MIB
my $i_vlan = $vtp->i_vlan2();
return $i_vlan if defined $i_vlan;
# 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;
}
return $i_vlan;
}
sub set_i_vlan {
my $vtp = shift;
# Check for CISCO-VLAN-MIB
my $i_vlan = $vtp->i_vlan2();
if (defined $i_vlan) {
return $vtp->set_i_vlan2(@_);
}
# only support the first case for now.
return undef;
}
1;
__END__
=head1 NAME
SNMP::Info::CiscoVTP - Perl5 Interface to Cisco's VLAN Management MIBs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $vtp = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $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.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
none.
=head2 Required MIBs
=over
=item CISCO-VTP-MIB
=item CISCO-VLAN-MEMBERSHIP-MIB
=item CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
=over
=item $vtp->vtp_version()
C<vtpVersion>
=item $vtp->vtp_maxstore()
C<vtpMaxVlanStorage>
=item $vtp->vtp_notify()
C<vtpNotificationsEnabled>
=item $vtp->vtp_notify_create()
C<vtpVlanCreatedNotifEnabled>
=item $vtp->vtp_notify_delete()
C<vtpVlanDeletedNotifEnabled>
=back
=head1 TABLE METHODS
You device will only implement a subset of these methods.
=head2 VLAN Table
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>
=item $vtp->v_state()
C<vtpVlanState>
=item $vtp->v_type()
C<vtpVlanType>
=item $vtp->v_name()
C<vtpVlanName>
=item $vtp->v_mtu()
C<vtpVlanMtu>
=item $vtp->v_said()
C<vtpVlanDot10Said>
=item $vtp->v_ring()
C<vtpVlanRingNumber>
=item $vtp->v_bridge()
C<vtpVlanBridgeNumber>
=item $vtp->v_stp()
C<vtpVlanStpType>
=item $vtp->v_parent()
C<vtpVlanParentVlan>
=item $vtp->v_trans1()
C<vtpVlanTranslationalVlan1>
=item $vtp->v_trans2()
C<vtpVlanTranslationalVlan2>
=item $vtp->v_btype()
C<vtpVlanBridgeType>
=item $vtp->v_hop_are()
C<vtpVlanAreHopCount>
=item $vtp->v_hop_ste()
C<vtpVlanSteHopCount>
=item $vtp->v_crf()
C<vtpVlanIsCRFBackup>
=item $vtp->v_type_ext()
C<vtpVlanTypeExt>
=item $vtp->v_if()
C<vtpVlanIfIndex>
=back
=head2 VLAN Interface Table
This table is from CISCO-VLAN-MEMBERSHIP-MIB::VmMembershipTable
=over
=item $vtp->i_vlan_type()
Static, Dynamic, or multiVlan.
C<vmVlanType>
=item $vtp->i_vlan()
The VLAN that a port is assigned to.
0 for no VLAN assigned.
C<vmVlan>
=item $vtp->i_vlan_stat()
Inactive, active, shutdown.
C<vmPortStatus>
=item $vtp->i_vlan_1()
Each bit represents a VLAN. This is 0 through 1023
C<vmVlans>
=item $vtp->i_vlan_2()
Each bit represents a VLAN. This is 1024 through 2047
C<vmVlans2k>
=item $vtp->i_vlan_3()
Each bit represents a VLAN. This is 2048 through 3071
C<vmVlans3k>
=item $vtp->i_vlan_4()
Each bit represents a VLAN. This is 3072 through 4095
C<vmVlans4k>
=back
=head2 Managment Domain Table
=over
=item $vtp->vtp_d_index()
C<managementDomainIndex>
=item $vtp->vtp_d_name()
C<managementDomainName>
=item $vtp->vtp_d_mode()
C<managementDomainLocalMode>
=item $vtp->vtp_d_rev()
C<managementDomainConfigRevNumber>
=item $vtp->vtp_d_updater()
C<managementDomainLastUpdater>
=item $vtp->vtp_d_last()
C<managementDomainLastChange>
=item $vtp->vtp_d_status()
C<managementDomainRowStatus>
=item $vtp->vtp_d_tftp()
C<managementDomainTftpServer>
=item $vtp->vtp_d_tftp_path()
C<managementDomainTftpPathname>
=item $vtp->vtp_d_pruning()
C<managementDomainPruningState>
=item $vtp->vtp_d_ver()
C<managementDomainVersionInUse>
=back
=cut

251
Info/Entity.pm Normal file
View File

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

View File

@@ -1,7 +1,9 @@
# SNMP::Info::EtherLike
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +30,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::EtherLike;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
@@ -39,23 +42,45 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::EtherLike::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$INIT = 0;
# Same info in both rfc1398 and this?
%MIBS = ('ETHERLIKE-MIB' => 'etherMIB' );
%GLOBALS = ();
%FUNCS = (
# EtherLike StatsTable
'el_index' => 'dot3StatsIndex',
'el_duplex' => 'dot3StatsDuplexStatus',
'el_chipset' => 'dot3StatsEtherChipSet',
'el_coll_excess' => 'dot3StatsExcessiveCollisions',
'el_coll_late' => 'dot3StatsLateCollisions',
'el_coll_mult' => 'dot3StatsMultipleCollisionFrames',
'el_coll_single' => 'dot3StatsSingleCollisionFrames',
'el_duplex' => 'dot3StatsDuplexStatus',
'el_error_alignment' => 'dot3StatsAlignmentErrors',
'el_error_fcs' => 'dot3StatsFCSErrors',
'el_error_cs' => 'dot3StatsCarrierSenseErrors',
'el_error_frame' => 'dot3StatsFrameTooLongs',
'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors',
'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors',
'el_error_sqe' => 'dot3StatsSQETestErrors',
'el_error_symbol' => 'dot3StatsSymbolErrors',
'el_index' => 'dot3StatsIndex',
'el_xmit_defer' => 'dot3StatsDeferredTransmissions',
# Ethernet-like Collision Statistics Group
'el_coll_count' => 'dot3CollCount',
'el_coll_freq' => 'dot3CollFrequencies'
);
%MUNGE = ( %SNMP::Info::MUNGE );
%MUNGE = ( %SNMP::Info::MUNGE,
'el_duplex' => \&munge_el_duplex,
);
sub munge_el_duplex {
my $duplex = shift;
return unless defined $duplex;
$duplex =~ s/Duplex$//;
return $duplex;
}
1;
__END__
@@ -63,64 +88,77 @@ __END__
=head1 NAME
SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB
=head1 DESCRIPTION
ETHERLIKE-MIB is used by some Layer 3 Devices such as Cisco routers.
Inherits all methods from SNMP::Info
SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB RFC 1398
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $el = new SNMP::Info::EtherLike(DestHost => 'myrouter',
Community => 'public');
my $el = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'router',
Community => 'public',
Version => 2
);
my $class = $cdp->class();
print " Using device sub class : $class\n";
my $el_decoder = $el->el_index();
my $el_duplex = $el->el_duplex();
# Find the duplex setting for a port on a device that implements ETHERLIKE-MIB
my $interfaces = $el->interfaces();
my $el_index = $el->el_index();
my $el_duplex = $el->el_duplex();
=head1 CREATING AN OBJECT
foreach my $el_port (keys %$el_duplex){
my $duplex = $el_duplex->{$el_port};
my $iid = $el_index->{$el_port};
my $port = $interfaces->{$iid};
print "PORT:$port set to duplex:$duplex\n";
}
=head1 DESCRIPTION
SNMP::Info::EtherLike is a subclass of SNMP::Info that supplies
access to the ETHERLIKE-MIB used by some Layer 3 Devices such as Cisco routers.
See RFC 1398 for more details.
Use or create a subclass of SNMP::Info that inherits this one. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item new SNMP::Info::EtherLike()
Arguments passed to new() are passed on to SNMP::Session::new()
my $el = new SNMP::Info::EtherLike(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $el;
=item $el->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $el->session();
# Set
my $newsession = new SNMP::Session(...);
$el->session($newsession);
=item ETHERLIKE-MIB
=back
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 GLOBALS
These are methods that return scalar values from SNMP
=over
=item None
=back
=head1 ETHERLIKE STATS TABLE (dot3StatsTable)
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 ETHERLIKE STATS TABLE (dot3StatsTable)
=over
@@ -136,6 +174,70 @@ Returns reference to hash. Indexes Stats Table to Duplex Status of port.
(B<dot3StatsDuplexStatus>)
=item $el->el_chipset()
(B<dot3StatsEtherChipSet>)
=item $el->el_coll_excess()
(B<dot3StatsExcessiveCollisions>)
=item $el->el_coll_late()
(B<dot3StatsLateCollisions>)
=item $el->el_coll_mult()
(B<dot3StatsMultipleCollisionFrames>)
=item $el->el_coll_single()
(B<dot3StatsSingleCollisionFrames>)
=item $el->el_error_alignment()
(B<dot3StatsAlignmentErrors>)
=item $el->el_error_fcs()
(B<dot3StatsFCSErrors>)
=item $el->el_error_cs()
(B<dot3StatsCarrierSenseErrors>)
=item $el->el_error_frame()
(B<dot3StatsFrameTooLongs>)
=item $el->el_error_mac_rec()
(B<dot3StatsInternalMacReceiveErrors>)
=item $el->el_error_mac_xmit()
(B<dot3StatsInternalMacTransmitErrors>)
=item $el->el_error_sqe()
(B<dot3StatsSQETestErrors>)
=item $el->el_error_symbol()
(B<dot3StatsSymbolErrors>)
=item $el->el_xmit_defer()
(B<dot3StatsDeferredTransmissions>)
=item $el->el_coll_count()
(B<dot3CollCount>)
=item $el->el_coll_freq()
(B<dot3CollFrequencies>)
=back
=cut

395
Info/FDP.pm Normal file
View File

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

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer1 - SNMP Interface to Layer1 Devices
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +30,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
@@ -40,13 +43,6 @@ use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Layer1::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = ( %SNMP::Info::MIBS,
'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex'
);
@@ -162,70 +158,80 @@ __END__
=head1 NAME
SNMP::Info::Layer1 - Perl5 Interface to Layer1 network devices.
SNMP::Info::Layer1 - Perl5 Interface to network devices serving Layer1 only.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $l1 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $l1->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
my $interfaces = $l1->interfaces();
my $i_up = $l1->i_up();
my $i_speed = $l1->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
=head1 DESCRIPTION
This class is usually used as a superclass for more specific device classes listed under
SNMP::Info::Layer1::* Please read all docs under SNMP::Info first.
Provides abstraction to the configuration information obtainable from a
Layer1 device through SNMP. Information is stored in a number of MIBs.
See super classes for descriptions of other available methods.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
Inherits from:
my $l1 = new SNMP::Info::Layer1(...);
SNMP::Info
MIBS:
MIBS listed in SNMP::Info
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $l1 = new SNMP::Info::Layer1(DestHost => 'mybridge' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer1()
Arguments passed to new() are passed on to SNMP::Session::new()
my $l1 = new SNMP::Info::Layer1(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $l1;
=item $l1->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $l1->session();
# Set
my $newsession = new SNMP::Session(...);
$l1->session($newsession);
=item SNMP::Info
=back
=head1 GLOBALS
=head2 Required MIBs
=over
=item $l1->vendor()
=item SNMP-REPEATER-MIB
Trys to discover the vendor from $l1->model() and $l1->vendor()
=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
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $l1->ports_managed()
@@ -233,6 +239,16 @@ Gets the number of ports under the interface mib
(B<ifNumber>)
=back
=head2 Overrides
=over
=item $l1->vendor()
Trys to discover the vendor from $l1->model() and $l1->vendor()
=item $l1->ports()
Adds the values from rptr_ports() and ports_managed()
@@ -245,8 +261,15 @@ Number of 'groups' in the Repeater MIB
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
@@ -291,4 +314,8 @@ Group (slot) Number for given port.
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer1::Allied
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +30,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Allied;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
@@ -63,6 +66,19 @@ sub vendor {
return 'allied';
}
sub os {
return 'allied';
}
sub os_ver {
my $allied = shift;
my $descr = $allied->description();
if ($descr =~ m/version (\d+\.\d+)/){
return $1;
}
}
sub model {
my $allied = shift;
@@ -110,68 +126,74 @@ __END__
SNMP::Info::Layer1::Allied - SNMP Interface to old Allied Hubs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $allied = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myhub',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $l1->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Allied device through SNMP. See inherited classes' documentation for
inherited methods.
Inherits from:
SNMP::Info::Layer1
Required MIBs:
ATI-MIB - Download for your device from http://www.allied-telesyn.com/allied/support/
MIBs listed in SNMP::Info::Layer1
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $allied = new SNMP::Info::Layer1::Allied(DestHost => 'mycat1900' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer1::Allied()
=item SNMP::Info::Layer1
Arguments passed to new() are passed on to SNMP::Session::new()
=back
my $allied = new SNMP::Info::Layer1::Allied(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $allied;
=head2 Required MIBs
=item $allied->session()
=over
Sets or returns the SNMP::Session object
=item ATI-MIB
# Get
my $sess = $allied->session();
Download for your device from http://www.allied-telesyn.com/allied/support/
# Set
my $newsession = new SNMP::Session(...);
$allied->session($newsession);
=item Inherited Classes
MIBs listed in SNMP::Info::Layer1 and its inherited classes.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $allied->vendor()
Returns 'allied' :)
=item $allied->os()
Returns 'allied'
=item $allied->os_ver()
Culls Version from description()
=item $allied->root_ip()
Returns IP Address of Managed Hub.
@@ -184,6 +206,10 @@ Trys to cull out AT-nnnnX out of the description field.
=back
=head2 Global Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -215,4 +241,8 @@ the values of ati_up() to 'up' and 'down'.
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer1::Asante
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +30,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Asante;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
@@ -79,6 +82,19 @@ sub interfaces {
return \%interfaces;
}
sub os {
return 'asante';
}
sub os_ver {
my $asante = shift;
my $descr = $asante->description();
if ($descr =~ /software v(\d+\.\d+)/){
return $1;
}
}
sub vendor {
return 'asante';
}
@@ -153,80 +169,79 @@ __END__
SNMP::Info::Layer1::Asante - SNMP Interface to old Asante 1012 Hubs
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Asante device through SNMP. See inherited classes' documentation for
inherited methods.
Inherits from:
SNMP::Info::Layer1
Required MIBs:
ASANTE-HUB1012-MIB - Download from http://www.mibdepot.com
MIBs listed in SNMP::Info::Layer1
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $asante = new SNMP::Info::Layer1::Asante(DestHost => 'mycat1900' ,
Community => 'public' );
# Let SNMP::Info determine the correct subclass for you.
my $asante = 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";
=head1 CREATING AN OBJECT
my $class = $asante->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Asante device through SNMP.
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer1::Asante()
=item SNMP::Info::Layer1
Arguments passed to new() are passed on to SNMP::Session::new()
=back
my $asante = new SNMP::Info::Layer1::Asante(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $asante;
=head2 Required MIBs
=item $asante->session()
=over
Sets or returns the SNMP::Session object
=item ASANTE-HUB1012-MIB
# Get
my $sess = $asante->session();
Download from http://www.mibdepot.com
# Set
my $newsession = new SNMP::Session(...);
$asante->session($newsession);
=item MIBs listed in SNMP::Info::Layer1
=back
=head1 GLOBALS
=head2 Overrides
=over
=item $asante->os()
Returns 'asante'
=item $asante->os_ver()
Culls software version from description()
=item $asante->vendor()
Returns 'asante' :)
=item $asante->root_ip()
Returns IP Address of Managed Hub.
(B<actualIpAddr>)
=item $asante->model()
Trys to cull out AT-nnnnX out of the description field.
=back
=head2 Globals inherited from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -258,4 +273,8 @@ the values of ati_up() to 'up' and 'down'.
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
=cut

554
Info/Layer1/Bayhub.pm Normal file
View File

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

524
Info/Layer1/S3000.pm Normal file
View File

@@ -0,0 +1,524 @@
# SNMP::Info::Layer1::S3000
# 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::S3000;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info::Layer1;
use SNMP::Info::Bridge;
@SNMP::Info::Layer1::S3000::ISA = qw/SNMP::Info::Layer1 SNMP::Info::Bridge/;
@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,
'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable',
'SYNOPTICS-COMMON-MIB' => 's3AgentType',
);
%GLOBALS = (
%SNMP::Info::Layer1::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
# From SYNOPTICS-COMMON-MIB
'os_bin' => 's3AgentFwVer',
's3000_major_ver' => 's3AgentSwMajorVer',
's3000_minor_ver' => 's3AgentSwMinorVer',
's3000_maint_ver' => 's3AgentSwMaintVer',
);
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
%SNMP::Info::Bridge::FUNCS,
# SYNOPTICS-ETHERNET-MIB::s3EnetPortTable
's3000_pb_index' => 's3EnetPortBoardIndex',
's3000_pp_index' => 's3EnetPortIndex',
's3000_up_admin' => 's3EnetPortPartStatus',
's3000_up' => 's3EnetPortLinkStatus',
# SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable
's3000_nb_index' => 's3EnetShowNodesSlotIndex',
's3000_np_index' => 's3EnetShowNodesPortIndex',
'fw_mac' => 's3EnetShowNodesMacAddress',
# SYNOPTICS-ETHERNET-MIB::s3EnetTopNmmTable
's3000_topo_port' => 's3EnetTopNmmPort',
's3000_topo_mac' => 's3EnetTopNmmMacAddr',
);
%MUNGE = (
%SNMP::Info::Layer1::MUNGE,
%SNMP::Info::Bridge::MUNGE,
's3000_topo_mac' => \&SNMP::Info::munge_mac
);
sub layers {
return '00000011';
}
sub os {
return 'synoptics';
}
sub vendor {
return 'nortel';
}
sub model {
my $s3000 = shift;
my $id = $s3000->id();
return undef unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^s3reg-//i;
return $1 if ($model =~ /((\d+){3}[\dX])/);
return $model;
}
sub os_ver {
my $s3000 = shift;
my $major_ver = $s3000->s3000_major_ver() || 0;
my $minor_ver = $s3000->s3000_minor_ver() || 0;
my $maint_ver = $s3000->s3000_maint_ver() || 0;
my $ver = "$major_ver.$minor_ver.$maint_ver";
return $ver;
}
sub mac {
my $s3000 = shift;
my $topo_port = $s3000->s3000_topo_port();
my $topo_mac = $s3000->s3000_topo_mac();
foreach my $entry (keys %$topo_port){
my $port = $topo_port->{$entry};
next unless $port == 0;
my $mac = $topo_mac->{$entry};
return $mac;
}
# Topology turned off, not supported.
return undef;
}
# Hubs do not support ifMIB requirements for get MAC
# and port status
sub i_index {
my $s3000 = shift;
my $b_index = $s3000->s3000_pb_index();
my $p_index = $s3000->s3000_pp_index();
my %i_index;
foreach my $iid (keys %$b_index){
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid}||0;
# We need to make up an index for multiple board instances.
my $index = ($board*256)+$port;
$i_index{$iid} = $index;
}
return \%i_index;
}
sub interfaces {
my $s3000 = shift;
my $i_index = $s3000->i_index();
my %if;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
# Index numbers are deterministic slot * 256 + port - see i_index()
my $port = $index % 256;
my $slot = int($index / 256);
my $slotport = "$slot.$port";
$if{$index} = $slotport;
}
return \%if;
}
sub i_duplex {
my $s3000 = shift;
my $port_index = $s3000->i_index();
my %i_duplex;
foreach my $iid (keys %$port_index){
my $index = $port_index->{$iid};
next unless defined $index;
# Hubs only function half duplex
my $duplex = 'half';
$i_duplex{$index}=$duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $s3000 = 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;
# Hubs only function half duplex
my $duplex = 'half';
$i_duplex_admin{$index}=$duplex;
}
return \%i_duplex_admin;
}
sub i_speed {
my $s3000 = 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;
# These hubs only support 10Mbs
my $speed = '10000000';
$i_speed{$index}=$speed;
}
return \%i_speed;
}
sub i_up {
my $s3000 = 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;
my $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$link_stat = 'up' if $link_stat =~ /on/i;
$link_stat = 'down' if $link_stat =~ /off/i;
$i_up{$index}=$link_stat;
}
return \%i_up;
}
sub i_up_admin {
my $s3000 = shift;
my $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 $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$i_up_admin{$index}=$link_stat;
}
return \%i_up_admin;
}
sub set_i_up_admin {
# map setting to those the hub will understand
my %setting = qw/up 2 down 3/;
my $s3000 = shift;
my ($setting, $iid) = @_;
my $i_index = $s3000->i_index();
my %reverse_i_index = reverse %$i_index;
$setting = lc($setting);
return 0 unless defined $setting{$setting};
$iid = $reverse_i_index{$iid};
return $s3000->set_s3000_up_admin($setting{$setting}, $iid);
}
# Hubs do not support the standard Bridge MIB
sub bp_index {
my $s3000 = shift;
my $b_index = $s3000->s3000_nb_index();
my $p_index = $s3000->s3000_np_index();
my $model = $s3000->model();
my %bp_index;
foreach my $iid (keys %$b_index){
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid}||0;
my $index = ($board*256)+$port;
$bp_index{$index} = $index;
}
return \%bp_index;
}
sub fw_port {
my $s3000 = shift;
my $b_index = $s3000->s3000_nb_index();
my $p_index = $s3000->s3000_np_index();
my $model = $s3000->model();
my %fw_port;
foreach my $iid (keys %$b_index){
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid}||0;
my $index = ($board*256)+$port;
$fw_port{$iid} = $index;
}
return \%fw_port;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::S3000 - SNMP Interface to Synoptics / Nortel Hubs
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $s3000 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $s3000->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bayhub device through SNMP. Also provides device MAC to port mapping through the propietary MIB.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $s3000 = new SNMP::Info::Layer1::S3000(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer1
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item SYNOPTICS-COMMON-MIB
=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
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $s3000->vendor()
Returns 'nortel'
=item $s3000->os()
Returns 'synoptics'
=item $s3000->model()
Cross references $s3000->id() to the SYNOPTICS-MIB and returns
the results.
Removes sreg- from the model name and returns only the numeric model identifier.
=item $stack->os_ver()
Returns the software version specified as major.minor.maint.
(B<s3AgentSwMajorVer>).(B<s3AgentSwMinorVer>).(B<s3AgentSwMaintVer>)
=item $stack->os_bin()
Returns the firmware version. (B<s3AgentFwVer>)
=item $s3000->mac()
Returns MAC of the advertised IP address of the device.
=back
=head2 Overrides
=over
=item $s3000->layers()
Returns 00000011. Class emulates Layer 2 functionality through proprietary MIBs.
=back
=head2 Globals imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $s3000->i_index()
Returns reference to map of IIDs to Interface index.
Since hubs do not support ifIndex, the interface index is created using the
formula (board * 256 + port). This is required to support devices with more than one module.
=item $s3000->interfaces()
Returns reference to map of IIDs to physical ports.
=item $s3000->i_duplex()
Returns half, hubs do not support full duplex.
=item $s3000->i_duplex_admin()
Returns half, hubs do not support full duplex.
=item $s3000->i_speed()
Returns 10000000. The hubs only support 10Mbs Ethernet.
=item $s3000->i_up()
Returns (B<s3EnetPortLinkStatus>) for each port. Translates on/off to up/down.
=item $s3000->i_up_admin()
Returns (B<s3EnetPortPartStatus>) for each port.
=item $s3000->set_i_up_admin(state, ifIndex)
Sets port state, must be supplied with state and port ifIndex
State choices are 'up'or 'down'
Example:
my %if_map = reverse %{$s3000->interfaces()};
$s3000->set_i_up_admin('down', $if_map{'1.1'})
or die "Couldn't change port state. ",$s3000->error(1);
=item $s3000->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $s3000->fw_port()
Returns reference to map of IIDs of the SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable
to the Interface index.
=item $s3000->fw_mac()
(B<s3EnetShowNodesMacAddress>)
=item $s3000->s3000_topo_port()
Returns reference to hash. Key: Table entry, Value:Port Number (interface iid)
(B<s3EnetTopNmmPort>)
=item $s3000->s3000_topo_mac()
(B<s3EnetTopNmmMacAddr>)
Returns reference to hash. Key: Table entry, Value:Remote MAC address
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See documentation in SNMP::Info::Layer1 for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004,2005 Max Baker -- All changes from Version 0.7 on
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,52 +30,44 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::CDP;
use SNMP::Info::Entity;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer2::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::CDP::MIBS,
'CISCO-PRODUCTS-MIB' => 'sysName',
'CISCO-STACK-MIB' => 'wsc1900sysID',
'HP-ICF-OID' => 'hpSwitch4000',
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::Entity::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::Entity::FUNCS,
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::Entity::MUNGE,
);
# Method OverRides
@@ -84,12 +78,14 @@ sub model {
my $l2 = shift;
my $id = $l2->id();
my $model = &SNMP::translateObj($id);
# HP
$model =~ s/^hpswitch//i;
# Cisco
$model =~ s/sysid$//i;
$model =~ s/^(cisco|catalyst)//i;
$model =~ s/^cat//i;
return $model;
}
@@ -99,7 +95,7 @@ sub vendor {
my $model = $l2->model();
my $descr = $l2->description();
if ($model =~ /hp/i or $descr =~ /hp/i) {
if ($model =~ /hp/i or $descr =~ /\bhp\b/i) {
return 'hp';
}
@@ -109,6 +105,25 @@ sub vendor {
}
sub serial {
my $l2 = shift;
my $serial1 = $l2->serial1();
my $e_descr = $l2->e_descr() || {};
my $e_serial = $l2->e_serial() || {};
my $serial2 = $e_serial->{1} || undef;
my $chassis = $e_descr->{1} || undef;
# precedence
# serial2,chassis parse,serial1
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/);
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/);
return undef;
}
sub i_ignore {
my $l2 = shift;
@@ -125,31 +140,18 @@ sub i_ignore {
return \%i_ignore;
}
# By Default we'll use the description field
sub interfaces {
my $l2 = shift;
my $interfaces = $l2->i_index();
my $i_descr = $l2->i_description();
my $i_name = $l2->i_name();
my %if;
foreach my $iid (keys %$interfaces){
# Replace the Index with the ifDescr field.
foreach my $iid (keys %$i_descr){
my $port = $i_descr->{$iid};
my $name = $i_name->{$iid};
$port = $name if (defined $name and $name !~ /^\s*$/);
next unless defined $port;
# Cisco 1900 has a space in some of its port descr.
# get rid of any weird characters
$port =~ s/[^\d\/,()\w]+//gi;
# Translate Cisco 2926,etc. from 1/5 to 1.5
$port =~ s/\//\./ if ($port =~ /^\d+\/\d+$/);
$if{$iid} = $port;
$interfaces->{$iid} = $port;
}
return \%if
return $interfaces;
}
1;
@@ -157,78 +159,88 @@ __END__
=head1 NAME
SNMP::Info::Layer2 - Perl5 Interface to Layer2 network devices.
SNMP::Info::Layer2 - Perl5 Interface to network devices serving Layer2 only.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $l2 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $l2->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
my $interfaces = $l2->interfaces();
my $i_up = $l2->i_up();
my $i_speed = $l2->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
=head1 DESCRIPTION
This class is usually used as a superclass for more specific device classes listed under
SNMP::Info::Layer2::* Please read all docs under SNMP::Info first.
Provides abstraction to the configuration information obtainable from a
Layer2 device through SNMP. Information is stored in a number of MIBs.
See super classes for descriptions of other available methods.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
Inherits from:
my $l2 = new SNMP::Info::Layer2(...);
SNMP::Info
SNMP::Info::Bridge
SNMP::Info::CDP
MIBS:
CISCO-PRODUCTS-MIB - Needed for ID of Cisco Products
CISCO-STACK-MIB - Needed for ID of Cisco Products
HP-ICF-OID - Needed for ID of HP Products
MIBS listed in SNMP::Info::Bridge and SNMP::Info::CDP
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
HP MIBs can be found at http://www.hp.com/rnd/software
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $l2 = new SNMP::Info::Layer2(DestHost => 'mybridge' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer2()
=item SNMP::Info
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::Bridge
my $l2 = new SNMP::Info::Layer2(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $l2;
=item $l2->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $l2->session();
# Set
my $newsession = new SNMP::Session(...);
$l2->session($newsession);
=item SNMP::Info::Entity
=back
=head2 Required MIBs
=over
=item Inherited Classes
MIBs required by the inherited classes listed above.
=back
MIBs can be found in netdisco-mibs package.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $l2->model()
Cross references $l2->id() with product IDs in the
Cisco and HP specific MIBs.
Cisco MIBs.
For HP devices, removes 'hpswitch' from the name
@@ -236,11 +248,26 @@ For Cisco devices, removes 'sysid' from the name
=item $l2->vendor()
Trys to discover the vendor from $l2->model() and $l2->vendor()
Trys to discover the vendor from $l2->model() and $l2->description()
=back
=head1 TABLE ENTRIES
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
@@ -260,4 +287,16 @@ Ignores ports with B<ifType> of loopback,propvirtual,other, and cpu
=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::Entity
See documentation in SNMP::Info::Entity for details.
=cut

261
Info/Layer2/Aironet.pm Normal file
View File

@@ -0,0 +1,261 @@
# SNMP::Info::Layer2::Aironet
# Max Baker
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Aironet;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::Entity;
use SNMP::Info::EtherLike;
use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
@SNMP::Info::Layer2::Aironet::ISA = qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike
SNMP::Info::CiscoStats SNMP::Info::CiscoVTP SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::Aironet::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'serial' => 'entPhysicalSerialNum.1',
'descr' => 'sysDescr'
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::Entity::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CDP::FUNCS,
'i_ssidlist' => 'cd11IfAuxSsid',
'i_ssidbcast' => 'cd11IfAuxSsidBroadcastSsid',
'i_80211channel' => 'cd11IfPhyDsssCurrentChannel',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
%SNMP::Info::Entity::MIBS,
%SNMP::Info::EtherLike::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CDP::MIBS,
'CISCO-DOT11-IF-MIB' => 'cd11IfAuxSsid',
);
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
);
sub vendor {
# Sorry, but it's true.
return 'cisco';
}
sub interfaces {
my $aironet = shift;
my $i_description = $aironet->i_description();
return $i_description;
}
# Tag on e_descr.1
sub description {
my $aironet = shift;
my $descr = $aironet->descr();
my $e_descr = $aironet->e_descr();
$descr = "$e_descr->{1} $descr" if defined $e_descr->{1};
return $descr;
}
# Fetch duplex from EtherLike
sub i_duplex {
my $aironet = shift;
my $el_duplex = $aironet->el_duplex();
my %i_duplex;
foreach my $d (keys %$el_duplex){
my $val = $el_duplex->{$d};
next unless defined $val;
$i_duplex{$d} = 'full' if $val =~ /full/i;
$i_duplex{$d} = 'half' if $val =~ /half/i;
}
return \%i_duplex;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Aironet - SNMP Interface to Cisco Aironet devices running IOS.
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $aironet = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $aironet->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides interface to SNMP Data available on newer Aironet devices running Cisco IOS.
Note there are two classes for Aironet devices :
=over
=item SNMP::Info::Layer3::Aironet
This class is for devices running Aironet software (older)
=item SNMP::Info::Layer2::Aironet
This class is for devices running Cisco IOS software (newer)
=back
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $aironet = new SNMP::Info::Layer2::Aironet(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::Entity
=item SNMP::Info::EtherLike
=item SNMP::Info::CiscoVTP
=back
=head2 Required MIBs
=over
=item Inherited Classes
MIBs required by the inherited classes listed above.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $aironet->discription()
Adds info from method e_descr() from SNMP::Info::Entity
=item $aironet->vendor()
Returns 'cisco' :)
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=head2 Globals imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
=head1 TABLE ENTRIES
=head2 Overrides
=over
=item $aironet->interfaces()
Uses the i_description() field.
=item $aironet->i_duplex()
Crosses information from SNMP::Info::EtherLike to get duplex info for interfaces.
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=head2 Table Methods imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
=cut

246
Info/Layer2/Allied.pm Normal file
View File

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

420
Info/Layer2/Aruba.pm Normal file
View File

@@ -0,0 +1,420 @@
# SNMP::Info::Layer2::Aruba
# Eric Miller
# $Id$
#
# 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:
#
# * 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::Aruba;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
@SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info SNMP::Info::Bridge 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,
'WLSX-SWITCH-MIB' => 'wlsxHostname',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'i_index2' => 'ifIndex',
'i_name2' => 'ifName',
# WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable
# Table index leafs do not return information
# therefore unable to use apESSID. We extract
# the information from the IID instead.
#'aruba_ap_essid' => 'apESSID',
'aruba_ap_name' => 'apLocation',
'aruba_ap_ip' => 'apIpAddress',
# WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable
# Table index leafs do not return information
# therefore unable to use staAccessPointBSSID
# or staPhyAddress. We extract the information from
# the IID instead.
#'fw_port' => 'staAccessPointBSSID',
#'fw_mac' => 'staPhyAddress',
'fw_user' => 'staUserName',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
);
sub layers {
return '00000011';
}
sub os {
return 'airos';
}
sub vendor {
return 'aruba';
}
sub os_ver {
my $aruba = shift;
my $descr = $aruba->description();
return undef unless defined $descr;
if ($descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub model {
my $aruba = shift;
my $id = $aruba->id();
return undef unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
return $model;
}
# Thin APs do not support ifMIB requirement
sub i_index {
my $aruba = shift;
my $i_index = $aruba->i_index2();
my $ap_index = $aruba->aruba_ap_name();
my %if_index;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
$if_index{$iid} = $index;
}
# Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){
# Convert the 0.254.123.456 index entry to a MAC address.
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$ap_id));
$if_index{$ap_id} = $mac;
}
return \%if_index;
}
sub interfaces {
my $aruba = shift;
my $i_index = $aruba->i_index();
my $i_descr = $aruba->i_description();
my %if;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if ($index =~ /^\d+$/ ) {
# Replace the Index with the ifDescr field.
my $port = $i_descr->{$iid};
next unless defined $port;
$if{$iid} = $port;
}
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) {
$if{$index} = $index;
}
else {
next;
}
}
return \%if;
}
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 %i_name;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if ($index =~ /^\d+$/ ) {
my $name = $i_name2->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) {
my $name = $ap_name->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
else {
next;
}
}
return \%i_name;
}
# 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 %bp_index;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
$bp_index{$iid} = $index;
}
# Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){
# Convert the 0.254.123.456 index entry to a MAC address.
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$ap_id));
$bp_index{$mac} = $mac;
}
return \%bp_index;
}
sub fw_port {
my $aruba = shift;
my $fw_idx = $aruba->fw_user();
my %fw_port;
foreach my $iid (keys %$fw_idx){
if ($iid =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/) {
my $port = join(':',map {sprintf("%02x",$_)} split(/\./,$2));
$fw_port{$iid} = $port;
}
else {
next;
}
}
return \%fw_port;
}
sub fw_mac {
my $aruba = shift;
my $fw_idx = $aruba->fw_user();
my %fw_mac;
foreach my $iid (keys %$fw_idx){
if ($iid =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/) {
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$1));
$fw_mac{$iid} = $mac;
}
else {
next;
}
}
return \%fw_mac;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Aruba - SNMP Interface to Aruba wireless switches
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
my $aruba = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $aruba->class();
print " Using device sub class : $class\n";
=head1 DESCRIPTION
SNMP::Info::Layer2::Aruba is a subclass of SNMP::Info that provides an interface
to Aruba wireless switches. The Aruba platform utilizes intelligent wireless
switches which control thin access points. The thin access points themselves
are unable to be polled for end station information.
This class emulates bridge functionality for the wireless switch. This enables
end station MAC addresses collection and correlation to the thin access point
the end station is using for communication.
For speed or debugging purposes you can call the subclass directly, but not after
determining a more specific class using the method above.
my $aruba = new SNMP::Info::Layer2::Aruba(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=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.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $aruba->model()
Returns model type. Cross references $aruba->id() with product IDs in the
Aruba MIB.
=item $aruba->vendor()
Returns 'aruba'
=item $aruba->os()
Returns 'airos'
=item $aruba->os_ver()
Returns the software version extracted from B<sysDescr>
=back
=head2 Overrides
=over
=item $aruba->layers()
Returns 00000011. Class emulates Layer 2 functionality for Thin APs through
proprietary MIBs.
=back
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $aruba->i_index()
Returns reference to map of IIDs to Interface index.
Extends ifIndex to support thin APs as device interfaces.
=item $aruba->interfaces()
Returns reference to map of IIDs to ports. Thin APs are implemented as device
interfaces. The thin AP MAC address is used as the port identifier.
=item $aruba->i_name()
Interface name. Returns (B<ifName>) for Ethernet interfaces and (B<apLocation>)
for thin AP interfaces.
=item $aruba->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $aruba->fw_port()
(B<staAccessPointBSSID>) as extracted from the IID.
=item $aruba->fw_mac()
(B<staPhyAddress>) as extracted from the IID.
=back
=head2 Aruba Switch AP Table (B<wlsxSwitchAccessPointTable>)
=over
=item $aruba->aruba_ap_name()
(B<apLocation>)
=item $aruba->aruba_ap_ip()
(B<apIpAddress>)
=back
=head2 Aruba Switch Station Management Table (B<wlsxSwitchStationMgmtTable>)
=over
=item $aruba->fw_user()
(B<staUserName>)
=cut

View File

@@ -1,5 +1,10 @@
# SNMP::Info::Layer2::Bay
# Max Baker
# This module depricated. See Layer2::BayStack
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -24,11 +29,10 @@
# 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.
# SNMP::Info::Layer2::Bay
# Max Baker <max@warped.org>
package SNMP::Info::Layer2::Bay;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
@@ -72,6 +76,44 @@ $SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
'i_mac2' => \&SNMP::Info::munge_mac ,
);
sub os {
return 'bay';
}
sub os_ver {
my $bay = shift;
my $descr = $bay->description();
return undef unless defined $descr;
# 303 / 304
if ($descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
# 450
if ($descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub os_bin {
my $bay = shift;
my $descr = $bay->description();
return undef unless defined $descr;
# 303 / 304
if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){
return $1;
}
# 450
if ($descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub vendor {
# or nortel, or synopsis?
return 'bay';
@@ -115,13 +157,16 @@ sub i_mac {
sub model {
my $bay = shift;
my $id = $bay->id();
return undef unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^sreg-//i;
my $descr = $bay->description();
return '303' if ($descr =~ /\D303\D/);
return '304' if ($descr =~ /\D304\D/);
return '450' if ($model =~ /BayStack450/);
return $model;
}
@@ -134,6 +179,7 @@ sub c_if {
my %c_if;
foreach my $entry (keys %$bay_topo_port){
my $port = $bay_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
$c_if{"$port.1"} = $port;
}
@@ -152,7 +198,8 @@ sub c_ip {
my %ip_port;
foreach my $entry (keys %$bay_topo_ip){
my $port = $bay_topo_port->{$entry};
next if $port == 0;
next unless defined $port;
next if ($port =~ /^[\d\.]+$/ and $port == 0);
my $ip = $bay_topo_ip->{$entry};
push(@{$ip_port{$port}},$ip);
}
@@ -178,6 +225,7 @@ sub c_port {
my %c_port;
foreach my $entry (keys %$bay_topo_seg){
my $port = $bay_topo_port->{$entry};
next unless defined $port;
next if $port == 0;
# For fake remotes (multiple IPs for a c_ip), use first found
@@ -202,7 +250,7 @@ sub c_platform {
my %c_platform;
foreach my $entry (keys %$bay_topo_platform){
my $port = $bay_topo_port->{$entry};
my $port = $bay_topo_port->{$entry} || 0;
next if $port == 0;
# For fake remotes (multiple IPs for a c_ip), use first found
@@ -216,79 +264,66 @@ sub c_platform {
return \%c_platform;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network Switches
SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network BayStack Switches
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
This module is Depricated. Please use Layer2::BayStack instead.
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bay device through SNMP.
Inherits from
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
SNMP::Info::Layer2
my $bay = new SNMP::Info::Layer2::Bay(...);
Required MIBs:
=head2 Inherited Classes
SYNOPTICS-ROOT-MIB
S5-ETH-MULTISEG-TOPOLOGY-MIB
MIBS listed in SNMP::Info::Layer2
=over
Bay MIBs can be found on the CD that came with your product.
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item SYNOPTICS-ROOT-MIB
=item S5-ETH-MULTISEG-TOPOLOGY-MIB
=item Inherited classes
MIBs required by SNMP::Info::Layer2 and its superclasses.
=back
Bay MIBs can be found on the CD that came with your product.
Or, if you still have a service contract they can be downloaded at
www.nortelnetworks.com
They have also been seen at : http://www.inotech.com/mibs/vendor/baynetworks/synoptics/synoptics.asp
Or http://www.oidview.com/mibs/detail.html under Synoptics.
You will need at least the two listed above, and probably a few more.
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $bay = new SNMP::Info::Layer2::Bay(DestHost => 'mybayswitch' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=over
=item new SNMP::Info::Layer2::Bay()
Arguments passed to new() are passed on to SNMP::Session::new()
my $bay = new SNMP::Info::Layer2::Bay(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $bay;
=item $bay->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $bay->session();
# Set
my $newsession = new SNMP::Session(...);
$bay->session($newsession);
=back
Or http://www.oidview.com/mibs/detail.html under Synoptics. Check also www.mibdepot.com
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $bay->vendor()
@@ -317,8 +352,15 @@ Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
@@ -425,4 +467,8 @@ Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg() i
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=cut

447
Info/Layer2/Baystack.pm Normal file
View File

@@ -0,0 +1,447 @@
# SNMP::Info::Layer2::Baystack
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 Max Baker changes from version 0.8 and beyond.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Baystack;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
use SNMP::Info::RapidCity;
use SNMP::Info::NortelStack;
@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::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::RapidCity::MIBS,
%SNMP::Info::NortelStack::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
%SNMP::Info::RapidCity::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::SONMP::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',
);
# 450's report full duplex as speed = 20mbps?!
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
$SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps';
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::SONMP::MUNGE,
%SNMP::Info::RapidCity::MUNGE,
%SNMP::Info::NortelStack::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub os {
my $baystack = shift;
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)) {
return 'boss';
}
return 'baystack';
}
sub os_bin {
my $baystack = shift;
my $descr = $baystack->description();
return undef unless defined $descr;
# 303 / 304
if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){
return $1;
}
# 450
if ($descr =~ m/FW:V(\d+\.\d+)/){
return $1;
}
if ($descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i){
return $1;
}
return undef;
}
sub vendor {
return 'nortel';
}
sub model {
my $baystack = shift;
my $id = $baystack->id();
return undef unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
my $descr = $baystack->description();
return '303' if (defined $descr and $descr =~ /\D303\D/);
return '304' if (defined $descr and $descr =~ /\D304\D/);
return 'BPS' if ($model =~ /BPS2000/i);
return $2 if ($model =~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)(\d+)/);
return $model;
}
sub 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 $index_factor = $baystack->index_factor();
my $slot_offset = $baystack->slot_offset();
my %if;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
# Ignore cascade ports
next if $index > 513;
my $port = ($index % $index_factor);
my $slot = (int($index / $index_factor)) + $slot_offset;
my $slotport = "$slot.$port";
$if{$iid} = $slotport;
}
return \%if;
}
sub i_mac {
my $baystack = shift;
my $i_mac = $baystack->i_mac2();
my %i_mac;
# Baystack 303's with a hw rev < 2.11.4.5 report the mac as all zeros
foreach my $iid (keys %$i_mac){
my $mac = $i_mac->{$iid};
next unless defined $mac;
next if $mac eq '00:00:00:00:00:00';
$i_mac{$iid}=$mac;
}
return \%i_mac;
}
sub i_name {
my $baystack = shift;
my $i_index = $baystack->i_index();
my $i_alias = $baystack->i_alias();
my $i_name2 = $baystack->i_name2();
my %i_name;
foreach my $iid (keys %$i_name2){
my $name = $i_name2->{$iid};
my $alias = $i_alias->{$iid};
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ?
$alias :
$name;
}
return \%i_name;
}
sub index_factor {
my $baystack = shift;
my $model = $baystack->model();
my $os = $baystack->os();
my $op_mode = $baystack->ns_op_mode();
$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'));
return $index_factor;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Baystack - SNMP Interface to Nortel Ethernet (Baystack) Switches
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $baystack = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $baystack->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a Nortel
Ethernet Switch (Baystack) through SNMP.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $baystack = new SNMP::Info::Layer2::Baystack(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::NortelStack
=item SNMP::Info::SONMP
=item SNMP::Info::RapidCity
=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
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $baystack->vendor()
Returns 'nortel'
=item $baystack->model()
Cross references $baystack->id() to the SYNOPTICS-MIB and returns
the results. 303s and 304s have the same ID, so we have a hack
to return depending on which it is.
Returns BPS for Business Policy Switch
For BayStack, EthernetRoutingSwitch, or EthernetSwitch extracts and returns
the switch numeric designation.
=item $baystack->os()
Returns 'baystack' or 'boss' depending on software version.
=item $baystack->os_bin()
Returns the firmware version extracted from B<sysDescr>.
=back
=head2 Overrides
=over
=item $baystack->index_factor()
Required by SNMP::Info::SONMP. Number representing the number of ports
reserved per slot within the device MIB.
Index factor on the Baystack switches are determined by the formula: Index
Factor = 64 if (model = 470 or (os eq 'boss' and operating in pure mode))
or else Index factor = 32.
Returns either 32 or 64 based upon the formula.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge 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.
=head2 Global Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $baystack->interfaces()
Returns reference to the map between IID and physical Port.
Slot and port numbers on the Baystack switches are determined by the formula:
port = (Interface index % Index factor)
slot = (int(Interface index / Index factor)) + Slot offset
The physical port name is returned as slot.port.
=item $baystack->i_ignore()
Returns reference to hash of IIDs to ignore.
=item $baystack->i_mac()
Returns the B<ifPhysAddress> table entries.
Removes all entries matching '00:00:00:00:00:00' -- Certain
revisions of Baystack firmware report all zeros for each port mac.
=item $baystack->i_name()
Crosses ifName with ifAlias and returns the human set port name if exists.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $baystack->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $baystack->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $baystack->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.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Table Methods imported from SNMP::Info::NortelStack
See documentation in SNMP::Info::NortelStack for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
=head2 Table Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer2::C1900
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,24 +30,37 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C1900;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoVTP
SNMP::Info::CDP SNMP::Info::CiscoStats 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::Layer2::GLOBALS,
%SNMP::Info::CiscoVTP::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',
@@ -59,16 +74,54 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
%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'
);
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
);
sub vendor {
return 'cisco';
}
sub os {
return 'catalyst';
}
sub os_ver {
my $c1900 = shift;
# Check for superclass one
my $os_ver = $c1900->SUPER::os_ver();
return $os_ver if defined $os_ver;
my $c1900_flash_status = $c1900->c1900_flash_status();
return undef unless defined $c1900_flash_status;
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();
foreach my $iid (keys %$i_descr){
$i_descr->{$iid} =~ s/\s*$//;
}
return $i_descr;
}
sub i_duplex {
my $c1900 = shift;
@@ -142,78 +195,123 @@ sub i_type {
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 $name = $c1900_p_name->{$port};
next unless defined $name;
next unless $name !~ /^\s*$/;
$i_name->{$port} = $name;
}
return $i_name;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::C1900 - SNMP Interface to old C1900 Network Switches
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
C1900 device through SNMP. See inherited classes' documentation for
inherited methods.
Inherits from:
SNMP::Info::Layer2
Required MIBs:
STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)
MIBs listed in SNMP::Info::Layer2
ESSWITCH-MIB is included in the Version 1 MIBS from Cisco.
They can be found at ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
SNMP::Info::Layer2::C1900 - Perl5 Interface to SNMP data from Cisco Catlyst 1900 Network Switches running CatOS
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $c1900 = new SNMP::Info::Layer2::C1900(DestHost => 'mycat1900' ,
Community => 'public' );
# Let SNMP::Info determine the correct subclass for you.
my $c1900 = 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";
=head1 CREATING AN OBJECT
my $class = $c1900->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
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.
my $c1900 = new SNMP::Info::Layer2::C1900(...);
=head2 Inherited classes
=over
=item new SNMP::Info::Layer2::C1900()
=item SNMP::Info::Layer2
Arguments passed to new() are passed on to SNMP::Session::new()
=back
my $c1900 = new SNMP::Info::Layer2::C1900(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $c1900;
=head2 Required MIBs
=item $c1900->session()
=over
Sets or returns the SNMP::Session object
=item STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)
# Get
my $sess = $c1900->session();
ESSWITCH-MIB is included in the Version 1 MIBS from Cisco.
# Set
my $newsession = new SNMP::Session(...);
$c1900->session($newsession);
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
=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.
Used by os_ver()
B<STAND-ALONE-ETHERNET-SWITCH-MIB::upgradeFlashBankStatus>
=item $c1900->os()
Returns 'catalyst'
=item $c1900->os_ver()
Returns CatOS version if obtainable. First tries to use
SNMP::Info::CiscoStats->os_ver() . If that fails then it
checks for the presence of $c1900->c1900_flash_status() and culls
the version from there.
=item $c1900->vendor()
Returns 'cisco' :)
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head1 TABLE ENTRIES
=head2 Overrides
@@ -232,6 +330,10 @@ 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.
=item $c1900->i_type()
Returns reference to hash of IID to port type
@@ -290,4 +392,8 @@ B<swPortConnectorType>
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer2::C2900
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,42 +30,63 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C2900;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoVTP
SNMP::Info::CDP SNMP::Info::CiscoStats 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::Layer2::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
'i_name' => 'ifAlias',
# C2900PortEntry
'c2900_p_index' => 'c2900PortIfIndex',
'c2900_p_duplex' => 'c2900PortDuplexStatus',
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
);
'c2900_p_index' => 'c2900PortIfIndex',
'c2900_p_duplex' => 'c2900PortDuplexStatus',
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'CISCO-C2900-MIB' => 'ciscoC2900MIB'
);
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
'CISCO-C2900-MIB' => 'ciscoC2900MIB',
);
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
);
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
);
sub vendor {
return 'cisco';
}
sub cisco_comm_indexing {
1;
}
sub i_duplex {
my $c2900 = shift;
@@ -113,6 +136,54 @@ 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 {
# 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};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
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 {
# 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};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_duplex_admin($duplexes{$duplex}, $iid);
}
# Use i_descritption for port key, cuz i_name can be manually entered.
sub interfaces {
my $c2900 = shift;
@@ -133,61 +204,75 @@ sub interfaces {
return \%if
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Network Switches
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Switches running IOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c2900 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c2900->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
C2900 device through SNMP.
MIBS: CISCO-C2900-MIB
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
Inherits all SNMP::Info::Layer2 methods.
my $c2900 = new SNMP::Info::Layer2::C2900(...);
=head1 AUTHOR
Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $c2900 = new SNMP::Info::Layer2::C2900(DestHost => 'mycat2900' ,
Community => 'public' );
=head1 CREATING AN OBJECT
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer2::C2900()
=item SNMP::Info::Layer2
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::CiscoVTP
my $c2900 = new SNMP::Info::Layer2::C2900(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $c2900;
=back
=item $c2900->session()
=head2 Required MIBs
Sets or returns the SNMP::Session object
=over
# Get
my $sess = $c2900->session();
=item CISCO-C2900-MIB
# Set
my $newsession = new SNMP::Session(...);
$c2900->session($newsession);
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
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $c2900->vendor()
@@ -196,8 +281,19 @@ Sets or returns the SNMP::Session object
=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.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
@@ -225,7 +321,34 @@ Sets or returns the SNMP::Session object
Returns reference to hash of IIDs to admin duplex setting
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin;
=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);
=back
@@ -260,5 +383,12 @@ Sets or returns the SNMP::Session object
=back
=cut
=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.
=cut

View File

@@ -1,7 +1,8 @@
# SNMP::Info::Layer2::Catalyst
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2002,2003 Regents of the University of California
# Copyright (c) 2003,2004 Max Baker changes from version 0.8 and beyond
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,114 +29,61 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Catalyst;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::CiscoVTP;
use SNMP::Info::CiscoStack;
use SNMP::Info::CDP;
use SNMP::Info::CiscoStats;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT
%MYGLOBALS %MYMIBS %MYFUNCS %MYMUNGE %MUNGE $INIT/ ;
@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::Layer2 Exporter/;
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::EXPORT_OK = qw//;
$DEBUG=0;
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
);
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MYMIBS = (
'CISCO-STACK-MIB' => 'moduleType',
'CISCO-VTP-MIB' => 'vtpVlanIndex'
);
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%MYMIBS );
%MYGLOBALS = (
# these are in CISCO-STACK-MIB
'sysip' => 'sysIpAddr',
'netmask' => 'sysNetMask',
'broadcast' => 'sysBroadcast',
'serial' => 'chassisSerialNumberString',
'model' => 'chassisModel',
'ps1_type' => 'chassisPs1Type',
'ps1_status' => 'chassisPs1Status',
'ps2_type' => 'chassisPs2Type',
'ps2_status' => 'chassisPs2Status',
'slots' => 'chassisNumSlots',
'fan' => 'chassisFanStatus'
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%MYGLOBALS
);
%MYFUNCS = (
'i_type2' => 'ifType',
# CISCO-STACK-MIB::moduleEntry
# These are blades in a catalyst device
'm_type' => 'moduleType',
'm_model' => 'moduleModel',
'm_serial' => 'moduleSerialNumber',
'm_status' => 'moduleStatus',
'm_name' => 'moduleName',
'm_ports' => 'moduleNumPorts',
'm_ports_status' => 'modulePortStatus',
'm_hwver' => 'moduleHwVersion',
'm_fwver' => 'moduleFwVersion',
'm_swver' => 'moduleSwVersion',
# Router Blades :
'm_ip' => 'moduleIPAddress',
'm_sub1' => 'moduleSubType',
'm_sub2' => 'moduleSubType2',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
# CISCO-VTP-MIB::VtpVlanEntry
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
);
%FUNCS = (
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%MYFUNCS
);
%MYMUNGE = (
'm_ports_status' => \&munge_port_status,
'p_duplex_admin' => \&SNMP::Info::munge_bits,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
);
%MUNGE = (
# Inherit all the built in munging
%MUNGE = (
%SNMP::Info::Layer2::MUNGE,
%MYMUNGE
);
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
);
%PORTSTAT = (1 => 'other',
2 => 'ok',
3 => 'minorFault',
4 => 'majorFault');
# Changes binary byte describing each port into ascii, and returns
# an ascii list separated by spaces.
sub munge_port_status {
my $status = shift;
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
return join(' ',@vals);
}
# 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
@@ -153,356 +101,185 @@ sub i_physical {
return \%i_physical;
}
sub i_type {
my $cat = shift;
my $p_port = $cat->p_port();
my $p_type = $cat->p_type();
# Get more generic port types from IF-MIB
my $i_type = $cat->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 $cat = shift;
my $p_port = $cat->p_port();
my $p_name = $cat->p_name();
my %i_name;
foreach my $port (keys %$p_name) {
my $iid = $p_port->{$port};
$i_name{$iid} = $p_name->{$port};
}
return \%i_name;
}
sub i_duplex {
my $cat = shift;
my $p_port = $cat->p_port();
my $p_duplex = $cat->p_duplex();
my %i_duplex;
foreach my $port (keys %$p_duplex) {
my $iid = $p_port->{$port};
$i_duplex{$iid} = $p_duplex->{$port};
}
return \%i_duplex;
}
sub i_duplex_admin {
my $cat = shift;
my $p_port = $cat->p_port();
my $p_duplex_admin = $cat->p_duplex_admin();
my %i_duplex_admin;
foreach my $port (keys %$p_duplex_admin) {
my $iid = $p_port->{$port};
next unless defined $iid;
my $duplex = $p_duplex_admin->{$port};
next unless defined $duplex;
my $string = 'other';
# see CISCO-STACK-MIB for a description of the bits
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
# we'll call it auto if both full and half are turned on, or if the
# specifically 'auto' flag bit is set.
$string = 'auto'
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
$i_duplex_admin{$iid} = $string;
}
return \%i_duplex_admin;
}
# $cat->interfaces() - Maps the ifIndex table to a physical port
sub interfaces {
my $self = shift;
my $interfaces = $self->i_index();
my $portnames = $self->p_port();
my %portmap = reverse %$portnames;
my %interfaces = ();
foreach my $iid (keys %$interfaces) {
my $if = $interfaces->{$iid};
$interfaces{$if} = $portmap{$iid};
}
return \%interfaces;
}
sub vendor {
return 'cisco';
}
sub os {
return 'catalyst';
}
sub os_ver {
my $cat = shift;
my $os_ver = $cat->SUPER::os_ver();
return $os_ver if defined $os_ver;
my $m_swver = $cat->m_swver();
return undef unless defined $m_swver;
# assume .1 entry is the chassis and the sw version we want.
return $m_swver->{1} if defined $m_swver->{1};
return undef;
}
# Workaround for incomplete bp_index
sub bp_index {
my $cat = shift;
my $p_index = $cat->p_port();
my $b_index = $cat->p_oidx();
my %bp_index;
foreach my $iid (keys %$p_index){
my $ifidx = $p_index->{$iid};
next unless defined $ifidx;
my $bpidx = $b_index->{$iid}||0;
$bp_index{$bpidx} = $ifidx;
}
return \%bp_index;
}
sub cisco_comm_indexing {
1;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco devices running Catalyst OS
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Catalyst device through SNMP. Information is stored in a number of
MIB's such as IF-MIB, CISCO-CDP-MIB, CISCO-STACK-MIB, CISCO-VTP-MIB,
and SWITCH-MIB.
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco Catalyst devices running Catalyst OS.
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $cat = new SNMP::Info::Layer2::Catalyst(DestHost => 'router' ,
Community => 'public' );
# Let SNMP::Info determine the correct subclass for you.
my $cat = 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";
=head1 CREATING AN OBJECT
my $class = $cat->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
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.
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.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $cat = new SNMP::Info::Layer2::Catalyst(...);
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer2::Catalyst()
=item SNMP::Info::Layer2
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::CiscoVTP
my $cat = new SNMP::Info::Layer2::Catalyst(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $cat;
=item $cat->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $cat->session();
# Set
my $newsession = new SNMP::Session(...);
$cat->session($newsession);
=item SNMP::Info::CiscoStack
=back
=head1 GLOBAL Values
=head2 Required MIBs
=over
=item $cat->netmask()
(B<sysNetMask>)
=item Inherited Classes' MIBs
=item $cat->broadcast()
(B<sysBroadcast>)
See SNMP::Info::Layer2 for its own MIB requirements.
=item $cat->serial()
(B<chassisSerialNumberString>)
See SNMP::Info::CiscoVTP for its own MIB requirements.
=item $cat->model()
(B<chassisModel>)
See SNMP::Info::CiscoStack for its own MIB requirements.
=item $cat->ps1_type()
(B<chassisPs1Type>)
=back
=item $cat->ps2_type()
(B<chassisPs2Type>)
These MIBs are found in the standard v2 MIBs from Cisco.
=item $cat->ps1_status()
(B<chassisPs1Status>)
=head1 GLOBALS
=item $cat->ps2_status()
(B<chassisPs2Status>)
These are methods that return scalar value from SNMP
=item $cat->slots()
(B<chassisNumSlots>)
=over
=item $cat->fan()
(B<chassisFanStatus>)
=item $cat->os()
Returns 'catalyst'
=item $cat->os_ver()
Tries to use the value from SNMP::Info::CiscoStats->os_ver() and if it fails
it grabs $cat->m_swver()->{1} and uses that.
=item $cat->vendor()
Returns 'cisco'
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.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $cat->interfaces()
=item $cat->bp_index()
Crosses p_port() with i_index() to get physical names.
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
=item $cat->i_physical()
Returns a map to IID for ports that are physical ports, not vlans, etc.
=item $cat->i_type()
Crosses p_port() with p_type() and returns the results.
Overrides with ifType if p_type() isn't available.
=item $cat->i_name()
Crosses p_name with p_port and returns results.
=item $cat->i_duplex()
Crosses p_duplex with p_port and returns results.
=item $cat->i_duplex_admin()
Crosses p_duplex_admin with p_port.
Munges bit_string returned from p_duplex_admin to get duplex settings.
Crosses (B<portCrossIndex>) to (B<portIfIndex>) since some devices seem to have
problems with BRIDGE-MIB
=back
=head2 Module table
=head2 Table Methods imported from SNMP::Info::CiscoVTP
This table holds configuration information for each of the blades installed in
the Catalyst device.
See documentation in SNMP::Info::CiscoVTP for details.
=over
=head2 Table Methods imported from SNMP::Info::Layer2
=item $cat->m_type()
(B<moduleType>)
See documentation in SNMP::Info::Layer2 for details.
=item $cat->m_model()
(B<moduleModel>)
=head2 Table Methods imported from SNMP::Info::Layer2::CiscoStack
=item $cat->m_serial()
(B<moduleSerialNumber>)
=item $cat->m_status()
(B<moduleStatus>)
=item $cat->m_name()
(B<moduleName>)
=item $cat->m_ports()
(B<moduleNumPorts>)
=item $cat->m_ports_status()
Returns a list of space separated status strings for the ports.
To see the status of port 4 :
@ports_status = split(' ', $cat->m_ports_status() );
$port4 = $ports_status[3];
(B<modulePortStatus>)
=item $cat->m_ports_hwver()
(B<moduleHwVersion>)
=item $cat->m_ports_fwver()
(B<moduleFwVersion>)
=item $cat->m_ports_swver()
(B<moduleSwVersion>)
=item $cat->m_ports_ip()
(B<moduleIPAddress>)
=item $cat->m_ports_sub1()
(B<moduleSubType>)
=item $cat->m_ports_sub2()
(B<moduleSubType2>)
=back
=head2 Modules - Router Blades
=over
=item $cat->m_ip()
(B<moduleIPAddress>)
=item $cat->m_sub1()
(B<moduleSubType>)
=item $cat->m_sub2()
(B<moduleSubType2>)
=back
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
=over
=item $cat->p_name()
(B<portName>)
=item $cat->p_type()
(B<portType>)
=item $cat->p_status()
(B<portOperStatus>)
=item $cat->p_status2()
(B<portAdditionalStatus>)
=item $cat->p_speed()
(B<portAdminSpeed>)
=item $cat->p_duplex()
(B<portDuplex>)
=item $cat->p_port()
(B<portIfIndex>)
=back
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
=over
=item $cat->p_speed_admin()
(B<portCpbSpeed>)
=item $cat->p_duplex_admin()
(B<portCpbDuplex>)
=back
=head2 VLAN Entry Table
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
for a good treaty of how to connect to the VLANs
=over
=item $cat->v_state()
(B<vtpVlanState>)
=item $cat->v_type()
(B<vtpVlanType>)
=item $cat->v_name()
(B<vtpVlanName>)
=item $cat->v_mtu()
(B<vtpVlanMtu>)
=back
See documentation in SNMP::Info::Layer2::CiscoStack for details.
=cut

521
Info/Layer2/Centillion.pm Normal file
View File

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

299
Info/Layer2/Foundry.pm Normal file
View File

@@ -0,0 +1,299 @@
# SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry Switches
#
# Copyright (c) 2005 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::Foundry;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::FDP;
use SNMP::Info::EtherLike;
use SNMP::Info::MAU;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer2::Foundry::ISA = qw/SNMP::Info::Layer2 SNMP::Info::FDP SNMP::Info::EtherLike
SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer2::Foundry::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::FDP::MIBS,
%SNMP::Info::EtherLike::MIBS,
%SNMP::Info::MAU::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::FDP::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::FDP::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::MAU::FUNCS,
'test' => 'dot1dStpPortState',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::FDP::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::MAU::MUNGE,
);
# Method OverRides
#sub bulkwalk_no { 1;}
*SNMP::Info::Layer2::Foundry::i_duplex = \&SNMP::Info::MAU::mau_i_duplex;
*SNMP::Info::Layer2::Foundry::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer2::Foundry::i_vlan = \&SNMP::Info::Bridge::qb_i_vlan_t;
# todo doc these
sub os_ver {
my $foundry = shift;
my $e_name = $foundry->e_name();
# find entity table entry for "stackmanaget.1"
my $unit_iid = undef;
foreach my $e (keys %$e_name){
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'stackmanaget.1';
}
# Default to OID method if no dice.
unless (defined $unit_iid){
return $foundry->SUPER::model();
}
# Find Model Name
my $e_fwver = $foundry->e_fwver();
if (defined $e_fwver->{$unit_iid}){
return $e_fwver->{$unit_iid};
}
# Not found in ENTITY-MIB, go up a level.
return $foundry->SUPER::os_ver();
}
sub model {
my $foundry = shift;
my $e_name = $foundry->e_name();
# find entity table entry for "unit.1"
my $unit_iid = undef;
foreach my $e (keys %$e_name){
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1';
}
# Default to OID method if no dice.
unless (defined $unit_iid){
return $foundry->SUPER::model();
}
# Find Model Name
my $e_model = $foundry->e_model();
if (defined $e_model->{$unit_iid}){
return $e_model->{$unit_iid};
}
# Not found in ENTITY-MIB, go up a level.
return $foundry->SUPER::model();
}
sub serial {
my $foundry = shift;
my $e_name = $foundry->e_name();
# find entity table entry for "unit.1"
my $unit_iid = undef;
foreach my $e (keys %$e_name){
my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1';
}
return undef unless defined $unit_iid;
# Look up serial of found entry.
my $e_serial = $foundry->e_serial();
return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid};
return $foundry->SUPER::serial();
}
sub interfaces {
my $foundry = shift;
my $i_descr = $foundry->i_description;
my $i_name = $foundry->i_name;
# use ifName only if it is in portn
# format. For EdgeIrons
# else use ifDescr
foreach my $iid (keys %$i_name){
my $name = $i_name->{$iid};
next unless defined $name;
$i_descr->{$iid} = $name
if $name =~ /^port\d+/i;
}
return $i_descr;
}
sub i_ignore {
my $foundry = shift;
my $i_type = $foundry->i_type();
my %i_ignore = ();
foreach my $iid (keys %$i_type){
my $type = $i_type->{$iid} || '';
$i_ignore{$iid}++
# 33 is the console port
if $type =~ /(loopback|propvirtual|other|cpu|33)/i;
}
return \%i_ignore;
}
sub os {
return 'foundry';
}
sub vendor {
return 'foundry';
}
# this hangs on a edgeiron24g
# TODO: check by devicetype and deferr to SUPER if not bad device
sub stp_p_state { undef; }
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Foundry - Perl5 Interface to Foundry FastIron Network Devices
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $foundry = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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";
=head1 DESCRIPTION
This module provides support for Foundry EdgeIron Switches
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=item SNMP::Info::FDP
=back
=head2 Required MIBs
=over
=item FOUNDRY-SN-ROOT-MIB
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item todo
=back
=head2 Globals imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Globals imported from SNMP::Info::FDP
See documentation in SNMP::Info::FDP for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item todo2
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See documentation in SNMP::Info::Layer2 for details.
=head2 Table Methods imported from SNMP::Info::FDP
See documentation in SNMP::Info::FDP for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer2::HP - SNMP Interface to HP ProCurve Switches
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# 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.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,80 +30,160 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::HP;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer2;
use SNMP::Info::MAU;
use SNMP::Info::Entity;
use SNMP::Info::CDP;
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT
%MYGLOBALS %MYMIBS %MYFUNCS %MYMUNGE %MUNGE $INIT/ ;
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer2 SNMP::Info::MAU Exporter/;
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::CDP Exporter/;
@SNMP::Info::Layer2::HP::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MYMIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum',
'RFC1271-MIB' => 'logDescription',
'HP-ICF-OID' => 'hpSwitch4000',
);
%MIBS = ( %SNMP::Info::Layer2::MIBS,
%SNMP::Info::MAU::MIBS,
%MYMIBS );
%SNMP::Info::Entity::MIBS,
%SNMP::Info::CDP::MIBS,
'RFC1271-MIB' => 'logDescription',
'HP-ICF-OID' => 'hpSwitch4000',
'HP-VLAN' => 'hpVlanMemberIndex',
'STATISTICS-MIB' => 'hpSwitchCpuStat',
'NETSWITCH-MIB' => 'hpMsgBufFree',
);
%MYGLOBALS = ('serial1' => 'entPhysicalSerialNum.1',
# 'model' => 'entPhysicalModelName.1',
);
%GLOBALS = (
%SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
%MYGLOBALS
);
%MYFUNCS = (
'i_type2' => 'ifType',
'e_map' => 'entAliasMappingIdentifier',
'e_name' => 'entPhysicalName',
'e_class' => 'entPhysicalClass',
'e_parent' => 'entPhysicalContainedIn',
'e_descr' => 'entPhysicalDescr',
'e_type' => 'entPhysicalVendorType',
'e_model' => 'entPhysicalModelName',
'e_hwver' => 'entPhysicalHardwareRev',
'e_swver' => 'entPhysicalSoftwareRev',
'e_fwver' => 'entPhysicalFirmwareRev',
'e_serial' => 'entPhysicalSerialNum',
# RFC1271
'l_descr' => 'logDescription'
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
'serial1' => 'entPhysicalSerialNum.1',
'hp_cpu' => 'hpSwitchCpuStat.0',
'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
'mem_free' => 'hpGlobalMemFreeBytes.1',
'mem_used' => 'hpGlobalMemAllocBytes.1',
'os_version' => 'hpSwitchOsVersion.0',
'os_bin' => 'hpSwitchRomVersion.0',
'mac' => 'hpSwitchBaseMACAddress.0',
'hp_vlans' => 'hpVlanNumber',
);
%FUNCS = (
%SNMP::Info::Layer2::FUNCS,
%SNMP::Info::MAU::FUNCS,
%MYFUNCS
);
%MYMUNGE = (
%SNMP::Info::Entity::FUNCS,
%SNMP::Info::CDP::FUNCS,
'bp_index2' => 'dot1dBasePortIfIndex',
'i_type2' => 'ifType',
# RFC1271
'l_descr' => 'logDescription',
# HP-VLAN-MIB
'hp_v_index' => 'hpVlanDot1QID',
'hp_v_name' => 'hpVlanIdentName',
'hp_v_state' => 'hpVlanIdentState',
'hp_v_type' => 'hpVlanIdentType',
'hp_v_status' => 'hpVlanIdentStatus',
'hp_v_mac' => 'hpVlanAddrPhysAddress',
'hp_v_if_index'=> 'hpVlanMemberIndex',
'hp_v_if_tag' => 'hpVlanMemberTagged2',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer2::MUNGE,
%SNMP::Info::MAU::MUNGE,
%MYMUNGE
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::CDP::MUNGE
);
%MODEL_MAP = (
'J4093A' => '2424M',
'J4110A' => '8000M',
'J4120A' => '1600M',
'J4121A' => '4000M',
'J4122A' => '2400M',
'J4138A' => '9308M',
'J4139A' => '9304M',
'J4812A' => '2512',
'J4813A' => '2524',
'J4815A' => '3324XL',
'J4819A' => '5308XL',
'J4840A' => '6308M-SX',
'J4841A' => '6208M-SX',
'J4850A' => '5304XL',
'J4851A' => '3124',
'J4865A' => '4108GL',
'J4874A' => '9315M',
'J4887A' => '4104GL',
'J4899A' => '2650',
'J4899B' => '2650-CR',
'J4900A' => '2626',
'J4900B' => '2626-CR',
'J4902A' => '6108',
'J4903A' => '2824',
'J4904A' => '2848',
'J4905A' => '3400cl-24G',
'J4906A' => '3400cl-48G',
'J8130A' => 'WAP-420-NA',
'J8131A' => 'WAP-420-WW',
'J8133A' => 'AP520WL',
'J8164A' => '2626-PWR',
'J8165A' => '2650-PWR',
'J8433A' => 'CX4-6400cl-6XG',
'J8474A' => 'MF-6400cl-6XG',
'J8718A' => '5404yl',
'J8719A' => '5408yl',
);
# 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();
}
sub mem_total {
my $hp = shift;
return $hp->hp_mem_total();
}
sub os {
return 'hp';
}
sub os_ver {
my $hp = shift;
my $os_version = $hp->os_version();
return $os_version if defined $os_version;
# Some older ones don't have this value,so we cull it from the description
my $descr = $hp->description();
if ($descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/) {
return $1;
}
return undef;
}
# Lookup model number, and translate the part number to the common number
sub model {
my $hp = shift;
my $id = $hp->id();
return undef unless defined $id;
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^hpswitch//i;
return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model;
}
# Some have the serial num in entity mib, some dont.
sub serial {
my $hp = shift;
@@ -109,6 +191,7 @@ sub serial {
# procurve 2xxx have this
my $serial = $hp->serial1();
return undef unless defined $serial;
# 4xxx dont
return undef if $serial =~ /nosuchobject/i;
@@ -124,7 +207,6 @@ sub interfaces {
foreach my $iid (keys %$interfaces){
my $descr = $i_descr->{$iid};
next unless defined $descr;
#$if{$iid} = $iid;
$if{$iid} = $descr if (defined $descr and length $descr);
}
@@ -132,26 +214,6 @@ sub interfaces {
}
# e_port maps EntityTable entries to IfTable
sub e_port {
my $hp = shift;
my $e_map = $hp->e_map();
my %e_port;
foreach my $e_id (keys %$e_map) {
my $id = $e_id;
$id =~ s/\.0$//;
my $iid = $e_map->{$e_id};
$iid =~ s/.*\.//;
$e_port{$id} = $iid;
}
return \%e_port;
}
sub i_type {
my $hp = shift;
my $e_descr = $hp->e_descr();
@@ -238,102 +300,57 @@ sub slots {
#
#}
sub i_duplex {
sub i_vlan {
my $hp = shift;
my $mau_index = $hp->mau_index();
my $mau_link = $hp->mau_link();
my %i_duplex;
foreach my $mau_port (keys %$mau_link){
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $linkoid = $mau_link->{$mau_port};
my $link = &SNMP::translateObj($linkoid);
next unless defined $link;
my $duplex = undef;
if ($link =~ /fd$/i) {
$duplex = 'full';
} elsif ($link =~ /hd$/i){
$duplex = 'half';
}
$i_duplex{$iid} = $duplex if defined $duplex;
# 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 $qb_i_vlan;
}
return \%i_duplex;
# HP4000 ... get it from HP-VLAN
# the hpvlanmembertagged2 table has an entry in the form of
# vlan.interface = /untagged/no/tagged/auto
my $i_vlan = {};
my $hp_v_index = $hp->hp_v_index();
my $hp_v_if_tag = $hp->hp_v_if_tag();
foreach my $row (keys %$hp_v_if_tag){
my ($index,$if) = split(/\./,$row);
my $tag = $hp_v_if_tag->{$row};
my $vlan = $hp_v_index->{$index};
next unless defined $tag;
$vlan = 'Trunk' if $tag eq 'tagged';
$vlan = 'Auto' if $tag eq 'auto';
undef $vlan if $tag eq 'no';
$i_vlan->{$if} = $vlan if defined $vlan;
}
return $i_vlan;
}
sub i_duplex_admin {
# Bridge MIB does not map Bridge Port to ifIndex correctly on all models
sub bp_index {
my $hp = shift;
my $interfaces = $hp->interfaces();
my $mau_index = $hp->mau_index();
my $mau_auto = $hp->mau_auto();
my $mau_autostat = $hp->mau_autostat();
my $mau_typeadmin = $hp->mau_type_admin();
my $mau_autosent = $hp->mau_autosent();
my %mau_reverse = reverse %$mau_index;
my %i_duplex_admin;
foreach my $iid (keys %$interfaces){
my $mau_index = $mau_reverse{$iid};
next unless defined $mau_index;
my $autostat = $mau_autostat->{$mau_index};
# HP25xx has this value
if (defined $autostat and $autostat =~ /enabled/i){
$i_duplex_admin{$iid} = 'auto';
next;
}
my $type = $mau_autosent->{$mau_index};
my $if_index = $hp->i_index();
my $model = $hp->model();
my $bp_index = $hp->bp_index2();
next unless defined $type;
unless (defined $model and $model =~ /(1600|2424|4000|8000)/) {
return $bp_index;
}
if ($type == 0) {
$i_duplex_admin{$iid} = 'none';
next;
}
my $full = $hp->_isfullduplex($type);
my $half = $hp->_ishalfduplex($type);
if ($full and !$half){
$i_duplex_admin{$iid} = 'full';
} elsif ($half) {
$i_duplex_admin{$iid} = 'half';
}
}
return \%i_duplex_admin;
my %mod_bp_index;
foreach my $iid (keys %$if_index){
$mod_bp_index{$iid} = $iid;
}
return \%mod_bp_index;
}
#sub i_up_admin {
# my $hp = shift;
#
# my $mau_index = $hp->mau_index();
# my $mau_status = $hp->mau_status();
#
# my %i_up_admin;
# foreach my $mau_port (keys %$mau_status){
# my $iid = $mau_index->{$mau_port};
# next unless defined $iid;
# my $status = $mau_status->{$mau_port};
#
# $i_up_admin{$iid} = ($status =~ /shutdown/i) ?
# 'down' : 'up';
# }
#
# return \%i_up_admin;
#
#}
1;
__END__
@@ -341,207 +358,250 @@ __END__
SNMP::Info::Layer2::HP - SNMP Interface to HP Procurve Switches
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
HP device through SNMP. Information is stored in a number of
MIB's such as IF-MIB, ENTITY-MIB, RFC1271-MIB, HP-ICF-OID, MAU-MIB
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $hp = new SNMP::Info::Layer2::HP(DestHost => 'router' ,
Community => 'public' );
# Let SNMP::Info determine the correct subclass for you.
my $hp = 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";
=head1 CREATING AN OBJECT
my $class = $hp->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
HP ProCurve Switch via SNMP.
Note: Some HP Switches will connect via SNMP version 1, but a lot of config data will
not be available. Make sure you try and connect with Version 2 first, and then fail back
to version 1.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $hp = new SNMP::Info::Layer2::HP(...);
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer2::HP()
=item SNMP::Info::Layer2
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::Entity
my $hp = new SNMP::Info::Layer2::HP(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $hp;
=item $hp->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $hp->session();
# Set
my $newsession = new SNMP::Session(...);
$hp->session($newsession);
=item $hp->all(), $hp->load_all()
Runs each of the HP List methods and returns a hash reference.
$hp->all() will call $hp->load_all() once and then return cahced valued.
Use $hp->load_all() to reload from the device.
=item SNMP::Info::MAU
=back
=head1 HP Global Configuration Values
=head2 Required MIBs
=over
=item $hp->name()
(B<sysName>)
=item RFC1271-MIB
=item $hp->ip()
(B<sysIpAddr>)
Included in V2 mibs from Cisco
=item $hp->netmask()
(B<sysNetMask>)
=item HP-ICF-OID
=item $hp->broadcast()
(B<sysBroadcast>)
=item HP-VLAN
=item $hp->location()
(B<sysLocation>)
(this MIB new with SNMP::Info 0.8)
=item $hp->contact()
(B<sysContact>)
=item STATISTICS-MIB
=item $hp->description()
(B<sysDescr>)
=item NETSWITCH-MIB
=item $hp->layers()
(B<sysServices>)
=back
=item $hp->serial()
(B<chassisSerialNumberString>)
The last three 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
Version 0.4 - Removed ENTITY-MIB e_*() methods to separate sub-class - SNMP::Info::Entity
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $hp->cpu()
Returns CPU Utilization in percentage.
=item $hp->log()
Returns all the log entries from the switch's log that are not Link up or down messages.
=item $hp->mem_free()
Returns bytes of free memory
=item $hp->mem_total()
Return bytes of total memory
=item $hp->mem_used()
Returns bytes of used memory
=item $hp->model()
(B<chassisModel>)
=item $hp->ps1_type()
(B<chassisPs1Type>)
Returns the model number of the HP Switch. Will translate between the HP Part number and
the common model number with this map :
=item $hp->ps2_type()
(B<chassisPs2Type>)
%MODEL_MAP = (
'J4093A' => '2424M',
'J4110A' => '8000M',
'J4120A' => '1600M',
'J4121A' => '4000M',
'J4122A' => '2400M',
'J4138A' => '9308M',
'J4139A' => '9304M',
'J4812A' => '2512',
'J4813A' => '2524',
'J4815A' => '3324XL',
'J4819A' => '5308XL',
'J4840A' => '6308M-SX',
'J4841A' => '6208M-SX',
'J4850A' => '5304XL',
'J4851A' => '3124',
'J4865A' => '4108GL',
'J4874A' => '9315M',
'J4887A' => '4104GL',
'J4899A' => '2650',
'J4899B' => '2650-CR',
'J4900A' => '2626',
'J4900B' => '2626-CR',
'J4902A' => '6108',
'J4903A' => '2824',
'J4904A' => '2848',
'J4905A' => '3400cl-24G',
'J4906A' => '3400cl-48G',
'J8130A' => 'WAP-420-NA',
'J8131A' => 'WAP-420-WW',
'J8133A' => 'AP520WL',
'J8164A' => '2626-PWR',
'J8165A' => '2650-PWR',
'J8433A' => 'CX4-6400cl-6XG',
'J8474A' => 'MF-6400cl-6XG',
'J8718A' => '5404yl',
'J8719A' => '5408yl',
=item $hp->ps1_status()
(B<chassisPs1Status>)
);
=item $hp->ps2_status()
(B<chassisPs2Status>)
=item $hp->os()
Returns hp
=item $hp->os_bin()
B<hpSwitchRomVersion.0>
=item $hp->os_ver()
Tries to use os_version() and if that fails will try and cull the version from
the description field.
=item $hp->os_version()
B<hpSwitchOsVersion.0>
=item $hp->serial()
Returns serial number if available through SNMP
=item $hp->slots()
(B<chassisNumSlots>)
=item $hp->fan()
(B<chassisFanStatus>)
Returns number of entries in $hp->e_name that have 'slot' in them.
=item $hp->vendor()
hp
=back
=head1 CATALYST TABLE ENTRIES
=head2 Globals imported from SNMP::Info::Layer2
=head2 Module table
See documentation in SNMP::Info::Layer2 for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $hp->m_type(), $hp->load_m_type()
(B<moduleType>)
=item $hp->interfaces()
=item $hp->m_model(), $hp->load_m_model()
(B<moduleModel>)
Uses $hp->i_description()
=item $hp->m_serial(), $hp->load_m_serial()
(B<moduleSerialNumber>)
=item $hp->i_duplex()
=item $hp->m_status(), $hp->load_m_status()
(B<moduleStatus>)
Maps $hp->mau_index() with $hp->mau_link(). Methods inherited from
SNMP::Info::MAU.
=item $hp->m_name(), $hp->load_m_name()
(B<moduleName>)
=item $hp->i_duplex_admin()
=item $hp->m_ports(), $hp->load_m_ports()
(B<moduleNumPorts>)
Maps $hp->mau_index() with $hp->mau_auto(), $hp->mau_autostat(),
$hp->typeadmin(), and $mau_autosent(). Methods inherited from
SNMP::Info::MAU.
=item $hp->m_ports_status(), $hp->load_m_ports_status()
Returns a list of space separated status strings for the ports.
To see the status of port 4 :
@ports_status = split(' ', $hp->m_ports_status() );
$port4 = $ports_status[3];
=item $hp->i_name()
(B<modulePortStatus>)
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
=item $hp->m_ports_hwver(), $hp->load_m_ports_hwver()
(B<moduleHwVersion>)
=item $hp->i_type()
=item $hp->m_ports_fwver(), $hp->load_m_ports_fwver()
(B<moduleFwVersion>)
Crosses i_type() with $hp->e_descr() using $hp->e_port()
=item $hp->m_ports_swver(), $hp->load_m_ports_swver()
(B<moduleSwVersion>)
=item $hp->i_vlan()
=item $hp->m_ports_ip(), $hp->load_m_ports_ip()
(B<moduleIPAddress>)
Looks in Q-BRIDGE-MIB -- see SNMP::Info::Bridge
=item $hp->m_ports_sub1(), $hp->load_m_ports_sub1()
(B<moduleSubType>)
and for older devices looks in HP-VLAN.
=item $hp->m_ports_sub2(), $hp->load_m_ports_sub2()
(B<moduleSubType2>)
=item $hp->bp_index()
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
Returns (B<ifIndex>) for both key and value for 1600, 2424, 4000, and 8000 models
since they seem to have problems with BRIDGE-MIB
=back
=head2 Port Entry Table
=head2 Table Methods imported from SNMP::Info::Layer2
=over
See documentation in SNMP::Info::Layer2 for details.
=item $hp->p_name(), $hp->load_p_name()
(B<portName>)
=head2 Table Methods imported from SNMP::Info::Entity
=item $hp->p_type(), $hp->load_p_type()
(B<portType>)
See documentation in SNMP::Info::Entity for details.
=item $hp->p_status(), $hp->load_p_status()
(B<portOperStatus>)
=head2 Table Methods imported from SNMP::Info::MAU
=item $hp->p_status2(), $hp->load_p_status2()
(B<portAdditionalStatus>)
See documentation in SNMP::Info::MAU for details.
=item $hp->p_speed(), $hp->load_p_speed()
(B<portAdminSpeed>)
=item $hp->p_duplex(), $hp->load_p_duplex()
(B<portDuplex>)
=item $hp->p_port(), $hp->load_p_port()
(B<portIfIndex>)
=back
=head2 VLAN Entry Table
ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
=over
=item $hp->v_state(), $hp->load_v_state()
(B<vtpVlanState>)
=item $hp->v_type(), $hp->load_v_type()
(B<vtpVlanType>)
=item $hp->v_name(), $hp->load_v_name()
(B<vtpVlanName>)
=item $hp->v_mtu(), $hp->load_v_mtu()
(B<vtpVlanMtu>)
=back
=cut

253
Info/Layer2/N2270.pm Normal file
View File

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

500
Info/Layer2/NAP222x.pm Normal file
View File

@@ -0,0 +1,500 @@
# SNMP::Info::Layer2::NAP222x
# Eric Miller
# $Id$
#
# 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:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::NAP222x;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
@SNMP::Info::Layer2::NAP222x::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP Exporter/;
@SNMP::Info::Layer2::NAP222x::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,
'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
'nt_hw_ver' => 'ntWlanSwHardwareVer',
'nt_fw_ver' => 'ntWlanSwBootRomVer',
'nt_sw_ver' => 'ntWlanSwOpCodeVer',
'nt_cc' => 'ntWlanSwCountryCode',
'tftp_action' => 'ntWlanTransferStart',
'tftp_host' => 'ntWlanFileServer',
'tftp_file' => 'ntWlanDestFile',
'tftp_type' => 'ntWlanFileType',
'tftp_result' => 'ntWlanFileTransferStatus',
'tftp_xtype' => 'ntWlanTransferType',
'tftp_src_file' => 'ntWlanSrcFile',
'ftp_user' => 'ntWlanUserName',
'ftp_pass' => 'ntWlanPassword',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::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',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
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();
return undef unless defined $bin;
if ($bin =~ m/(\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub vendor {
return 'nortel';
}
sub model {
my $nap222x = shift;
my $descr = $nap222x->description();
return undef unless defined $descr;
return 'AP-2220' if ($descr =~ /2220/);
return 'AP-2221' if ($descr =~ /2221/);
return 'AP-2225' if ($descr =~ /2225/);
return undef;
}
sub mac {
my $nap222x = shift;
my $i_mac = $nap222x->i_mac();
# Return Interface MAC
foreach my $entry (keys %$i_mac){
my $sn = $i_mac->{$entry};
next unless $sn;
return $sn;
}
return undef;
}
sub serial {
my $nap222x = shift;
my $i_mac = $nap222x->i_mac();
# Return Interface MAC
foreach my $entry (keys %$i_mac){
my $sn = $i_mac->{$entry};
next unless $sn;
return $sn;
}
return 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 %interfaces = ();
foreach my $iid (keys %$interfaces){
my $desc = $description->{$iid};
next unless defined $desc;
next if $desc =~ /lo/i;
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_duplex {
my $nap222x = shift;
my $mode = $nap222x->nt_dpx();
my $port_name = $nap222x->nt_prt_name();
my $interfaces = $nap222x->interfaces();
my %i_duplex;
foreach my $if (keys %$interfaces){
my $port = $interfaces->{$if};
next unless $port =~ /dp/i;
foreach my $idx (keys %$mode) {
my $name = $port_name->{$idx}||'unknown';
next unless $name eq $port;
my $duplex = $mode->{$idx};
$duplex = 'other' unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if}=$duplex;
}
}
return \%i_duplex;
}
sub i_duplex_admin {
my $nap222x = shift;
my $dpx_admin = $nap222x->nt_dpx_admin();
my $nt_auto = $nap222x->nt_auto();
my $interfaces = $nap222x->interfaces();
my $port_name = $nap222x->nt_prt_name();
my %i_duplex_admin;
foreach my $if (keys %$interfaces){
my $port = $interfaces->{$if};
next unless $port =~ /dp/i;
foreach my $idx (keys %$dpx_admin) {
my $name = $port_name->{$idx}||'unknown';
next unless $name eq $port;
my $duplex = $dpx_admin->{$idx};
my $auto = $nt_auto->{$idx};
$duplex = 'other' unless defined $duplex;
$duplex = 'half' if ($duplex =~ /half/i and $auto =~ /disabled/i);
$duplex = 'full' if ($duplex =~ /full/i and $auto =~ /disabled/i);
$duplex = 'auto' if $auto =~ /enabled/i;
$i_duplex_admin{$if}=$duplex;
}
}
return \%i_duplex_admin;
}
sub i_name {
my $nap222x = shift;
my $interfaces = $nap222x->interfaces();
my %i_name;
foreach my $if (keys %$interfaces){
my $desc = $interfaces->{$if};
next unless defined $desc;
my $name = 'unknown';
$name = 'Ethernet Interface' if $desc =~ /dp/i;
$name = 'Wireless Interface B' if $desc =~ /ndc/i;
$name = 'Wireless Interface A' if $desc =~ /ar/i;
$i_name{$if} = $name;
}
return \%i_name;
}
# dot1dBasePortTable does not exist and dot1dTpFdbPort does not map to ifIndex
sub bp_index {
my $nap222x = shift;
my $interfaces = $nap222x->interfaces();
my %bp_index;
foreach my $iid (keys %$interfaces){
my $desc = $interfaces->{$iid};
next unless defined $desc;
next unless $desc =~ /(ndc|ar)/i;
my $port = 1;
$port = 2 if $desc =~ /ndc/i;
$bp_index{$port} = $iid;
}
return \%bp_index;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::nap222x - SNMP Interface to Nortel 2220 Series Access Points
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $nap222x = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $nap222x->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a Nortel
2220 series wireless Access Points through SNMP.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $nap222x = new SNMP::Info::Layer2::nap222x(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::SONMP
=back
=head2 Required MIBs
=over
=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.
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 Families, Wireless LAN, WLAN - Access Point 2220, Software.
Filter on mibs and download the latest version's archive.
=head1 GLOBALS
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>.
=item $nap222x->os_bin()
Returns the firmware version extracted from B<ntWlanSwBootRomVer>.
=item $nap222x->mac()
Returns the MAC address of the first Ethernet Interface.
=item $nap222x->serial()
Returns the MAC address of the first Ethernet Interface.
=item $nap222x->nt_hw_ver()
Returns the hardware version.
B<ntWlanSwHardwareVer>
=item $nap222x->nt_cc()
Returns the country code of the AP.
B<ntWlanSwHardwareVer>
=item $nap222x->tftp_action()
B<ntWlanTransferStart>
=item $nap222x->tftp_host()
B<ntWlanFileServer>
=item $nap222x->tftp_file()
B<ntWlanDestFile>
=item $nap222x->tftp_type()
B<ntWlanFileType>
=item $nap222x->tftp_result()
B<ntWlanFileTransferStatus>
=item $nap222x->tftp_xtype()
B<ntWlanTransferType>
=item $nap222x->tftp_src_file()
B<ntWlanSrcFile>
=item $nap222x->ftp_user()
B<ntWlanUserName>
=item $nap222x->ftp_pass()
B<ntWlanPassword>
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $nap222x->interfaces()
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>
=item $nap222x->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs.
B<ntWlanPortCapabilities>
=item $nap222x->i_name()
Returns a human name based upon port description.
=item $nap222x->bp_index()
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.
=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.
=cut

277
Info/Layer2/Orinoco.pm Normal file
View File

@@ -0,0 +1,277 @@
# SNMP::Info::Layer2::Orinoco
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 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::Orinoco;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
@SNMP::Info::Layer2::Orinoco::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
);
sub os {
return 'orinoco';
}
sub os_ver {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
if ($descr =~ m/V(\d+\.\d+)/){
return $1;
}
if ($descr =~ m/v(\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub os_bin {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
if ($descr =~ m/V(\d+\.\d+)$/){
return $1;
}
if ($descr =~ m/v(\d+\.\d+\.\d+)$/){
return $1;
}
return undef;
}
sub vendor {
return 'proxim';
}
sub model {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
return $1 if ($descr =~ /(AP-\d+)/);
return 'WavePOINT-II' if ($descr =~ /WavePOINT-II/);
return undef;
}
sub serial {
my $orinoco = shift;
my $descr = $orinoco->description();
return undef unless defined $descr;
$descr = $1 if $descr =~ /SN-(\S+)/;
return $descr;
}
sub i_ignore {
my $orinoco = shift;
my $descr = $orinoco->i_description();
my %i_ignore;
foreach my $if (keys %$descr){
my $type = $descr->{$if};
# Skip virtual interfaces
$i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i;
}
return \%i_ignore;
}
sub interfaces {
my $orinoco = shift;
my $interfaces = $orinoco->i_index();
my $descriptions = $orinoco->i_description();
my %interfaces = ();
foreach my $iid (keys %$interfaces){
my $desc = $descriptions->{$iid};
next unless defined $desc;
next if $desc =~ /(lo|empty|PCMCIA)/i;
$desc = 'AMD' if $desc =~ /AMD/;
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::Orinoco - SNMP Interface to Orinoco Series Access Points
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $orinoco = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $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.
For speed or debugging purposes you can call the subclass directly, but not after
determining a more specific class using the method above.
my $orinoco = new SNMP::Info::Layer2::Orinoco(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item Inherited classes
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $orinoco->vendor()
Returns 'Proxim' :)
=item $orinoco->model()
Returns the model extracted from B<sysDescr>.
=item $orinoco->os()
Returns 'Orinoco'
=item $orinoco->os_ver()
Returns the software version extracted from B<sysDescr>.
=item $orinoco->os_bin()
Returns the firmware version extracted from B<sysDescr>.
=item $orinoco->serial()
Returns the serial number extracted from B<sysDescr>.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $orinoco->interfaces()
Returns reference to map of IIDs to physical ports.
=item $orinoco->i_ignore()
Returns reference to hash of IIDs to ignore.
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=cut

224
Info/Layer2/ZyXEL_DSLAM.pm Normal file
View File

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

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer3 - SNMP Interface to Layer3 devices
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker -- All changes from Version 0.7 on
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,67 +30,76 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::CDP;
use SNMP::Info::Bridge;
use SNMP::Info::EtherLike;
use SNMP::Info::Entity;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::ISA = qw/SNMP::Info SNMP::Info::CDP SNMP::Info::Bridge SNMP::Info::EtherLike Exporter/;
@SNMP::Info::Layer3::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::EtherLike
SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$INIT = 0;
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::EtherLike::MIBS,
'ENTITY-MIB' => 'entPhysicalName',
'HP-ICF-OID' => 'hpSwitch4000',
'CISCO-PRODUCTS-MIB' => 'sysName',
'OSPF-MIB' => 'ospfRouterId',
%SNMP::Info::Entity::MIBS,
'OSPF-MIB' => 'ospfRouterId',
'BGP4-MIB' => 'bgpIdentifier',
);
%GLOBALS = (
# Inherit the super class ones
%SNMP::Info::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1',
'router_ip' => 'ospfRouterId.0',
%SNMP::Info::Entity::GLOBALS,
'mac' => 'ifPhysAddress.1',
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
'router_ip' => 'ospfRouterId.0',
'bgp_id' => 'bgpIdentifier.0',
'bgp_local_as' => 'bgpLocalAs.0',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::Entity::FUNCS,
# IFMIB
'i_name2' => 'ifName',
# Address Translation Table (ARP Cache)
'at_index' => 'atIfIndex',
'at_paddr' => 'atPhysAddress',
'at_netaddr' => 'atNetAddress',
'ospf_ip' => 'ospfHostIpAddress'
'ospf_ip' => 'ospfHostIpAddress',
# BGP Peer Table
'bgp_peers' => 'bgpPeerLocalAddr',
'bgp_peer_id' => 'bgpPeerIdentifier',
'bgp_peer_state' => 'bgpPeerState',
'bgp_peer_as' => 'bgpPeerRemoteAs',
'bgp_peer_addr' => 'bgpPeerRemoteAddr',
'bgp_peer_fsm_est_trans' => 'bgpPeerFsmEstablishedTransitions',
'bgp_peer_in_tot_msgs' => 'bgpPeerInTotalMessages',
'bgp_peer_in_upd_el_time' => 'bgpPeerInUpdateElapsedTime',
'bgp_peer_in_upd' => 'bgpPeerInUpdates',
'bgp_peer_out_tot_msgs' => 'bgpPeerOutTotalMessages',
'bgp_peer_out_upd' => 'bgpPeerOutUpdates',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::Entity::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
@@ -101,16 +112,18 @@ sub root_ip {
my $router_ip = $l3->router_ip();
my $ospf_ip = $l3->ospf_ip();
# return the first one found here (should be only)
# return the first one found here (should be only one)
if (defined $ospf_ip and scalar(keys %$ospf_ip)){
foreach my $key (keys %$ospf_ip){
my $ip = $ospf_ip->{$key};
print " SNMP::Layer3::root_ip() using $ip\n" if $DEBUG;
next if $ip eq '0.0.0.0';
next unless $l3->snmp_connect_ip($ip);
print " SNMP::Layer3::root_ip() using $ip\n" if $l3->debug();
return $ip;
}
}
return $router_ip if defined $router_ip;
return $router_ip if ( (defined $router_ip) and ($router_ip ne '0.0.0.0') and ($l3->snmp_connect_ip($router_ip)) );
return undef;
}
@@ -122,7 +135,7 @@ sub i_ignore {
my %i_ignore;
foreach my $if (keys %$interfaces) {
# lo -> cisco aironet 350 loopback
if ($interfaces->{$if} =~ /(tunnel|loopback|lo|null)/i){
if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|null)/i){
$i_ignore{$if}++;
}
}
@@ -132,10 +145,20 @@ sub i_ignore {
sub serial {
my $l3 = shift;
my $chassis = $l3->chassis();
my $serial1 = $l3->serial1();
my $e_descr = $l3->e_descr() || {};
my $e_serial = $l3->e_serial() || {};
my $serial2 = $e_serial->{1} || undef;
my $chassis = $e_descr->{1} || undef;
# precedence
# serial2,chassis parse,serial1
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/);
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/);
return undef;
}
# $l3->model() - the sysObjectID returns an IID to an entry in
@@ -143,9 +166,19 @@ sub serial {
sub model {
my $l3 = shift;
my $id = $l3->id();
unless (defined $id){
print " SNMP::Info::Layer3::model() - Device does not support sysObjectID\n" if $l3->debug();
return undef;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^cisco//i;
$model =~ s/^catalyst//;
$model =~ s/^cat//;
return $model;
}
@@ -210,81 +243,97 @@ sub vendor {
my $descr = $l3->description();
return 'cisco' if ($descr =~ /(cisco|ios)/i);
return 'cisco' if ($descr =~ /(cisco|\bios\b)/i);
return 'foundry' if ($descr =~ /foundry/i);
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3 - Perl5 Interface to network devices using Layer3
=head1 DESCRIPTION
Provides generic methods for accessing SNMP data for Layer 3 network devices.
Includes support for Layer2+3 devices. See super classes for other inherited
methods.
Inherits from:
SNMP::Info
SNMP::Info::Bridge
SNMP::Info::CDP
SNMP::Info::EtherLike
Required MIBs:
ENTITY-MIB - For model identification
CISCO-PRODUCTS-MIB - For model identification
HP-ICF-OID - For model identification
MIBS listed in SNMP::Info::CDP, SNMP::Info::Bridge, and SNMP::Info::Etherlike
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
HP MIBs can be found at http://www.hp.com/rnd/software
SNMP::Info::Layer3 - Perl5 Interface to network devices serving Layer3 or Layers 2 & 3
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $l3 = new SNMP::Info::Layer3(DestHost => 'router' ,
Community => 'public' );
# Let SNMP::Info determine the correct subclass for you.
my $l3 = 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";
=head1 CREATING AN OBJECT
my $class = $l3->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
# Let's get some basic Port information
my $interfaces = $l3->interfaces();
my $i_up = $l3->i_up();
my $i_speed = $l3->i_speed();
foreach my $iid (keys %$interfaces) {
my $port = $interfaces->{$iid};
my $up = $i_up->{$iid};
my $speed = $i_speed->{$iid}
print "Port $port is $up. Port runs at $speed.\n";
}
=head1 DESCRIPTION
This class is usually used as a superclass for more specific device classes listed under
SNMP::Info::Layer3::* Please read all docs under SNMP::Info first.
Provides generic methods for accessing SNMP data for Layer 3 network devices.
Includes support for Layer2+3 devices.
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(...);
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer3()
=item SNMP::Info
Arguments passed to new() are passed on to SNMP::Session::new()
=item SNMP::Info::Bridge
my $l3 = new SNMP::Info::Layer3(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $l3;
For L2/L3 devices.
=item $l3->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $l3->session();
# Set
my $newsession = new SNMP::Session(...);
$l3->session($newsession);
=item SNMP::Info::EtherLike
=back
=head2 Required MIBs
=over
=item OSPF-MIB
=item BGP4-MIB
=item Inherited Classes
MIBs required by the inherited classes listed above.
=back
MIBs can be found in the netdisco-mibs package.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $l3->mac()
@@ -293,15 +342,27 @@ Returns root port mac address
(B<ifPhysAddress.1>)
=item $l3->chassis()
=item $l3->router_ip()
Returns Chassis type (model).
(B<ospfRouterId.0>)
(B<entPhysicalDescr.1>)
=item $l3->bgp_id()
=item $l3->serial()
(B<bgpIdentifier.0>)
Trys to cull a serial number from $l3->chassis()
Returns the BGP identifier of the local system
=item $l3->bgp_local_as()
Returns the local autonomous system number
(B<bgpLocalAs.0>)
=back
=head2 Overrides
=over
=item $l3->model()
@@ -309,14 +370,37 @@ Trys to reference $l3->id() to one of the product MIBs listed above
Removes 'cisco' from cisco devices for readability.
=item $l3->serial()
Trys to cull a serial number from ENTITY-MIB, description, and OLD-CISCO-... mib
=item $l3->vendor()
Trys to cull a Vendor name from B<sysDescr>
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Globals imported from SNMP::Info::EtherLike
See documentation in SNMP::Info::EtherLike for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
@@ -374,4 +458,98 @@ Returns reference to hash of Arp Cache Entries to IP Address
=back
=head2 BGP Peer Table
=over
=item $l3->bgp_peers()
Returns reference to hash of BGP peer to local IP address
(B<bgpPeerLocalAddr>)
=item $l3->bgp_peer_id()
Returns reference to hash of BGP peer to BGP peer identifier
(B<bgpPeerIdentifier>)
=item $l3->bgp_peer_state()
Returns reference to hash of BGP peer to BGP peer state
(B<bgpPeerState>)
=item $l3->bgp_peer_as()
Returns reference to hash of BGP peer to BGP peer autonomous system number
(B<bgpPeerRemoteAs>)
=item $l3->bgp_peer_addr()
Returns reference to hash of BGP peer to BGP peer IP address
(B<bgpPeerRemoteAddr>)
=item $l3->bgp_peer_fsm_est_trans()
Returns reference to hash of BGP peer to the total number of times the BGP FSM
transitioned into the established state
(B<bgpPeerFsmEstablishedTransitions>)
=item $l3->bgp_peer_in_tot_msgs()
Returns reference to hash of BGP peer to the total number of messages received
from the remote peer on this connection
(B<bgpPeerInTotalMessages>)
=item $l3->bgp_peer_in_upd_el_time()
Returns reference to hash of BGP peer to the elapsed time in seconds since
the last BGP UPDATE message was received from the peer.
(B<bgpPeerInUpdateElapsedTime>)
=item $l3->bgp_peer_in_upd()
Returns reference to hash of BGP peer to the number of BGP UPDATE messages
received on this connection
(B<bgpPeerInUpdates>)
=item $l3->bgp_peer_out_tot_msgs()
Returns reference to hash of BGP peer to the total number of messages transmitted
to the remote peer on this connection
(B<bgpPeerOutTotalMessages>)
=item $l3->bgp_peer_out_upd()
Returns reference to hash of BGP peer to the number of BGP UPDATE messages
transmitted on this connection
(B<bgpPeerOutUpdates>)
=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::EtherLike
See documentation in SNMP::Info::EtherLike for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer3::Aironet
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +30,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Aironet;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
@@ -39,10 +42,6 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Aironet::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$INIT = 0;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'AWCVX-MIB' => 'awcIfTable',
@@ -81,6 +80,26 @@ $INIT = 0;
'fw_mac2' => \&SNMP::Info::munge_mac,
);
sub os {
return 'aironet';
}
sub os_ver {
my $aironet = shift;
my $descr = $aironet->description() || '';
# CAP340 11.21, AP4800-E 11.21
if ($descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/){
return $2;
}
if ($descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/){
return $1;
}
return undef;
}
# Override wireless port with static info
sub bp_index {
my $aironet = shift;
@@ -109,11 +128,14 @@ sub fw_mac {
# remove port 0 forwarding table entries, only port 0 static entries
foreach my $fw (keys %$fw_mac){
my $port = $fw_port->{$fw};
next unless defined $port;
delete $fw_mac->{$fw} if $port == 0;
}
foreach my $bs (keys %$bs_mac){
$fw_mac->{$bs} = $bs_mac->{$bs};
my $entry = $bs;
$entry =~ s/\.0$//;
$fw_mac->{$entry} = $bs_mac->{$bs};
}
return $fw_mac;
@@ -127,7 +149,9 @@ sub fw_port {
foreach my $bs (keys %$bs_port){
$fw_port->{$bs} = $bs_port->{$bs};
my $entry = $bs;
$entry =~ s/\.0$//;
$fw_port->{$entry} = $bs_port->{$bs};
}
return $fw_port;
@@ -188,60 +212,78 @@ __END__
=head1 NAME
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices
=head1 DESCRIPTION
Inherits all methods from SNMP::Info::Layer3
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices running Aironet software, not IOS
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $aironet = new SNMP::Info::Layer3::Aironet(DestHost => 'myswitch',
Community => 'public');
my $mac = $aironet->mac();
# Let SNMP::Info determine the correct subclass for you.
my $aironet = 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";
=head1 CREATING AN OBJECT
my $class = $aironet->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info subclass to provide access to SNMP data for an Aironet device running Aironet software,
not cisco IOS.
Note there are two classes for Aironet devices :
=over
=item new SNMP::Info::Layer3::Aironet()
=item SNMP::Info::Layer3::Aironet
Arguments passed to new() are passed on to SNMP::Session::new()
This class is for devices running Aironet software (older)
my $aironet = new SNMP::Info::Layer3::Aironet(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $aironet;
=item SNMP::Info::Layer2::Aironet
=item $aironet->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $aironet->session();
# Set
my $newsession = new SNMP::Session(...);
$aironet->session($newsession);
This class is for devices running Cisco IOS software (newer)
=back
=head1 Globals
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $aironet = new SNMP::Info::Layer3::Aironet(...);
=head2 Inherited Classes
=over
=item $aironet->mac()
=item SNMP::Info::Layer3
Gives the MAC Address of the wireless side
=back
B<dot11StationID.2>
=head2 Required MIBs
=over
=item AWCVX-MIB
=item IEEE802dot11-MIB
=back
These MIBs are now included in the v2.tar.gz archive available from ftp.cisco.com. Make sure you
have a current version.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $aironet->awc_duplex()
@@ -249,47 +291,34 @@ Gives the admin duplex setting for the Ethernet Port.
B<awcEtherDuplex.0>
=item $aironet->mac()
Gives the MAC Address of the wireless side
B<dot11StationID.2>
=item $aironet->os()
'aironet'
=item $aironet->os_ver
Tries to cull the version from the description field.
=item $aironet->vendor()
Returns 'cisco'.
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head1 TABLE ENTRIES
=head2 Aironet specific items
=over
=item $aironet->awc_default_mac()
Gives the default MAC address of each interface.
B<awcIfDefaultPhyAddress>
=item $aironet->awc_mac()
Gives the actual MAC address of each interface.
B<awcIfPhyAddress>
=item $aironet->awc_ip()
Gives the IP Address assigned to each interface.
B<awcIfIpAddress>
=item $aironet->awc_netmask()
Gives the NetMask for each interface.
B<awcIfIpNetMask>
=item $aironet->awc_msdu()
B<awcIfMSDUMaxLength>
=back
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
@@ -324,4 +353,42 @@ Ignores ports that are of type ``rptr'' and ``lo''.
=back
=head2 Aironet specific items
=over
=item $aironet->awc_default_mac()
Gives the default MAC address of each interface.
B<awcIfDefaultPhyAddress>
=item $aironet->awc_mac()
Gives the actual MAC address of each interface.
B<awcIfPhyAddress>
=item $aironet->awc_ip()
Gives the IP Address assigned to each interface.
B<awcIfIpAddress>
=item $aironet->awc_netmask()
Gives the NetMask for each interface.
B<awcIfIpNetMask>
=item $aironet->awc_msdu()
B<awcIfMSDUMaxLength>
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=cut

444
Info/Layer3/AlteonAD.pm Normal file
View File

@@ -0,0 +1,444 @@
# SNMP::Info::Layer3::AlteonAD
# Eric Miller
# $Id$
#
# Copyright (c) 2004 Eric Miller
# All Rights Reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::AlteonAD;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
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::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
'ALTEON-TIGON-SWITCH-MIB' => 'agSoftwareVersion',
'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt',
'ALTEON-TS-NETWORK-MIB' => 'agPortTableMaxEnt',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
'sw_ver' => 'agSoftwareVersion',
'tftp_action' => 'agTftpAction',
'tftp_host' => 'agTftpServer',
'tftp_file' => 'agTftpCfgFileName',
'tftp_result' => 'agTftpLastActionStatus',
);
%FUNCS = (
%SNMP::Info::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',
'ag_p_cfg_pvid' => 'agPortCurCfgPVID',
'ag_p_cfg_fe_auto' => 'agPortCurCfgFastEthAutoNeg',
'ag_p_cfg_fe_mode' => 'agPortCurCfgFastEthMode',
'ag_p_cfg_ge_auto' => 'agPortCurCfgGigEthAutoNeg',
'ag_p_cfg_name' => 'agPortCurCfgPortName',
# From portInfoTable
'p_info_idx' => 'portInfoIndx',
'p_info_mode' => 'portInfoMode',
# From portInfoTable
'ip_cfg_vlan' => 'ipCurCfgIntfVlan',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub model {
my $alteon = shift;
my $desc = $alteon->description();
return undef unless defined $desc;
return 'AD2' if ($desc =~ /AD2/);
return 'AD3' if ($desc =~ /AD3/);
return 'AD4' if ($desc =~ /AD4/);
return '180' if ($desc =~ /180/);
return '183' if ($desc =~ /183/);
return '184' if ($desc =~ /184/);
return $desc;
}
sub vendor {
return 'nortel';
}
sub os {
return 'webos';
}
sub os_ver {
my $alteon = shift;
my $version = $alteon->sw_ver();
return undef unless defined $version;
return $version;
}
sub interfaces {
my $alteon = shift;
my $interfaces = $alteon->i_index();
my $descriptions = $alteon->i_description();
my %interfaces = ();
foreach my $iid (keys %$interfaces){
my $desc = $descriptions->{$iid};
next unless defined $desc;
if ($desc =~ /(^net\d+)/) {
$desc = $1;
}
elsif (($iid > 256) and ($iid < 266)) {
$desc = ($iid % 256);
}
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_duplex {
my $alteon = shift;
my $p_mode = $alteon->p_info_mode();
my %i_duplex;
foreach my $if (keys %$p_mode){
my $duplex = $p_mode->{$if};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
my $idx = $if + 256;
$i_duplex{$idx}=$duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $alteon = shift;
my $ag_pref = $alteon->ag_p_cfg_pref();
my $ag_fe_auto = $alteon->ag_p_cfg_fe_auto();
my $ag_fe_mode = $alteon->ag_p_cfg_fe_mode();
my $ag_ge_auto = $alteon->ag_p_cfg_ge_auto();
my %i_duplex_admin;
foreach my $if (keys %$ag_pref){
my $pref = $ag_pref->{$if};
next unless defined $pref;
my $string = 'other';
if ($pref =~ /gigabit/i) {
my $ge_auto = $ag_ge_auto->{$if};
$string = 'full' if ($ge_auto =~ /off/i);
$string = 'auto' if ($ge_auto =~ /on/i);
}
elsif ($pref =~ /fast/i) {
my $fe_auto = $ag_fe_auto->{$if};
my $fe_mode = $ag_fe_mode->{$if};
$string = 'half' if ($fe_mode =~ /half/i and $fe_auto =~ /off/i);
$string = 'full' if ($fe_mode =~ /full/i and $fe_auto =~ /off/i);
$string = 'auto' if $fe_auto =~ /on/i;
}
my $idx = $if + 256;
$i_duplex_admin{$idx}=$string;
}
return \%i_duplex_admin;
}
sub i_vlan {
my $alteon = shift;
my $ag_vlans = $alteon->ag_p_cfg_pvid();
my $ip_vlans = $alteon->ip_cfg_vlan();
my %i_vlan;
foreach my $if (keys %$ip_vlans){
my $ip_vlanid = $ip_vlans->{$if};
next unless defined $ip_vlanid;
$i_vlan{$if}=$ip_vlanid;
}
foreach my $if (keys %$ag_vlans){
my $ag_vlanid = $ag_vlans->{$if};
next unless defined $ag_vlanid;
my $idx = $if + 256;
$i_vlan{$idx}=$ag_vlanid;
}
return \%i_vlan;
}
sub i_name {
my $alteon = shift;
my $p_name = $alteon->ag_p_cfg_name();
my %i_name;
foreach my $iid (keys %$p_name){
my $name = $p_name->{$iid};
next unless defined $name;
my $idx = $iid + 256;
$i_name{$idx} = $name;
}
return \%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 %bp_index;
foreach my $iid (keys %$b_index){
my $port = $b_index->{$iid};
next unless defined $port;
$port = $port + 256;
$bp_index{$iid} = $port;
}
return \%bp_index;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::AlteonAD - Perl5 Interface to Nortel Networks' Alteon Ace
Director Series Layer 2-7 Switches.
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $alteon = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $alteon->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Layer 2-7 load balancing switches running Nortel Networks'
Alteon Web OS Traffic Control Software.
For speed or debugging purposes you can call the subclass directly, but not after
determining a more specific class using the method above.
my $alteon = new SNMP::Info::Layer3::AlteonAD(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item ALTEON-TIGON-SWITCH-MIB
=item ALTEON-TS-PHYSICAL-MIB
=item ALTEON-TS-NETWORK-MIB
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 Families, Alteon,
Alteon Web OS Traffic Control Software, Software. Filter on mibs and download
the latest version's archive.
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $alteon->model()
Returns the model extracted from B<sysDescr>
=item $alteon->vendor()
Returns 'nortel'
=item $alteon->os()
Returns 'webos'
=item $alteon->os_ver()
Returns the software version reported by B<agSoftwareVersion>
=item $alteon->tftp_action()
(B<agTftpAction>)
=item $alteon->tftp_host()
(B<agTftpServer>)
=item $alteon->tftp_file()
(B<agTftpCfgFileName>)
=item $alteon->tftp_result()
(B<agTftpLastActionStatus>)
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $alteon->interfaces()
Returns reference to the map between IID and physical port.
Utilizes description for network interfaces. Ports are determined by
formula (ifIndex mod 256).
=item $alteon->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs.
=item $alteon->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs.
=item $alteon->i_vlan()
Returns reference to hash. Maps port VLAN ID to IIDs.
=item $alteon->i_name()
Maps (B<agPortCurCfgPortName>) to port and returns the human set port name if exists.
=item $alteon->bp_index()
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.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=cut

529
Info/Layer3/BayRS.pm Normal file
View File

@@ -0,0 +1,529 @@
# SNMP::Info::Layer3::BayRS
# Eric Miller
# $Id$
#
# Copyright (c) 2004 Eric Miller, Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::BayRS;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE %MODEL_MAP/;
@SNMP::Info::Layer3::BayRS::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer3::BayRS::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
'Wellfleet-HARDWARE-MIB' => 'wfHwBpIdOpt',
'Wellfleet-OSPF-MIB' => 'wfOspfRouterId',
'Wellfleet-DOT1QTAG-CONFIG-MIB' => 'wfDot1qTagCfgVlanName',
'Wellfleet-CSMACD-MIB' => 'wfCSMACDCct',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
'bp_id' => 'wfHwBpIdOpt',
'bp_serial' => 'wfHwBpSerialNumber',
'ospf_rtr_id' => 'wfOspfRouterId',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# From Wellfleet-CSMACD-MIB::wfCSMACDTable
'wf_csmacd_cct' => 'wfCSMACDCct',
'wf_csmacd_slot' => 'wfCSMACDSlot',
'wf_csmacd_conn' => 'wfCSMACDConnector',
'wf_csmacd_mtu' => 'wfCSMACDMtu',
'wf_duplex' => 'wfCSMACDLineCapability',
'wf_csmacd_line' => 'wfCSMACDLineNumber',
# From Wellfleet-CSMACD-MIB::wfCSMACDAutoNegTable
'wf_auto' => 'wfCSMACDAutoNegSpeedSelect',
# From Wellfleet-DOT1QTAG-CONFIG-MIB::wfDot1qTagConfigTable
'wf_vlan_name' => 'wfDot1qTagCfgVlanName',
'wf_local_vlan_id' => 'wfDot1qTagCfgLocalVlanId',
'wf_global_vlan_id' => 'wfDot1qTagCfgGlobalVlanId',
'wf_vlan_port' => 'wfDot1qTagCfgPhysicalPortId',
# From Wellfleet-HARDWARE-MIB::wfHwTable
'wf_hw_slot' => 'wfHwSlot',
'wf_hw_mod_id' => 'wfHwModIdOpt',
'wf_hw_mod_rev' => 'wfHwModRev',
'wf_hw_mod_ser' => 'wfHwModSerialNumber',
'wf_hw_mobo_id' => 'wfHwMotherBdIdOpt ',
'wf_hw_mobo_rev' => 'wfHwMotherBdRev',
'wf_hw_mobo_ser' => 'wfHwMotherBdSerialNumber',
'wf_hw_diag' => 'wfHwDiagPromRev',
'wf_hw_boot' => 'wfHwBootPromRev',
'wf_hw_mobo_mem' => 'wfHwMotherBdMemorySize',
'wf_hw_cfg_time' => 'wfHwConfigDateAndTime ',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
%MODEL_MAP = (
'acefn' => 'FN',
'aceln' => 'LN',
'acecn' => 'CN',
'afn' => 'AFN',
'in' => 'IN',
'an' => 'AN',
'arn' => 'ARN',
'sys5000' => '5000',
'freln' => 'BLN',
'frecn' => 'BCN',
'frerbln' => 'BLN-2',
'asn' => 'ASN',
'asnzcable' => 'ASN-Z',
'asnbcable' => 'ASN-B',
);
sub model {
my $bayrs = shift;
my $bp_id = $bayrs->bp_id();
return defined $MODEL_MAP{$bp_id} ? $MODEL_MAP{$bp_id} : $bp_id;
}
sub vendor {
return 'nortel';
}
sub os {
return 'bayrs';
}
sub os_ver {
my $bayrs = shift;
my $descr = $bayrs->description();
return undef unless defined $descr;
if ($descr =~ m/rel\/(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub serial {
my $bayrs = shift;
my $serialnum = $bayrs->bp_serial();
$serialnum = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$serialnum)));
return $serialnum if defined $serialnum ;
return undef;
}
sub interfaces {
my $bayrs = shift;
my $description = $bayrs->i_description();
my $vlan_ids = $bayrs->wf_global_vlan_id();
my $vlan_idx = $bayrs->wf_local_vlan_id();
my %interfaces = ();
foreach my $iid (keys %$description){
my $desc = $description->{$iid};
next unless defined $desc;
$desc = $1 if $desc =~ /(^[A-Z]\d+)/;
$interfaces{$iid} = $desc;
}
foreach my $iid (keys %$vlan_ids){
my $vlan = $vlan_ids->{$iid};
next unless defined $vlan;
my $vlan_if = $vlan_idx->{$iid};
next unless defined $vlan_if;
my $desc = 'Vlan' . $vlan;
$interfaces{$vlan_if} = $desc;
}
return \%interfaces;
}
sub i_name {
my $bayrs = shift;
my $i_index = $bayrs->i_index();
my $description = $bayrs->i_description();
my $v_name = $bayrs->wf_vlan_name();
my $vlan_idx = $bayrs->wf_local_vlan_id();
my %i_name;
foreach my $iid (keys %$description){
my $name = $description->{$iid};
next unless defined $name;
$i_name{$iid} = $name;
}
# Get VLAN Virtual Router Interfaces
foreach my $vid (keys %$v_name){
my $v_name = $v_name->{$vid};
next unless defined $v_name;
my $vlan_if = $vlan_idx->{$vid};
next unless defined $vlan_if;
$i_name{$vlan_if} = $v_name;
}
return \%i_name;
}
sub i_duplex {
my $bayrs = shift;
my $wf_cct = $bayrs->wf_csmacd_cct();
my $wf_duplex = $bayrs->wf_duplex();
my %i_duplex;
foreach my $if (keys %$wf_cct){
my $idx = $wf_cct->{$if};
next unless defined $idx;
my $duplex = $wf_duplex->{$if};
next unless defined $duplex;
my $string = 'half';
$string = 'full' if $duplex =~ /duplex/i;
$i_duplex{$idx}=$string;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $bayrs = shift;
my $wf_cct = $bayrs->wf_csmacd_cct();
my $wf_duplex = $bayrs->wf_duplex();
my $wf_auto = $bayrs->wf_auto();
my $wf_slot = $bayrs->wf_csmacd_slot();
my $wf_conn = $bayrs->wf_csmacd_conn();
my %i_duplex_admin;
foreach my $if (keys %$wf_cct){
my $idx = $wf_cct->{$if};
next unless defined $idx;
my $duplex = $wf_duplex->{$if};
next unless defined $duplex;
my $slot = $wf_slot->{$if};
my $conn = $wf_conn->{$if};
my $auto_idx = "$slot.$conn";
my $auto = $wf_auto->{$auto_idx};
my $string = 'other';
if ($auto) {
$string = 'half';
$string = 'full' if $auto =~ /duplex/i;
$string = 'auto' if $auto =~ /nway/i;
}
elsif ($duplex) {
$string = 'half';
$string = 'full' if $duplex =~ /duplex/i;
}
$i_duplex_admin{$idx}=$string;
}
return \%i_duplex_admin;
}
sub i_vlan {
my $bayrs = shift;
my $wf_cct = $bayrs->wf_csmacd_cct();
my $wf_mtu = $bayrs->wf_csmacd_mtu();
my $wf_line = $bayrs->wf_csmacd_line();
my $wf_local_vid = $bayrs->wf_local_vlan_id();
my $wf_global_vid = $bayrs->wf_global_vlan_id();
my $wf_vport = $bayrs->wf_vlan_port();
my %i_vlan;
# Look for VLANs on Ethernet Interfaces
foreach my $if (keys %$wf_cct){
my $idx = $wf_cct->{$if};
next unless defined $idx;
# Check MTU size, if unable to carry VLAN tag skip.
my $mtu = $wf_mtu->{$if};
next if (($mtu =~ /default/i) or ($mtu < 1522));
my $line = $wf_line->{$if};
my @vlans = ();
foreach my $v_idx (keys %$wf_vport){
my $port = $wf_vport->{$v_idx};
next unless defined $port;
next if ($port != $line);
my $vlan = $wf_global_vid->{$v_idx};
push(@vlans, $vlan);
}
my $vlans = join (',', @vlans);
$i_vlan{$idx}=$vlans;
}
# Add VLAN on VLAN Interfaces
foreach my $idx (keys %$wf_global_vid){
my $v_if = $wf_local_vid->{$idx};
next unless defined $v_if;
my $vlan = $wf_global_vid->{$idx};
next unless defined $vlan;
$i_vlan{$v_if}=$vlan;
}
return \%i_vlan;
}
sub root_ip {
my $bayrs = shift;
my $ip_index = $bayrs->ip_index();
my $ip_table = $bayrs->ip_table();
# Check for CLIP
foreach my $entry (keys %$ip_index){
my $idx = $ip_index->{$entry};
next unless $idx == 0;
my $clip = $ip_table->{$entry};
next unless ( (defined $clip) and ($clip ne '0.0.0.0') and ($bayrs->snmp_connect_ip($clip)) );
print " SNMP::Layer3::BayRS::root_ip() using $clip\n" if $bayrs->debug();
return $clip;
}
# Check for OSPF Router ID
my $ospf_ip = $bayrs->ospf_rtr_id();
if ((defined $ospf_ip) and ($ospf_ip ne '0.0.0.0') and ($bayrs->snmp_connect_ip($ospf_ip)) ) {
print " SNMP::Layer3::BayRS::root_ip() using $ospf_ip\n" if $bayrs->debug();
return $ospf_ip;
}
return undef;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::BayRS - Perl5 Interface to Nortel routers running BayRS.
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $bayrs = 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 = $bayrs->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for routers running Nortel BayRS.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $bayrs = new SNMP::Info::Layer3::BayRS(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item Wellfleet-HARDWARE-MIB
=item Wellfleet-OSPF-MIB
=item Wellfleet-DOT1QTAG-CONFIG-MIB
=item Wellfleet-CSMACD-MIB
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $bayrs->model()
Returns the model of the BayRS router. Will translate between the MIB model and
the common model with this map :
%MODEL_MAP = (
'acefn' => 'FN',
'aceln' => 'LN',
'acecn' => 'CN',
'afn' => 'AFN',
'in' => 'IN',
'an' => 'AN',
'arn' => 'ARN',
'sys5000' => '5000',
'freln' => 'BLN',
'frecn' => 'BCN',
'frerbln' => 'BLN-2',
'asn' => 'ASN',
'asnzcable' => 'ASN-Z',
'asnbcable' => 'ASN-B',
);
=item $bayrs->vendor()
Returns 'nortel'
=item $bayrs->os()
Returns 'bayrs'
=item $bayrs->os_ver()
Returns the software version extracted from B<sysDescr>
=item $bayrs->serial()
Returns (B<wfHwBpSerialNumber>) after conversion to ASCII decimal
=item $bayrs->root_ip()
Returns the primary IP used to communicate with the router.
Returns the first found: CLIP (CircuitLess IP), (B<wfOspfRouterId>), or undefined.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $bayrs->interfaces()
Returns reference to the map between IID and physical Port.
The physical port name is stripped to letter and numbers to signify
port type and slot port (S11) if the default platform naming was
maintained. Otherwise the port is the interface description.
=item $bayrs->i_name()
Returns (B<ifDescr>) along with VLAN name (B<wfDot1qTagCfgVlanName>) for VLAN
interfaces.
=item $bayrs->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs for Ethernet
interfaces.
=item $bayrs->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs for Ethernet interfaces.
=item $bayrs->i_vlan()
Returns reference to hash. Maps port VLAN ID to IIDs.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $bayrs->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $bayrs->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $bayrs->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.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=cut

288
Info/Layer3/C3550.pm Normal file
View File

@@ -0,0 +1,288 @@
# SNMP::Info::Layer3::C3550
# Max Baker
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
# Copyright (c) 2003, Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C3550;
$VERSION = 1.0;
# $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 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::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::CiscoImage::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoImage::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::CiscoImage::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::CiscoImage::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';
}
sub model {
my $c3550 = shift;
my $id = $c3550->id();
my $model = &SNMP::translateObj($id) || $id;
$model =~ s/^catalyst//;
# turn 355048 into 3550-48
if ($model =~ /^(35\d\d)(\d\d(T|G)?)$/) {
$model = "$1-$2";
}
return $model;
}
# Ports is encoded into the model number
sub ports {
my $c3550 = shift;
my $ports2 = $c3550->ports2();
my $id = $c3550->id();
my $model = &SNMP::translateObj($id);
if ($model =~ /(12|24|48)(C|T|TS|G|TS-E|TS-S|T-E)?$/) {
return $1;
}
return $ports2;
}
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
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c3550 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c3550->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
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.
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(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See SNMP::Info::CiscoStack for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See SNMP::Info::CiscoImage for its own MIB requirements.
See SNMP::Info::CDP for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $c3550->vendor()
Returns 'cisco'
=item $c3550->model()
Will take the translated model number and try to format it better.
355048 -> 3550-48
355012G -> 3550-12G
=item $c3550->ports()
Trys to cull the number of ports from the model number.
=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.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage 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 SNMP::Info::Layer3 for details.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
=head2 Table Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
=cut

262
Info/Layer3/C4000.pm Normal file
View File

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

252
Info/Layer3/C6500.pm Normal file
View File

@@ -0,0 +1,252 @@
# SNMP::Info::Layer3::C6500
# Max Baker
#
# Copyright (c) 2003,2004,2005 Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the Author, nor
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C6500;
# $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 vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = 1.0;
@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/;
@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::CiscoImage::MIBS,
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS,
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoImage::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoImage::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; }
1;
__END__
=head1 NAME
SNMP::Info::Layer3::C6500 - Perl5 Interface to Cisco Catalyst 6500 Layer 2/3 Switches running IOS and/or CatOS
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $c6500 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $c6500->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches.
These devices run IOS but have some of the same 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.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $c6500 = new SNMP::Info::Layer3::C6500(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CiscoStack
=item SNMP::Info::CiscoStats
=item SNMP::Info::CDP
=item SNMP::Info::CiscoImage
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See SNMP::Info::CiscoStack for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See SNMP::Info::CDP for its own MIB requirements.
See SNMP::Info::CiscoImage for its own MIB requirements.
=back
=head1 GLOBALS
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.
=head2 Global Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage 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 SNMP::Info::Layer3 for details.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
=head2 Table Methods imported from SNMP::Info::CiscoStack
See documentation in SNMP::Info::CiscoStack for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
=cut

214
Info/Layer3/Cisco.pm Normal file
View File

@@ -0,0 +1,214 @@
# SNMP::Info::Layer3::Cisco
# Max Baker
#
# Copyright (c) 2004-6 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::Layer3::Cisco;
# $Id$
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 vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
$VERSION = 1.0;
@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/;
@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::CiscoQOS::MIBS,
);
%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::CiscoQOS::GLOBALS,
);
%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::CiscoQOS::FUNCS,
);
%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::CiscoQOS::MUNGE,
);
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Cisco - Perl5 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 on 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::Layer3
=item SNMP::Info::CiscoVTP
=item SNMP::Info::CDP
=item SNMP::Info::CiscoStats
=item SNMP::Info::CiscoImage
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See SNMP::Info::Layer3 for its own MIB requirements.
See SNMP::Info::CiscoVTP for its own MIB requirements.
See SNMP::Info::CiscoStats for its own MIB requirements.
See SNMP::Info::CDP for its own MIB requirements.
See SNMP::Info::CiscoImage 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 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.
=head2 Globals imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
=head2 Globals imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
=head2 Globals imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage 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 SNMP::Info::Layer3 for details.
=head2 Table Methods imported from SNMP::Info::CiscoVTP
See documentation in SNMP::Info::CiscoVTP for details.
=head2 Table Methods imported from SNMP::Info::CDP
See documentation in SNMP::Info::CDP for details.
=head2 Table Methods imported from SNMP::Info::CiscoStats
See documentation in SNMP::Info::CiscoStats for details.
=head2 Table Methods imported from SNMP::Info::CiscoImage
See documentation in SNMP::Info::CiscoImage for details.
=cut

322
Info/Layer3/Contivity.pm Normal file
View File

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

331
Info/Layer3/Extreme.pm Normal file
View File

@@ -0,0 +1,331 @@
# SNMP::Info::Layer3::Extreme - SNMP Interface to Extreme devices
# Eric Miller
#
# Copyright (c) 2005 Eric Miller
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Extreme;
# $Id$
use strict;
use Exporter;
use SNMP::Info::Layer3;
use SNMP::Info::MAU;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = 1.0;
@SNMP::Info::Layer3::Extreme::ISA = qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//;
%MIBS = ( %SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS,
'EXTREME-BASE-MIB' => 'extremeAgent',
'EXTREME-SYSTEM-MIB' => 'extremeSystem',
'EXTREME-FDB-MIB' => 'extremeSystem',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS,
'serial' => 'extremeSystemID',
'temp' => 'extremeCurrentTemperature',
'ps1_status' => 'extremePowerSupplyStatus.1',
'fan' => 'extremeFanOperational.1',
'mac' => 'dot1dBaseBridgeAddress',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS,
# EXTREME-FDB-MIB:extremeFdbMacFdbTable
'fw_mac' => 'extremeFdbMacFdbMacAddress',
'fw_port' => 'extremeFdbMacFdbPortIfIndex',
'fw_status' => 'extremeFdbMacFdbStatus',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE,
%SNMP::Info::MAU::MUNGE,
);
# 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;
sub model {
my $extreme = shift;
my $id = $extreme->id();
unless (defined $id){
print " SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n" if $extreme->debug();
return undef;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
return $model;
}
sub vendor {
return 'extreme';
}
sub os {
return 'extreme';
}
sub os_ver {
my $extreme = shift;
my $descr = $extreme->description();
return undef unless defined $descr;
if ($descr =~ m/Version ([\d.]*)/){
return $1;
}
return undef;
}
# We're not using BRIDGE-MIB
sub bp_index {
my $extreme = shift;
my $if_index = $extreme->i_index();
my %bp_index;
foreach my $iid (keys %$if_index){
$bp_index{$iid} = $iid;
}
return \%bp_index;
}
# Index values in the Q-BRIDGE-MIB are the same
# as in the BRIDGE-MIB and do not match ifIndex.
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;
}
$i_vlan{$iid}=$vlan;
}
return \%i_vlan;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Extreme - Perl5 Interface to Extreme Network Devices
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $extreme = 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 = $extreme->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from an
Extreme device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $extreme = new SNMP::Info::Layer3::Extreme(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=item SNMP::Info::MAU
=back
=head2 Required MIBs
=over
=item EXTREME-BASE-MIB
=item EXTREME-SYSTEM-MIB
=item EXTREME-FDB-MIB
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $extreme->bulkwalk_no
Return C<1>. Bulkwalk is currently turned off for this class.
=item $extreme->model()
Returns model type. Checks $extreme->id() against the EXTREME-BASE-MIB.
=item $extreme->vendor()
Returns extreme
=item $extreme->os()
Returns extreme
=item $extreme->serial()
Returns serial number
(B<extremeSystemID>)
=item $extreme->temp()
Returns system temperature
(B<extremeCurrentTemperature>)
=item $extreme->ps1_status()
Returns status of power supply 1
(B<extremePowerSupplyStatus.1>)
=item $extreme->fan()
Returns fan status
(B<extremeFanOperational.1>)
=item $extreme->mac()
Returns base mac
(B<dot1dBaseBridgeAddress>)
=back
=head2 Overrides
=over
=back
=head2 Globals imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head2 Globals imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $extreme->fw_mac()
(B<extremeFdbMacFdbMacAddress>)
=item $extreme->fw_port()
(B<extremeFdbMacFdbPortIfIndex>)
=item $extreme->fw_status()
(B<extremeFdbMacFdbStatus>)
=item $extreme->i_vlan()
Returns a mapping between ifIndex and the VLAN.
=item $stack->bp_index()
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
Returns (B<ifIndex>) for both key and value since we're using EXTREME-FDB-MIB
rather than BRIDGE-MIB.
=back
=head2 Table Methods imported from SNMP::Info::Layer3
See documentation in SNMP::Info::Layer3 for details.
=head2 Table Methods imported from SNMP::Info::MAU
See documentation in SNMP::Info::MAU for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry devices
# Max Baker <max@warped.org>
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# 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.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,27 +30,25 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Foundry;
$VERSION = 0.1;
# $Id$
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::Layer3;
use SNMP::Info::FDP;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
$VERSION = 1.0;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::Layer3 SNMP::Info::FDP Exporter/;
@SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$INIT = 0;
%MIBS = ( %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%MIBS = ( %SNMP::Info::Layer3::MIBS,
%SNMP::Info::FDP::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
# IP-FORWARD-MIB
# ETHERLIKE-MIB
# RFC1398-MIB
@@ -57,9 +57,8 @@ $INIT = 0;
);
%GLOBALS = (
# Inherit the super class ones
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::FDP::GLOBALS,
'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1',
'serial' => 'snChasSerNum',
@@ -75,13 +74,9 @@ $INIT = 0;
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Layer3::FUNCS,
%SNMP::Info::FDP::FUNCS,
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# FOUNDRY-MIB
# snSwPortInfoTable - Switch Port Information Group
'sw_index' => 'snSwPortIfIndex',
@@ -92,14 +87,16 @@ $INIT = 0;
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Layer3::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;
@@ -137,6 +134,10 @@ sub i_duplex {
my $foundry = shift;
my $sw_index = $foundry->sw_index();
my $sw_duplex= $foundry->sw_duplex();
unless (defined $sw_index and defined $sw_duplex){
return $foundry->SUPER::i_duplex();
}
my %i_duplex;
foreach my $sw_port (keys %$sw_duplex){
@@ -153,6 +154,10 @@ 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){
@@ -168,6 +173,10 @@ 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){
@@ -193,11 +202,35 @@ sub model {
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]+)/;
$model =~ s/^sn//;
return $model;
}
sub os {
my $foundry = shift;
my $descr = $foundry->description();
if ($descr =~ m/IronWare/i) {
return 'IronWare';
}
return 'foundry';
}
sub os_ver {
my $foundry = shift;
my $os_version = $foundry->os_version();
return $os_version if defined $os_version;
# Some older ones don't have this value,so we cull it from the description
my $descr = $foundry->description();
if ($descr =~ m/Version (\d\S*)/) {
return $1;
}
return undef;
}
# $foundry->interfaces() - Map the Interfaces to their physical names
sub interfaces {
my $foundry = shift;
@@ -216,158 +249,176 @@ sub interfaces {
sub vendor {
return 'foundry';
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry Network Devices
=head1 DESCRIPTION
This module provides limited functionality from older Foundry devices.
Specifically designed for a FI4802
Data comes RFC1213 and FOUNDRY-SN-ROOT-MIB
Inherits all methods from both SNMP::Info and SNMP::Info::Bridge
SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry FastIron Network Devices
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $foundry = new SNMP::Info::Layer3::Foundry(DestHost => 'switch' ,
Community => 'public' );
# 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";
=head1 CREATING AN OBJECT
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.
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.
my $foundry = new SNMP::Info::Layer3::Foundry(...);
=head2 Inherited Classes
=over
=item new SNMP::Info::Layer3::Foundry()
=item SNMP::Info
Arguments passed to new() are passed on to SNMP::Session::new()
my $foundry = new SNMP::Info::Layer3::Foundry(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $foundry;
=item $foundry->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $foundry->session();
# Set
my $newsession = new SNMP::Session(...);
$foundry->session($newsession);
=back
=head1 GLOBAL VALUES
=head2 Required MIBs
=over
=item FOUNDRY-SN-ROOT-MIB
=item Inherited Classes' MIBs
See classes listed above for their required MIBs.
=back
The Foundry MIBS can be downloaded from www.mibdepot.com and ??
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=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 then parses out xxNNNN
=item $foundry->vendor()
Returns 'foundry' :)
Returns 'foundry' :)
=item $foundry->mac()
Returns MAC Address of root port.
Returns MAC Address of root port.
(B<ifPhysAddress.1>)
(B<ifPhysAddress.1>)
=item $foundry->chassis()
Returns Chassis type.
Returns Chassis type.
(B<entPhysicalDescr.1>)
(B<entPhysicalDescr.1>)
=item $foundry->serial()
Returns serial number of device.
Returns serial number of device.
(B<snChasSerNum>)
(B<snChasSerNum>)
=item $foundry->temp()
Returns the chassis temperature
Returns the chassis temperature
(B<snChasActualTemperature>)
(B<snChasActualTemperature>)
=item $foundry->ps1_type()
Returns the Description for the power supply
Returns the Description for the power supply
(B<snChasPwrSupplyDescription.1>)
(B<snChasPwrSupplyDescription.1>)
=item $foundry->ps1_status()
Returns the status of the power supply.
Returns the status of the power supply.
(B<snChasPwrSupplyOperStatus.1>)
(B<snChasPwrSupplyOperStatus.1>)
=item $foundry->fan()
Returns the status of the chassis fan.
Returns the status of the chassis fan.
(B<snChasFanOperStatus.1>)
(B<snChasFanOperStatus.1>)
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $foundry->interfaces()
Returns reference to hash of interface names to iids.
Returns reference to hash of interface names to iids.
Uses B<ifDescr>.
Uses B<ifDescr>.
=item $foundry->i_name()
Returns reference to hash of interface names.
Trys for B<ifAlias> and Defaults to B<ifName>
Returns reference to hash of interface names.
Trys for B<ifAlias> and Defaults to B<ifName>
=item $foundry->i_ignore()
Returns reference to hash of interfaces to be ignored.
Returns reference to hash of interfaces to be ignored.
Ignores interfaces with descriptions of tunnel,loopback,null
Ignores interfaces with descriptions of tunnel,loopback,null
=item $foundry->i_duplex()
Returns reference to hash of interface link duplex status.
Returns reference to hash of interface link duplex status.
Crosses $foundry->sw_duplex() with $foundry->sw_index()
Crosses $foundry->sw_duplex() with $foundry->sw_index()
=item $foundry->i_type()
Returns reference to hash of interface types.
Crosses $foundry->sw_type() with $foundry->sw_index()
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 .
Returns reference to hash of interface speeds .
Crosses $foundry->sw_speeD() with $foundry->sw_index() and
does a little munging.
Crosses $foundry->sw_speeD() with $foundry->sw_index() and
does a little munging.
=back
@@ -377,21 +428,21 @@ Sets or returns the SNMP::Session object
=item $foundry->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
(B<ipNetToMediaIfIndex>)
=item $foundry->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
(B<ipNetToMediaPhysAddress>)
=item $foundry->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
(B<ipNetToMediaNetAddress>)
=back
@@ -401,28 +452,32 @@ Sets or returns the SNMP::Session object
=item $foundry->sw_index()
Returns reference to hash. Maps Table to Interface IID.
Returns reference to hash. Maps Table to Interface IID.
(B<snSwPortIfIndex>)
(B<snSwPortIfIndex>)
=item $foundry->sw_duplex()
Returns reference to hash. Current duplex status for switch ports.
Returns reference to hash. Current duplex status for switch ports.
(B<snSwPortInfoChnMode>)
(B<snSwPortInfoChnMode>)
=item $foundry->sw_type()
Returns reference to hash. Current Port Type .
Returns reference to hash. Current Port Type .
(B<snSwPortInfoMediaType>)
(B<snSwPortInfoMediaType>)
=item $foundry->sw_speed()
Returns reference to hash. Current Port Speed.
Returns reference to hash. Current Port Speed.
(B<snSwPortInfoSpeed>)
(B<snSwPortInfoSpeed>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=cut

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

@@ -0,0 +1,179 @@
# SNMP::Info::Layer3::Juniper
# 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::Juniper;
# $Id$
use Exporter;
use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Juniper::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::Layer3::MIBS,
'JUNIPER-CHASSIS-DEFINES-MIB' => 'jnxChassisDefines',
'JUNIPER-MIB' => 'jnxBoxAnatomy',
);
%GLOBALS = (
%SNMP::Info::Layer3::GLOBALS,
'serial' => 'jnxBoxSerialNo.0',
);
%FUNCS = (
%SNMP::Info::Layer3::FUNCS,
);
%MUNGE = (
%SNMP::Info::Layer3::MUNGE,
);
sub vendor {
return 'juniper';
}
sub os {
return 'junos';
}
sub os_ver {
my $juniper = shift;
my $descr = $juniper->description();
return undef unless defined $descr;
if ($descr =~ m/kernel JUNOS (\S+)/) {
return $1;
}
return undef;
}
sub model {
my $l3 = shift;
my $id = $l3->id();
unless (defined $id){
print " SNMP::Info::Layer3::Juniper::model() - Device does not support sysObjectID\n" if $l3->debug();
return undef;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^jnxProductName//i;
return $model;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Juniper - Perl5 Interface to L3 Juniper Devices
=head1 AUTHOR
Bill Fenner
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $juniper = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# 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 = $juniper->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Subclass for Generic Juniper Routers running JUNOS
=head2 Inherited Classes
=over
=item SNMP::Info::Layer3
=back
=head2 Required MIBs
=over
=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 $juniper->vendor()
Returns 'juniper'
=item $juniper->os()
Returns 'junos'
=item $juniper->os_ver()
Returns the software version extracted from sysDescr.
=item $juniper->model()
Returns the model from sysObjectID, with jnxProductName
removed from the beginning.
=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.
=cut

320
Info/Layer3/N1600.pm Normal file
View File

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

710
Info/Layer3/Passport.pm Normal file
View File

@@ -0,0 +1,710 @@
# SNMP::Info::Layer3::Passport
# Eric Miller
# $Id$
#
# Copyright (c) 2004 Eric Miller, Max Baker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Passport;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
use SNMP::Info::RapidCity;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::Passport::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::RapidCity Exporter/;
@SNMP::Info::Layer3::Passport::EXPORT_OK = qw//;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::SONMP::MIBS,
%SNMP::Info::RapidCity::MIBS,
'OSPF-MIB' => 'ospfRouterId',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
%SNMP::Info::RapidCity::GLOBALS,
'router_ip' => 'ospfRouterId'
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::SONMP::FUNCS,
%SNMP::Info::RapidCity::FUNCS,
'i_index2' => 'ifIndex',
'i_mac2' => 'ifPhysAddress',
'i_description2' => 'ifDescr',
'i_name2' => 'ifName',
'ip_index2' => 'ipAdEntIfIndex',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
'i_name2' => 'ifName'
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::SONMP::MUNGE,
%SNMP::Info::RapidCity::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub model {
my $passport = shift;
my $id = $passport->id();
unless (defined $id){
print " SNMP::Info::Layer3::Passport::model() - Device does not support sysObjectID\n" if $passport->debug();
return undef;
}
my $model = &SNMP::translateObj($id);
return $id unless defined $model;
$model =~ s/^rcA//i;
return $model;
}
sub vendor {
return 'nortel';
}
sub os {
return 'passport';
}
sub os_ver {
my $passport = shift;
my $descr = $passport->description();
return undef unless defined $descr;
#Passport
if ($descr =~ m/(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
#Accelar
if ($descr =~ m/(\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub i_index {
my $passport = shift;
my $model = $passport->model();
my $i_index = $passport->i_index2();
my $vlan_index = $passport->rc_vlan_if();
my $cpu_index = $passport->rc_cpu_ifindex();
my $virt_ip = $passport->rc_virt_ip();
my %if_index;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
$if_index{$iid} = $index;
}
# Get VLAN Virtual Router Interfaces
foreach my $vid (keys %$vlan_index){
my $v_index = $vlan_index->{$vid};
next unless defined $v_index;
next if $v_index == 0;
$if_index{$v_index} = $v_index;
}
if (defined $model and $model =~ /(86)/) {
# Get CPU Ethernet Interfaces
foreach my $cid (keys %$cpu_index){
my $c_index = $cpu_index->{$cid};
next unless defined $c_index;
next if $c_index == 0;
$if_index{$c_index} = $c_index;
}
# Check for Virtual Mgmt Interface
unless ($virt_ip eq '0.0.0.0') {
# Make up an index number, 1 is not reserved AFAIK
$if_index{1} = 1;
}
}
return \%if_index;
}
sub interfaces {
my $passport = shift;
my $model = $passport->model();
my $index_factor = $passport->index_factor();
my $port_offset = $passport->port_offset();
my $i_index = $passport->i_index();
my $vlan_id = $passport->rc_vlan_id();
my $vlan_index = $passport->rc_vlan_if();
my %reverse_vlan = reverse %$vlan_index;
my %if;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if (($index == 1) and ($model =~ /(86)/)) {
$if{$index} = 'Cpu.Virtual';
}
elsif (($index == 192) and ($model eq '8603')) {
$if{$index} = 'Cpu.3';
}
elsif (($index == 320) and ($model =~ /(8606|8610|8610co)/)) {
$if{$index} = 'Cpu.5';
}
elsif (($index == 384) and ($model =~ /(8606|8610|8610co)/)) {
$if{$index} = 'Cpu.6';
}
elsif (($index > 2000 and $model =~ /(86|81)/) or
($index > 256 and $model =~ /(105|11|12)/)) {
my $vlan_index = $reverse_vlan{$iid};
my $v_id = $vlan_id->{$vlan_index};
next unless defined $v_id;
my $v_port = 'Vlan'."$v_id";
$if{$index} = $v_port;
}
else {
my $port = ($index % $index_factor) + $port_offset;
my $slot = int($index / $index_factor);
my $slotport = "$slot.$port";
$if{$iid} = $slotport;
}
}
return \%if;
}
sub i_mac {
my $passport = shift;
my $model = $passport->model();
my $i_mac = $passport->i_mac2();
my $vlan_mac = $passport->rc_vlan_mac();
my $vlan_index = $passport->rc_vlan_if();
my $cpu_mac = $passport->rc_cpu_mac();
my $chassis_base_mac = $passport->rc_base_mac();
my $virt_ip = $passport->rc_virt_ip();
my %if_mac;
foreach my $iid (keys %$i_mac){
my $mac = $i_mac->{$iid};
next unless defined $mac;
$if_mac{$iid} = $mac;
}
# Get VLAN Virtual Router Interfaces
foreach my $iid (keys %$vlan_mac){
my $v_mac = $vlan_mac->{$iid};
my $v_id = $vlan_index->{$iid};
next unless defined $v_mac;
$if_mac{$v_id} = $v_mac;
}
if (defined $model and $model =~ /(86)/) {
# Get CPU Ethernet Interfaces
foreach my $iid (keys %$cpu_mac){
my $mac = $cpu_mac->{$iid};
next unless defined $mac;
$if_mac{$iid} = $mac;
}
# Check for Virtual Mgmt Interface
unless ($virt_ip eq '0.0.0.0'){
my @virt_mac = split /:/, $chassis_base_mac;
$virt_mac[0] = hex($virt_mac[0]);
$virt_mac[1] = hex($virt_mac[1]);
$virt_mac[2] = hex($virt_mac[2]);
$virt_mac[3] = hex($virt_mac[3]);
$virt_mac[4] = hex($virt_mac[4]) + 0x03;
$virt_mac[5] = hex($virt_mac[5]) + 0xF8;
my $mac = join(':',map { sprintf "%02x",$_ } @virt_mac);
$if_mac{1} = $mac;
}
}
return \%if_mac;
}
sub i_description {
my $passport = shift;
my $i_descr = $passport->i_description2();
my $v_descr = $passport->rc_vlan_name();
my $vlan_index = $passport->rc_vlan_if();
my %descr;
foreach my $iid (keys %$i_descr){
my $if_descr = $i_descr->{$iid};
next unless defined $if_descr;
$descr{$iid} = $if_descr;
}
# Get VLAN Virtual Router Interfaces
foreach my $vid (keys %$v_descr){
my $vl_descr = $v_descr->{$vid};
my $v_id = $vlan_index->{$vid};
next unless defined $vl_descr;
$descr{$v_id} = $vl_descr;
}
return \%descr;
}
sub i_name {
my $passport = shift;
my $model = $passport->model();
my $i_index = $passport->i_index();
my $rc_alias = $passport->rc_alias();
my $i_name2 = $passport->i_name2();
my $v_name = $passport->rc_vlan_name();
my $vlan_index = $passport->rc_vlan_if();
my %reverse_vlan = reverse %$vlan_index;
my %i_name;
foreach my $iid (keys %$i_index){
if (($iid == 1) and ($model =~ /(86)/)) {
$i_name{$iid} = 'CPU Virtual Management IP';
}
elsif (($iid == 192) and ($model eq '8603')) {
$i_name{$iid} = 'CPU 3 Ethernet Port';
}
elsif (($iid == 320) and ($model =~ /(8606|8610|8610co)/)) {
$i_name{$iid} = 'CPU 5 Ethernet Port';
}
elsif (($iid == 384) and ($model =~ /(8606|8610|8610co)/)) {
$i_name{$iid} = 'CPU 6 Ethernet Port';
}
elsif (($iid > 2000 and defined $model and $model =~ /(86|81)/) or
($iid > 256 and defined $model and $model =~ /(105|11|12)/)) {
my $vlan_index = $reverse_vlan{$iid};
my $vlan_name = $v_name->{$vlan_index};
next unless defined $vlan_name;
$i_name{$iid} = $vlan_name;
}
else {
my $name = $i_name2->{$iid};
my $alias = $rc_alias->{$iid};
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ?
$alias :
$name;
}
}
return \%i_name;
}
sub ip_index {
my $passport = shift;
my $model = $passport->model();
my $ip_index = $passport->ip_index2();
my $cpu_ip = $passport->rc_cpu_ip();
my $virt_ip = $passport->rc_virt_ip();
my %ip_index;
foreach my $ip (keys %$ip_index){
my $iid = $ip_index->{$ip};
next unless defined $iid;
$ip_index{$ip} = $iid;
}
# Only 8600 has CPU and Virtual Management IP
if (defined $model and $model =~ /(86)/) {
# Get CPU Ethernet IP
foreach my $cid (keys %$cpu_ip){
my $c_ip = $cpu_ip->{$cid};
next unless defined $c_ip;
$ip_index{$c_ip} = $cid;
}
# Get Virtual Mgmt IP
$ip_index{$virt_ip} = 1;
}
return \%ip_index;
}
sub root_ip {
my $passport = shift;
my $model = $passport->model();
my $rc_ip_addr = $passport->rc_ip_addr();
my $rc_ip_type = $passport->rc_ip_type();
my $virt_ip = $passport->rc_virt_ip();
my $router_ip = $passport->router_ip();
my $sonmp_topo_port = $passport->sonmp_topo_port();
my $sonmp_topo_ip = $passport->sonmp_topo_ip();
# Only 8600 has CLIP or Management Virtual IP
if (defined $model and $model =~ /(86)/) {
# Return CLIP (CircuitLess IP)
foreach my $iid (keys %$rc_ip_type){
my $ip_type = $rc_ip_type->{$iid};
next unless ((defined $ip_type) and ($ip_type =~ /circuitLess/i));
my $ip = $rc_ip_addr->{$iid};
next unless defined $ip;
return $ip if $passport->snmp_connect_ip($ip);
}
# Return Management Virtual IP address
if ( (defined $virt_ip) and ($virt_ip ne '0.0.0.0') ) {
return $virt_ip if $passport->snmp_connect_ip($virt_ip);
}
}
# Return OSPF Router ID
if ((defined $router_ip) and ($router_ip ne '0.0.0.0')) {
foreach my $iid (keys %$rc_ip_addr){
my $ip = $rc_ip_addr->{$iid};
next unless $router_ip eq $ip;
return $router_ip if $passport->snmp_connect_ip($router_ip);
}
}
# Otherwise Return SONMP Advertised IP Address
foreach my $entry (keys %$sonmp_topo_port){
my $port = $sonmp_topo_port->{$entry};
next unless $port == 0;
my $ip = $sonmp_topo_ip->{$entry};
return $ip if ( (defined $ip) and ($ip ne '0.0.0.0') and ($passport->snmp_connect_ip($ip)) );
}
return undef;
}
# Required for SNMP::Info::SONMP
sub index_factor {
my $passport = shift;
my $model = $passport->model();
my $index_factor = 64;
# Older Accelar models use base 16 instead of 64
$index_factor = 16 if (defined $model and $model =~ /(105|11|12)/);
return $index_factor;
}
sub slot_offset {
return 0;
}
sub port_offset {
return 1;
}
# Bridge MIB does not map Bridge Port to ifIndex correctly
sub bp_index {
my $passport = shift;
my $if_index = $passport->i_index();
my %bp_index;
foreach my $iid (keys %$if_index){
$bp_index{$iid} = $iid;
}
return \%bp_index;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Passport - Perl5 Interface to modular Nortel Ethernet Routing
Switches (formerly Passport / Accelar)
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $passport = 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 = $passport->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for modular Nortel Ethernet Routing Switches (formerly
Passport and Accelar Series Switches).
These devices have some of the same charactersitics as the stackable Nortel
Ethernet Switches (Baystack). For example, extended interface information is
gleened from RAPID-CITY.
For speed or debugging purposes you can call the subclass directly, but not after
determining a more specific class using the method above.
my $passport = new SNMP::Info::Layer3::Passport(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::SONMP
=item SNMP::Info::RapidCity
=back
=head2 Required MIBs
=over
=item OSPF-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::SONMP for its own MIB requirements.
See SNMP::Info::RapidCity for its own MIB requirements.
OSPF-MIB is included in the archive at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $passport->model()
Returns model type. Checks $passport->id() against the
RAPID-CITY-MIB and then parses out rcA.
=item $passport->vendor()
Returns 'nortel'
=item $passport->os()
Returns 'passport'
=item $passport->os_ver()
Returns the software version extracted from B<sysDescr>
=item $passport->serial()
Returns (B<rcChasSerialNumber>)
=item $passport->root_ip()
Returns the primary IP used to communicate with the device. Returns the first
found: CLIP (CircuitLess IP), Management Virtual IP (B<rcSysVirtualIpAddr>),
OSPF Router ID (B<ospfRouterId>), SONMP Advertised IP Address.
=back
=head2 Overrides
=over
=item $passport->index_factor()
Required by SNMP::Info::SONMP. Returns 64 for 8600, 16 for Accelar.
=item $passport->port_offset()
Required by SNMP::Info::SONMP. Returns 1.
=item $passport->slot_offset()
Required by SNMP::Info::SONMP. Returns 0.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
=head2 Global Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $passport->i_index()
Returns SNMP IID to Interface index. Extends (B<ifIndex>) by adding the index of
the CPU virtual management IP (if present), each CPU Ethernet port, and each VLAN
to ensure the virtual router ports are captured.
=item $passport->interfaces()
Returns reference to the map between IID and physical Port.
Slot and port numbers on the Passport switches are determined by the formula:
port = (ifIndex % index_factor) + port_offset, slot = int(ifIndex / index_factor).
The physical port name is returned as slot.port. CPU Ethernet ports are prefixed
with CPU and VLAN interfaces are returned as the VLAN ID prefixed with Vlan.
=item $passport->i_mac()
MAC address of the interface. Note this is just the MAC of the port, not anything
connected to it.
=item $passport->i_description()
Description of the interface. Usually a little longer single word name that is both
human and machine friendly. Not always.
=item $passport->i_name()
Crosses rc_alias() (B<rcPortName>) with ifAlias() and returns the human set port
name if exists.
=item $passport->ip_index()
Maps the IP Table to the IID. Extends (B<ipAdEntIfIndex>) by adding the index of
the CPU virtual management IP (if present) and each CPU Ethernet port.
=item $passport->bp_index()
Returns reference to hash of bridge port table entries map back to interface identifier (iid)
Returns (B<ifIndex>) for both key and value since some devices seem to have
problems with BRIDGE-MIB
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $passport->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $passport->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $passport->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.
=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.
=head2 Table Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
=cut

View File

@@ -1,7 +1,9 @@
# SNMP::Info::MAU - Media Access Unit - RFC2668
# Max Baker <max@warped.org>
# SNMP::Info::MAU - Media Access Unit - RFC 2668
# Max Baker
#
# Copyright (c) 2002, Regents of the University of California
# 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.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +30,8 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::MAU;
$VERSION = 0.1;
$VERSION = 1.0;
# $Id$
use strict;
@@ -39,11 +42,6 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::MAU::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$INIT = 0;
%MIBS = ('MAU-MIB' => 'mauMod');
%GLOBALS = (
@@ -102,68 +100,206 @@ sub _ishalfduplex{
return 0;
}
my %_mau_i_speed_map = (
'10' => '10 Mbps',
'100' => '100 Mbps',
'1000' => '1.0 Gbps',
'10Gig' => '10 Gbps',
);
sub mau_i_speed_admin {
my $mau = shift;
my $mau_index = $mau->mau_index();
my $mau_type_admin = $mau->mau_type_admin();
my %i_speed_admin;
foreach my $mau_port (keys %$mau_type_admin){
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $type_adminoid = $mau_type_admin->{$mau_port};
my $type_admin = &SNMP::translateObj($type_adminoid);
next unless defined $type_admin;
if ($type_adminoid eq '.0.0') {
$i_speed_admin{$iid} = 'auto';
} elsif ($type_admin =~ /^dot3MauType(.*)Base/ && $_mau_i_speed_map{$1}) {
$i_speed_admin{$iid} = $_mau_i_speed_map{$1};
}
}
return \%i_speed_admin;
}
sub mau_i_duplex {
my $mau = shift;
my $mau_index = $mau->mau_index();
my $mau_link = $mau->mau_link();
my %i_duplex;
foreach my $mau_port (keys %$mau_link){
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $linkoid = $mau_link->{$mau_port};
my $link = &SNMP::translateObj($linkoid);
next unless defined $link;
my $duplex = undef;
if ($link =~ /fd$/i) {
$duplex = 'full';
} elsif ($link =~ /hd$/i){
$duplex = 'half';
}
$i_duplex{$iid} = $duplex if defined $duplex;
}
return \%i_duplex;
}
sub mau_i_duplex_admin {
my $mau = shift;
my $mau_index = $mau->mau_index();
my $mau_autostat = $mau->mau_autostat();
my $mau_type_admin = $mau->mau_type_admin();
# Older HP4000's don't implement ifMauDefaultType, but we can
# figure out from ifMauAutoNegCapAdvertised what we'd like.
if (!defined($mau_type_admin)) {
return mau_i_duplex_admin_old($mau,$mau_index,$mau_autostat);
}
my %i_duplex_admin;
foreach my $mau_port (keys %$mau_type_admin){
my $iid = $mau_index->{$mau_port};
next unless defined $iid;
my $autostat = $mau_autostat->{$mau_port};
if (defined $autostat and $autostat =~ /enabled/i){
$i_duplex_admin{$iid} = 'auto';
next;
}
my $type_adminoid = $mau_type_admin->{$mau_port};
my $type_admin = &SNMP::translateObj($type_adminoid);
next unless defined $type_admin;
my $duplex = undef;
if ($type_admin =~ /fd$/i) {
$duplex = 'full';
} elsif ($type_admin =~ /hd$/i){
$duplex = 'half';
}
$i_duplex_admin{$iid} = $duplex if defined $duplex;
}
return \%i_duplex_admin;
}
sub mau_i_duplex_admin_old {
my $mau = shift;
my $mau_index = shift;
my $mau_autostat = shift;
my $interfaces = $mau->interfaces();
my $mau_autosent = $mau->mau_autosent();
my %mau_reverse = reverse %$mau_index;
my %i_duplex_admin;
foreach my $iid (keys %$interfaces){
my $mau_index = $mau_reverse{$iid};
next unless defined $mau_index;
my $autostat = $mau_autostat->{$mau_index};
# HP25xx has this value
if (defined $autostat and $autostat =~ /enabled/i){
$i_duplex_admin{$iid} = 'auto';
next;
}
my $type = $mau_autosent->{$mau_index};
next unless defined $type;
if ($type == 0) {
$i_duplex_admin{$iid} = 'none';
next;
}
my $full = $mau->_isfullduplex($type);
my $half = $mau->_ishalfduplex($type);
if ($full and !$half){
$i_duplex_admin{$iid} = 'full';
} elsif ($half) {
$i_duplex_admin{$iid} = 'half';
}
}
return \%i_duplex_admin;
}
1;
__END__
=head1 NAME
SNMP::Info::MAU - Perl5 Interface to SNMP Medium Access Unit (MAU) MIB (RFC2668)
=head1 DESCRIPTION
MAU-MIB is used by Layer 2 devices like HP Switches . The MAU table
contains link and duplex info for the port itself and the device
connected to that port.
Inherits all methods from SNMP::Info
SNMP::Info::MAU - Perl5 Interface to Medium Access Unit (MAU) MIB (RFC 2668) via SNMP
=head1 AUTHOR
Max Baker (C<max@warped.org>)
Max Baker
=head1 SYNOPSIS
my $mau = new SNMP::Info::MAU( DestHost => 'myswitch',
Community => 'public');
my $mau = new SNMP::Info (
AutoSpecify => 1,
Debug => 1,
DestHost => 'hpswitch',
Community => 'public',
Version => 2
);
my $class = $mau->class();
print " Using device sub class : $class\n";
=head1 CREATING AN OBJECT
=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.
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.
For debugging purposes call the class directly as you would SNMP::Info
my $mau = new SNMP::Info::MAU(...);
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item new SNMP::Info::MAU()
Arguments passed to new() are passed on to SNMP::Session::new()
my $mau = new SNMP::Info::MAU(
DestHost => $host,
Community => 'public',
Version => 3,...
)
die "Couldn't connect.\n" unless defined $mau;
=item $mau->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $mau->session();
# Set
my $newsession = new SNMP::Session(...);
$mau->session($newsession);
=item $mau->all(), $mau->load_all()
Queries each of the methods listed in %FUNCS and returns a hash reference.
$mau->all() will call $mau->load_all() once and then return cahced valued.
Use $mau->load_all() to reload from the device.
=item MAU-MIB
=back
=head1 MAU Global Configuration Values
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
@@ -171,7 +307,37 @@ Use $mau->load_all() to reload from the device.
=back
=head1 MAU INTERFACE TABLE ENTRIES
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $mau->mau_i_duplex()
Parses mau_index and mau_link to return the duplex information for
interfaces.
=item $mau->mau_i_duplex_admin()
Parses C<mac_index>,C<mau_autostat>,C<mau_type_admin> in
order to find the admin duplex setting for all the interfaces.
Returns either (auto,full,half).
=item $mau->mau_i_duplex_admin_old()
Called by mau_i_duplex_admin() if C<mau_type_admin> is empty.
Parses C<mau_index>,C<mau_autostat>,C<mau_autosent> in
order to find the admin duplex setting for all the interfaces.
Returns either (auto,none,full,half).
=back
=head2 MAU INTERFACE TABLE ENTRIES
=over
@@ -233,10 +399,18 @@ of the port from a MAU POV.
(B<ifMauTypeList>)
=item $mau->mau_type_admin()
(C<ifMauDefaultType>)
=item $mau->mau_auto() - Returns status of auto-negotiation mode for ports.
(B<ifMauAutoNegAdminStatus>)
=item $mau->mau_autostat()
(C<ifMauAutoNegAdminStatus>)
=item $mau->mau_autosent() - Returns a 32 bit bit-string representing the
capabilities we are broadcasting on that port
@@ -271,4 +445,5 @@ capabilities of the device on the other end.
high. Currently bits 10,12,15,17,19.
=back
=cut

386
Info/NortelStack.pm Normal file
View File

@@ -0,0 +1,386 @@
# SNMP::Info::NortelStack
# Eric Miller
# $Id$
#
# Copyright (c) 2004-6 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:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::NortelStack;
$VERSION = 1.0;
use strict;
use Exporter;
use SNMP::Info;
@SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::NortelStack::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
%MIBS = (
# S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below
'S5-AGENT-MIB' => 's5AgMyGrpIndx',
'S5-CHASSIS-MIB' => 's5ChasType',
);
%GLOBALS = (
# From S5-AGENT-MIB
'ns_ag_ver' => 's5AgInfoVer',
'ns_op_mode' => 's5AgSysCurrentOperationalMode',
'ns_auto_pvid' => 's5AgSysAutoPvid',
'tftp_host' => 's5AgSysTftpServerAddress',
'tftp_file' => 's5AgSysBinaryConfigFilename',
'tftp_action' => 's5AgInfoFileAction',
'tftp_result' => 's5AgInfoFileStatus',
'vlan' => 's5AgSysManagementVlanId',
# From S5-CHASSIS-MIB
'serial' => 's5ChasSerNum',
'ns_cfg_chg' => 's5ChasGblConfChngs',
'ns_cfg_time' => 's5ChasGblConfLstChng',
);
%FUNCS = (
# From S5-AGENT-MIB::s5AgMyIfTable
'i_cfg_file' => 's5AgMyIfCfgFname',
'i_cfg_host' => 's5AgMyIfLdSvrAddr',
# From S5-CHASSIS-MIB::s5ChasComTable
'ns_com_grp_idx' => 's5ChasComGrpIndx',
'ns_com_ns_com_idx'=> 's5ChasComIndx',
'ns_com_sub_idx' => 's5ChasComSubIndx',
'ns_com_type' => 's5ChasComType',
'ns_com_descr' => 's5ChasComDescr',
'ns_com_ver' => 's5ChasComVer',
'ns_com_serial' => 's5ChasComSerNum',
# From S5-CHASSIS-MIB::s5ChasStoreTable
'ns_store_grp_idx' => 's5ChasStoreGrpIndx',
'ns_store_ns_com_idx' => 's5ChasStoreComIndx',
'ns_store_sub_idx' => 's5ChasStoreSubIndx',
'ns_store_idx' => 's5ChasStoreIndx',
'ns_store_type' => 's5ChasStoreType',
'ns_store_size' => 's5ChasStoreCurSize',
'ns_store_ver' => 's5ChasStoreCntntVer',
);
%MUNGE = (
);
sub os_ver {
my $bayhub = shift;
my $ver = $bayhub->ns_ag_ver();
return undef unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
if ($ver =~ m/V(\d+\.\d+\.\d+)/i){
return $1;
}
return undef;
}
sub os_bin {
my $bayhub = shift;
my $ver = $bayhub->ns_ag_ver();
return undef unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/i){
return $1;
}
if ($ver =~ m/V(\d+\.\d+.\d+)/i){
return $1;
}
return undef;
}
1;
__END__
=head1 NAME
SNMP::Info::NortelStack - Perl5 Interface to Nortel Stack information using SNMP
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $stack = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $stack->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::NortelStack is a subclass of SNMP::Info that provides an interface
to C<S5-AGENT-MIB> and C<S5-CHASSIS-MIB>. These MIBs are used across the
Nortel Stackable Ethernet Switches (BayStack), as well as, older Nortel devices
such as the Centillion family of ATM switches.
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item S5-AGENT-MIB
=item S5-CHASSIS-MIB
=item S5-ROOT-MIB and S5-TCS-MIB are required by the other MIBs.
=back
=head1 GLOBAL METHODS
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>)
=item $stack->os_bin()
Returns the firmware version extracted from (B<s5AgInfoVer>)
=item $stack->ns_ag_ver()
Returns the version of the agent in the form 'major.minor.maintenance[letters]'.
(B<s5AgInfoVer>)
=item $stack->ns_op_mode()
Returns the stacking mode.
(B<s5AgSysCurrentOperationalMode>)
=item $stack->tftp_action()
This object is used to download or upload a config file or an image file.
(B<s5AgInfoFileAction>)
=item $stack->tftp_result()
Returns the status of the latest action as shown by $stack->tftp_action().
(B<s5AgInfoFileStatus>)
=item $stack->ns_auto_pvid()
Returns the value indicating whether adding a port as a member of a VLAN
automatically results in its PVID being set to be the same as that VLAN ID.
(B<s5AgSysAutoPvid>)
=item $stack->tftp_file()
Name of the binary configuration file that will be downloaded/uploaded when
the $stack->tftp_action() object is set.
(B<s5AgSysBinaryConfigFilename>)
=item $stack->tftp_host()
The IP address of the TFTP server for all TFTP operations.
(B<s5AgSysTftpServerAddress>)
=item $stack->vlan()
Returns the VLAN ID of the system's management VLAN.
(B<s5AgSysManagementVlanId>)
=item $stack->ch_ser()
Returns the serial number of the chassis.
(B<s5ChasSerNum>)
=item $stack->ns_cfg_chg()
Returns the total number of configuration changes (other than attachment changes,
or physical additions or removals) in the chassis that have been detected since
cold/warm start.
(B<s5ChasGblConfChngs>)
=item $stack->ns_cfg_time()
Returns the value of sysUpTime when the last configuration change (other than
attachment changes, or physical additions or removals) in the chassis was
detected.
(B<s5ChasGblConfLstChng>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Agent Interface Table (s5AgMyIfTable)
=over
=item $stack->i_cfg_file()
Returns reference to hash. Key: Table entry, Value: Name of the file
(B<s5AgMyIfCfgFname>)
=item $stack->i_cfg_host()
Returns reference to hash. Key: Table entry, Value: IP address of the load server
(B<s5AgMyIfLdSvrAddr>)
=back
=head2 Chassis Components Table (s5ChasComTable)
=over
=item $stack->ns_com_grp_idx()
Returns reference to hash. Key: Table entry, Value: Index of the chassis level
group which contains this component.
(B<s5ChasComGrpIndx>)
=item $stack->ns_com_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.
(B<s5ChasComIndx>)
=item $stack->ns_com_sub_idx()
Returns reference to hash. Key: Table entry, Value: Index of the sub-component
in the component.
(B<s5ChasComSubIndx>)
=item $stack->ns_com_type()
Returns reference to hash. Key: Table entry, Value: Type
(B<s5ChasComType>)
=item $stack->ns_com_descr()
Returns reference to hash. Key: Table entry, Value: Description
(B<s5ChasComDescr>)
=item $stack->ns_com_ver()
Returns reference to hash. Key: Table entry, Value: Version
(B<s5ChasComVer>)
=item $stack->ns_com_serial()
Returns reference to hash. Key: Table entry, Value: Serial Number
(B<s5ChasComSerNum>)
=back
=head2 Storage Area Table (s5ChasStoreTable)
=over
=item $stack->ns_store_grp_idx()
Returns reference to hash. Key: Table entry, Value: Index of the chassis level
group.
(B<s5ChasStoreGrpIndx>)
=item $stack->ns_store_ns_com_idx()
Returns reference to hash. Key: Table entry, Value: Index of the group.
(B<s5ChasStoreComIndx>)
=item $stack->ns_store_sub_idx()
Returns reference to hash. Key: Table entry, Value: Index of the sub-component.
(B<s5ChasStoreSubIndx>)
=item $stack->ns_store_idx()
Returns reference to hash. Key: Table entry, Value: Index of the storage area.
(B<s5ChasStoreIndx>)
=item $stack->ns_store_type()
Returns reference to hash. Key: Table entry, Value: Type
(B<s5ChasStoreType>)
=item $stack->ns_store_size()
Returns reference to hash. Key: Table entry, Value: Size
(B<s5ChasStoreCurSize>)
=item $stack->ns_store_ver()
Returns reference to hash. Key: Table entry, Value: Version
(B<s5ChasStoreCntntVer>)
=back
=cut

689
Info/RapidCity.pm Normal file
View File

@@ -0,0 +1,689 @@
# SNMP::Info::RapidCity
# $Id$
#
# Copyright (c) 2004-6 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:
#
# * 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::RapidCity;
$VERSION = 1.0;
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/;
%MIBS = (
'RAPID-CITY' => 'rapidCity',
);
%GLOBALS = (
'serial' => 'rcChasSerialNumber',
'chassis' => 'rcChasType',
'slots' => 'rcChasNumSlots',
'tftp_host' => 'rcTftpHost',
'tftp_file' => 'rcTftpFile',
'tftp_action' => 'rcTftpAction',
'tftp_result' => 'rcTftpResult',
'rc_ch_rev' => 'rcChasHardwareRevision',
'rc_base_mac' => 'rc2kChassisBaseMacAddr',
'rc_virt_ip' => 'rcSysVirtualIpAddr',
);
%FUNCS = (
# From RAPID-CITY::rcPortTable
'rc_index' => 'rcPortIndex',
'rc_duplex' => 'rcPortOperDuplex',
'rc_duplex_admin' => 'rcPortAdminDuplex',
'rc_speed_admin' => 'rcPortAdminSpeed',
'rc_auto' => 'rcPortAutoNegotiate',
'rc_alias' => 'rcPortName',
# From RAPID-CITY::rc2kCpuEthernetPortTable
'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex',
'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus',
'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus',
'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr',
'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate',
'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex',
'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex',
'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed',
'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed',
'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr',
# From RAPID-CITY::rcVlanPortTable
'rc_i_vlan_if' => 'rcVlanPortIndex',
'rc_i_vlan_num' => 'rcVlanPortNumVlanIds',
'rc_i_vlan' => 'rcVlanPortVlanIds',
'rc_i_vlan_type' => 'rcVlanPortType',
'rc_i_vlan_pvid' => 'rcVlanPortDefaultVlanId',
'rc_i_vlan_tag' => 'rcVlanPortPerformTagging',
# From RAPID-CITY::rcVlanTable
'rc_vlan_id' => 'rcVlanId',
'rc_vlan_name' => 'rcVlanName',
'rc_vlan_color' => 'rcVlanColor',
'rc_vlan_if' => 'rcVlanIfIndex',
'rc_vlan_stg' => 'rcVlanStgId',
'rc_vlan_type' => 'rcVlanType',
'rc_vlan_members' => 'rcVlanPortMembers',
'rc_vlan_mac' => 'rcVlanMacAddress',
# From RAPID-CITY::rcIpAddrTable
'rc_ip_index' => 'rcIpAdEntIfIndex',
'rc_ip_addr' => 'rcIpAdEntAddr',
'rc_ip_type' => 'rcIpAdEntIfType',
# From RAPID-CITY::rcChasFanTable
'rc_fan_op' => 'rcChasFanOperStatus',
# From RAPID-CITY::rcChasPowerSupplyTable
'rc_ps_op' => 'rcChasPowerSupplyOperStatus',
# From RAPID-CITY::rcChasPowerSupplyDetailTable
'rc_ps_type' => 'rcChasPowerSupplyDetailType',
'rc_ps_serial' => 'rcChasPowerSupplyDetailSerialNumber',
'rc_ps_rev' => 'rcChasPowerSupplyDetailHardwareRevision',
'rc_ps_part' => 'rcChasPowerSupplyDetailPartNumber',
'rc_ps_detail' => 'rcChasPowerSupplyDetailDescription',
# From RAPID-CITY::rcCardTable
'rc_c_type' => 'rcCardType',
'rc_c_serial' => 'rcCardSerialNumber',
'rc_c_rev' => 'rcCardHardwareRevision',
'rc_c_part' => 'rcCardPartNumber',
# From RAPID-CITY::rc2kCardTable
'rc2k_c_ftype' => 'rc2kCardFrontType',
'rc2k_c_fdesc' => 'rc2kCardFrontDescription',
'rc2k_c_fserial' => 'rc2kCardFrontSerialNum',
'rc2k_c_frev' => 'rc2kCardFrontHwVersion',
'rc2k_c_fpart' => 'rc2kCardFrontPartNumber',
'rc2k_c_fdate' => 'rc2kCardFrontDateCode',
'rc2k_c_fdev' => 'rc2kCardFrontDeviations',
'rc2k_c_btype' => 'rc2kCardBackType',
'rc2k_c_bdesc' => 'rc2kCardBackDescription',
'rc2k_c_bserial' => 'rc2kCardBackSerialNum',
'rc2k_c_brev' => 'rc2kCardBackHwVersion',
'rc2k_c_bpart' => 'rc2kCardBackPartNumber',
'rc2k_c_bdate' => 'rc2kCardBackDateCode',
'rc2k_c_bdev' => 'rc2kCardBackDeviations',
# From RAPID-CITY::rc2kMdaCardTable
'rc2k_mda_type' => 'rc2kMdaCardType',
'rc2k_mda_desc' => 'rc2kMdaCardDescription',
'rc2k_mda_serial' => 'rc2kMdaCardSerialNum',
'rc2k_mda_rev' => 'rc2kMdaCardHwVersion',
'rc2k_mda_part' => 'rc2kMdaCardPartNumber',
'rc2k_mda_date' => 'rc2kMdaCardDateCode',
'rc2k_mda_dev' => 'rc2kMdaCardDeviations',
);
%MUNGE = (
'rc_base_mac' => \&SNMP::Info::munge_mac,
'rc_vlan_mac' => \&SNMP::Info::munge_mac,
'rc_cpu_mac' => \&SNMP::Info::munge_mac,
);
sub i_duplex {
my $rapidcity = 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 %i_duplex;
foreach my $if (keys %$interfaces){
my $duplex = $rc_duplex->{$if};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if}=$duplex;
}
# Get CPU Ethernet Interfaces for 8600 Series
foreach my $iid (keys %$rc_cpu_duplex){
my $c_duplex = $rc_cpu_duplex->{$iid};
next unless defined $c_duplex;
$i_duplex{$iid} = $c_duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $rapidcity = 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 %i_duplex_admin;
foreach my $if (keys %$interfaces){
my $duplex = $rc_duplex_admin->{$if};
next unless defined $duplex;
my $auto = $rc_auto->{$if}||'false';
my $string = 'other';
$string = 'half' if ($duplex =~ /half/i and $auto =~ /false/i);
$string = 'full' if ($duplex =~ /full/i and $auto =~ /false/i);
$string = 'auto' if $auto =~ /true/i;
$i_duplex_admin{$if}=$string;
}
# Get CPU Ethernet Interfaces for 8600 Series
foreach my $iid (keys %$rc_cpu_duplex_admin){
my $c_duplex = $rc_cpu_duplex_admin->{$iid};
next unless defined $c_duplex;
my $c_auto = $rc_cpu_auto->{$iid};
my $string = 'other';
$string = 'half' if ($c_duplex =~ /half/i and $c_auto =~ /false/i);
$string = 'full' if ($c_duplex =~ /full/i and $c_auto =~ /false/i);
$string = 'auto' if $c_auto =~ /true/i;
$i_duplex_admin{$iid} = $string;
}
return \%i_duplex_admin;
}
sub i_vlan {
my $rapidcity = 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_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);
my @vlans = ();
while($#vlanids > 0) {
my $h = join('', splice(@vlanids,0,2));
push(@vlans, hex($h));
}
my $vlans = join (',', @vlans);
$i_vlan{$if}=$vlans;
}
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};
$i_vlan{$vlan_if}=$vlan;
}
return \%i_vlan;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer2::RapidCity - SNMP Interface to the Nortel RapidCity MIB
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $rapidcity = 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 = $rapidcity->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
SNMP::Info::RapidCity is a subclass of SNMP::Info that provides an interface
to the C<RAPID-CITY> MIB. This MIB is used across the Nortel Ethernet Routing
Switch and Ethernet Switch product lines (Formerly known as Passport,
BayStack, and Acclear).
Use or create in a subclass of SNMP::Info. Do not use directly.
=head2 Inherited Classes
None.
=head2 Required MIBs
=over
=item RAPID-CITY
=back
=head1 GLOBAL METHODS
These are methods that return scalar values from SNMP
=over
=item $rapidcity->chassis_base_mac()
(B<rc2kChassisBaseMacAddr>)
=item $rapidcity->ch_serial()
(B<rcChasSerialNumber>)
=item $rapidcity->rc_ch_rev()
(B<rcChasHardwareRevision>)
=item $rapidcity->chassis()
(B<rcChasType>)
=item $rapidcity->slots()
(B<rcChasNumSlots>)
=item $rapidcity->rc_virt_ip()
(B<rcSysVirtualIpAddr>)
=item $rapidcity->tftp_host()
(B<rcTftpHost>)
=item $rapidcity->tftp_file()
(B<rcTftpFile>)
=item $rapidcity->tftp_action()
(B<rcTftpAction>)
=item $rapidcity->tftp_result()
(B<rcTftpResult>)
=back
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=over
=item $rapidcity->i_duplex()
Returns reference to map of IIDs to current link duplex.
=item $rapidcity->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting.
=item $rapidcity->i_vlan()
Returns a mapping between ifIndex and the VLAN.
=back
=head2 RAPID-CITY Port Table (B<rcPortTable>)
=over
=item $rapidcity->rc_index()
(B<rcPortIndex>)
=item $rapidcity->rc_duplex()
(B<rcPortOperDuplex>)
=item $rapidcity->rc_duplex_admin()
(B<rcPortAdminDuplex>)
=item $rapidcity->rc_speed_admin()
(B<rcPortAdminSpeed>)
=item $rapidcity->rc_auto()
(B<rcPortAutoNegotiate>)
=item $rapidcity->rc_alias()
(B<rcPortName>)
=back
=head2 RAPID-CITY CPU Ethernet Port Table (B<rc2kCpuEthernetPortTable>)
=over
=item $rapidcity->rc_cpu_ifindex()
(B<rc2kCpuEthernetPortIfIndex>)
=item $rapidcity->rc_cpu_admin()
(B<rc2kCpuEthernetPortAdminStatus>)
=item $rapidcity->rc_cpu_oper()
(B<rc2kCpuEthernetPortOperStatus>)
=item $rapidcity->rc_cpu_ip()
(B<rc2kCpuEthernetPortAddr>)
=item $rapidcity->rc_cpu_auto()
(B<rc2kCpuEthernetPortAutoNegotiate>)
=item $rapidcity->rc_cpu_duplex_admin()
(B<rc2kCpuEthernetPortAdminDuplex>)
=item $rapidcity->rc_cpu_duplex()
(B<rc2kCpuEthernetPortOperDuplex>)
=item $rapidcity->rc_cpu_speed_admin()
(B<rc2kCpuEthernetPortAdminSpeed>)
=item $rapidcity->rc_cpu_speed_oper()
(B<rc2kCpuEthernetPortOperSpeed>)
=item $rapidcity->rc_cpu_mac()
(B<rc2kCpuEthernetPortMgmtMacAddr>)
=back
=head2 RAPID-CITY VLAN Port Table (B<rcVlanPortTable>)
=over
=item $rapidcity->rc_i_vlan_if()
(B<rcVlanPortIndex>)
=item $rapidcity->rc_i_vlan_num()
(B<rcVlanPortNumVlanIds>)
=item $rapidcity->rc_i_vlan()
(B<rcVlanPortVlanIds>)
=item $rapidcity->rc_i_vlan_type()
(B<rcVlanPortType>)
=item $rapidcity->rc_i_vlan_pvid()
(B<rcVlanPortDefaultVlanId>)
=item $rapidcity->rc_i_vlan_tag()
(B<rcVlanPortPerformTagging>)
=back
=head2 RAPID-CITY VLAN Table (B<rcVlanTable>)
=over
=item $rapidcity->rc_vlan_id()
(B<rcVlanId>)
=item $rapidcity->rc_vlan_name()
(B<rcVlanName>)
=item $rapidcity->rc_vlan_color()
(B<rcVlanColor>)
=item $rapidcity->rc_vlan_if()
(B<rcVlanIfIndex>)
=item $rapidcity->rc_vlan_stg()
(B<rcVlanStgId>)
=item $rapidcity->rc_vlan_type()
(B<rcVlanType>)
=item $rapidcity->rc_vlan_members()
(B<rcVlanPortMembers>)
=item $rapidcity->rc_vlan_mac()
(B<rcVlanMacAddress>)
=back
=head2 RAPID-CITY IP Address Table (B<rcIpAddrTable>)
=over
=item $rapidcity->rc_ip_index()
(B<rcIpAdEntIfIndex>)
=item $rapidcity->rc_ip_addr()
(B<rcIpAdEntAddr>)
=item $rapidcity->rc_ip_type()
(B<rcIpAdEntIfType>)
=back
=head2 RAPID-CITY Chassis Fan Table (B<rcChasFanTable>)
=over
=item $rapidcity->rc_fan_op()
(B<rcChasFanOperStatus>)
=back
=head2 RAPID-CITY Power Supply Table (B<rcChasPowerSupplyTable>)
=over
=item $rapidcity->rc_ps_op()
(B<rcChasPowerSupplyOperStatus>)
=back
=head2 RAPID-CITY Power Supply Detail Table (B<rcChasPowerSupplyDetailTable>)
=over
=item $rapidcity->rc_ps_type()
(B<rcChasPowerSupplyDetailType>)
=item $rapidcity->rc_ps_serial()
(B<rcChasPowerSupplyDetailSerialNumber>)
=item $rapidcity->rc_ps_rev()
(B<rcChasPowerSupplyDetailHardwareRevision>)
=item $rapidcity->rc_ps_part()
(B<rcChasPowerSupplyDetailPartNumber>)
=item $rapidcity->rc_ps_detail()
(B<rcChasPowerSupplyDetailDescription>)
=back
=head2 RAPID-CITY Card Table (B<rcCardTable>)
=over
=item $rapidcity->rc_c_type()
(B<rcCardType>)
=item $rapidcity->rc_c_serial()
(B<rcCardSerialNumber>)
=item $rapidcity->rc_c_rev()
(B<rcCardHardwareRevision>)
=item $rapidcity->rc_c_part()
(B<rcCardPartNumber>)
=back
=head2 RAPID-CITY 2k Card Table (B<rc2kCardTable>)
=over
=item $rapidcity->rc2k_c_ftype()
(B<rc2kCardFrontType>)
=item $rapidcity->rc2k_c_fdesc()
(B<rc2kCardFrontDescription>)
=item $rapidcity->rc2k_c_fserial()
(B<rc2kCardFrontSerialNum>)
=item $rapidcity->rc2k_c_frev()
(B<rc2kCardFrontHwVersion>)
=item $rapidcity->rc2k_c_fpart()
(B<rc2kCardFrontPartNumber>)
=item $rapidcity->rc2k_c_fdate()
(B<rc2kCardFrontDateCode>)
=item $rapidcity->rc2k_c_fdev()
(B<rc2kCardFrontDeviations>)
=item $rapidcity->rc2k_c_btype()
(B<rc2kCardBackType>)
=item $rapidcity->rc2k_c_bdesc()
(B<rc2kCardBackDescription>)
=item $rapidcity->rc2k_c_bserial()
(B<rc2kCardBackSerialNum>)
=item $rapidcity->rc2k_c_brev()
(B<rc2kCardBackHwVersion>)
=item $rapidcity->rc2k_c_bpart()
(B<rc2kCardBackPartNumber>)
=item $rapidcity->rc2k_c_bdate()
(B<rc2kCardBackDateCode>)
=item $rapidcity->rc2k_c_bdev()
(B<rc2kCardBackDeviations>)
=back
=head2 RAPID-CITY MDA Card Table (B<rc2kMdaCardTable>)
=over
=item $rapidcity->rc2k_mda_type()
(B<rc2kMdaCardType>)
=item $rapidcity->rc2k_mda_desc()
(B<rc2kMdaCardDescription>)
=item $rapidcity->rc2k_mda_serial()
(B<rc2kMdaCardSerialNum>)
=item $rapidcity->rc2k_mda_rev()
(B<rc2kMdaCardHwVersion>)
=item $rapidcity->rc2k_mda_part()
(B<rc2kMdaCardPartNumber>)
=item $rapidcity->rc2k_mda_date()
(B<rc2kMdaCardDateCode>)
=item $rapidcity->rc2k_mda_dev()
(B<rc2kMdaCardDeviations>)
=cut

501
Info/SONMP.pm Normal file
View File

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

View File

@@ -1,22 +1,61 @@
ChangeLog
COPYRIGHT
DeviceMatrix.txt
Info.pm
Info/Airespace.pm
Info/Bridge.pm
Info/CDP.pm
Info/CiscoImage.pm
Info/CiscoQOS.pm
Info/CiscoRTT.pm
Info/CiscoStack.pm
Info/CiscoStats.pm
Info/CiscoVTP.pm
Info/Entity.pm
Info/EtherLike.pm
Info/FDP.pm
Info/Layer1.pm
Info/Layer1/Allied.pm
Info/Layer1/Asante.pm
Info/Layer1/Bayhub.pm
Info/Layer1/S3000.pm
Info/Layer2.pm
Info/Layer2/Aironet.pm
Info/Layer2/Allied.pm
Info/Layer2/Aruba.pm
Info/Layer2/Bay.pm
Info/Layer2/Baystack.pm
Info/Layer2/C1900.pm
Info/Layer2/C2900.pm
Info/Layer2/Catalyst.pm
Info/Layer2/Centillion.pm
Info/Layer2/Foundry.pm
Info/Layer2/HP.pm
Info/Layer2/N2270.pm
Info/Layer2/NAP222x.pm
Info/Layer2/Orinoco.pm
Info/Layer2/ZyXEL_DSLAM.pm
Info/Layer3.pm
Info/Layer3/Aironet.pm
Info/Layer3/AlteonAD.pm
Info/Layer3/BayRS.pm
Info/Layer3/C3550.pm
Info/Layer3/C4000.pm
Info/Layer3/C6500.pm
Info/Layer3/Cisco.pm
Info/Layer3/Contivity.pm
Info/Layer3/Extreme.pm
Info/Layer3/Foundry.pm
Info/Layer3/Juniper.pm
Info/Layer3/N1600.pm
Info/Layer3/Passport.pm
Info/MAU.pm
MANIFEST
Info/NortelStack.pm
Info/RapidCity.pm
Info/SONMP.pm
Makefile.PL
MANIFEST This list of files
README
test.pl
t/make_dev_matrix.pl
t/prereq.t
t/test_class.pl

View File

@@ -1,9 +1,16 @@
# SNMP::Info - Makefile.PL
# $Id$
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'SNMP::Info',
'VERSION_FROM' => 'Info.pm',
'PREREQ_PM' => {'SNMP' => '4'},
'PREREQ_PM' => {
'Math::BigInt' => 0
# SNMP not available on CPAN .
# Install with net-snmp.sourceforge.net
# 'SNMP' => '4'
},
($] >= 5.005 ?
(ABSTRACT_FROM => 'Info.pm',
AUTHOR => 'Max Baker <max@warped.org>')
@@ -14,5 +21,6 @@ WriteMakefile(
sub MY::postamble { "
.PHONY: readme
readme:
readme: README
README: Info.pm
pod2text -l Info.pm > README" }

1256
README

File diff suppressed because it is too large Load Diff

332
t/make_dev_matrix.pl Executable file
View File

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

81
t/prereq.t Executable file
View File

@@ -0,0 +1,81 @@
#!/usr/local/bin/perl -w
# prereq.t - Test file for prerequesites for SNMP::Info
# $Id$
use Test::More tests=> 3;
# Check for SNMP Module
my $have_snmp=0;
eval {
require SNMP;
};
if ($@){
print STDERR <<'end_snmp';
Net-SNMP not found. Net-SNMP installs the perl modules
SNMP and SNMP::Session. As of version 4.2.1 and greater the Perl
modules are no longer distributed on CPAN, as they are specific to different
versions of SNMP.
Install Net-SNMP from http://net-snmp.sourceforge.net and make sure you run
configure with the --with-perl-modules switch!
Note to Redhat Users: Redhat, in its infinite wisdom, does not install the
Perl modules as part of their 8.0 RPMS. Please uninstall them and install the
newest version by hand.
end_snmp
ok(0,'Net-SNMP not installed, or missing Perl modules.');
} else {
$have_snmp=1;
ok(1,'Net-SNMP installed');
}
# Check for version
SKIP: {
skip('SNMP not installed, no further testing',2) unless $have_snmp;
my $VERSION = $SNMP::VERSION;
ok(defined $VERSION ? 1 : 1, "found version for SNMP");
my ($ver_maj,$ver_min,$ver_rev) = split(/\./,$VERSION);
ok ($ver_maj >= 4, 'Net-SNMP ver 4 or higher');
if ($ver_maj == 4 and $ver_min == 2 and $ver_rev == 0){
print STDERR << "end_420";
SNMP module version 4.2.0 found. Please triple check that you have
version 4.2.0 of Net-SNMP installed, and that you did not accidently install
the SNMP module found on CPAN. All newer versions are bundled with
Net-SNMP, and are not available on CPAN. Please find them at
http://net-snmp.sourceforge.net . Make sure you run configure with the
--with-perl-modules switch.
end_420
}
if( $ver_maj == 5 and $ver_min == 0 and $ver_rev == 1 ){
print STDERR << "end_501";
Perl module of Net-SNMP 5.0.1 is buggy. Please upgrade.
end_501
}
}
print STDERR << "end_mibs";
Make sure you download and install the MIBS needed for SNMP::Info.
See Man page or perldoc for SNMP::Info.
end_mibs
# vim:syntax=perl

166
t/test_class.pl Executable file
View File

@@ -0,0 +1,166 @@
#!/usr/bin/perl -w
#
# test_class.pl
#
# Test a device class in SNMP::Info against a device.
#
# Max Baker
#
# $Id$
#
use lib '/usr/local/netdisco';
use SNMP::Info;
use Getopt::Long;
use strict;
use vars qw/$Class $Dev $Comm $Ver @Dump %Dumped/;
# Default Values
$Class = '';
$Dev = '';
$Comm = '';
$Ver = 2;
@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,
);
&usage unless ($Dev and $Comm);
$Class = $Class ? "SNMP::Info::$Class" : 'SNMP::Info';
eval "require $Class;";
if ($@) {
die "Can't load Class specified : $Class.\n\n$@\n";
}
print "Class $Class loaded.\n";
print "Dumping : ",join(',',@Dump),"\n" if scalar @Dump;
my $dev = new $Class( 'AutoSpecify' => 0,
'AutoVerBack' => 0,
'Version' => $Ver,
'Debug' => 0,
'DestHost' => $Dev,
'Community' => $Comm
) or die "\n";
print "Connected to $Dev.\n";
print "It's a ", $dev->device_type(), ".\n";
my $layers = $dev->layers();
unless (defined $layers){
die "Are you sure you got the right community string and version?\nCan't fetch layers.\n";
}
print "Fetching global info...\n\n";
my @globals = qw/description uptime contact name location layers ports mac serial
ps1_type ps2_type ps1_status ps2_status fan slots vendor os os_ver/;
foreach my $global (@globals){
test_global($dev,$global);
}
print "\nFetching interface info...\n\n";
my @fns = qw/interfaces i_type i_ignore i_description i_mtu i_speed i_mac i_up
i_up_admin i_name i_duplex i_duplex_admin i_stp_state
i_lastchange/;
foreach my $fn (@fns){
test_fn($dev,$fn);
}
print "\nTesting Misc...\n\n";
my @misc = qw/v_name v_port/;
foreach my $fn (@misc){
test_fn($dev,$fn);
}
foreach my $fn (@Dump) {
test_fn($dev,$fn) unless $Dumped{$fn};
}
#--------------------------------
sub test_global {
my $dev = shift;
my $method = shift;
my $value;
eval {
$value = $dev->$method();
};
if ($@){
my $err = $@;
$err =~ s/[[:cntrl:]]+/ /g;
printf "%-20s Blew up. $err\n",$method;
return 0;
}
unless (defined $value){
printf "%-20s Does not exist.\n",$method;
return 0;
}
$value =~ s/[[:cntrl:]]+/ /g;
if (length $value > 60) {
$value = substr($value,0,60);
$value .= '...';
}
printf "%-20s %s \n",$method,$value;
return 1;
}
sub test_fn {
my $dev = shift;
my $method = shift;
my $results;
eval {
$results = $dev->$method();
};
if ($@){
my $err = $@;
$err =~ s/\n/ /g;
printf "%-20s Blew up. $err\n",$method;
return 0;
}
unless (defined $results and scalar keys %$results) {
printf "%-20s Empty Results.\n",$method;
return 0;
}
printf "%-20s %d rows.\n",$method, scalar(keys %$results);
if (grep(/^$method$/,@Dump)) {
$Dumped{$method} = 1;
foreach my $iid (keys %$results){
print " $iid : $results->{$iid}\n";
}
}
return 1;
}
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
end_usage
exit;
}

17
test.pl
View File

@@ -1,17 +0,0 @@
# SNMP::Info - test.pl
#
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
#
use Test;
BEGIN { plan tests => 1 };
use SNMP::Info;
ok(1);
# If we made it this far, we're ok.
#########################
# No tests yet.
print "No test's implemented yet. \n";