diff --git a/.travis.yml b/.travis.yml index df184c42..ebd46574 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_install: - mkdir ~/netdisco-mibs - cd ~/netdisco-mibs install: - - curl -sL https://github.com/netdisco/netdisco-mibs/releases/download/4.004/netdisco-mibs.tar.gz | tar --strip-components=1 -zxf - + - curl -sL https://github.com/netdisco/netdisco-mibs/releases/download/4.007/netdisco-mibs.tar.gz | tar --strip-components=1 -zxf - - cpanm --quiet --notest PkgConfig Test::CChecker Alien::zlib::Static Alien::OpenSSL::Static Alien::SNMP::MAXTC before_script: - 'cd ${TRAVIS_BUILD_DIR}' diff --git a/Build.PL b/Build.PL index 0344b1f5..cbbd4c82 100644 --- a/Build.PL +++ b/Build.PL @@ -33,6 +33,7 @@ Module::Build->new( 'Path::Class' => '0', 'File::Slurper' => '0', 'Test::Exception' => '0.43', + 'Class::Inspector' => '0', }, # script_files => [ # ], diff --git a/Changes b/Changes index ac212b2d..d3a33d7e 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,25 @@ +Version 3.54 (2018-04-01) + + [NEW FEATURES] + * #141 Avocent ACS files for correct discovery in Netdisco + * Add support for Avocent ACS 5K/6K/8K terminal servers in Layer1::Cyclades + + [ENHANCEMENTS] + + * #215 Nokia/Alcatel-Lucent 7705 LLDP + * #220 Alcatel-Lucent / Nokia SR 7750 missing neighbors + * Improve Layer3::Timetra model detection + + [BUG FIXES] + + * Fix logic in Layer1::Asante i_up() method + * Fix MIB leaf typo in IPv6 + * Don't use MIB leafs that are not-accessible according to MIB + * Fix logic for determining if MIB leaf supports set operations + NOTE: Fixing this logic now results in methods starting with set_ on MIB + leafs without Write or Create access failing validation in + _validate_autoload_method() + Version 3.53 (2018-03-22) [NEW FEATURES] diff --git a/MANIFEST b/MANIFEST index 687e207f..1c2e3c07 100644 --- a/MANIFEST +++ b/MANIFEST @@ -145,4 +145,17 @@ xt/00_local_versionsync.t xt/10_remote_snmplabs.t xt/20_run.t xt/lib/My/Test/Class.pm -xt/lib/SNMP/Info/Test.pm +xt/lib/Test/SNMP/Info.pm +xt/lib/Test/SNMP/Info/AdslLine.pm +xt/lib/Test/SNMP/Info/Aggregate.pm +xt/lib/Test/SNMP/Info/Airespace.pm +xt/lib/Test/SNMP/Info/Layer1/Allied.pm +xt/lib/Test/SNMP/Info/Layer1/Asante.pm +xt/lib/Test/SNMP/Info/Layer1/Bayhub.pm +xt/lib/Test/SNMP/Info/Layer1/Cyclades.pm +xt/lib/Test/SNMP/Info/Layer1/S3000.pm +xt/lib/Test/SNMP/Info/Layer2/3Com.pm +xt/lib/Test/SNMP/Info/Layer2/Airespace.pm +xt/lib/Test/SNMP/Info/Layer2/Allied.pm +xt/lib/Test/SNMP/Info/Layer2/Baystack.pm +xt/lib/Test/SNMP/Info/Layer3/Timetra.pm diff --git a/META.json b/META.json index 1701b59f..533240a9 100644 --- a/META.json +++ b/META.json @@ -34,6 +34,7 @@ }, "test" : { "requires" : { + "Class::Inspector" : "0", "File::Find" : "0", "File::Slurper" : "0", "Path::Class" : "0", @@ -48,479 +49,479 @@ "provides" : { "SNMP::Info" : { "file" : "lib/SNMP/Info.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::AMAP" : { "file" : "lib/SNMP/Info/AMAP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::AdslLine" : { "file" : "lib/SNMP/Info/AdslLine.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Aggregate" : { "file" : "lib/SNMP/Info/Aggregate.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Airespace" : { "file" : "lib/SNMP/Info/Airespace.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Bridge" : { "file" : "lib/SNMP/Info/Bridge.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CDP" : { "file" : "lib/SNMP/Info/CDP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoAgg" : { "file" : "lib/SNMP/Info/CiscoAgg.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoConfig" : { "file" : "lib/SNMP/Info/CiscoConfig.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoPortSecurity" : { "file" : "lib/SNMP/Info/CiscoPortSecurity.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoPower" : { "file" : "lib/SNMP/Info/CiscoPower.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoQOS" : { "file" : "lib/SNMP/Info/CiscoQOS.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoRTT" : { "file" : "lib/SNMP/Info/CiscoRTT.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoStack" : { "file" : "lib/SNMP/Info/CiscoStack.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoStats" : { "file" : "lib/SNMP/Info/CiscoStats.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoStpExtensions" : { "file" : "lib/SNMP/Info/CiscoStpExtensions.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::CiscoVTP" : { "file" : "lib/SNMP/Info/CiscoVTP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::EDP" : { "file" : "lib/SNMP/Info/EDP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Entity" : { "file" : "lib/SNMP/Info/Entity.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::EtherLike" : { "file" : "lib/SNMP/Info/EtherLike.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::FDP" : { "file" : "lib/SNMP/Info/FDP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::IEEE802dot11" : { "file" : "lib/SNMP/Info/IEEE802dot11.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::IEEE802dot3ad" : { "file" : "lib/SNMP/Info/IEEE802dot3ad.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::IPv6" : { "file" : "lib/SNMP/Info/IPv6.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::LLDP" : { "file" : "lib/SNMP/Info/LLDP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer1" : { "file" : "lib/SNMP/Info/Layer1.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer1::Allied" : { "file" : "lib/SNMP/Info/Layer1/Allied.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer1::Asante" : { "file" : "lib/SNMP/Info/Layer1/Asante.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer1::Bayhub" : { "file" : "lib/SNMP/Info/Layer1/Bayhub.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer1::Cyclades" : { "file" : "lib/SNMP/Info/Layer1/Cyclades.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer1::S3000" : { "file" : "lib/SNMP/Info/Layer1/S3000.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2" : { "file" : "lib/SNMP/Info/Layer2.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::3Com" : { "file" : "lib/SNMP/Info/Layer2/3Com.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Adtran" : { "file" : "lib/SNMP/Info/Layer2/Adtran.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Airespace" : { "file" : "lib/SNMP/Info/Layer2/Airespace.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Aironet" : { "file" : "lib/SNMP/Info/Layer2/Aironet.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Allied" : { "file" : "lib/SNMP/Info/Layer2/Allied.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Baystack" : { "file" : "lib/SNMP/Info/Layer2/Baystack.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::C1900" : { "file" : "lib/SNMP/Info/Layer2/C1900.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::C2900" : { "file" : "lib/SNMP/Info/Layer2/C2900.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Catalyst" : { "file" : "lib/SNMP/Info/Layer2/Catalyst.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Centillion" : { "file" : "lib/SNMP/Info/Layer2/Centillion.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Cisco" : { "file" : "lib/SNMP/Info/Layer2/Cisco.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::CiscoSB" : { "file" : "lib/SNMP/Info/Layer2/CiscoSB.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::HP" : { "file" : "lib/SNMP/Info/Layer2/HP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::HP4000" : { "file" : "lib/SNMP/Info/Layer2/HP4000.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::HPVC" : { "file" : "lib/SNMP/Info/Layer2/HPVC.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Kentrox" : { "file" : "lib/SNMP/Info/Layer2/Kentrox.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::N2270" : { "file" : "lib/SNMP/Info/Layer2/N2270.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::NAP222x" : { "file" : "lib/SNMP/Info/Layer2/NAP222x.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::NWSS2300" : { "file" : "lib/SNMP/Info/Layer2/NWSS2300.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Netgear" : { "file" : "lib/SNMP/Info/Layer2/Netgear.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Orinoco" : { "file" : "lib/SNMP/Info/Layer2/Orinoco.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Trapeze" : { "file" : "lib/SNMP/Info/Layer2/Trapeze.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::Ubiquiti" : { "file" : "lib/SNMP/Info/Layer2/Ubiquiti.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer2::ZyXEL_DSLAM" : { "file" : "lib/SNMP/Info/Layer2/ZyXEL_DSLAM.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3" : { "file" : "lib/SNMP/Info/Layer3.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Aironet" : { "file" : "lib/SNMP/Info/Layer3/Aironet.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::AlcatelLucent" : { "file" : "lib/SNMP/Info/Layer3/AlcatelLucent.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::AlteonAD" : { "file" : "lib/SNMP/Info/Layer3/AlteonAD.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Altiga" : { "file" : "lib/SNMP/Info/Layer3/Altiga.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Arista" : { "file" : "lib/SNMP/Info/Layer3/Arista.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Aruba" : { "file" : "lib/SNMP/Info/Layer3/Aruba.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::BayRS" : { "file" : "lib/SNMP/Info/Layer3/BayRS.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::BlueCoatSG" : { "file" : "lib/SNMP/Info/Layer3/BlueCoatSG.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::C3550" : { "file" : "lib/SNMP/Info/Layer3/C3550.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::C4000" : { "file" : "lib/SNMP/Info/Layer3/C4000.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::C6500" : { "file" : "lib/SNMP/Info/Layer3/C6500.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::CheckPoint" : { "file" : "lib/SNMP/Info/Layer3/CheckPoint.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Cisco" : { "file" : "lib/SNMP/Info/Layer3/Cisco.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::CiscoASA" : { "file" : "lib/SNMP/Info/Layer3/CiscoASA.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::CiscoFWSM" : { "file" : "lib/SNMP/Info/Layer3/CiscoFWSM.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::CiscoSwitch" : { "file" : "lib/SNMP/Info/Layer3/CiscoSwitch.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Contivity" : { "file" : "lib/SNMP/Info/Layer3/Contivity.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Cumulus" : { "file" : "lib/SNMP/Info/Layer3/Cumulus.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::DLink" : { "file" : "lib/SNMP/Info/Layer3/DLink.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Dell" : { "file" : "lib/SNMP/Info/Layer3/Dell.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Enterasys" : { "file" : "lib/SNMP/Info/Layer3/Enterasys.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Extreme" : { "file" : "lib/SNMP/Info/Layer3/Extreme.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::F5" : { "file" : "lib/SNMP/Info/Layer3/F5.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Force10" : { "file" : "lib/SNMP/Info/Layer3/Force10.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Fortinet" : { "file" : "lib/SNMP/Info/Layer3/Fortinet.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Foundry" : { "file" : "lib/SNMP/Info/Layer3/Foundry.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::H3C" : { "file" : "lib/SNMP/Info/Layer3/H3C.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::HP9300" : { "file" : "lib/SNMP/Info/Layer3/HP9300.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Huawei" : { "file" : "lib/SNMP/Info/Layer3/Huawei.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::IBMGbTor" : { "file" : "lib/SNMP/Info/Layer3/IBMGbTor.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Juniper" : { "file" : "lib/SNMP/Info/Layer3/Juniper.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Lantronix" : { "file" : "lib/SNMP/Info/Layer3/Lantronix.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Microsoft" : { "file" : "lib/SNMP/Info/Layer3/Microsoft.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Mikrotik" : { "file" : "lib/SNMP/Info/Layer3/Mikrotik.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::N1600" : { "file" : "lib/SNMP/Info/Layer3/N1600.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::NetSNMP" : { "file" : "lib/SNMP/Info/Layer3/NetSNMP.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Netscreen" : { "file" : "lib/SNMP/Info/Layer3/Netscreen.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Nexus" : { "file" : "lib/SNMP/Info/Layer3/Nexus.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::PacketFront" : { "file" : "lib/SNMP/Info/Layer3/PacketFront.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::PaloAlto" : { "file" : "lib/SNMP/Info/Layer3/PaloAlto.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Passport" : { "file" : "lib/SNMP/Info/Layer3/Passport.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Pf" : { "file" : "lib/SNMP/Info/Layer3/Pf.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Pica8" : { "file" : "lib/SNMP/Info/Layer3/Pica8.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::SonicWALL" : { "file" : "lib/SNMP/Info/Layer3/SonicWALL.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Steelhead" : { "file" : "lib/SNMP/Info/Layer3/Steelhead.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Sun" : { "file" : "lib/SNMP/Info/Layer3/Sun.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Tasman" : { "file" : "lib/SNMP/Info/Layer3/Tasman.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::Timetra" : { "file" : "lib/SNMP/Info/Layer3/Timetra.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::VMware" : { "file" : "lib/SNMP/Info/Layer3/VMware.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer3::VyOS" : { "file" : "lib/SNMP/Info/Layer3/VyOS.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer7" : { "file" : "lib/SNMP/Info/Layer7.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer7::APC" : { "file" : "lib/SNMP/Info/Layer7/APC.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer7::CiscoIPS" : { "file" : "lib/SNMP/Info/Layer7/CiscoIPS.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer7::Gigamon" : { "file" : "lib/SNMP/Info/Layer7/Gigamon.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer7::Neoteris" : { "file" : "lib/SNMP/Info/Layer7/Neoteris.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::Layer7::Netscaler" : { "file" : "lib/SNMP/Info/Layer7/Netscaler.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::MAU" : { "file" : "lib/SNMP/Info/MAU.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::MRO" : { "file" : "lib/SNMP/Info/MRO.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::NortelStack" : { "file" : "lib/SNMP/Info/NortelStack.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::PowerEthernet" : { "file" : "lib/SNMP/Info/PowerEthernet.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::RapidCity" : { "file" : "lib/SNMP/Info/RapidCity.pm", - "version" : "3.53" + "version" : "3.54" }, "SNMP::Info::SONMP" : { "file" : "lib/SNMP/Info/SONMP.pm", - "version" : "3.53" + "version" : "3.54" } }, "release_status" : "stable", @@ -530,7 +531,7 @@ }, "homepage" : "http://netdisco.org/", "license" : [ - "http://opensource.org/licenses/BSD-3-Clause" + "http://opensource.org/licenses/bsd-license.php" ], "repository" : { "url" : "https://github.com/netdisco/snmp-info" @@ -538,6 +539,6 @@ "x_IRC" : "irc://irc.freenode.org/#netdisco", "x_MailingList" : "https://lists.sourceforge.net/lists/listinfo/snmp-info-users" }, - "version" : "3.53", - "x_serialization_backend" : "JSON::PP version 2.94" + "version" : "3.54", + "x_serialization_backend" : "JSON::PP version 2.97001" } diff --git a/META.yml b/META.yml index 43bebdb5..6e85336e 100644 --- a/META.yml +++ b/META.yml @@ -3,6 +3,7 @@ abstract: 'OO Interface to Network devices and MIBs through SNMP' author: - 'Eric A. Miller ' build_requires: + Class::Inspector: '0' File::Find: '0' File::Slurper: '0' Path::Class: '0' @@ -23,361 +24,361 @@ name: SNMP-Info provides: SNMP::Info: file: lib/SNMP/Info.pm - version: '3.53' + version: '3.54' SNMP::Info::AMAP: file: lib/SNMP/Info/AMAP.pm - version: '3.53' + version: '3.54' SNMP::Info::AdslLine: file: lib/SNMP/Info/AdslLine.pm - version: '3.53' + version: '3.54' SNMP::Info::Aggregate: file: lib/SNMP/Info/Aggregate.pm - version: '3.53' + version: '3.54' SNMP::Info::Airespace: file: lib/SNMP/Info/Airespace.pm - version: '3.53' + version: '3.54' SNMP::Info::Bridge: file: lib/SNMP/Info/Bridge.pm - version: '3.53' + version: '3.54' SNMP::Info::CDP: file: lib/SNMP/Info/CDP.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoAgg: file: lib/SNMP/Info/CiscoAgg.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoConfig: file: lib/SNMP/Info/CiscoConfig.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoPortSecurity: file: lib/SNMP/Info/CiscoPortSecurity.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoPower: file: lib/SNMP/Info/CiscoPower.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoQOS: file: lib/SNMP/Info/CiscoQOS.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoRTT: file: lib/SNMP/Info/CiscoRTT.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoStack: file: lib/SNMP/Info/CiscoStack.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoStats: file: lib/SNMP/Info/CiscoStats.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoStpExtensions: file: lib/SNMP/Info/CiscoStpExtensions.pm - version: '3.53' + version: '3.54' SNMP::Info::CiscoVTP: file: lib/SNMP/Info/CiscoVTP.pm - version: '3.53' + version: '3.54' SNMP::Info::EDP: file: lib/SNMP/Info/EDP.pm - version: '3.53' + version: '3.54' SNMP::Info::Entity: file: lib/SNMP/Info/Entity.pm - version: '3.53' + version: '3.54' SNMP::Info::EtherLike: file: lib/SNMP/Info/EtherLike.pm - version: '3.53' + version: '3.54' SNMP::Info::FDP: file: lib/SNMP/Info/FDP.pm - version: '3.53' + version: '3.54' SNMP::Info::IEEE802dot11: file: lib/SNMP/Info/IEEE802dot11.pm - version: '3.53' + version: '3.54' SNMP::Info::IEEE802dot3ad: file: lib/SNMP/Info/IEEE802dot3ad.pm - version: '3.53' + version: '3.54' SNMP::Info::IPv6: file: lib/SNMP/Info/IPv6.pm - version: '3.53' + version: '3.54' SNMP::Info::LLDP: file: lib/SNMP/Info/LLDP.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer1: file: lib/SNMP/Info/Layer1.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer1::Allied: file: lib/SNMP/Info/Layer1/Allied.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer1::Asante: file: lib/SNMP/Info/Layer1/Asante.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer1::Bayhub: file: lib/SNMP/Info/Layer1/Bayhub.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer1::Cyclades: file: lib/SNMP/Info/Layer1/Cyclades.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer1::S3000: file: lib/SNMP/Info/Layer1/S3000.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2: file: lib/SNMP/Info/Layer2.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::3Com: file: lib/SNMP/Info/Layer2/3Com.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Adtran: file: lib/SNMP/Info/Layer2/Adtran.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Airespace: file: lib/SNMP/Info/Layer2/Airespace.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Aironet: file: lib/SNMP/Info/Layer2/Aironet.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Allied: file: lib/SNMP/Info/Layer2/Allied.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Baystack: file: lib/SNMP/Info/Layer2/Baystack.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::C1900: file: lib/SNMP/Info/Layer2/C1900.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::C2900: file: lib/SNMP/Info/Layer2/C2900.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Catalyst: file: lib/SNMP/Info/Layer2/Catalyst.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Centillion: file: lib/SNMP/Info/Layer2/Centillion.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Cisco: file: lib/SNMP/Info/Layer2/Cisco.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::CiscoSB: file: lib/SNMP/Info/Layer2/CiscoSB.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::HP: file: lib/SNMP/Info/Layer2/HP.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::HP4000: file: lib/SNMP/Info/Layer2/HP4000.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::HPVC: file: lib/SNMP/Info/Layer2/HPVC.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Kentrox: file: lib/SNMP/Info/Layer2/Kentrox.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::N2270: file: lib/SNMP/Info/Layer2/N2270.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::NAP222x: file: lib/SNMP/Info/Layer2/NAP222x.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::NWSS2300: file: lib/SNMP/Info/Layer2/NWSS2300.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Netgear: file: lib/SNMP/Info/Layer2/Netgear.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Orinoco: file: lib/SNMP/Info/Layer2/Orinoco.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Trapeze: file: lib/SNMP/Info/Layer2/Trapeze.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::Ubiquiti: file: lib/SNMP/Info/Layer2/Ubiquiti.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer2::ZyXEL_DSLAM: file: lib/SNMP/Info/Layer2/ZyXEL_DSLAM.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3: file: lib/SNMP/Info/Layer3.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Aironet: file: lib/SNMP/Info/Layer3/Aironet.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::AlcatelLucent: file: lib/SNMP/Info/Layer3/AlcatelLucent.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::AlteonAD: file: lib/SNMP/Info/Layer3/AlteonAD.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Altiga: file: lib/SNMP/Info/Layer3/Altiga.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Arista: file: lib/SNMP/Info/Layer3/Arista.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Aruba: file: lib/SNMP/Info/Layer3/Aruba.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::BayRS: file: lib/SNMP/Info/Layer3/BayRS.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::BlueCoatSG: file: lib/SNMP/Info/Layer3/BlueCoatSG.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::C3550: file: lib/SNMP/Info/Layer3/C3550.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::C4000: file: lib/SNMP/Info/Layer3/C4000.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::C6500: file: lib/SNMP/Info/Layer3/C6500.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::CheckPoint: file: lib/SNMP/Info/Layer3/CheckPoint.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Cisco: file: lib/SNMP/Info/Layer3/Cisco.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::CiscoASA: file: lib/SNMP/Info/Layer3/CiscoASA.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::CiscoFWSM: file: lib/SNMP/Info/Layer3/CiscoFWSM.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::CiscoSwitch: file: lib/SNMP/Info/Layer3/CiscoSwitch.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Contivity: file: lib/SNMP/Info/Layer3/Contivity.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Cumulus: file: lib/SNMP/Info/Layer3/Cumulus.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::DLink: file: lib/SNMP/Info/Layer3/DLink.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Dell: file: lib/SNMP/Info/Layer3/Dell.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Enterasys: file: lib/SNMP/Info/Layer3/Enterasys.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Extreme: file: lib/SNMP/Info/Layer3/Extreme.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::F5: file: lib/SNMP/Info/Layer3/F5.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Force10: file: lib/SNMP/Info/Layer3/Force10.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Fortinet: file: lib/SNMP/Info/Layer3/Fortinet.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Foundry: file: lib/SNMP/Info/Layer3/Foundry.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::H3C: file: lib/SNMP/Info/Layer3/H3C.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::HP9300: file: lib/SNMP/Info/Layer3/HP9300.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Huawei: file: lib/SNMP/Info/Layer3/Huawei.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::IBMGbTor: file: lib/SNMP/Info/Layer3/IBMGbTor.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Juniper: file: lib/SNMP/Info/Layer3/Juniper.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Lantronix: file: lib/SNMP/Info/Layer3/Lantronix.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Microsoft: file: lib/SNMP/Info/Layer3/Microsoft.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Mikrotik: file: lib/SNMP/Info/Layer3/Mikrotik.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::N1600: file: lib/SNMP/Info/Layer3/N1600.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::NetSNMP: file: lib/SNMP/Info/Layer3/NetSNMP.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Netscreen: file: lib/SNMP/Info/Layer3/Netscreen.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Nexus: file: lib/SNMP/Info/Layer3/Nexus.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::PacketFront: file: lib/SNMP/Info/Layer3/PacketFront.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::PaloAlto: file: lib/SNMP/Info/Layer3/PaloAlto.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Passport: file: lib/SNMP/Info/Layer3/Passport.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Pf: file: lib/SNMP/Info/Layer3/Pf.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Pica8: file: lib/SNMP/Info/Layer3/Pica8.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::SonicWALL: file: lib/SNMP/Info/Layer3/SonicWALL.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Steelhead: file: lib/SNMP/Info/Layer3/Steelhead.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Sun: file: lib/SNMP/Info/Layer3/Sun.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Tasman: file: lib/SNMP/Info/Layer3/Tasman.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::Timetra: file: lib/SNMP/Info/Layer3/Timetra.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::VMware: file: lib/SNMP/Info/Layer3/VMware.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer3::VyOS: file: lib/SNMP/Info/Layer3/VyOS.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer7: file: lib/SNMP/Info/Layer7.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer7::APC: file: lib/SNMP/Info/Layer7/APC.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer7::CiscoIPS: file: lib/SNMP/Info/Layer7/CiscoIPS.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer7::Gigamon: file: lib/SNMP/Info/Layer7/Gigamon.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer7::Neoteris: file: lib/SNMP/Info/Layer7/Neoteris.pm - version: '3.53' + version: '3.54' SNMP::Info::Layer7::Netscaler: file: lib/SNMP/Info/Layer7/Netscaler.pm - version: '3.53' + version: '3.54' SNMP::Info::MAU: file: lib/SNMP/Info/MAU.pm - version: '3.53' + version: '3.54' SNMP::Info::MRO: file: lib/SNMP/Info/MRO.pm - version: '3.53' + version: '3.54' SNMP::Info::NortelStack: file: lib/SNMP/Info/NortelStack.pm - version: '3.53' + version: '3.54' SNMP::Info::PowerEthernet: file: lib/SNMP/Info/PowerEthernet.pm - version: '3.53' + version: '3.54' SNMP::Info::RapidCity: file: lib/SNMP/Info/RapidCity.pm - version: '3.53' + version: '3.54' SNMP::Info::SONMP: file: lib/SNMP/Info/SONMP.pm - version: '3.53' + version: '3.54' recommends: Class::ISA: '0' File::Slurp: '0' @@ -392,7 +393,7 @@ resources: MailingList: https://lists.sourceforge.net/lists/listinfo/snmp-info-users bugtracker: https://github.com/netdisco/snmp-info/issues homepage: http://netdisco.org/ - license: http://opensource.org/licenses/BSD-3-Clause + license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/netdisco/snmp-info -version: '3.53' +version: '3.54' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff --git a/README b/README index 39ba3934..6a9ccf67 100644 --- a/README +++ b/README @@ -1,33 +1,28 @@ NAME - SNMP::Info - OO Interface to Network devices and MIBs through SNMP VERSION - - SNMP::Info - Version 3.53 + SNMP::Info - Version 3.54 AUTHOR - SNMP::Info is maintained by team of Open Source authors headed by Eric Miller, Bill Fenner, Max Baker, Jeroen van Ingen and Oliver Gorwits. - Please visit http://sourceforge.net/projects/snmp-info/ for most + Please visit for most up-to-date list of developers. SNMP::Info was originally created at UCSC for the Netdisco project - http://netdisco.org by Max Baker. + by Max Baker. DEVICES SUPPORTED - There are now generic classes for most types of device and so the authors recommend loading SNMP::Info with AutoSpecify, and then reporting to the mail list any missing functionality (such as neighbor discovery tables). SYNOPSIS - use SNMP::Info; - + my $info = new SNMP::Info( # Auto Discover more specific Device Class AutoSpecify => 1, @@ -37,35 +32,35 @@ SYNOPSIS Community => 'public', Version => 2 ) or die "Can't connect to device.\n"; - + my $err = $info->error(); die "SNMP Community or Version probably wrong connecting to device. $err\n" if defined $err; - + $name = $info->name(); $class = $info->class(); print "SNMP::Info is using this device class : $class\n"; - + # Find out the Duplex status for the ports my $interfaces = $info->interfaces(); my $i_duplex = $info->i_duplex(); - + # Get CDP Neighbor info my $c_if = $info->c_if(); my $c_ip = $info->c_ip(); my $c_port = $info->c_port(); - + # Print out data per port foreach my $iid (keys %$interfaces){ my $duplex = $i_duplex->{$iid}; # Print out physical port name, not snmp iid my $port = $interfaces->{$iid}; - + print "$port: "; print "$duplex duplex" if defined $duplex; - + # The CDP Table has table entries different than the interface tables. # So we use c_if to get the map from cdp table to interface table. - + my %c_map = reverse %$c_if; my $c_key = $c_map{$iid}; unless (defined $c_key) { @@ -74,20 +69,18 @@ SYNOPSIS } my $neighbor_ip = $c_ip->{$c_key}; my $neighbor_port = $c_port->{$c_key}; - + print " connected to $neighbor_ip / $neighbor_port\n" if defined $neighbor_ip; print "\n"; - + } SUPPORT - - Please direct all support, help, and bug requests to the - snmp-info-users Mailing List at - http://lists.sourceforge.net/lists/listinfo/snmp-info-users. + Please direct all support, help, and bug requests to the snmp-info-users + Mailing List at + . DESCRIPTION - SNMP::Info gives an object oriented interface to information obtained through SNMP. @@ -98,9 +91,9 @@ DESCRIPTION network devices, leaving the device-specific hacks behind the scenes in subclasses. - In the SYNOPSIS example we fetch the name of all the ports on the - device and the duplex setting for that port with two methods -- - interfaces() and i_duplex(). + In the SYNOPSIS example we fetch the name of all the ports on the device + and the duplex setting for that port with two methods -- interfaces() + and i_duplex(). The information may be coming from any number of MIB files and is very vendor specific. SNMP::Info provides you a common method for all @@ -110,296 +103,259 @@ DESCRIPTION knowledge. The module is not limited to network devices. Any MIB or device can be - given an objected oriented front-end by making a module that consists - of a couple hashes. See EXTENDING SNMP::INFO. + given an objected oriented front-end by making a module that consists of + a couple hashes. See EXTENDING SNMP::INFO. REQUIREMENTS - 1. Net-SNMP + To use this module, you must have Net-SNMP installed on your system. + More specifically you need the Perl modules that come with it. - To use this module, you must have Net-SNMP installed on your system. - More specifically you need the Perl modules that come with it. + DO NOT INSTALL SNMP:: or Net::SNMP from CPAN! - DO NOT INSTALL SNMP:: or Net::SNMP from CPAN! + The SNMP module is matched to an install of net-snmp, and must be + installed from the net-snmp source tree. - The SNMP module is matched to an install of net-snmp, and must be - installed from the net-snmp source tree. + The Perl module "SNMP" is found inside the net-snmp distribution. Go + to the perl/ directory of the distribution to install it, or run + "./configure --with-perl-modules" from the top directory of the + net-snmp distribution. - The Perl module SNMP is found inside the net-snmp distribution. Go to - the perl/ directory of the distribution to install it, or run - ./configure --with-perl-modules from the top directory of the - net-snmp distribution. + Net-SNMP can be found at http://net-snmp.sourceforge.net - Net-SNMP can be found at http://net-snmp.sourceforge.net + Version 5.3.2 or greater is recommended. - Version 5.3.2 or greater is recommended. + Versions 5.0.1, 5.0301 and 5.0203 have issues with bulkwalk and are + not supported. - Versions 5.0.1, 5.0301 and 5.0203 have issues with bulkwalk and are - not supported. - - Redhat Users: Some versions that come with certain versions of - Redhat/Fedora don't have the Perl library installed. Uninstall the - RPM and install by hand. + Redhat Users: Some versions that come with certain versions of + Redhat/Fedora don't have the Perl library installed. Uninstall the + RPM and install by hand. 2. MIBS + SNMP::Info operates on textual descriptors found in MIBs. - SNMP::Info operates on textual descriptors found in MIBs. + If you are using SNMP::Info separate from Netdisco, download the + Netdisco MIB package at + - If you are using SNMP::Info separate from Netdisco, download the - Netdisco MIB package at - http://sourceforge.net/projects/netdisco/files/netdisco-mibs/latest-s - napshot/ - - Make sure that your snmp.conf is updated to point to your MIB - directory and that the MIBs are world-readable. + Make sure that your snmp.conf is updated to point to your MIB + directory and that the MIBs are world-readable. DESIGN GOALS - 1. Use of textual MIB leaf identifier and enumerated values - * All values are retrieved via MIB Leaf node names + * All values are retrieved via MIB Leaf node names - For example SNMP::Info has an entry in its %GLOBALS hash for - ``sysName'' instead of 1.3.6.1.2.1.1.5. + For example SNMP::Info has an entry in its %GLOBALS hash for + ``sysName'' instead of 1.3.6.1.2.1.1.5. - * Data returned is in the enumerated value form. + * Data returned is in the enumerated value form. - For Example instead of looking up 1.3.6.1.2.1.2.2.1.3 and getting - back 23 + For Example instead of looking up 1.3.6.1.2.1.2.2.1.3 and + getting back 23 - SNMP::Info will ask for RFC1213-MIB::ifType and will get back ppp. + SNMP::Info will ask for "RFC1213-MIB::ifType" and will get back + "ppp". 2. SNMP::Info is easily extended to new devices + You can create a new subclass for a device by providing four hashes + : %GLOBALS, %MIBS, %FUNCS, and %MUNGE. - You can create a new subclass for a device by providing four hashes : - %GLOBALS, %MIBS, %FUNCS, and %MUNGE. + Or you can override any existing methods from a parent class by + making a short subroutine. - Or you can override any existing methods from a parent class by - making a short subroutine. + See the section EXTENDING SNMP::INFO for more details. - See the section EXTENDING SNMP::INFO for more details. - - When you make a new subclass for a device, please be sure to send it - back to the developers (via Source Forge or the mailing list) for - inclusion in the next version. + When you make a new subclass for a device, please be sure to send it + back to the developers (via Source Forge or the mailing list) for + inclusion in the next version. SUBCLASSES - These are the subclasses that implement MIBs and support devices: Required MIBs not included in the install instructions above are noted here. - MIB Subclasses - + MIB Subclasses These subclasses implement method to access one or more MIBs. These are not used directly, but rather inherited from device subclasses. - For more info run perldoc on any of the following module names. + For more info run "perldoc" on any of the following module names. SNMP::Info::AdslLine + SNMP Interface to the ADSL-LINE-MIB for ADSL interfaces. - SNMP Interface to the ADSL-LINE-MIB for ADSL interfaces. + Requires the ADSL-LINE-MIB, down loadable from Cisco. - Requires the ADSL-LINE-MIB, down loadable from Cisco. - - See documentation in SNMP::Info::AdslLine for details. + See documentation in SNMP::Info::AdslLine for details. SNMP::Info::Aggregate + SNMP Interface to IF-MIB "ifStackTable" Aggregated Links - SNMP Interface to IF-MIB ifStackTable Aggregated Links - - See documentation in SNMP::Info::Aggregate for details. + See documentation in SNMP::Info::Aggregate for details. SNMP::Info::Airespace + AIRESPACE-WIRELESS-MIB and AIRESPACE-SWITCHING-MIB. Inherited by + devices based on the Airespace wireless platform. - AIRESPACE-WIRELESS-MIB and AIRESPACE-SWITCHING-MIB. Inherited by - devices based on the Airespace wireless platform. - - See documentation in SNMP::Info::Airespace for details. + See documentation in SNMP::Info::Airespace for details. SNMP::Info::AMAP + ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB. Alcatel Mapping Adjacency + Protocol (AMAP) Support. - ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB. Alcatel Mapping Adjacency - Protocol (AMAP) Support. - - See documentation in SNMP::Info::AMAP for details. + See documentation in SNMP::Info::AMAP for details. SNMP::Info::Bridge + BRIDGE-MIB (RFC1286). QBRIDGE-MIB. Inherited by devices with Layer2 + support. - BRIDGE-MIB (RFC1286). QBRIDGE-MIB. Inherited by devices with Layer2 - support. - - See documentation in SNMP::Info::Bridge for details. + See documentation in SNMP::Info::Bridge for details. SNMP::Info::CiscoAgg + SNMP Interface to Cisco Aggregated Links - SNMP Interface to Cisco Aggregated Links - - See documentation in SNMP::Info::CiscoAgg for details. + See documentation in SNMP::Info::CiscoAgg for details. SNMP::Info::CDP + CISCO-CDP-MIB. Cisco Discovery Protocol (CDP) Support. Inherited by + Cisco, Enterasys, and HP devices. - CISCO-CDP-MIB. Cisco Discovery Protocol (CDP) Support. Inherited by - Cisco, Enterasys, and HP devices. - - See documentation in SNMP::Info::CDP for details. + See documentation in SNMP::Info::CDP for details. SNMP::Info::CiscoConfig + CISCO-CONFIG-COPY-MIB, CISCO-FLASH-MIB, and OLD-CISCO-SYS-MIB. These + OIDs facilitate the writing of configuration files. - CISCO-CONFIG-COPY-MIB, CISCO-FLASH-MIB, and OLD-CISCO-SYS-MIB. These - OIDs facilitate the writing of configuration files. - - See documentation in SNMP::Info::CiscoConfig for details. + See documentation in SNMP::Info::CiscoConfig for details. SNMP::Info::CiscoPortSecurity + CISCO-PORT-SECURITY-MIB and CISCO-PAE-MIB. - CISCO-PORT-SECURITY-MIB and CISCO-PAE-MIB. - - See documentation in SNMP::Info::CiscoPortSecurity for details. + See documentation in SNMP::Info::CiscoPortSecurity for details. SNMP::Info::CiscoPower + CISCO-POWER-ETHERNET-EXT-MIB. - CISCO-POWER-ETHERNET-EXT-MIB. - - See documentation in SNMP::Info::CiscoPower for details. + See documentation in SNMP::Info::CiscoPower for details. SNMP::Info::CiscoQOS + CISCO-CLASS-BASED-QOS-MIB. A collection of OIDs providing + information about a Cisco device's QOS config. - CISCO-CLASS-BASED-QOS-MIB. A collection of OIDs providing information - about a Cisco device's QOS config. - - See documentation in SNMP::Info::CiscoQOS for details. + See documentation in SNMP::Info::CiscoQOS for details. SNMP::Info::CiscoRTT + CISCO-RTTMON-MIB. A collection of OIDs providing information about a + Cisco device's RTT values. - CISCO-RTTMON-MIB. A collection of OIDs providing information about a - Cisco device's RTT values. - - See documentation in SNMP::Info::CiscoRTT for details. + See documentation in SNMP::Info::CiscoRTT for details. SNMP::Info::CiscoStack + CISCO-STACK-MIB. - CISCO-STACK-MIB. - - See documentation in SNMP::Info::CiscoStack for details. + See documentation in SNMP::Info::CiscoStack for details. SNMP::Info::CiscoStpExtensions + CISCO-STP-EXTENSIONS-MIB - CISCO-STP-EXTENSIONS-MIB - - See documentation in SNMP::Info::CiscoStpExtensions for details. + See documentation in SNMP::Info::CiscoStpExtensions for details. SNMP::Info::CiscoStats + OLD-CISCO-CPU-MIB, CISCO-PROCESS-MIB, and CISCO-MEMORY-POOL-MIB. + Provides common interfaces for memory, cpu, and os statistics for + Cisco devices. - OLD-CISCO-CPU-MIB, CISCO-PROCESS-MIB, and CISCO-MEMORY-POOL-MIB. - Provides common interfaces for memory, cpu, and os statistics for - Cisco devices. - - See documentation in SNMP::Info::CiscoStats for details. + See documentation in SNMP::Info::CiscoStats for details. SNMP::Info::CiscoVTP + CISCO-VTP-MIB, CISCO-VLAN-MEMBERSHIP-MIB, + CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB - CISCO-VTP-MIB, CISCO-VLAN-MEMBERSHIP-MIB, - CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB - - See documentation in SNMP::Info::CiscoVTP for details. + See documentation in SNMP::Info::CiscoVTP for details. SNMP::Info::EDP + Extreme Discovery Protocol. EXTREME-EDP-MIB - Extreme Discovery Protocol. EXTREME-EDP-MIB - - See documentation in SNMP::Info::EDP for details. + See documentation in SNMP::Info::EDP for details. SNMP::Info::Entity + ENTITY-MIB. Used for device info in Cisco and other vendors. - ENTITY-MIB. Used for device info in Cisco and other vendors. - - See documentation in SNMP::Info::Entity for details. + See documentation in SNMP::Info::Entity for details. SNMP::Info::EtherLike + EtherLike-MIB (RFC1398) - Some Layer3 devices implement this MIB, as + well as some Aironet Layer 2 devices (non Cisco). - EtherLike-MIB (RFC1398) - Some Layer3 devices implement this MIB, as - well as some Aironet Layer 2 devices (non Cisco). - - See documentation in SNMP::Info::EtherLike for details. + See documentation in SNMP::Info::EtherLike for details. SNMP::Info::FDP + Foundry (Brocade) Discovery Protocol. FOUNDRY-SN-SWITCH-GROUP-MIB - Foundry (Brocade) Discovery Protocol. FOUNDRY-SN-SWITCH-GROUP-MIB - - See documentation in SNMP::Info::FDP for details. + See documentation in SNMP::Info::FDP for details. SNMP::Info::IPv6 + SNMP Interface for obtaining configured IPv6 addresses and mapping + IPv6 addresses to MAC addresses and interfaces, using information + from IP-MIB, IPV6-MIB and/or CISCO-IETF-IP-MIB. - SNMP Interface for obtaining configured IPv6 addresses and mapping - IPv6 addresses to MAC addresses and interfaces, using information - from IP-MIB, IPV6-MIB and/or CISCO-IETF-IP-MIB. - - See documentation in SNMP::Info::IPv6 for details. + See documentation in SNMP::Info::IPv6 for details. SNMP::Info::IEEE802dot11 + IEEE802dot11-MIB. A collection of OIDs providing information about + standards based 802.11 wireless devices. - IEEE802dot11-MIB. A collection of OIDs providing information about - standards based 802.11 wireless devices. - - See documentation in SNMP::Info::IEEE802dot11 for details. + See documentation in SNMP::Info::IEEE802dot11 for details. SNMP::Info::IEEE802dot3ad + SNMP Interface to IEEE Aggregated Links. IEEE8023-LAG-MIB - SNMP Interface to IEEE Aggregated Links. IEEE8023-LAG-MIB - - See documentation in SNMP::Info::IEEE802dot3ad for details. + See documentation in SNMP::Info::IEEE802dot3ad for details. SNMP::Info::LLDP + LLDP-MIB, LLDP-EXT-DOT1-MIB, and LLDP-EXT-DOT3-MIB. Link Layer + Discovery Protocol (LLDP) Support. - LLDP-MIB, LLDP-EXT-DOT1-MIB, and LLDP-EXT-DOT3-MIB. Link Layer - Discovery Protocol (LLDP) Support. - - See documentation in SNMP::Info::LLDP for details. + See documentation in SNMP::Info::LLDP for details. SNMP::Info::MAU + MAU-MIB (RFC2668). Some Layer2 devices use this for extended + Ethernet (Media Access Unit) interface information. - MAU-MIB (RFC2668). Some Layer2 devices use this for extended Ethernet - (Media Access Unit) interface information. - - See documentation in SNMP::Info::MAU for details. + See documentation in SNMP::Info::MAU for details. SNMP::Info::MRO + Method resolution introspection for SNMP::Info - Method resolution introspection for SNMP::Info - - See documentation in SNMP::Info::MRO for details. + See documentation in SNMP::Info::MRO for details. SNMP::Info::NortelStack + S5-AGENT-MIB, S5-CHASSIS-MIB. - S5-AGENT-MIB, S5-CHASSIS-MIB. - - See documentation in SNMP::Info::NortelStack for details. + See documentation in SNMP::Info::NortelStack for details. SNMP::Info::PowerEthernet + POWER-ETHERNET-MIB - POWER-ETHERNET-MIB - - See documentation in SNMP::Info::PowerEthernet for details. + See documentation in SNMP::Info::PowerEthernet for details. SNMP::Info::RapidCity + RAPID-CITY. Inherited by Avaya switches for duplex and VLAN + information. - RAPID-CITY. Inherited by Avaya switches for duplex and VLAN - information. - - See documentation in SNMP::Info::RapidCity for details. + See documentation in SNMP::Info::RapidCity for details. SNMP::Info::SONMP + SynOptics Network Management Protocol (SONMP) SYNOPTICS-ROOT-MIB, + S5-ETH-MULTISEG-TOPOLOGY-MIB. Inherited by + Avaya/Nortel/Bay/Synoptics switches and hubs. - SynOptics Network Management Protocol (SONMP) SYNOPTICS-ROOT-MIB, - S5-ETH-MULTISEG-TOPOLOGY-MIB. Inherited by Avaya/Nortel/Bay/Synoptics - switches and hubs. - - See documentation in SNMP::Info::SONMP for details. - - Device Subclasses + See documentation in SNMP::Info::SONMP for details. + Device Subclasses These subclasses inherit from one or more classes to provide a common interface to data obtainable from network devices. @@ -407,567 +363,485 @@ SUBCLASSES (See Above). SNMP::Info::Layer1 + Generic Layer1 Device subclass. - Generic Layer1 Device subclass. + See documentation in SNMP::Info::Layer1 for details. - See documentation in SNMP::Info::Layer1 for details. + SNMP::Info::Layer1::Allied + Subclass for Allied Telesis Repeaters / Hubs. - SNMP::Info::Layer1::Allied + Requires ATI-MIB - Subclass for Allied Telesis Repeaters / Hubs. + See documentation in SNMP::Info::Layer1::Allied for details. - Requires ATI-MIB + SNMP::Info::Layer1::Asante + Subclass for Asante 1012 Hubs. - See documentation in SNMP::Info::Layer1::Allied for details. + Requires ASANTE-HUB1012-MIB - SNMP::Info::Layer1::Asante + See documentation in SNMP::Info::Layer1::Asante for details. - Subclass for Asante 1012 Hubs. + SNMP::Info::Layer1::Bayhub + Subclass for Nortel/Bay hubs. This includes System 5000, 100 + series, 200 series, and probably more. - Requires ASANTE-HUB1012-MIB + See documentation in SNMP::Info::Layer1::Bayhub for details. - See documentation in SNMP::Info::Layer1::Asante for details. + SNMP::Info::Layer1::Cyclades + Subclass for Cyclades/Avocent terminal servers. - SNMP::Info::Layer1::Bayhub + See documentation in SNMP::Info::Layer1::Cyclades for details. - Subclass for Nortel/Bay hubs. This includes System 5000, 100 - series, 200 series, and probably more. + SNMP::Info::Layer1::S3000 + Subclass for Bay/Synoptics hubs. This includes System 3000, + 281X, and probably more. - See documentation in SNMP::Info::Layer1::Bayhub for details. - - SNMP::Info::Layer1::Cyclades - - Subclass for Cyclades terminal servers. - - See documentation in SNMP::Info::Layer1::Cyclades for details. - - SNMP::Info::Layer1::S3000 - - Subclass for Bay/Synoptics hubs. This includes System 3000, 281X, - and probably more. - - See documentation in SNMP::Info::Layer1::S3000 for details. + See documentation in SNMP::Info::Layer1::S3000 for details. SNMP::Info::Layer2 + Generic Layer2 Device subclass. - Generic Layer2 Device subclass. + See documentation in SNMP::Info::Layer2 for details. - See documentation in SNMP::Info::Layer2 for details. + SNMP::Info::Layer2::3Com + SNMP::Info::Layer2::3Com - SNMP Interface to L2 3Com Switches - SNMP::Info::Layer2::3Com + See documentation in SNMP::Info::Layer2::3Com for details. - SNMP::Info::Layer2::3Com - SNMP Interface to L2 3Com Switches + SNMP::Info::Layer2::Adtran + Subclass for Adtran devices. - See documentation in SNMP::Info::Layer2::3Com for details. + See documentation in SNMP::Info::Layer2::Adtran for details. - SNMP::Info::Layer2::Adtran + SNMP::Info::Layer2::Airespace + Subclass for Cisco (Airespace) wireless controllers. - Subclass for Adtran devices. + See documentation in SNMP::Info::Layer2::Airespace for details. - See documentation in SNMP::Info::Layer2::Adtran for details. + SNMP::Info::Layer2::Aironet + Class for Cisco Aironet wireless devices that run IOS. See also + Layer3::Aironet for Aironet devices that don't run IOS. - SNMP::Info::Layer2::Airespace + See documentation in SNMP::Info::Layer2::Aironet for details. - Subclass for Cisco (Airespace) wireless controllers. + SNMP::Info::Layer2::Allied + Allied Telesis switches. - See documentation in SNMP::Info::Layer2::Airespace for details. + See documentation in SNMP::Info::Layer2::Allied for details. - SNMP::Info::Layer2::Aironet + SNMP::Info::Layer2::Baystack + Subclass for Avaya/Nortel/Bay Ethernet Switch/Baystack switches. + This includes 303, 304, 350, 380, 410, 420, 425, 450, 460, 470 + series, 2500 series, 4000 series, 5000 series, Business Ethernet + Switch (BES), Business Policy Switch (BPS), VSP 7000 series, and + probably others. - Class for Cisco Aironet wireless devices that run IOS. See also - Layer3::Aironet for Aironet devices that don't run IOS. + See documentation in SNMP::Info::Layer2::Baystack for details. - See documentation in SNMP::Info::Layer2::Aironet for details. + SNMP::Info::Layer2::Kentrox + Class for Kentrox DataSMART DSU/CSU. See + SNMP::Info::Layer2::Kentrox for details. - SNMP::Info::Layer2::Allied + SNMP::Info::Layer2::C1900 + Subclass for Cisco Catalyst 1900 and 1900c Devices running + CatOS. - Allied Telesis switches. + See documentation in SNMP::Info::Layer2::C1900 for details. - See documentation in SNMP::Info::Layer2::Allied for details. + SNMP::Info::Layer2::C2900 + Subclass for Cisco Catalyst 2900, 2950, 3500XL, and 3548 devices + running IOS. - SNMP::Info::Layer2::Baystack + See documentation in SNMP::Info::Layer2::C2900 for details. - Subclass for Avaya/Nortel/Bay Ethernet Switch/Baystack switches. - This includes 303, 304, 350, 380, 410, 420, 425, 450, 460, 470 - series, 2500 series, 4000 series, 5000 series, Business Ethernet - Switch (BES), Business Policy Switch (BPS), VSP 7000 series, and - probably others. + SNMP::Info::Layer2::Catalyst + Subclass for Cisco Catalyst switches running CatOS. These + switches usually report a model number that starts with "wsc". + Note that this class does not support everything that has the + name Catalyst. - See documentation in SNMP::Info::Layer2::Baystack for details. + See documentation in SNMP::Info::Layer2::Catalyst for details. - SNMP::Info::Layer2::Kentrox + SNMP::Info::Layer2::Centillion + Subclass for Nortel/Bay Centillion and 5000BH ATM switches. - Class for Kentrox DataSMART DSU/CSU. See - SNMP::Info::Layer2::Kentrox for details. + See documentation in SNMP::Info::Layer2::Centillion for details. - SNMP::Info::Layer2::C1900 + SNMP::Info::Layer2::Cisco + Generic Cisco subclass for layer 2 devices that are not yet + supported in more specific subclassesand the base layer 2 Cisco + class for other device specific layer 2 Cisco classes. - Subclass for Cisco Catalyst 1900 and 1900c Devices running CatOS. + See documentation in SNMP::Info::Layer2::Cisco for details. - See documentation in SNMP::Info::Layer2::C1900 for details. + SNMP::Info::Layer2::CiscoSB + Subclass for Cisco's "Small Business" product line, acquired + from Linksys. This currently comprises the Sx300/500 line of + switches. - SNMP::Info::Layer2::C2900 + See documentation in SNMP::Info::Layer2::CiscoSB for details. - Subclass for Cisco Catalyst 2900, 2950, 3500XL, and 3548 devices - running IOS. + SNMP::Info::Layer2::HP + Subclass for more recent HP Procurve Switches - See documentation in SNMP::Info::Layer2::C2900 for details. + Requires HP-ICF-OID and ENTITY-MIB downloaded from HP. - SNMP::Info::Layer2::Catalyst + See documentation in SNMP::Info::Layer2::HP for details. - Subclass for Cisco Catalyst switches running CatOS. These switches - usually report a model number that starts with wsc. Note that this - class does not support everything that has the name Catalyst. + SNMP::Info::Layer2::HP4000 + Subclass for older HP Procurve Switches - See documentation in SNMP::Info::Layer2::Catalyst for details. + Requires HP-ICF-OID and ENTITY-MIB downloaded from HP. - SNMP::Info::Layer2::Centillion + See documentation in SNMP::Info::Layer2::HP4000 for details. - Subclass for Nortel/Bay Centillion and 5000BH ATM switches. + SNMP::Info::Layer2::HPVC + Subclass for HP Virtual Connect Switches - See documentation in SNMP::Info::Layer2::Centillion for details. + See documentation in SNMP::Info::Layer2::HPVC for details. - SNMP::Info::Layer2::Cisco + SNMP::Info::Layer2::N2270 + Subclass for Nortel 2270 wireless switches. - Generic Cisco subclass for layer 2 devices that are not yet - supported in more specific subclassesand the base layer 2 Cisco - class for other device specific layer 2 Cisco classes. + See documentation in SNMP::Info::Layer2::N2270 for details. - See documentation in SNMP::Info::Layer2::Cisco for details. + SNMP::Info::Layer2::NAP222x + Subclass for Nortel 222x series wireless access points. - SNMP::Info::Layer2::CiscoSB + See documentation in SNMP::Info::Layer2::NAP222x for details. - Subclass for Cisco's "Small Business" product line, acquired from - Linksys. This currently comprises the Sx300/500 line of switches. + SNMP::Info::Layer2::Netgear + Subclass for Netgear switches - See documentation in SNMP::Info::Layer2::CiscoSB for details. + See documentation in SNMP::Info::Layer2::Netgear for details. - SNMP::Info::Layer2::HP + SNMP::Info::Layer2::NWSS2300 + SNMP Interface to Avaya (Trapeze) Wireless Controllers - Subclass for more recent HP Procurve Switches + See documentation in SNMP::Info::Layer2::NWSS2300 for details. - Requires HP-ICF-OID and ENTITY-MIB downloaded from HP. + SNMP::Info::Layer2::Orinoco + Subclass for Orinoco/Proxim wireless access points. - See documentation in SNMP::Info::Layer2::HP for details. + See documentation in SNMP::Info::Layer2::Orinoco for details. - SNMP::Info::Layer2::HP4000 + SNMP::Info::Layer2::Trapeze + SNMP Interface to Juniper (Trapeze) Wireless Controllers - Subclass for older HP Procurve Switches + See documentation in SNMP::Info::Layer2::Trapeze for details. - Requires HP-ICF-OID and ENTITY-MIB downloaded from HP. + SNMP::Info::Layer2::Ubiquiti + SNMP Interface to Ubiquiti Access Points and other devices - See documentation in SNMP::Info::Layer2::HP4000 for details. + See documentation in SNMP::Info::Layer2::Ubiquiti for details. - SNMP::Info::Layer2::HPVC + SNMP::Info::Layer2::ZyXEL_DSLAM + Zyxel DSLAMs. Need I say more? - Subclass for HP Virtual Connect Switches - - See documentation in SNMP::Info::Layer2::HPVC for details. - - SNMP::Info::Layer2::N2270 - - Subclass for Nortel 2270 wireless switches. - - See documentation in SNMP::Info::Layer2::N2270 for details. - - SNMP::Info::Layer2::NAP222x - - Subclass for Nortel 222x series wireless access points. - - See documentation in SNMP::Info::Layer2::NAP222x for details. - - SNMP::Info::Layer2::Netgear - - Subclass for Netgear switches - - See documentation in SNMP::Info::Layer2::Netgear for details. - - SNMP::Info::Layer2::NWSS2300 - - SNMP Interface to Avaya (Trapeze) Wireless Controllers - - See documentation in SNMP::Info::Layer2::NWSS2300 for details. - - SNMP::Info::Layer2::Orinoco - - Subclass for Orinoco/Proxim wireless access points. - - See documentation in SNMP::Info::Layer2::Orinoco for details. - - SNMP::Info::Layer2::Trapeze - - SNMP Interface to Juniper (Trapeze) Wireless Controllers - - See documentation in SNMP::Info::Layer2::Trapeze for details. - - SNMP::Info::Layer2::Ubiquiti - - SNMP Interface to Ubiquiti Access Points and other devices - - See documentation in SNMP::Info::Layer2::Ubiquiti for details. - - SNMP::Info::Layer2::ZyXEL_DSLAM - - Zyxel DSLAMs. Need I say more? - - See documentation in SNMP::Info::Layer2::ZyXEL_DSLAM for details. + See documentation in SNMP::Info::Layer2::ZyXEL_DSLAM for + details. SNMP::Info::Layer3 + Generic Layer3 and Layer2+3 Device subclass. - Generic Layer3 and Layer2+3 Device subclass. + See documentation in SNMP::Info::Layer3 for details. - See documentation in SNMP::Info::Layer3 for details. + SNMP::Info::Layer3::Aironet + Subclass for Cisco Aironet wireless access points (AP) not + running IOS. These are usually older devices. - SNMP::Info::Layer3::Aironet + MIBs for these devices now included in v2.tar.gz available from + ftp.cisco.com. - Subclass for Cisco Aironet wireless access points (AP) not running - IOS. These are usually older devices. + Note Layer2::Aironet - MIBs for these devices now included in v2.tar.gz available from - ftp.cisco.com. + See documentation in SNMP::Info::Layer3::Aironet for details. - Note Layer2::Aironet + SNMP::Info::Layer3::AlcatelLucent + Alcatel-Lucent OmniSwitch Class. - See documentation in SNMP::Info::Layer3::Aironet for details. + See documentation in SNMP::Info::Layer3::AlcatelLucent for + details. - SNMP::Info::Layer3::AlcatelLucent + SNMP::Info::Layer3::AlteonAD + Subclass for Radware Alteon Series ADC switches and Nortel + BladeCenter Layer2-3 GbE Switch Modules. - Alcatel-Lucent OmniSwitch Class. + See documentation in SNMP::Info::Layer3::AlteonAD for details. - See documentation in SNMP::Info::Layer3::AlcatelLucent for details. + SNMP::Info::Layer3::Altiga + See documentation in SNMP::Info::Layer3::Altiga for details. - SNMP::Info::Layer3::AlteonAD + SNMP::Info::Layer3::Arista + See documentation in SNMP::Info::Layer3::Arista for details. - Subclass for Radware Alteon Series ADC switches and Nortel - BladeCenter Layer2-3 GbE Switch Modules. + SNMP::Info::Layer3::Aruba + Subclass for Aruba wireless switches. - See documentation in SNMP::Info::Layer3::AlteonAD for details. + See documentation in SNMP::Info::Layer3::Aruba for details. - SNMP::Info::Layer3::Altiga + SNMP::Info::Layer3::BayRS + Subclass for Avaya/Nortel/Bay Multiprotocol/BayRS routers. This + includes BCN, BLN, ASN, ARN, AN, 2430, and 5430 routers. - See documentation in SNMP::Info::Layer3::Altiga for details. + See documentation in SNMP::Info::Layer3::BayRS for details. - SNMP::Info::Layer3::Arista + SNMP::Info::Layer3::BlueCoatSG + Subclass for Blue Coat SG series proxy devices. - See documentation in SNMP::Info::Layer3::Arista for details. + See documentation in SNMP::Info::Layer3::BlueCoatSG for details. - SNMP::Info::Layer3::Aruba + SNMP::Info::Layer3::C3550 + Subclass for Cisco Catalyst 3550,3540,3560 2/3 switches running + IOS. - Subclass for Aruba wireless switches. + See documentation in SNMP::Info::Layer3::C3550 for details. - See documentation in SNMP::Info::Layer3::Aruba for details. + SNMP::Info::Layer3::C4000 + This class covers Catalyst 4000s and 4500s. - SNMP::Info::Layer3::BayRS + See documentation in SNMP::Info::Layer3::C4000 for details. - Subclass for Avaya/Nortel/Bay Multiprotocol/BayRS routers. This - includes BCN, BLN, ASN, ARN, AN, 2430, and 5430 routers. + SNMP::Info::Layer3::C6500 + This class covers Catalyst 6500s in native mode, hybrid mode. + Catalyst 3750's, 2970's and probably others. - See documentation in SNMP::Info::Layer3::BayRS for details. + See documentation in SNMP::Info::Layer3::C6500 for details. - SNMP::Info::Layer3::BlueCoatSG + SNMP::Info::Layer3::CheckPoint + Subclass for CheckPoint devices - Subclass for Blue Coat SG series proxy devices. + See documentation in SNMP::Info::Layer3::CheckPoint for details. - See documentation in SNMP::Info::Layer3::BlueCoatSG for details. + SNMP::Info::Layer3::Cisco + This is a simple wrapper around layer 3 for IOS devices and the + base layer 3 Cisco class for other device specific layer 3 Cisco + classes. - SNMP::Info::Layer3::C3550 + See documentation in SNMP::Info::Layer3::Cisco for details. - Subclass for Cisco Catalyst 3550,3540,3560 2/3 switches running - IOS. + SNMP::Info::Layer3::CiscoASA + Subclass for Cisco Adaptive Security Appliances. - See documentation in SNMP::Info::Layer3::C3550 for details. + See documentation in SNMP::Info::Layer3::CiscoASA for details. - SNMP::Info::Layer3::C4000 + SNMP::Info::Layer3::CiscoFWSM + Subclass for Cisco Firewall Services Modules. - This class covers Catalyst 4000s and 4500s. + See documentation in SNMP::Info::Layer3::CiscoFWSM for details. - See documentation in SNMP::Info::Layer3::C4000 for details. + SNMP::Info::Layer3::CiscoSwitch + Base class for L3 Cisco switches. See documentation in + SNMP::Info::Layer3::CiscoSwitch for details. - SNMP::Info::Layer3::C6500 + SNMP::Info::Layer3::Contivity + Subclass for Avaya/Nortel Contivity/VPN Routers. - This class covers Catalyst 6500s in native mode, hybrid mode. - Catalyst 3750's, 2970's and probably others. + See documentation in SNMP::Info::Layer3::Contivity for details. - See documentation in SNMP::Info::Layer3::C6500 for details. + SNMP::Info::Layer3::Cumulus + Subclass for Cumulus Networks Routers. - SNMP::Info::Layer3::CheckPoint + See documentation in SNMP::Info::Layer3::Cumulus for details. - Subclass for CheckPoint devices + SNMP::Info::Layer3::DLink + Subclass for DLink devices. - See documentation in SNMP::Info::Layer3::CheckPoint for details. + See documentation in SNMP::Info::Layer3::DLink for details. - SNMP::Info::Layer3::Cisco + SNMP::Info::Layer3::Dell + Subclass for Dell PowerConnect switches. D-Link, the IBM + BladeCenter Gigabit Ethernet Switch Module and some Linksys + switches also use this module based upon MIB support. - This is a simple wrapper around layer 3 for IOS devices and the - base layer 3 Cisco class for other device specific layer 3 Cisco - classes. + See documentation in SNMP::Info::Layer3::Dell for details. - See documentation in SNMP::Info::Layer3::Cisco for details. + SNMP::Info::Layer3::Enterasys + Subclass for Enterasys devices. - SNMP::Info::Layer3::CiscoASA + See documentation in SNMP::Info::Layer3::Enterasys for details. - Subclass for Cisco Adaptive Security Appliances. + SNMP::Info::Layer3::Extreme + Subclass for Extreme Networks switches. - See documentation in SNMP::Info::Layer3::CiscoASA for details. + See documentation in SNMP::Info::Layer3::Extreme for details. - SNMP::Info::Layer3::CiscoFWSM + SNMP::Info::Layer3::F5 + Subclass for F5 devices. - Subclass for Cisco Firewall Services Modules. + See documentation in SNMP::Info::Layer3::F5 for details. - See documentation in SNMP::Info::Layer3::CiscoFWSM for details. + SNMP::Info::Layer3::Force10 + Subclass for Force10 devices. - SNMP::Info::Layer3::CiscoSwitch + See documentation in SNMP::Info::Layer3::Force10 for details. - Base class for L3 Cisco switches. See documentation in - SNMP::Info::Layer3::CiscoSwitch for details. + SNMP::Info::Layer3::Fortinet + Subclass for Fortinet devices. - SNMP::Info::Layer3::Contivity + See documentation in SNMP::Info::Layer3::Fortinet for details. - Subclass for Avaya/Nortel Contivity/VPN Routers. + SNMP::Info::Layer3::Foundry + Subclass for Brocade (Foundry) Network devices. - See documentation in SNMP::Info::Layer3::Contivity for details. + See documentation in SNMP::Info::Layer3::Foundry for details. - SNMP::Info::Layer3::Cumulus + SNMP::Info::Layer3::H3C + SNMP Interface to Layer 3 Devices, H3C & HP A-series. - Subclass for Cumulus Networks Routers. + See documentation in SNMP::Info::Layer3::H3C for details. - See documentation in SNMP::Info::Layer3::Cumulus for details. + SNMP::Info::Layer3::HP9300 + Subclass for HP network devices which Foundry Networks was the + Original Equipment Manufacturer (OEM) such as the HP ProCurve + 9300 and 6300 series. - SNMP::Info::Layer3::DLink + See documentation in SNMP::Info::Layer3::HP9300 for details. - Subclass for DLink devices. + SNMP::Info::Layer3::Huawei + SNMP Interface to Huawei Layer 3 switches and routers. - See documentation in SNMP::Info::Layer3::DLink for details. + See documentation in SNMP::Info::Layer3::Huawei for details. - SNMP::Info::Layer3::Dell + SNMP::Info::Layer3::IBMGbTor + SNMP Interface to IBM Rackswitch (formerly Blade Network + Technologies) network devices. - Subclass for Dell PowerConnect switches. D-Link, the IBM - BladeCenter Gigabit Ethernet Switch Module and some Linksys - switches also use this module based upon MIB support. + See documentation in SNMP::Info::Layer3::IBMGbTor for details. - See documentation in SNMP::Info::Layer3::Dell for details. + SNMP::Info::Layer3::Juniper + Subclass for Juniper devices - SNMP::Info::Layer3::Enterasys + See documentation in SNMP::Info::Layer3::Juniper for details. - Subclass for Enterasys devices. + SNMP::Info::Layer3::Lantronix + Subclass for Lantronix devices - See documentation in SNMP::Info::Layer3::Enterasys for details. + See documentation in SNMP::Info::Layer3::Lantronix for details. - SNMP::Info::Layer3::Extreme + SNMP::Info::Layer3::Microsoft + Subclass for Generic Microsoft Routers running Microsoft Windows + OS. - Subclass for Extreme Networks switches. + See documentation in SNMP::Info::Layer3::Microsoft for details. - See documentation in SNMP::Info::Layer3::Extreme for details. + SNMP::Info::Layer3::Mikrotik + Subclass for Mikrotik devices running RouterOS. - SNMP::Info::Layer3::F5 + See documentation in SNMP::Info::Layer3::Mikrotik for details. - Subclass for F5 devices. + SNMP::Info::Layer3::N1600 + Subclass for Avaya/Nortel Ethernet Routing Switch 1600 series. - See documentation in SNMP::Info::Layer3::F5 for details. + See documentation in SNMP::Info::Layer3::N1600 for details. - SNMP::Info::Layer3::Force10 + SNMP::Info::Layer3::NetSNMP + Subclass for host systems running Net-SNMP. - Subclass for Force10 devices. + See documentation in SNMP::Info::Layer3::NetSNMP for details. - See documentation in SNMP::Info::Layer3::Force10 for details. + SNMP::Info::Layer3::Netscreen + Subclass for Juniper NetScreen. - SNMP::Info::Layer3::Fortinet + See documentation in SNMP::Info::Layer3::Netscreen for details. - Subclass for Fortinet devices. + SNMP::Info::Layer3::Nexus + Subclass for Cisco Nexus devices running NX-OS - See documentation in SNMP::Info::Layer3::Fortinet for details. + See documentation in SNMP::Info::Layer3::Nexus for details. - SNMP::Info::Layer3::Foundry + SNMP::Info::Layer3::PacketFront + Subclass for PacketFront DRG series CPE. - Subclass for Brocade (Foundry) Network devices. + See documentation in SNMP::Info::Layer3::PacketFront for + details. - See documentation in SNMP::Info::Layer3::Foundry for details. + SNMP::Info::Layer3::PaloAlto + Subclass for Palo Alto firewalls. - SNMP::Info::Layer3::H3C + See documentation in SNMP::Info::Layer3::PaloAlto for details. - SNMP Interface to Layer 3 Devices, H3C & HP A-series. + SNMP::Info::Layer3::Passport + Subclass for Avaya/Nortel Ethernet Routing Switch/Passport 8000 + series, Accelar, and VSP 9000 series switches. - See documentation in SNMP::Info::Layer3::H3C for details. + See documentation in SNMP::Info::Layer3::Passport for details. - SNMP::Info::Layer3::HP9300 + SNMP::Info::Layer3::Pf + Subclass for FreeBSD-Based Firewalls using Pf /Pf Sense - Subclass for HP network devices which Foundry Networks was the - Original Equipment Manufacturer (OEM) such as the HP ProCurve 9300 - and 6300 series. + See documentation in SNMP::Info::Layer3::Pf for details. - See documentation in SNMP::Info::Layer3::HP9300 for details. + SNMP::Info::Layer3::Pica8 + Subclass for Pica8 devices. - SNMP::Info::Layer3::Huawei + See documentation in SNMP::Info::Layer3::Pica8 for details. - SNMP Interface to Huawei Layer 3 switches and routers. + SNMP::Info::Layer3::SonicWALL + Subclass for generic SonicWALL devices. See documentation in + SNMP::Info::Layer3::SonicWALL for details. - See documentation in SNMP::Info::Layer3::Huawei for details. + SNMP::Info::Layer3::Steelhead + Subclass for Riverbed Steelhead WAN optimization appliances. See + documentation in SNMP::Info::Layer3::Steelhead for details. - SNMP::Info::Layer3::IBMGbTor + SNMP::Info::Layer3::Sun + Subclass for Generic Sun Routers running SunOS. - SNMP Interface to IBM Rackswitch (formerly Blade Network - Technologies) network devices. + See documentation in SNMP::Info::Layer3::Sun for details. - See documentation in SNMP::Info::Layer3::IBMGbTor for details. + SNMP::Info::Layer3::Tasman + Subclass for Avaya Secure Routers. - SNMP::Info::Layer3::Juniper + See documentation in SNMP::Info::Layer3::Tasman for details. - Subclass for Juniper devices + SNMP::Info::Layer3::Timetra + Alcatel-Lucent SR Class. - See documentation in SNMP::Info::Layer3::Juniper for details. + See documentation in SNMP::Info::Layer3::Timetra for details. - SNMP::Info::Layer3::Lantronix + SNMP::Info::Layer3::VyOS + Subclass for VyOS routers. - Subclass for Lantronix devices + See documentation in SNMP::Info::Layer3::VyOS for details. - See documentation in SNMP::Info::Layer3::Lantronix for details. + SNMP::Info::Layer3::VMware + Subclass for VMware ESXi hosts. - SNMP::Info::Layer3::Microsoft - - Subclass for Generic Microsoft Routers running Microsoft Windows - OS. - - See documentation in SNMP::Info::Layer3::Microsoft for details. - - SNMP::Info::Layer3::Mikrotik - - Subclass for Mikrotik devices running RouterOS. - - See documentation in SNMP::Info::Layer3::Mikrotik for details. - - SNMP::Info::Layer3::N1600 - - Subclass for Avaya/Nortel Ethernet Routing Switch 1600 series. - - See documentation in SNMP::Info::Layer3::N1600 for details. - - SNMP::Info::Layer3::NetSNMP - - Subclass for host systems running Net-SNMP. - - See documentation in SNMP::Info::Layer3::NetSNMP for details. - - SNMP::Info::Layer3::Netscreen - - Subclass for Juniper NetScreen. - - See documentation in SNMP::Info::Layer3::Netscreen for details. - - SNMP::Info::Layer3::Nexus - - Subclass for Cisco Nexus devices running NX-OS - - See documentation in SNMP::Info::Layer3::Nexus for details. - - SNMP::Info::Layer3::PacketFront - - Subclass for PacketFront DRG series CPE. - - See documentation in SNMP::Info::Layer3::PacketFront for details. - - SNMP::Info::Layer3::PaloAlto - - Subclass for Palo Alto firewalls. - - See documentation in SNMP::Info::Layer3::PaloAlto for details. - - SNMP::Info::Layer3::Passport - - Subclass for Avaya/Nortel Ethernet Routing Switch/Passport 8000 - series, Accelar, and VSP 9000 series switches. - - See documentation in SNMP::Info::Layer3::Passport for details. - - SNMP::Info::Layer3::Pf - - Subclass for FreeBSD-Based Firewalls using Pf /Pf Sense - - See documentation in SNMP::Info::Layer3::Pf for details. - - SNMP::Info::Layer3::Pica8 - - Subclass for Pica8 devices. - - See documentation in SNMP::Info::Layer3::Pica8 for details. - - SNMP::Info::Layer3::SonicWALL - - Subclass for generic SonicWALL devices. See documentation in - SNMP::Info::Layer3::SonicWALL for details. - - SNMP::Info::Layer3::Steelhead - - Subclass for Riverbed Steelhead WAN optimization appliances. See - documentation in SNMP::Info::Layer3::Steelhead for details. - - SNMP::Info::Layer3::Sun - - Subclass for Generic Sun Routers running SunOS. - - See documentation in SNMP::Info::Layer3::Sun for details. - - SNMP::Info::Layer3::Tasman - - Subclass for Avaya Secure Routers. - - See documentation in SNMP::Info::Layer3::Tasman for details. - - SNMP::Info::Layer3::Timetra - - Alcatel-Lucent SR Class. - - See documentation in SNMP::Info::Layer3::Timetra for details. - - SNMP::Info::Layer3::VyOS - - Subclass for VyOS routers. - - See documentation in SNMP::Info::Layer3::VyOS for details. - - SNMP::Info::Layer3::VMware - - Subclass for VMware ESXi hosts. - - See documentation in SNMP::Info::Layer3::VMware for details. + See documentation in SNMP::Info::Layer3::VMware for details. SNMP::Info::Layer7 + Generic Layer7 Devices. - Generic Layer7 Devices. + See documentation in SNMP::Info::Layer7 for details. - See documentation in SNMP::Info::Layer7 for details. + SNMP::Info::Layer7::APC + Subclass for APC UPS devices - SNMP::Info::Layer7::APC + See documentation in SNMP::Info::Layer7::APC for details. - Subclass for APC UPS devices + SNMP::Info::Layer7::CiscoIPS + Subclass for Cisco IPS devices - See documentation in SNMP::Info::Layer7::APC for details. + See documentation in "SNMP::Info::Layer7::Cisco IPS" for + details. - SNMP::Info::Layer7::CiscoIPS + SNMP::Info::Layer7::Gigamon + Subclass for Gigamon devices - Subclass for Cisco IPS devices + See documentation in SNMP::Info::Layer7::Gigamon for details. - See documentation in "SNMP::Info::Layer7::Cisco IPS" for details. + SNMP::Info::Layer7::Netscaler + Subclass for Citrix Netscaler appliances - SNMP::Info::Layer7::Gigamon + See documentation in SNMP::Info::Layer7::Netscaler for details. - Subclass for Gigamon devices + SNMP::Info::Layer7::Neoteris + Subclass for Juniper SSL VPN appliances - See documentation in SNMP::Info::Layer7::Gigamon for details. - - SNMP::Info::Layer7::Netscaler - - Subclass for Citrix Netscaler appliances - - See documentation in SNMP::Info::Layer7::Netscaler for details. - - SNMP::Info::Layer7::Neoteris - - Subclass for Juniper SSL VPN appliances - - See documentation in SNMP::Info::Layer7::Neoteris for details. + See documentation in SNMP::Info::Layer7::Neoteris for details. Thanks - Thanks for testing and coding help (in no particular order) to : Alexander Barthel, Andy Ford, Alexander Hartmaier, Andrew Herrick, Alex Kramarov, Bernhard Augenstein, Bradley Baetz, Brian Chow, Brian Wilson, @@ -978,177 +852,158 @@ Thanks Netdisco README! USAGE - - Constructor - + Constructor new() + Creates a new object and connects via SNMP::Session. - Creates a new object and connects via SNMP::Session. + my $info = new SNMP::Info( 'Debug' => 1, + 'AutoSpecify' => 1, + 'BigInt' => 1, + 'BulkWalk' => 1, + 'BulkRepeaters' => 20, + 'IgnoreNetSNMPConf' => 1, + 'LoopDetect' => 1, + 'DestHost' => 'myrouter', + 'Community' => 'public', + 'Version' => 2, + 'MibDirs' => ['dir1','dir2','dir3'], + ) or die; - my $info = new SNMP::Info( 'Debug' => 1, - 'AutoSpecify' => 1, - 'BigInt' => 1, - 'BulkWalk' => 1, - 'BulkRepeaters' => 20, - 'IgnoreNetSNMPConf' => 1, - 'LoopDetect' => 1, - 'DestHost' => 'myrouter', - 'Community' => 'public', - 'Version' => 2, - 'MibDirs' => ['dir1','dir2','dir3'], - ) or die; + SNMP::Info Specific Arguments : - SNMP::Info Specific Arguments : + AutoSpecify + Returns an object of a more specific device class - AutoSpecify + (default 0, which means "off") - Returns an object of a more specific device class + BigInt + Return Math::BigInt objects for 64 bit counters. Sets on a + global scope, not object. - (default 0, which means "off") + (default 0, which means "off") - BigInt + BulkWalk + Set to 0 to turn off BULKWALK commands for SNMPv2 connections. - Return Math::BigInt objects for 64 bit counters. Sets on a global - scope, not object. + Note that BULKWALK is turned off for Net-SNMP versions 5.1.x + because of a bug. - (default 0, which means "off") + (default 1, which means "on") - BulkWalk + BulkRepeaters + Set number of MaxRepeaters for BULKWALK operation. See "perldoc + SNMP" -> bulkwalk() for more info. - Set to 0 to turn off BULKWALK commands for SNMPv2 connections. + (default 20) - Note that BULKWALK is turned off for Net-SNMP versions 5.1.x - because of a bug. + LoopDetect + Detects looping during getnext table column walks by comparing + IIDs for each instance. A loop is detected if the same IID is + seen more than once and the walk is aborted. Note: This will not + detect loops during a bulkwalk operation, Net-SNMP's internal + bulkwalk function must detect the loop. - (default 1, which means "on") + Set to 0 to turn off loop detection. - BulkRepeaters + (default 1, which means "on") - Set number of MaxRepeaters for BULKWALK operation. See perldoc SNMP - -> bulkwalk() for more info. + IgnoreNetSNMPConf + Net-SNMP version 5.0 and higher read configuration files, + snmp.conf or snmp.local.conf, from /etc/snmp, /usr/share/snmp, + /usr/lib(64)/snmp, or $HOME/.snmp and uses those settings to + automatically parse MIB files, etc. - (default 20) + Set to 1 "on" to ignore Net-SNMP configuration files by + overriding the "SNMPCONFPATH" environmental variable during + object initialization. Note: MibDirs must be defined or Net-SNMP + will not be able to load MIBs and initialize the object. - LoopDetect + (default 0, which means "off") - Detects looping during getnext table column walks by comparing IIDs - for each instance. A loop is detected if the same IID is seen more - than once and the walk is aborted. Note: This will not detect loops - during a bulkwalk operation, Net-SNMP's internal bulkwalk function - must detect the loop. + Debug + Prints Lots of debugging messages. Pass 2 to print even more + debugging messages. - Set to 0 to turn off loop detection. + (default 0, which means "off") - (default 1, which means "on") + DebugSNMP + Set $SNMP::debugging level for Net-SNMP. - IgnoreNetSNMPConf + See SNMP for more details. - Net-SNMP version 5.0 and higher read configuration files, snmp.conf - or snmp.local.conf, from /etc/snmp, /usr/share/snmp, - /usr/lib(64)/snmp, or $HOME/.snmp and uses those settings to - automatically parse MIB files, etc. + MibDirs + Array ref to list of directories in which to look for MIBs. Note + this will be in addition to the ones setup in snmp.conf at the + system level. - Set to 1 "on" to ignore Net-SNMP configuration files by overriding - the SNMPCONFPATH environmental variable during object - initialization. Note: MibDirs must be defined or Net-SNMP will not - be able to load MIBs and initialize the object. + (default use net-snmp settings only) - (default 0, which means "off") + RetryNoSuch + When using SNMP Version 1, try reading values even if they come + back as "no such variable in this MIB". Set to false if so + desired. This feature lets you read SNMPv2 data from an SNMP + version 1 connection, and should probably be left on. - Debug + (default 1, which means "on") - Prints Lots of debugging messages. Pass 2 to print even more - debugging messages. + Session + SNMP::Session object to use instead of connecting on own. - (default 0, which means "off") + (default creates session automatically) - DebugSNMP + Offline + Causes SNMP::Info to avoid network activity and return data only + from its cache. If you ask for something not in the cache, an + error is thrown. See also the "cache()" and "offline()" methods. - Set $SNMP::debugging level for Net-SNMP. + (default 0, which means "online") - See SNMP for more details. + Cache + Pass in a HashRef to prime the cache of retrieved data. Useful + for creating an instance in "Offline" mode from a previously + dumped cache. See also the "cache()" method to retrieve a cache + after running actial queries. - MibDirs + OTHER + All other arguments are passed to SNMP::Session. - Array ref to list of directories in which to look for MIBs. Note - this will be in addition to the ones setup in snmp.conf at the - system level. + See SNMP::Session for a list of other possible arguments. - (default use net-snmp settings only) + A Note about the wrong Community string or wrong SNMP Version: - RetryNoSuch + If a connection is using the wrong community string or the wrong + SNMP version, the creation of the object will not fail. The device + still answers the call on the SNMP port, but will not return + information. Check the error() method after you create the device + object to see if there was a problem in connecting. - When using SNMP Version 1, try reading values even if they come - back as "no such variable in this MIB". Set to false if so desired. - This feature lets you read SNMPv2 data from an SNMP version 1 - connection, and should probably be left on. + A note about SNMP Versions : - (default 1, which means "on") + Some older devices don't support SNMP version 2, and will not return + anything when a connection under Version 2 is attempted. - Session + Some newer devices will support Version 1, but will not return all + the data they might have if you had connected under Version 1 - SNMP::Session object to use instead of connecting on own. - - (default creates session automatically) - - Offline - - Causes SNMP::Info to avoid network activity and return data only - from its cache. If you ask for something not in the cache, an error - is thrown. See also the cache() and offline() methods. - - (default 0, which means "online") - - Cache - - Pass in a HashRef to prime the cache of retrieved data. Useful for - creating an instance in Offline mode from a previously dumped - cache. See also the cache() method to retrieve a cache after - running actial queries. - - OTHER - - All other arguments are passed to SNMP::Session. - - See SNMP::Session for a list of other possible arguments. - - A Note about the wrong Community string or wrong SNMP Version: - - If a connection is using the wrong community string or the wrong SNMP - version, the creation of the object will not fail. The device still - answers the call on the SNMP port, but will not return information. - Check the error() method after you create the device object to see if - there was a problem in connecting. - - A note about SNMP Versions : - - Some older devices don't support SNMP version 2, and will not return - anything when a connection under Version 2 is attempted. - - Some newer devices will support Version 1, but will not return all - the data they might have if you had connected under Version 1 - - When trying to get info from a new device, you may have to try - version 2 and then fallback to version 1. + When trying to get info from a new device, you may have to try + version 2 and then fallback to version 1. update() + Replace the existing session with a new one with updated values, + without re-identifying the device. The only supported changes are to + Community or Context. - Replace the existing session with a new one with updated values, - without re-identifying the device. The only supported changes are to - Community or Context. + Clears the object cache. - Clears the object cache. + This is useful, e.g., when a device supports multiple contexts (via + changes to the Community string, or via the SNMPv3 Context + parameter), but a context that you want to access does not support + the objects (e.g., "sysObjectID", "sysDescr") that we use to + identify the device. - This is useful, e.g., when a device supports multiple contexts (via - changes to the Community string, or via the SNMPv3 Context - parameter), but a context that you want to access does not support - the objects (e.g., sysObjectID, sysDescr) that we use to identify the - device. - - Data is Cached - - Methods and subroutines requesting data from a device will only load - the data once, and then return cached versions of that data. + Data is Cached + Methods and subroutines requesting data from a device will only load the + data once, and then return cached versions of that data. Run $info->load_METHOD() where method is something like 'i_name' to reload data from a method. @@ -1157,162 +1012,140 @@ USAGE globals and table methods. The cache can be retrieved or set using the $info->cache() method. This - works together with the Offline option. - - Object Scalar Methods + works together with the "Offline" option. + Object Scalar Methods These are for package related data, not directly supplied from SNMP. $info->clear_cache() - - Clears the cached data. This includes GLOBALS data and TABLE METHOD - data. + Clears the cached data. This includes GLOBALS data and TABLE METHOD + data. $info->debug(1) - - Returns current debug status, and optionally toggles debugging info - for this object. + Returns current debug status, and optionally toggles debugging info + for this object. $info->offline([1|0]) + Returns if offline mode is currently turned on for this object. - Returns if offline mode is currently turned on for this object. - - Optionally sets the Offline parameter. + Optionally sets the Offline parameter. $info->cache([new_cache]) + Returns a HashRef of all cached data in this object. There will be a + "store" key for table data and then one key for each leaf. - Returns a HashRef of all cached data in this object. There will be a - store key for table data and then one key for each leaf. - - Optionally sets the cache parameters if passed a HashRef. + Optionally sets the cache parameters if passed a HashRef. $info->bulkwalk([1|0]) + Returns if bulkwalk is currently turned on for this object. - Returns if bulkwalk is currently turned on for this object. - - Optionally sets the bulkwalk parameter. + Optionally sets the bulkwalk parameter. $info->loopdetect([1|0]) + Returns if loopdetect is currently turned on for this object. - Returns if loopdetect is currently turned on for this object. - - Optionally sets the loopdetect parameter. + Optionally sets the loopdetect parameter. $info->device_type() + Returns the Subclass name for this device. "SNMP::Info" is returned + if no more specific class is available. - Returns the Subclass name for this device. SNMP::Info is returned if - no more specific class is available. + First the device is checked for Layer 3 support and a specific + subclass, then Layer 2 support and subclasses are checked. - First the device is checked for Layer 3 support and a specific - subclass, then Layer 2 support and subclasses are checked. + This means that Layer 2 / 3 switches and routers will fall under the + SNMP::Info::Layer3 subclasses. - This means that Layer 2 / 3 switches and routers will fall under the - SNMP::Info::Layer3 subclasses. - - If the device still can be connected to via SNMP::Info, then - SNMP::Info is returned. + If the device still can be connected to via SNMP::Info, then + SNMP::Info is returned. $info->error(no_clear) + Returns Error message if there is an error, or undef if there is + not. - Returns Error message if there is an error, or undef if there is not. - - Reading the error will clear the error unless you set the no_clear - flag. + Reading the error will clear the error unless you set the no_clear + flag. $info->has_layer(3) + Returns non-zero if the device has the supplied layer in the OSI + Model - Returns non-zero if the device has the supplied layer in the OSI - Model - - Returns if the device doesn't support the layers() call. + Returns if the device doesn't support the layers() call. $info->snmp_comm() - - Returns SNMP Community string used in connection. + Returns SNMP Community string used in connection. $info->snmp_ver() - - Returns SNMP Version used for this connection + Returns SNMP Version used for this connection $info->specify() + Returns an object of a more-specific subclass. - Returns an object of a more-specific subclass. + my $info = new SNMP::Info(...); + # Returns more specific object type + $info = $info->specific(); - my $info = new SNMP::Info(...); - # Returns more specific object type - $info = $info->specific(); + Usually this method is called internally from new(AutoSpecify => 1) - Usually this method is called internally from new(AutoSpecify => 1) - - See device_type() entry for how a subclass is chosen. + See device_type() entry for how a subclass is chosen. $info->cisco_comm_indexing() + Returns 0. Is an overridable method used for vlan indexing for snmp + calls on certain Cisco devices. - Returns 0. Is an overridable method used for vlan indexing for snmp - calls on certain Cisco devices. - - See - ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIn - dexing.html - - Globals (Scalar Methods) + See + + Globals (Scalar Methods) These are methods to return scalar data from RFC1213. Some subset of these is probably available for any network device that speaks SNMP. $info->uptime() + Uptime in hundredths of seconds since device became available. - Uptime in hundredths of seconds since device became available. - - (sysUpTime) + ("sysUpTime") $info->contact() - - (sysContact) + ("sysContact") $info->name() - - (sysName) + ("sysName") $info->location() - - (sysLocation) + ("sysLocation") $info->layers() + This returns a binary encoded string where each digit represents a + layer of the OSI model served by the device. - This returns a binary encoded string where each digit represents a - layer of the OSI model served by the device. + eg: 01000010 means layers 2 (physical) and 7 (Application) + are served. - eg: 01000010 means layers 2 (physical) and 7 (Application) - are served. + Note: This string is 8 digits long. - Note: This string is 8 digits long. + See $info->has_layer() - See $info->has_layer() - - (sysServices) + ("sysServices") $info->ports() + Number of interfaces available on this device. - Number of interfaces available on this device. + Not too useful as the number of SNMP interfaces usually does not + correspond with the number of physical ports - Not too useful as the number of SNMP interfaces usually does not - correspond with the number of physical ports - - (ifNumber) + ("ifNumber") $info->ipforwarding() + The indication of whether the entity is acting as an IP gateway - The indication of whether the entity is acting as an IP gateway + Returns either forwarding or not-forwarding - Returns either forwarding or not-forwarding - - (ipForwarding) - - Table Methods + ("ipForwarding") + Table Methods Each of these methods returns a hash_reference to a hash keyed on the interface index in SNMP. @@ -1323,11 +1156,10 @@ USAGE '9.99' => 'FastEthernet/2' } - The key is what you would see if you were to do an snmpwalk, and in - some cases changes between reboots of the network device. - - Partial Table Fetches + The key is what you would see if you were to do an snmpwalk, and in some + cases changes between reboots of the network device. + Partial Table Fetches If you want to get only a part of an SNMP table or a single instance from the table and you know the IID for the part of the table that you want, you can specify it in the call: @@ -1341,374 +1173,331 @@ USAGE Partial table results are not cached. - Interface Information - + Interface Information $info->interfaces() - - This methods is overridden in each subclass to provide a mapping - between the Interface Table Index (iid) and the physical port name. + This methods is overridden in each subclass to provide a mapping + between the Interface Table Index (iid) and the physical port name. $info->if_ignore() + Returns a reference to a hash where key values that exist are + interfaces to ignore. - Returns a reference to a hash where key values that exist are - interfaces to ignore. - - Ignored interfaces are ones that are usually not physical ports or - Virtual Lans (VLANs) such as the Loopback interface, or the CPU - interface. + Ignored interfaces are ones that are usually not physical ports or + Virtual Lans (VLANs) such as the Loopback interface, or the CPU + interface. $info->bulkwalk_no() - - Returns 0. Is an overridable method used for turn off bulkwalk for - the device class. + Returns 0. Is an overridable method used for turn off bulkwalk for + the device class. $info->i_index() + Default SNMP IID to Interface index. - Default SNMP IID to Interface index. - - (ifIndex) + ("ifIndex") $info->i_description() + Description of the interface. Usually a little longer single word + name that is both human and machine friendly. Not always. - Description of the interface. Usually a little longer single word - name that is both human and machine friendly. Not always. - - (ifDescr) + ("ifDescr") $info->i_type() + Interface type, such as Vlan, Ethernet, Serial - Interface type, such as Vlan, Ethernet, Serial - - (ifType) + ("ifType") $info->i_mtu() + INTEGER. Interface MTU value. - INTEGER. Interface MTU value. - - (ifMtu) + ("ifMtu") $info->i_speed() + Speed of the link, human format. See munge_speed() later in document + for details. - Speed of the link, human format. See munge_speed() later in document - for details. - - (ifSpeed, ifHighSpeed if necessary) + ("ifSpeed", "ifHighSpeed" if necessary) $info->i_speed_raw() + Speed of the link in bits per second without munging. If + i_speed_high is available it will be used and multiplied by + 1_000_000. - Speed of the link in bits per second without munging. If i_speed_high - is available it will be used and multiplied by 1_000_000. - - (ifSpeed, ifHighSpeed if necessary) + ("ifSpeed", "ifHighSpeed" if necessary) $info->i_speed_high() + Speed of a high-speed link, human format. See munge_highspeed() + later in document for details. You should not need to call this + directly, as i_speed() will call it if it needs to. - Speed of a high-speed link, human format. See munge_highspeed() later - in document for details. You should not need to call this directly, - as i_speed() will call it if it needs to. - - (ifHighSpeed) + ("ifHighSpeed") $info->i_mac() + MAC address of the interface. Note this is just the MAC of the port, + not anything connected to it. - MAC address of the interface. Note this is just the MAC of the port, - not anything connected to it. - - (ifPhysAddress) + ("ifPhysAddress") $info->i_up() + Link Status of the interface. Typical values are 'up' and 'down'. - Link Status of the interface. Typical values are 'up' and 'down'. - - (ifOperStatus) + ("ifOperStatus") $info->i_up_admin() + Administrative status of the port. Typical values are 'enabled' and + 'disabled'. - Administrative status of the port. Typical values are 'enabled' and - 'disabled'. - - (ifAdminStatus) + ("ifAdminStatus") $info->i_lastchange() + The value of "sysUpTime" when this port last changed states + (up,down). - The value of sysUpTime when this port last changed states (up,down). - - (ifLastChange) + ("ifLastChange") $info->i_name() + Interface Name field. Supported by a smaller subset of devices, this + fields is often human set. - Interface Name field. Supported by a smaller subset of devices, this - fields is often human set. - - (ifName) + ("ifName") $info->i_alias() + Interface Name field. For certain devices this is a more human + friendly form of i_description(). For others it is a human set field + like i_name(). - Interface Name field. For certain devices this is a more human - friendly form of i_description(). For others it is a human set field - like i_name(). - - (ifAlias) - - Interface Statistics + ("ifAlias") + Interface Statistics $info->i_octet_in(), $info->i_octets_out(), $info->i_octet_in64(), $info->i_octets_out64() + Bandwidth. - Bandwidth. + Number of octets sent/received on the interface including framing + characters. - Number of octets sent/received on the interface including framing - characters. + 64 bit version may not exist on all devices. - 64 bit version may not exist on all devices. + NOTE: To manipulate 64 bit counters you need to use Math::BigInt, + since the values are too large for a normal Perl scalar. Set the + global $SNMP::Info::BIGINT to 1 , or pass the BigInt value to new() + if you want SNMP::Info to do it for you. - NOTE: To manipulate 64 bit counters you need to use Math::BigInt, - since the values are too large for a normal Perl scalar. Set the - global $SNMP::Info::BIGINT to 1 , or pass the BigInt value to new() - if you want SNMP::Info to do it for you. - - (ifInOctets) (ifOutOctets) (ifHCInOctets) (ifHCOutOctets) + ("ifInOctets") ("ifOutOctets") ("ifHCInOctets") ("ifHCOutOctets") $info->i_errors_in(), $info->i_errors_out() + Number of packets that contained an error preventing delivery. See + "IF-MIB" for more info. - Number of packets that contained an error preventing delivery. See - IF-MIB for more info. - - (ifInErrors) (ifOutErrors) + ("ifInErrors") ("ifOutErrors") $info->i_pkts_ucast_in(), $info->i_pkts_ucast_out(), $info->i_pkts_ucast_in64(), $info->i_pkts_ucast_out64() + Number of packets not sent to a multicast or broadcast address. - Number of packets not sent to a multicast or broadcast address. + 64 bit version may not exist on all devices. - 64 bit version may not exist on all devices. - - (ifInUcastPkts) (ifOutUcastPkts) (ifHCInUcastPkts) (ifHCOutUcastPkts) + ("ifInUcastPkts") ("ifOutUcastPkts") ("ifHCInUcastPkts") + ("ifHCOutUcastPkts") $info->i_pkts_nucast_in(), $info->i_pkts_nucast_out(), + Number of packets sent to a multicast or broadcast address. - Number of packets sent to a multicast or broadcast address. + These methods are deprecated by i_pkts_multi_in() and + i_pkts_bcast_in() according to "IF-MIB". Actual device usage may + vary. - These methods are deprecated by i_pkts_multi_in() and - i_pkts_bcast_in() according to IF-MIB. Actual device usage may vary. - - (ifInNUcastPkts) (ifOutNUcastPkts) + ("ifInNUcastPkts") ("ifOutNUcastPkts") $info->i_pkts_multi_in() $info->i_pkts_multi_out(), $info->i_pkts_multi_in64(), $info->i_pkts_multi_out64() + Number of packets sent to a multicast address. - Number of packets sent to a multicast address. + 64 bit version may not exist on all devices. - 64 bit version may not exist on all devices. - - (ifInMulticastPkts) (ifOutMulticastPkts) (ifHCInMulticastPkts) - (ifHCOutMulticastPkts) + ("ifInMulticastPkts") ("ifOutMulticastPkts") ("ifHCInMulticastPkts") + ("ifHCOutMulticastPkts") $info->i_pkts_bcast_in() $info->i_pkts_bcast_out(), $info->i_pkts_bcast_in64() $info->i_pkts_bcast_out64() + Number of packets sent to a broadcast address on an interface. - Number of packets sent to a broadcast address on an interface. + 64 bit version may not exist on all devices. - 64 bit version may not exist on all devices. - - (ifInBroadcastPkts) (ifOutBroadcastPkts) (ifHCInBroadcastPkts) - (ifHCOutBroadcastPkts) + ("ifInBroadcastPkts") ("ifOutBroadcastPkts") ("ifHCInBroadcastPkts") + ("ifHCOutBroadcastPkts") $info->i_discards_in() $info->i_discards_out() + "The number of inbound packets which were chosen to be discarded + even though no errors had been detected to prevent their being + deliverable to a higher-layer protocol. One possible reason for + discarding such a packet could be to free up buffer space." + ("IF-MIB") - "The number of inbound packets which were chosen to be discarded even - though no errors had been detected to prevent their being deliverable - to a higher-layer protocol. One possible reason for discarding such a - packet could be to free up buffer space." (IF-MIB) - - (ifInDiscards) (ifOutDiscards) + ("ifInDiscards") ("ifOutDiscards") $info->i_bad_proto_in() + "For packet-oriented interfaces, the number of packets received via + the interface which were discarded because of an unknown or + unsupported protocol. For character-oriented or fixed-length + interfaces that support protocol multiplexing the number of + transmission units received via the interface which were discarded + because of an unknown or unsupported protocol. For any interface + that does not support protocol multiplexing, this counter will + always be 0." - "For packet-oriented interfaces, the number of packets received via - the interface which were discarded because of an unknown or - unsupported protocol. For character-oriented or fixed-length - interfaces that support protocol multiplexing the number of - transmission units received via the interface which were discarded - because of an unknown or unsupported protocol. For any interface that - does not support protocol multiplexing, this counter will always be - 0." - - (ifInUnknownProtos) + ("ifInUnknownProtos") $info->i_qlen_out() + "The length of the output packet queue (in packets)." - "The length of the output packet queue (in packets)." - - (ifOutQLen) + ("ifOutQLen") $info->i_specific() + See "IF-MIB" for full description - See IF-MIB for full description + ("ifSpecific") - (ifSpecific) - - IP Address Table - - Each entry in this table is an IP address in use on this device. - Usually this is implemented in Layer3 Devices. + IP Address Table + Each entry in this table is an IP address in use on this device. Usually + this is implemented in Layer3 Devices. $info->ip_index() + Maps the IP Table to the IID - Maps the IP Table to the IID - - (ipAdEntIfIndex) + ("ipAdEntIfIndex") $info->ip_table() + Maps the Table to the IP address - Maps the Table to the IP address - - (ipAdEntAddr) + ("ipAdEntAddr") $info->ip_netmask() + Gives netmask setting for IP table entry. - Gives netmask setting for IP table entry. - - (ipAdEntNetMask) + ("ipAdEntNetMask") $info->ip_broadcast() + Gives broadcast address for IP table entry. - Gives broadcast address for IP table entry. - - (ipAdEntBcastAddr) - - IP Routing Table + ("ipAdEntBcastAddr") + IP Routing Table $info->ipr_route() + The route in question. A value of 0.0.0.0 is the default gateway + route. - The route in question. A value of 0.0.0.0 is the default gateway - route. - - (ipRouteDest) + ("ipRouteDest") $info->ipr_if() + The interface (IID) that the route is on. Use interfaces() to map. - The interface (IID) that the route is on. Use interfaces() to map. - - (ipRouteIfIndex) + ("ipRouteIfIndex") $info->ipr_1() + Primary routing metric for this route. - Primary routing metric for this route. - - (ipRouteMetric1) + ("ipRouteMetric1") $info->ipr_2() + If metrics are not used, they should be set to -1 - If metrics are not used, they should be set to -1 - - (ipRouteMetric2) + ("ipRouteMetric2") $info->ipr_3() - - (ipRouteMetric3) + ("ipRouteMetric3") $info->ipr_4() - - (ipRouteMetric4) + ("ipRouteMetric4") $info->ipr_5() - - (ipRouteMetric5) + ("ipRouteMetric5") $info->ipr_dest() + From RFC1213: - From RFC1213: + "The IP address of the next hop of this route. + (In the case of a route bound to an interface + which is realized via a broadcast media, the value + of this field is the agent's IP address on that + interface.)" - "The IP address of the next hop of this route. - (In the case of a route bound to an interface - which is realized via a broadcast media, the value - of this field is the agent's IP address on that - interface.)" - - (ipRouteNextHop) + ("ipRouteNextHop") $info->ipr_type() + From RFC1213: - From RFC1213: + other(1), -- none of the following + invalid(2), -- an invalidated route + -- route to directly + direct(3), -- connected (sub-)network + -- route to a non-local + indirect(4) -- host/network/sub-network - other(1), -- none of the following - invalid(2), -- an invalidated route - -- route to directly - direct(3), -- connected (sub-)network - -- route to a non-local - indirect(4) -- host/network/sub-network - - - "The type of route. Note that the values - direct(3) and indirect(4) refer to the notion of - direct and indirect routing in the IP - architecture. - - Setting this object to the value invalid(2) has - the effect of invalidating the corresponding entry - in the ipRouteTable object. That is, it - effectively disassociates the destination - identified with said entry from the route - identified with said entry. It is an - implementation-specific matter as to whether the - agent removes an invalidated entry from the table. - Accordingly, management stations must be prepared - to receive tabular information from agents that - corresponds to entries not currently in use. - Proper interpretation of such entries requires - examination of the relevant ipRouteType object." - (ipRouteType) + "The type of route. Note that the values + direct(3) and indirect(4) refer to the notion of + direct and indirect routing in the IP + architecture. + + Setting this object to the value invalid(2) has + the effect of invalidating the corresponding entry + in the ipRouteTable object. That is, it + effectively disassociates the destination + identified with said entry from the route + identified with said entry. It is an + implementation-specific matter as to whether the + agent removes an invalidated entry from the table. + Accordingly, management stations must be prepared + to receive tabular information from agents that + corresponds to entries not currently in use. + Proper interpretation of such entries requires + examination of the relevant ipRouteType object." + + ("ipRouteType") $info->ipr_proto() + From RFC1213: - From RFC1213: + other(1), -- none of the following + -- non-protocol information, + -- e.g., manually configured + local(2), -- entries + -- set via a network + netmgmt(3), -- management protocol + -- obtained via ICMP, + icmp(4), -- e.g., Redirect + -- the remaining values are + -- all gateway routing + -- protocols + egp(5), + ggp(6), + hello(7), + rip(8), + is-is(9), + es-is(10), + ciscoIgrp(11), + bbnSpfIgp(12), + ospf(13), + bgp(14) - other(1), -- none of the following - -- non-protocol information, - -- e.g., manually configured - local(2), -- entries - -- set via a network - netmgmt(3), -- management protocol - -- obtained via ICMP, - icmp(4), -- e.g., Redirect - -- the remaining values are - -- all gateway routing - -- protocols - egp(5), - ggp(6), - hello(7), - rip(8), - is-is(9), - es-is(10), - ciscoIgrp(11), - bbnSpfIgp(12), - ospf(13), - bgp(14) - - (ipRouteProto) + ("ipRouteProto") $info->ipr_age() + Seconds since route was last updated or validated. - Seconds since route was last updated or validated. - - (ipRouteAge) + ("ipRouteAge") $info->ipr_mask() + Subnet Mask of route. 0.0.0.0 for default gateway. - Subnet Mask of route. 0.0.0.0 for default gateway. - - (ipRouteMask) + ("ipRouteMask") $info->ipr_info() + Reference to MIB definition specific to routing protocol. - Reference to MIB definition specific to routing protocol. - - (ipRouteInfo) - - Topology Information + ("ipRouteInfo") + Topology Information Based upon the manufacturer and software version devices may support some combination of Layer 2 topology protocol information. SNMP::Info supports querying Link Layer Discovery Protocol (LLDP), Cisco Discovery @@ -1719,122 +1508,104 @@ USAGE For protocol specific information and implementation: LLDP: See SNMP::Info::LLDP for details. - CDP: See SNMP::Info::CDP for details. - SONMP: See SNMP::Info::SONMP for details. - FDP: See SNMP::Info::FDP for details. - EDP: See SNMP::Info::EDP for details. - AMAP: See SNMP::Info::AMAP for details. - Topology Capabilities - + Topology Capabilities $info->has_topo() + Reports Layer 2 topology protocols which are supported and running + on a device. - Reports Layer 2 topology protocols which are supported and running on - a device. - - Returns either a reference to an array of protocols, possible values - being: lldp, cdp, sonmp, fdp, edp, amap or undef if no protocols are - supported or running. - - Common Topology Table Information + Returns either a reference to an array of protocols, possible values + being: "lldp", "cdp", "sonmp", "fdp", "edp", "amap" or "undef" if no + protocols are supported or running. + Common Topology Table Information The common topology table methods below will query the device for information from the specified topology protocols and return a single hash combining all information. As a result, there may be identical topology information returned from the two protocols causing duplicate entries. It is the calling program's responsibility to identify any - duplicate entries and remove duplicates if necessary. If it is - necessary to understand which protocol provided the information, - utilize the protocol specific methods directly rather than the generic - methods. + duplicate entries and remove duplicates if necessary. If it is necessary + to understand which protocol provided the information, utilize the + protocol specific methods directly rather than the generic methods. The methods support partial table fetches by providing a partial as the first argument. If a reference to an array is provided as the second argument, those protocols will be queried for information. The supported array values - are: lldp, cdp, sonmp, fdp, edp, amap. + are: "lldp", "cdp", "sonmp", "fdp", "edp", "amap". If nothing is passed in as the second argument, the methods will call has_topo() to determine supported and running topology protocols on the device. $info->c_ip(partial, topology_protocol_arrayref) + Returns reference to hash. Key: iid, Value: remote IPv4 address - Returns reference to hash. Key: iid, Value: remote IPv4 address + If multiple entries exist with the same local port, c_if(), with the + same IPv4 address, c_ip(), it may be a duplicate entry. - If multiple entries exist with the same local port, c_if(), with the - same IPv4 address, c_ip(), it may be a duplicate entry. + If multiple entries exist with the same local port, c_if(), with + different IPv4 addresses, c_ip(), there is either a device in + between two or more devices utilizing a different topology protocol + or multiple devices which are not directly connected. - If multiple entries exist with the same local port, c_if(), with - different IPv4 addresses, c_ip(), there is either a device in between - two or more devices utilizing a different topology protocol or - multiple devices which are not directly connected. - - Use the protocol specific methods to dig deeper. + Use the protocol specific methods to dig deeper. $info->c_if(partial, topology_protocol_arrayref) - - Returns reference to hash. Key: iid, Value: local device port - (interfaces) + Returns reference to hash. Key: iid, Value: local device port + (interfaces) $info->c_port(partial, topology_protocol_arrayref) - - Returns reference to hash. Key: iid, Value: remote port (interfaces) + Returns reference to hash. Key: iid, Value: remote port (interfaces) $info->c_id(partial, topology_protocol_arrayref) + Returns reference to hash. Key: iid, Value: string value used to + identify the chassis component associated with the remote system. - Returns reference to hash. Key: iid, Value: string value used to - identify the chassis component associated with the remote system. - - Note: SONMP does not return this information. + Note: SONMP does not return this information. $info->c_platform(partial, topology_protocol_arrayref) + Returns reference to hash. Key: iid, Value: Remote Device Type - Returns reference to hash. Key: iid, Value: Remote Device Type - - Note: EDP does not provide this information. LLDP uses - (lldpRemSysDesc) or lldp_rem_sysname as the closest match. + Note: EDP does not provide this information. LLDP uses + ("lldpRemSysDesc") or "lldp_rem_sysname" as the closest match. $info->c_cap(partial, topology_protocol_arrayref) + Returns reference to hash of arrays. Key: iid, Value: Array of + capabilities supported by the device. See the specific protocol + class for string values which could be elements within the array. - Returns reference to hash of arrays. Key: iid, Value: Array of - capabilities supported by the device. See the specific protocol class - for string values which could be elements within the array. - - Note: Only CDP and LLDP support this method. + Note: Only CDP and LLDP support this method. SETTING DATA VIA SNMP - This section explains how to use SNMP::Info to do SNMP Set operations. $info->set_METHOD($value) + Sets the global METHOD to value. Assumes that iid is .0 - Sets the global METHOD to value. Assumes that iid is .0 + Returns if failed, or the return value from SNMP::Session::set() + (snmp_errno) - Returns if failed, or the return value from SNMP::Session::set() - (snmp_errno) - - $info->set_location("Here!"); + $info->set_location("Here!"); $info->set_METHOD($value,$iid) + Table Methods. Set iid of method to value. - Table Methods. Set iid of method to value. + Returns if failed, or the return value from SNMP::Session::set() + (snmp_errno) - Returns if failed, or the return value from SNMP::Session::set() - (snmp_errno) + # Disable a port administratively + my %if_map = reverse %{$info->interfaces()} + $info->set_i_up_admin('down', $if_map{'FastEthernet0/0'}) + or die "Couldn't disable the port. ",$info->error(1); - # Disable a port administratively - my %if_map = reverse %{$info->interfaces()} - $info->set_i_up_admin('down', $if_map{'FastEthernet0/0'}) - or die "Couldn't disable the port. ",$info->error(1); - - NOTE: You must be connected to your device with a ReadWrite community + NOTE: You must be connected to your device with a "ReadWrite" community string in order for set operations to work. NOTE: This will only set data listed in %FUNCS and %GLOBALS. For data @@ -1842,12 +1613,11 @@ SETTING DATA VIA SNMP subroutines will need to be added if they haven't been already. Quiet Mode - SNMP::Info will not chirp anything to STDOUT unless there is a serious error (in which case it will probably die). - To get lots of debug info, set the Debug flag when calling new() or - call $info->debug(1); + To get lots of debug info, set the Debug flag when calling new() or call + $info->debug(1); When calling a method check the return value. If the return value is undef then check $info->error() @@ -1857,26 +1627,25 @@ Quiet Mode my $name = $info->name() or die "Couldn't get sysName!" . $name->error(); EXTENDING SNMP::INFO - To support a new class (vendor or platform) of device, add a Perl package with the data structures and methods listed below. - If this seems a little scary, then the SNMP::Info developers are - usually happy to accept the SNMP data from your device and make an - attempt at the class themselves. Usually a "beta" release will go to - CPAN for you to verify the implementation. - - Gathering MIB data for SNMP::Info Developers + If this seems a little scary, then the SNMP::Info developers are usually + happy to accept the SNMP data from your device and make an attempt at + the class themselves. Usually a "beta" release will go to CPAN for you + to verify the implementation. + Gathering MIB data for SNMP::Info Developers The preference is to open a feature request in the SourceForge project. This allows all developers to have visibility into the request. Please include pointers to the applicable platform MIBs. For development we - will need an snmpwalk of the device. There is a tool now included in - the SNMP::Info distribution to help with this task, although you'll - most likely need to download the distribution from CPAN as it's - included in the "contrib/util" directory. + will need an "snmpwalk" of the device. There is a tool now included in + the SNMP::Info distribution to help with this task, although you'll most + likely need to download the distribution from CPAN as it's included in + the ""contrib/util"" directory. - The utility is named make_snmpdata.pl. Run it with a command line like: + The utility is named "make_snmpdata.pl". Run it with a command line + like: ./make_snmpdata.pl -c community -i -d device_ip \ -m /home/netdisco-mibs/rfc:/home/netdisco-mibs/net-snmp:/home/netdisco-mibs/dir3 \ @@ -1884,112 +1653,105 @@ EXTENDING SNMP::INFO POWER-ETHERNET-MIB IPV6-MIB LLDP-MIB DEVICE-SPECIFIC-MIB-NAME(s) > output.txt This will print to the file every MIB entry with data in a format that - the developers can use to emulate read operations without needing - access to the device. Preference would be to mask any sensitive data in - the output, zip the file, and upload as an attachment to the - Sourceforge tracker. However, if you do not feel comfortable uploading - the output to the tracker you could e-mail it to the developer that has - claimed the ticket. - - Data Structures required in new Subclass + the developers can use to emulate read operations without needing access + to the device. Preference would be to mask any sensitive data in the + output, zip the file, and upload as an attachment to the Sourceforge + tracker. However, if you do not feel comfortable uploading the output to + the tracker you could e-mail it to the developer that has claimed the + ticket. + Data Structures required in new Subclass A class inheriting this class must implement these data structures : $INIT - - Used to flag if the MIBs have been loaded yet. + Used to flag if the MIBs have been loaded yet. %GLOBALS + Contains a hash in the form ( method_name => SNMP MIB leaf name ) + These are scalar values such as name, uptime, etc. - Contains a hash in the form ( method_name => SNMP MIB leaf name ) - These are scalar values such as name, uptime, etc. + To resolve MIB leaf name conflicts between private MIBs, you may + prefix the leaf name with the MIB replacing each - (dash) and : + (colon) with an _ (underscore). For example, + ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion would be used as the hash + value instead of the net-snmp notation + ALTEON-TIGON-SWITCH-MIB::agSoftwareVersion. - To resolve MIB leaf name conflicts between private MIBs, you may - prefix the leaf name with the MIB replacing each - (dash) and : - (colon) with an _ (underscore). For example, - ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion would be used as the hash - value instead of the net-snmp notation - ALTEON-TIGON-SWITCH-MIB::agSoftwareVersion. - - When choosing the name for the methods, be aware that other new Sub - Modules might inherit this one to get it's features. Try to choose a - prefix for methods that will give it's own name space inside the - SNMP::Info methods. + When choosing the name for the methods, be aware that other new Sub + Modules might inherit this one to get it's features. Try to choose a + prefix for methods that will give it's own name space inside the + SNMP::Info methods. %FUNCS + Contains a hash in the form ( method_name => SNMP MIB leaf name) + These are table entries, such as the "ifIndex" - Contains a hash in the form ( method_name => SNMP MIB leaf name) - These are table entries, such as the ifIndex - - To resolve MIB leaf name conflicts between private MIBs, you may - prefix the leaf name with the MIB replacing each - (dash) and : - (colon) with an _ (underscore). For example, - ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName would be used as the - hash value instead of the net-snmp notation - ALTEON-TS-PHYSICAL-MIB::agPortCurCfgPortName. + To resolve MIB leaf name conflicts between private MIBs, you may + prefix the leaf name with the MIB replacing each - (dash) and : + (colon) with an _ (underscore). For example, + ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName would be used as the + hash value instead of the net-snmp notation + ALTEON-TS-PHYSICAL-MIB::agPortCurCfgPortName. %MIBS + A list of each mib needed. - A list of each mib needed. + ('MIB-NAME' => 'itemToTestForPresence') - ('MIB-NAME' => 'itemToTestForPresence') + The value for each entry should be a MIB object to check for to make + sure that the MIB is present and has loaded correctly. - The value for each entry should be a MIB object to check for to make - sure that the MIB is present and has loaded correctly. - - $info->init() will throw an exception if a MIB does not load. + $info->init() will throw an exception if a MIB does not load. %MUNGE + A map between method calls (from %FUNCS or %GLOBALS) and subroutine + methods. The subroutine called will be passed the data as it gets it + from SNMP and it should return that same data in a more human + friendly format. - A map between method calls (from %FUNCS or %GLOBALS) and subroutine - methods. The subroutine called will be passed the data as it gets it - from SNMP and it should return that same data in a more human - friendly format. + Sample %MUNGE: - Sample %MUNGE: + (my_ip => \&munge_ip, + my_mac => \&munge_mac, + my_layers => \&munge_dec2bin + ) - (my_ip => \&munge_ip, - my_mac => \&munge_mac, - my_layers => \&munge_dec2bin - ) - - Sample Subclass - - Let's make a sample Layer 2 Device subclass. This class will inherit - the Cisco Vlan module as an example. + Sample Subclass + Let's make a sample Layer 2 Device subclass. This class will inherit the + Cisco Vlan module as an example. ----------------------- snip -------------------------------- # SNMP::Info::Layer2::Sample - + package SNMP::Info::Layer2::Sample; - + $VERSION = 0.1; - + use strict; - + use Exporter; use SNMP::Info::Layer2; use SNMP::Info::CiscoVTP; - + @SNMP::Info::Layer2::Sample::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoVTP Exporter/; @SNMP::Info::Layer2::Sample::EXPORT_OK = qw//; - + use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/; - + %MIBS = (%SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoVTP::MIBS, 'SUPER-DOOPER-MIB' => 'supermibobject' ); - + %GLOBALS = (%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS, 'name' => 'supermib_supername', 'favorite_color' => 'supermib_fav_color_object', 'favorite_movie' => 'supermib_fav_movie_val' ); - + %FUNCS = (%SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoVTP::FUNCS, # Super Dooper MIB - Super Hero Table @@ -1997,35 +1759,35 @@ EXTENDING SNMP::INFO 'super_hero_name' => 'SuperHeroIfName', 'super_hero_powers' => 'SuperHeroIfPowers' ); - - + + %MUNGE = (%SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoVTP::MUNGE, 'super_hero_powers' => \&munge_powers ); - + # OverRide uptime() method from %SNMP::Info::GLOBALS sub uptime { my $sample = shift; - + my $name = $sample->name(); - + # this is silly but you get the idea return '600' if defined $name ; } - + # Create our own munge function sub munge_powers { my $power = shift; - + # Take the returned obscure value and return something useful. return 'Fire' if $power =~ /reallyhot/i; return 'Ice' if $power =~ /reallycold/i; - + # Else return $power; } - + # Copious Documentation here!!! =head1 NAME =head1 AUTHOR @@ -2038,18 +1800,16 @@ EXTENDING SNMP::INFO =head1 TABLE METHODS =head2 Overrides =cut - + 1; # don't forget this line ----------------------- snip -------------------------------- Be sure and send the debugged version to - snmp-info-users@lists.sourceforge.net to be included in the next - version of SNMP::Info. + snmp-info-users@lists.sourceforge.net to be included in the next version + of SNMP::Info. SNMP::INFO INTERNALS - - Object Namespace - + Object Namespace Internal data is stored with bareword keys. For example $info->{debug} SNMP Data is stored or marked cached with keys starting with an @@ -2058,386 +1818,330 @@ SNMP::INFO INTERNALS Cached Table data is stored in $info->store() and marked cached per above. - Package Globals - + Package Globals These set the default value for an object upon creation. $DEBUG - - Default 0. Sends copious debug info to stdout. This global sets the - object's debug status in new() unless 'Debug' argument passed in - new(). Change objects' debug status with $info->debug(). + Default 0. Sends copious debug info to stdout. This global sets the + object's debug status in new() unless 'Debug' argument passed in + new(). Change objects' debug status with $info->debug(). $BIGINT - - Default 0. Set to true to have 64 bit counters return Math::BigInt - objects instead of scalar string values. See note under Interface - Statistics about 64 bit values. + Default 0. Set to true to have 64 bit counters return Math::BigInt + objects instead of scalar string values. See note under Interface + Statistics about 64 bit values. $NOSUCH - - Default 1. Set to false to disable RetryNoSuch option for - SNMP::Session. Or see method in new() to do it on an object scope. + Default 1. Set to false to disable RetryNoSuch option for + SNMP::Session. Or see method in new() to do it on an object scope. $REPEATERS + Default 20. MaxRepeaters for BULKWALK operations. See "perldoc SNMP" + for more info. Can change by passing BulkRepeaters option in new() - Default 20. MaxRepeaters for BULKWALK operations. See perldoc SNMP - for more info. Can change by passing BulkRepeaters option in new() - - Data Munging Callback Subroutines - + Data Munging Callback Subroutines munge_speed() + Makes human friendly speed ratings using %SPEED_MAP - Makes human friendly speed ratings using %SPEED_MAP + %SPEED_MAP = ( + '56000' => '56 kbps', + '64000' => '64 kbps', + '115000' => '115 kpbs', + '1500000' => '1.5 Mbps', + '1536000' => 'T1', + '1544000' => 'T1', + '2000000' => '2.0 Mbps', + '2048000' => '2.048 Mbps', + '3072000' => 'Dual T1', + '3088000' => 'Dual T1', + '4000000' => '4.0 Mbps', + '10000000' => '10 Mbps', + '11000000' => '11 Mbps', + '20000000' => '20 Mbps', + '16000000' => '16 Mbps', + '16777216' => '16 Mbps', + '44210000' => 'T3', + '44736000' => 'T3', + '45000000' => '45 Mbps', + '45045000' => 'DS3', + '46359642' => 'DS3', + '51850000' => 'OC-1', + '54000000' => '54 Mbps', + '64000000' => '64 Mbps', + '100000000' => '100 Mbps', + '200000000' => '200 Mbps', + '149760000' => 'ATM on OC-3', + '155000000' => 'OC-3', + '155519000' => 'OC-3', + '155520000' => 'OC-3', + '400000000' => '400 Mbps', + '599040000' => 'ATM on OC-12', + '622000000' => 'OC-12', + '622080000' => 'OC-12', + '1000000000' => '1.0 Gbps', + '2000000000' => '2.0 Gbps', + '2488000000' => 'OC-48', + ) - %SPEED_MAP = ( - '56000' => '56 kbps', - '64000' => '64 kbps', - '115000' => '115 kpbs', - '1500000' => '1.5 Mbps', - '1536000' => 'T1', - '1544000' => 'T1', - '2000000' => '2.0 Mbps', - '2048000' => '2.048 Mbps', - '3072000' => 'Dual T1', - '3088000' => 'Dual T1', - '4000000' => '4.0 Mbps', - '10000000' => '10 Mbps', - '11000000' => '11 Mbps', - '20000000' => '20 Mbps', - '16000000' => '16 Mbps', - '16777216' => '16 Mbps', - '44210000' => 'T3', - '44736000' => 'T3', - '45000000' => '45 Mbps', - '45045000' => 'DS3', - '46359642' => 'DS3', - '51850000' => 'OC-1', - '54000000' => '54 Mbps', - '64000000' => '64 Mbps', - '100000000' => '100 Mbps', - '200000000' => '200 Mbps', - '149760000' => 'ATM on OC-3', - '155000000' => 'OC-3', - '155519000' => 'OC-3', - '155520000' => 'OC-3', - '400000000' => '400 Mbps', - '599040000' => 'ATM on OC-12', - '622000000' => 'OC-12', - '622080000' => 'OC-12', - '1000000000' => '1.0 Gbps', - '2000000000' => '2.0 Gbps', - '2488000000' => 'OC-48', - ) - - Note: high speed interfaces (usually 1 Gbps or faster) have their - link speed in ifHighSpeed. i_speed() automatically determines whether - to use ifSpeed or ifHighSpeed; if the latter is used, the value is - munged by munge_highspeed(). SNMP::Info can return speeds up to - terabit levels this way. + Note: high speed interfaces (usually 1 Gbps or faster) have their + link speed in "ifHighSpeed". i_speed() automatically determines + whether to use "ifSpeed" or "ifHighSpeed"; if the latter is used, + the value is munged by munge_highspeed(). SNMP::Info can return + speeds up to terabit levels this way. munge_highspeed() - - Makes human friendly speed ratings for ifHighSpeed + Makes human friendly speed ratings for "ifHighSpeed" munge_ip() - - Takes a binary IP and makes it dotted ASCII + Takes a binary IP and makes it dotted ASCII munge_mac() - - Takes an octet stream (HEX-STRING) and returns a colon separated - ASCII hex string. + Takes an octet stream (HEX-STRING) and returns a colon separated + ASCII hex string. munge_prio_mac() - - Takes an 2-byte octet stream (HEX-STRING) and returns a colon - separated ASCII hex string. + Takes an 2-byte octet stream (HEX-STRING) and returns a colon + separated ASCII hex string. munge_prio_port() - - Takes an 8-byte octet stream (HEX-STRING) and returns a colon - separated ASCII hex string. + Takes an 8-byte octet stream (HEX-STRING) and returns a colon + separated ASCII hex string. munge_octet2hex() - - Takes a binary octet stream and returns an ASCII hex string + Takes a binary octet stream and returns an ASCII hex string munge_dec2bin() - - Takes a binary char and returns its ASCII binary representation + Takes a binary char and returns its ASCII binary representation munge_bits - - Takes a SNMP2 'BITS' field and returns the ASCII bit string + Takes a SNMP2 'BITS' field and returns the ASCII bit string munge_counter64 - - If $BIGINT is set to true, then a Math::BigInt object is returned. - See Math::BigInt for details. + If $BIGINT is set to true, then a Math::BigInt object is returned. + See Math::BigInt for details. munge_i_up + Net-SNMP tends to load "RFC1213-MIB" first, and so ignores the + updated enumeration for "ifOperStatus" in "IF-MIB". This munge + handles the "newer" definitions for the enumeration in IF-MIB. - Net-SNMP tends to load RFC1213-MIB first, and so ignores the updated - enumeration for ifOperStatus in IF-MIB. This munge handles the - "newer" definitions for the enumeration in IF-MIB. - - TODO: Get the precedence of MIBs and overriding of MIB data in - Net-SNMP figured out. Heirarchy/precendence of MIBS in SNMP::Info. + TODO: Get the precedence of MIBs and overriding of MIB data in + Net-SNMP figured out. Heirarchy/precendence of MIBS in SNMP::Info. munge_port_list + Takes an octet string representing a set of ports and returns a + reference to an array of binary values each array element + representing a port. - Takes an octet string representing a set of ports and returns a - reference to an array of binary values each array element - representing a port. - - If the element has a value of '1', then that port is included in the - set of ports; the port is not included if it has a value of '0'. + If the element has a value of '1', then that port is included in the + set of ports; the port is not included if it has a value of '0'. munge_null() - - Removes control characters from a string + Removes control characters from a string munge_e_type() + Takes an OID and return the object name if the right MIB is loaded. - Takes an OID and return the object name if the right MIB is loaded. - - Internally Used Functions - + Internally Used Functions $info->init() - - Used internally. Loads all entries in %MIBS. + Used internally. Loads all entries in %MIBS. $info->args() - - Returns a reference to the argument hash supplied to SNMP::Session + Returns a reference to the argument hash supplied to SNMP::Session $info->class() - - Returns the class name of the object. + Returns the class name of the object. $info->error_throw(error message) + Stores the error message for use by $info->error() - Stores the error message for use by $info->error() - - If $info->debug() is true, then the error message is carped too. + If $info->debug() is true, then the error message is carped too. $info->funcs() - - Returns a reference to the %FUNCS hash. + Returns a reference to the %FUNCS hash. $info->globals() - - Returns a reference to the %GLOBALS hash. + Returns a reference to the %GLOBALS hash. $info->mibs() - - Returns a reference to the %MIBS hash. + Returns a reference to the %MIBS hash. $info->munge() - - Returns a reference of the %MUNGE hash. + Returns a reference of the %MUNGE hash. $info->nosuch() - - Returns NoSuch value set or not in new() + Returns NoSuch value set or not in new() $info->session() - - Gets or Sets the SNMP::Session object. + Gets or Sets the SNMP::Session object. $info->store(new_store) + Returns or sets hash store for Table functions. - Returns or sets hash store for Table functions. + Store is a hash reference in this format : - Store is a hash reference in this format : - - $info->store = { attribute => { iid => value , iid2 => value2, ... } - }; + $info->store = { attribute => { iid => value , iid2 => value2, ... } + }; $info->_global() + Used internally by AUTOLOAD to create dynamic methods from %GLOBALS + or a single instance MIB Leaf node name from a loaded MIB. - Used internally by AUTOLOAD to create dynamic methods from %GLOBALS - or a single instance MIB Leaf node name from a loaded MIB. + Example: $info->name() on the first call dispatches to AUTOLOAD() + which calls $info->_global('name') creating the method name(). - Example: $info->name() on the first call dispatches to AUTOLOAD() - which calls $info->_global('name') creating the method name(). - - These methods return data as a scalar. + These methods return data as a scalar. $info->_set(attr,val,iid,type) + Used internally by set_multi() to run an SNMP set command. When run + clears attr cache. - Used internally by set_multi() to run an SNMP set command. When run - clears attr cache. + Attr can be passed as either a scalar or a reference to an array or + array of arrays when used with set_multi(). - Attr can be passed as either a scalar or a reference to an array or - array of arrays when used with set_multi(). - - Example: $info->set_name('dog',3) uses autoload to resolve to - $info->_set('name','dog',3); + Example: $info->set_name('dog',3) uses autoload to resolve to + $info->_set('name','dog',3); $info->_make_setter(val,iid) + Used internally by AUTOLOAD to create dynamic methods from either + %GLOBALS, %FUNCS, or a valid mib leaf from a loaded MIB which runs + an SNMP set command. When run clears the attribute cache. - Used internally by AUTOLOAD to create dynamic methods from either - %GLOBALS, %FUNCS, or a valid mib leaf from a loaded MIB which runs an - SNMP set command. When run clears the attribute cache. - - Example: $info->set_name('dog',3) dispatches to autoload to resolve - to $info->_set('name','dog',3) and _make_setter creates the - set_name() method. + Example: $info->set_name('dog',3) dispatches to autoload to resolve + to $info->_set('name','dog',3) and _make_setter creates the + set_name() method. $info->set_multi(arrayref) + Used to run an SNMP set command on several new values in the one + request. Returns the result of $info->_set(method). - Used to run an SNMP set command on several new values in the one - request. Returns the result of $info->_set(method). + Pass either a reference to a 4 element array [, , , + ] or a reference to an array of 4 element arrays to specify + multiple values. - Pass either a reference to a 4 element array [, , , - ] or a reference to an array of 4 element arrays to specify - multiple values. + - One of the following forms: + 1) leaf identifier (e.g., C<'sysContact'>) + 2) An entry in either %FUNCS, %GLOBALS (e.g., 'contact') + - The dotted-decimal, instance identifier. For scalar MIB objects + use '0' + - The SNMP data value being set (e.g., 'netdisco') + - Optional as the MIB should be loaded. - - One of the following forms: - 1) leaf identifier (e.g., C<'sysContact'>) - 2) An entry in either %FUNCS, %GLOBALS (e.g., 'contact') - - The dotted-decimal, instance identifier. For scalar MIB objects - use '0' - - The SNMP data value being set (e.g., 'netdisco') - - Optional as the MIB should be loaded. + If one of the set assignments is invalid, then the request will be + rejected without applying any of the new values - regardless of the + order they appear in the list. - If one of the set assignments is invalid, then the request will be - rejected without applying any of the new values - regardless of the - order they appear in the list. + Example: my $vlan_set = [ + ['qb_v_untagged',"$old_vlan_id","$old_untagged_portlist"], + ['qb_v_egress',"$new_vlan_id","$new_egress_portlist"], + ['qb_v_egress',"$old_vlan_id","$old_egress_portlist"], + ['qb_v_untagged',"$new_vlan_id","$new_untagged_portlist"], + ['qb_i_vlan',"$port","$new_vlan_id"], ]; - Example: my $vlan_set = [ - ['qb_v_untagged',"$old_vlan_id","$old_untagged_portlist"], - ['qb_v_egress',"$new_vlan_id","$new_egress_portlist"], - ['qb_v_egress',"$old_vlan_id","$old_egress_portlist"], - ['qb_v_untagged',"$new_vlan_id","$new_untagged_portlist"], - ['qb_i_vlan',"$port","$new_vlan_id"], ]; - - $info->set_multi($vlan_set); + $info->set_multi($vlan_set); $info->load_all() + Debugging routine. This does not include any overridden method or + method implemented by subroutine. - Debugging routine. This does not include any overridden method or - method implemented by subroutine. + Runs $info->load_METHOD() for each entry in $info->funcs(); - Runs $info->load_METHOD() for each entry in $info->funcs(); + Returns $info->store() -- See store() entry. - Returns $info->store() -- See store() entry. - - Note return value has changed since version 0.3 + Note return value has changed since version 0.3 $info->all() + Runs $info->load_all() once then returns $info->store(); - Runs $info->load_all() once then returns $info->store(); + Use $info->load_all() to reload the data. - Use $info->load_all() to reload the data. - - Note return value has changed since version 0.3 + Note return value has changed since version 0.3 $info->_load_attr() + Used internally by AUTOLOAD to create dynamic methods from %FUNCS or + a MIB Leaf node name contained within a table of a loaded MIB. - Used internally by AUTOLOAD to create dynamic methods from %FUNCS or - a MIB Leaf node name contained within a table of a loaded MIB. + Supports partial table fetches and single instance table fetches. + See "Partial Table Fetches" in SNMP::Info. - Supports partial table fetches and single instance table fetches. See - "Partial Table Fetches" in SNMP::Info. - - These methods return data as a reference to a hash. + These methods return data as a reference to a hash. $info->_show_attr() - - Used internally by AUTOLOAD to return data called by methods listed - in %FUNCS. + Used internally by AUTOLOAD to return data called by methods listed + in %FUNCS. $info->snmp_connect_ip(ip) - - Returns true or false based upon snmp connectivity to an IP. + Returns true or false based upon snmp connectivity to an IP. modify_port_list(portlist,offset,replacement) - - Replaces the specified bit in a port_list array and returns the - packed bitmask + Replaces the specified bit in a port_list array and returns the + packed bitmask $info->_cache(attr, data) + Cache retrieved data so that if it's asked for again, we use the + cache instead of going back to Net-SNMP. Data is cached inside the + blessed hashref $self. - Cache retrieved data so that if it's asked for again, we use the - cache instead of going back to Net-SNMP. Data is cached inside the - blessed hashref $self. - - Accepts the leaf and value (scalar, or hashref for a table). Does not - return anything useful. + Accepts the leaf and value (scalar, or hashref for a table). Does + not return anything useful. $info->_munge(attr, data) + Raw data returned from Net-SNMP might not be formatted correctly or + might have platform-specific bugs or mistakes. The MUNGE feature of + SNMP::Info allows for fixups to take place. - Raw data returned from Net-SNMP might not be formatted correctly or - might have platform-specific bugs or mistakes. The MUNGE feature of - SNMP::Info allows for fixups to take place. - - Accepts the leaf and value (scalar, or hashref for a table) and - returns the raw or the munged data, as appropriate. That is, you do - not need to know whether MUNGE is installed, and it's safe to call - this method regardless. + Accepts the leaf and value (scalar, or hashref for a table) and + returns the raw or the munged data, as appropriate. That is, you do + not need to know whether MUNGE is installed, and it's safe to call + this method regardless. _validate_autoload_method(method) + Used internally by AUTOLOAD to validate that a dynamic method should + be created. Returns the OID of the MIB leaf node the method will get + or set. - Used internally by AUTOLOAD to validate that a dynamic method should - be created. Returns the OID of the MIB leaf node the method will get - or set. - - 1. Returns unless method is listed in %FUNCS, %GLOBALS, or is MIB - Leaf node name in a loaded MIB for given class. - - 2. Translates the MIB Leaf node name to an OID. - - 3. Checks to see if the method access type is allowed for the - resolved OID. Write access for set_ methods, read access for others. + 1. Returns unless method is listed in %FUNCS, %GLOBALS, or is MIB + Leaf node name in a loaded MIB for given class. + 2. Translates the MIB Leaf node name to an OID. + 3. Checks to see if the method access type is allowed for the + resolved OID. Write access for set_ methods, read access for others. $info->can() + Overrides UNIVERSAL::can() so that objects will correctly report + their capabilities to include dynamic methods generated at run time + via AUTOLOAD. - Overrides UNIVERSAL::can() so that objects will correctly report - their capabilities to include dynamic methods generated at run time - via AUTOLOAD. + Calls parent can() first to see if method exists, if not validates + that a method should be created then dispatches to the appropriate + internal method for creation. The newly created method is inserted + into the symbol table returning to AUTOLOAD only for the initial + method call. - Calls parent can() first to see if method exists, if not validates - that a method should be created then dispatches to the appropriate - internal method for creation. The newly created method is inserted - into the symbol table returning to AUTOLOAD only for the initial - method call. + Returns undef if the method does not exist and can not be created. - Returns undef if the method does not exist and can not be created. - - AUTOLOAD - - Each entry in either %FUNCS, %GLOBALS, or MIB Leaf node names present - in loaded MIBs are used by AUTOLOAD() to create dynamic methods. - Generated methods are inserted into the symbol table so that subsequent - calls can avoid AUTOLOAD() and dispatch directly. - - 1. Returns unless method is listed in %FUNCS, %GLOBALS, or is a MIB - Leaf node name in a loaded MIB for given class. + AUTOLOAD + Each entry in either %FUNCS, %GLOBALS, or MIB Leaf node names present in + loaded MIBs are used by AUTOLOAD() to create dynamic methods. Generated + methods are inserted into the symbol table so that subsequent calls can + avoid AUTOLOAD() and dispatch directly. + 1. Returns unless method is listed in %FUNCS, %GLOBALS, or is a MIB Leaf + node name in a loaded MIB for given class. 2. If the method exists in %GLOBALS or is a single instance MIB Leaf node name from a loaded MIB, _global() generates the method. - 3. If a set_ prefix is present _make_setter() generates the method. - 4. If the method exists in %FUNCS or is a MIB Leaf node name contained within a table from a loaded MIB, _load_attr() generates the method. - - 5. A load_ prefix forces reloading of data and does not use cached - data. - + 5. A load_ prefix forces reloading of data and does not use cached data. 6. A _raw suffix returns data ignoring any munge routines. - Override any dynamic method listed in %GLOBALS, %FUNCS, or MIB Leaf - node name a by creating a subroutine with the same name. + Override any dynamic method listed in %GLOBALS, %FUNCS, or MIB Leaf node + name a by creating a subroutine with the same name. - For example to override $info->name() create `` sub name {...}'' in - your subclass. + For example to override $info->name() create `` sub name {...}'' in your + subclass. COPYRIGHT AND LICENSE - Changes from SNMP::Info Version 0.7 and on are: Copyright (c) 2003-2010 Max Baker and SNMP::Info Developers All rights reserved. @@ -2460,12 +2164,12 @@ COPYRIGHT AND LICENSE 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. + 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. diff --git a/lib/SNMP/Info.pm b/lib/SNMP/Info.pm index 715c973c..a265eded 100644 --- a/lib/SNMP/Info.pm +++ b/lib/SNMP/Info.pm @@ -24,7 +24,7 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG %SPEED_MAP $NOSUCH $BIGINT $REPEATERS/; -$VERSION = '3.53'; +$VERSION = '3.54'; =head1 NAME @@ -32,7 +32,7 @@ SNMP::Info - OO Interface to Network devices and MIBs through SNMP =head1 VERSION -SNMP::Info - Version 3.53 +SNMP::Info - Version 3.54 =head1 AUTHOR @@ -474,7 +474,7 @@ See documentation in L for details. =item SNMP::Info::Layer1::Cyclades -Subclass for Cyclades terminal servers. +Subclass for Cyclades/Avocent terminal servers. See documentation in L for details. @@ -1588,6 +1588,7 @@ sub device_type { 8072 => 'SNMP::Info::Layer3::NetSNMP', 9303 => 'SNMP::Info::Layer3::PacketFront', 10002 => 'SNMP::Info::Layer2::Ubiquiti', + 10418 => 'SNMP::Info::Layer1::Cyclades', 12325 => 'SNMP::Info::Layer3::Pf', 12356 => 'SNMP::Info::Layer3::Fortinet', 14179 => 'SNMP::Info::Layer2::Airespace', @@ -1628,6 +1629,7 @@ sub device_type { 5624 => 'SNMP::Info::Layer3::Enterasys', 6486 => 'SNMP::Info::Layer3::AlcatelLucent', 9303 => 'SNMP::Info::Layer3::PacketFront', + 10418 => 'SNMP::Info::Layer1::Cyclades', 11898 => 'SNMP::Info::Layer2::Orinoco', 14179 => 'SNMP::Info::Layer2::Airespace', 14525 => 'SNMP::Info::Layer2::Trapeze', @@ -1638,6 +1640,7 @@ sub device_type { my %l1sysoidmap = ( 2925 => 'SNMP::Info::Layer1::Cyclades', + 10418 => 'SNMP::Info::Layer1::Cyclades', ); my %l7sysoidmap = ( @@ -3085,7 +3088,7 @@ ALTEON-TS-PHYSICAL-MIB::agPortCurCfgPortName. %FUNCS = ( # IF-MIB::IfEntry 'interfaces' => 'ifIndex', - # IF-MIB::IfEntry + # IF-MIB::IfXEntry 'i_name' => 'ifName', # IF-MIB::IfEntry @@ -3888,7 +3891,6 @@ These methods return data as a scalar. sub _global { my $method = shift; my $oid = shift; - return sub {} if $method eq 'CARP_TRACE'; return sub { my $self = shift; @@ -3986,8 +3988,9 @@ sub _set { } else { $self->error_throw( - "SNMP::Info::_set($attr,$val) - Failed. Invalid argument for attr." + "SNMP::Info::_set - Failed. Invalid arguments" ); + return; } my $sess = $self->session(); @@ -4218,8 +4221,6 @@ sub _load_attr { return unless defined $sess; my $ver = $self->snmp_ver(); - my $nosuch = $self->nosuch(); - my $store = $self->store(); my $load = $method =~ /^load/; my $raw = $method =~ /raw$/; @@ -4631,15 +4632,13 @@ sub _validate_autoload_method { # If we were given a fully qualified OID because we don't have the MIB # file, it will translate above but we won't be able to check access so # skip the check and return - if ($access) { - unless ( ( $method =~ /^set/ && $access =~ /Write|Create/ ) - || $access =~ /Read|Create/ ) - { + if ($access && $method =~ /^set/ && $access !~ /Write|Create/) { + print "SNMP::Info::_validate_autoload_method($attr : $oid) Not accessable for requested operation.\n" if $self->debug(); return; - } + } # If the parent of the leaf has indexes it is contained within a table @@ -4687,6 +4686,8 @@ sub can { # use results of parent can() return $self->SUPER::can($method) if $self->SUPER::can($method); + return if $method eq 'CARP_TRACE'; + my $validated = $self->_validate_autoload_method($method); return unless $validated; @@ -4763,6 +4764,8 @@ sub AUTOLOAD { my $self = shift; my ($sub_name) = $AUTOLOAD =~ /::(\w+)$/; + return if $sub_name eq 'CARP_TRACE'; + # Typos in function calls in SNMP::Info subclasses turn into # AUTOLOAD requests for non-methods. While this is deprecated, # we'll still get called, so report a less confusing error. diff --git a/lib/SNMP/Info/AMAP.pm b/lib/SNMP/Info/AMAP.pm index 098a734d..c9d998ec 100644 --- a/lib/SNMP/Info/AMAP.pm +++ b/lib/SNMP/Info/AMAP.pm @@ -38,7 +38,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB' => 'aipAMAPRemDeviceType', ); diff --git a/lib/SNMP/Info/AdslLine.pm b/lib/SNMP/Info/AdslLine.pm index 68a2a1e5..a7f767f3 100644 --- a/lib/SNMP/Info/AdslLine.pm +++ b/lib/SNMP/Info/AdslLine.pm @@ -38,7 +38,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'ADSL-LINE-MIB' => 'adslLineType' ); diff --git a/lib/SNMP/Info/Aggregate.pm b/lib/SNMP/Info/Aggregate.pm index 6873baee..7a3f6b77 100644 --- a/lib/SNMP/Info/Aggregate.pm +++ b/lib/SNMP/Info/Aggregate.pm @@ -38,9 +38,10 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; -%MIBS = (); # IF-MIB +# Load MIB for leafs referenced within class +%MIBS = ('IF-MIB' => 'ifIndex',); %GLOBALS = (); diff --git a/lib/SNMP/Info/Airespace.pm b/lib/SNMP/Info/Airespace.pm index 307251dc..8f1b9e82 100644 --- a/lib/SNMP/Info/Airespace.pm +++ b/lib/SNMP/Info/Airespace.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Bridge.pm b/lib/SNMP/Info/Bridge.pm index bb69d2ed..ac6c0581 100644 --- a/lib/SNMP/Info/Bridge.pm +++ b/lib/SNMP/Info/Bridge.pm @@ -42,7 +42,7 @@ use SNMP::Info; use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'BRIDGE-MIB' => 'dot1dBaseBridgeAddress', diff --git a/lib/SNMP/Info/CDP.pm b/lib/SNMP/Info/CDP.pm index 0299872c..9d39b71c 100644 --- a/lib/SNMP/Info/CDP.pm +++ b/lib/SNMP/Info/CDP.pm @@ -43,7 +43,7 @@ use SNMP::Info; use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT %CDP_CAPABILITIES/; -$VERSION = '3.53'; +$VERSION = '3.54'; # Five data structures required by SNMP::Info %MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' ); diff --git a/lib/SNMP/Info/CiscoAgg.pm b/lib/SNMP/Info/CiscoAgg.pm index 03981200..e545fa4c 100644 --- a/lib/SNMP/Info/CiscoAgg.pm +++ b/lib/SNMP/Info/CiscoAgg.pm @@ -43,7 +43,7 @@ use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::IEEE802dot3ad::MIBS, diff --git a/lib/SNMP/Info/CiscoConfig.pm b/lib/SNMP/Info/CiscoConfig.pm index e4d9e4f0..6543a66c 100644 --- a/lib/SNMP/Info/CiscoConfig.pm +++ b/lib/SNMP/Info/CiscoConfig.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-CONFIG-COPY-MIB' => 'ccCopyTable', diff --git a/lib/SNMP/Info/CiscoPortSecurity.pm b/lib/SNMP/Info/CiscoPortSecurity.pm index 37baa7b6..6a4ecc12 100644 --- a/lib/SNMP/Info/CiscoPortSecurity.pm +++ b/lib/SNMP/Info/CiscoPortSecurity.pm @@ -38,7 +38,7 @@ use Exporter; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PAECAPABILITIES/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB', diff --git a/lib/SNMP/Info/CiscoPower.pm b/lib/SNMP/Info/CiscoPower.pm index 1e913b9d..342ad315 100644 --- a/lib/SNMP/Info/CiscoPower.pm +++ b/lib/SNMP/Info/CiscoPower.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex', 'CISCO-CDP-MIB' => 'cdpCachePowerConsumption' ); diff --git a/lib/SNMP/Info/CiscoQOS.pm b/lib/SNMP/Info/CiscoQOS.pm index a48fb717..dfaab61b 100644 --- a/lib/SNMP/Info/CiscoQOS.pm +++ b/lib/SNMP/Info/CiscoQOS.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex', ); diff --git a/lib/SNMP/Info/CiscoRTT.pm b/lib/SNMP/Info/CiscoRTT.pm index 72139993..e8d841f4 100644 --- a/lib/SNMP/Info/CiscoRTT.pm +++ b/lib/SNMP/Info/CiscoRTT.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner', ); diff --git a/lib/SNMP/Info/CiscoStack.pm b/lib/SNMP/Info/CiscoStack.pm index 0638db25..fa6b452e 100644 --- a/lib/SNMP/Info/CiscoStack.pm +++ b/lib/SNMP/Info/CiscoStack.pm @@ -38,7 +38,7 @@ use Exporter; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-STACK-MIB' => 'ciscoStackMIB', ); diff --git a/lib/SNMP/Info/CiscoStats.pm b/lib/SNMP/Info/CiscoStats.pm index b2bcfc29..152244cd 100644 --- a/lib/SNMP/Info/CiscoStats.pm +++ b/lib/SNMP/Info/CiscoStats.pm @@ -42,7 +42,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'SNMPv2-MIB' => 'sysDescr', diff --git a/lib/SNMP/Info/CiscoStpExtensions.pm b/lib/SNMP/Info/CiscoStpExtensions.pm index 7cda5efc..242b9358 100644 --- a/lib/SNMP/Info/CiscoStpExtensions.pm +++ b/lib/SNMP/Info/CiscoStpExtensions.pm @@ -36,7 +36,7 @@ use SNMP::Info::Bridge; use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/; -$VERSION = '3.53'; +$VERSION = '3.54'; @SNMP::Info::CiscoStpExtensions::ISA = qw/SNMP::Info::Bridge SNMP::Info Exporter/; @SNMP::Info::CiscoStpExtensions::EXPORT_OK = qw//; diff --git a/lib/SNMP/Info/CiscoVTP.pm b/lib/SNMP/Info/CiscoVTP.pm index 5f1c4d46..875f5cc2 100644 --- a/lib/SNMP/Info/CiscoVTP.pm +++ b/lib/SNMP/Info/CiscoVTP.pm @@ -41,7 +41,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'CISCO-VTP-MIB' => 'vtpVlanName', diff --git a/lib/SNMP/Info/EDP.pm b/lib/SNMP/Info/EDP.pm index 526dcb09..bc35b3c9 100644 --- a/lib/SNMP/Info/EDP.pm +++ b/lib/SNMP/Info/EDP.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'EXTREME-EDP-MIB' => 'extremeEdpPortIfIndex', diff --git a/lib/SNMP/Info/Entity.pm b/lib/SNMP/Info/Entity.pm index 8f0455cf..c04df6f8 100644 --- a/lib/SNMP/Info/Entity.pm +++ b/lib/SNMP/Info/Entity.pm @@ -41,7 +41,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum' ); diff --git a/lib/SNMP/Info/EtherLike.pm b/lib/SNMP/Info/EtherLike.pm index 7146f1a8..372238c1 100644 --- a/lib/SNMP/Info/EtherLike.pm +++ b/lib/SNMP/Info/EtherLike.pm @@ -41,7 +41,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'EtherLike-MIB' => 'etherMIB' ); @@ -68,7 +68,6 @@ $VERSION = '3.53'; 'el_xmit_defer' => 'dot3StatsDeferredTransmissions', # Ethernet-like Collision Statistics Group - 'el_coll_count' => 'dot3CollCount', 'el_coll_freq' => 'dot3CollFrequencies' ); diff --git a/lib/SNMP/Info/FDP.pm b/lib/SNMP/Info/FDP.pm index 21b38063..8cacfa5a 100644 --- a/lib/SNMP/Info/FDP.pm +++ b/lib/SNMP/Info/FDP.pm @@ -42,7 +42,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' ); diff --git a/lib/SNMP/Info/IEEE802dot11.pm b/lib/SNMP/Info/IEEE802dot11.pm index 21ce9d66..0accee1b 100644 --- a/lib/SNMP/Info/IEEE802dot11.pm +++ b/lib/SNMP/Info/IEEE802dot11.pm @@ -38,7 +38,7 @@ use Exporter; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'IEEE802dot11-MIB' => 'dot11DesiredSSID', ); diff --git a/lib/SNMP/Info/IEEE802dot3ad.pm b/lib/SNMP/Info/IEEE802dot3ad.pm index e6bb71d8..da49a726 100644 --- a/lib/SNMP/Info/IEEE802dot3ad.pm +++ b/lib/SNMP/Info/IEEE802dot3ad.pm @@ -43,7 +43,7 @@ use SNMP::Info::Aggregate; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Aggregate::MIBS, diff --git a/lib/SNMP/Info/IPv6.pm b/lib/SNMP/Info/IPv6.pm index da3a0e2d..251532ae 100644 --- a/lib/SNMP/Info/IPv6.pm +++ b/lib/SNMP/Info/IPv6.pm @@ -44,7 +44,7 @@ use constant { IPV6MIB => 3, }; -$VERSION = '3.53'; +$VERSION = '3.54'; @@ -67,7 +67,7 @@ $VERSION = '3.53'; 'ip_n2p_phys_state' => 'ipNetToPhysicalState', # IP-MIB 'c_inet_phys_state' => 'cInetNetToMediaState', # CISCO-IETF-IP-MIB - 'i6_n2p_phys_state' => 'ipv6NetToMediaState', # IPV6-MIB + 'i6_n2p_phys_state' => 'ipv6IfNetToMediaState', # IPV6-MIB 'ip_pfx_origin' => 'ipAddressPrefixOrigin', # IP-MIB 'c_pfx_origin' => 'cIpAddressPfxOrigin', # CISCO-IETF-IP-MIB @@ -75,8 +75,9 @@ $VERSION = '3.53'; 'ip_addr6_pfx' => 'ipAddressPrefix', # IP-MIB 'c_addr6_pfx' => 'cIpAddressPrefix', # CISCO-IETF-IP-MIB - 'ip_addr6_pfxlen' => 'ipAddressPrefixLength', # IP-MIB - 'c_addr6_pfxlen' => 'cIpAddressPfxLength', # CISCO-IETF-IP-MIB + # Commented out are not-accessible according to MIB + #'ip_addr6_pfxlen' => 'ipAddressPrefixLength', # IP-MIB + #'c_addr6_pfxlen' => 'cIpAddressPfxLength', # CISCO-IETF-IP-MIB 'i6_addr_pfxlen' => 'ipv6AddrPfxLength', # IPV6-MIB 'ip_addr6_index' => 'ipAddressIfIndex', # IP-MIB diff --git a/lib/SNMP/Info/LLDP.pm b/lib/SNMP/Info/LLDP.pm index 732b6cad..5740fdb5 100644 --- a/lib/SNMP/Info/LLDP.pm +++ b/lib/SNMP/Info/LLDP.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'LLDP-MIB' => 'lldpLocSysCapEnabled', diff --git a/lib/SNMP/Info/Layer1.pm b/lib/SNMP/Info/Layer1.pm index 136fc045..0abde8d5 100644 --- a/lib/SNMP/Info/Layer1.pm +++ b/lib/SNMP/Info/Layer1.pm @@ -41,7 +41,7 @@ use SNMP::Info; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, 'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex' ); diff --git a/lib/SNMP/Info/Layer1/Allied.pm b/lib/SNMP/Info/Layer1/Allied.pm index 32a9b59a..01be736d 100644 --- a/lib/SNMP/Info/Layer1/Allied.pm +++ b/lib/SNMP/Info/Layer1/Allied.pm @@ -41,7 +41,7 @@ use SNMP::Info::Layer1; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # Set for No CDP %GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, 'root_ip' => 'actualIPAddr', ); @@ -71,6 +71,7 @@ sub os_ver { if ( $descr =~ m/version (\d+\.\d+)/ ) { return $1; } + return; } sub model { diff --git a/lib/SNMP/Info/Layer1/Asante.pm b/lib/SNMP/Info/Layer1/Asante.pm index 6a15d005..7c443ea3 100644 --- a/lib/SNMP/Info/Layer1/Asante.pm +++ b/lib/SNMP/Info/Layer1/Asante.pm @@ -41,7 +41,7 @@ use SNMP::Info::Layer1; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # Set for No CDP %GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, ); @@ -84,6 +84,7 @@ sub os_ver { if ( $descr =~ /software v(\d+\.\d+)/ ) { return $1; } + return; } sub vendor { @@ -94,7 +95,7 @@ sub model { my $asante = shift; my $id = $asante->id(); - my $model = &SNMP::translateObj($id); + my $model = SNMP::translateObj($id); return $model; } @@ -108,8 +109,8 @@ sub i_up { my $i_up = {}; foreach my $port ( keys %$asante_up ) { my $up = $asante_up->{$port}; - $i_up->{$port} = 'down' if $up =~ /on/; - $i_up->{$port} = 'up' if $up =~ /off/; + $i_up->{$port} = 'down' if $up =~ /off/; + $i_up->{$port} = 'up' if $up =~ /on/; } return $i_up; @@ -149,7 +150,7 @@ sub i_name { my $asante = shift; my $partial = shift; - my $i_name = $asante->orig_i_descr($partial) || {}; + my $i_name = $asante->orig_i_description($partial) || {}; my %i_name; diff --git a/lib/SNMP/Info/Layer1/Bayhub.pm b/lib/SNMP/Info/Layer1/Bayhub.pm index 568583a6..91290e13 100644 --- a/lib/SNMP/Info/Layer1/Bayhub.pm +++ b/lib/SNMP/Info/Layer1/Bayhub.pm @@ -42,7 +42,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer1/Cyclades.pm b/lib/SNMP/Info/Layer1/Cyclades.pm index 6a4272a1..aea13144 100644 --- a/lib/SNMP/Info/Layer1/Cyclades.pm +++ b/lib/SNMP/Info/Layer1/Cyclades.pm @@ -1,7 +1,7 @@ # SNMP::Info::Layer1::Cyclades # $Id$ # -# Copyright (c) 2008 Eric Miller +# Copyright (c) 2018 Eric Miller # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -39,38 +39,105 @@ use SNMP::Info::Layer1; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer1::MIBS, - 'CYCLADES-ACS-SYS-MIB' => 'cyACSversion', - 'CYCLADES-ACS-CONF-MIB' => 'cyEthIPaddr', - 'CYCLADES-ACS-INFO-MIB' => 'cyISPortTty', + 'CYCLADES-ACS-SYS-MIB' => 'cyACSversion', + 'CYCLADES-ACS5K-SYS-MIB' => 'cyACS5Kversion', + 'CYCLADES-ACS-CONF-MIB' => 'cyACSConf', + 'CYCLADES-ACS5K-CONF-MIB' => 'cyACS5KConf', + 'CYCLADES-ACS-INFO-MIB' => 'cyACSInfo', + 'CYCLADES-ACS5K-INFO-MIB' => 'cyACS5KInfo', + 'ACS-MIB' => 'acs6016', + 'ACS8000-MIB' => 'acs8048', ); %GLOBALS = ( - # CYCLADES-ACS-SYS-MIB %SNMP::Info::Layer1::GLOBALS, - 'os_ver' => 'cyACSversion', - 'cy_model' => 'cyACSpname', - 'serial' => 'cyACSDevId', - 'root_ip' => 'cyEthIPaddr', - 'ps1_status' => 'cyACSPw1', - 'ps2_status' => 'cyACSPw2', + + # CYCLADES-ACS-SYS-MIB + 'cy_os_ver' => 'cyACSversion', + 'cy_model' => 'cyACSpname', + 'cy_serial' => 'cyACSDevId', + 'cy_ps1_status' => 'cyACSPw1', + 'cy_ps2_status' => 'cyACSPw2', + + # CYCLADES-ACS-CONF-MIB + 'cy_root_ip' => 'CYCLADES_ACS_CONF_MIB__cyEthIPaddr', + + # CYCLADES-ACS5K-SYS-MIB + 'cy5k_os_ver' => 'cyACS5Kversion', + 'cy5k_model' => 'cyACS5Kpname', + 'cy5k_serial' => 'cyACS5KDevId', + 'cy5k_ps1_status' => 'cyACS5KPw1', + 'cy5k_ps2_status' => 'cyACS5KPw2', + + # CYCLADES-ACS5K-CONF-MIB + 'cy5k_root_ip' => 'CYCLADES_ACS5K_CONF_MIB__cyEthIPaddr', + + # ACS-MIB + 'acs_os_ver' => 'ACS_MIB__acsFirmwareVersion', + 'acs_model' => 'ACS_MIB__acsProductModel', + 'acs_serial' => 'ACS_MIB__acsSerialNumber', + 'acs_ps1_status' => 'ACS_MIB__acsPowerSupplyStatePw1', + 'acs_ps2_status' => 'ACS_MIB__acsPowerSupplyStatePw2', + + # ACS8000-MIB + 'acs8k_os_ver' => 'ACS8000_MIB__acsFirmwareVersion', + 'acs8k_model' => 'ACS8000_MIB__acsProductModel', + 'acs8k_serial' => 'ACS8000_MIB__acsSerialNumber', + 'acs8k_ps1_status' => 'ACS8000_MIB__acsPowerSupplyStatePw1', + 'acs8k_ps2_status' => 'ACS8000_MIB__acsPowerSupplyStatePw2', ); %FUNCS = ( %SNMP::Info::Layer1::FUNCS, # CYCLADES-ACS-INFO-MIB::cyInfoSerialTable - 'cy_port_tty' => 'cyISPortTty', - 'cy_port_name' => 'cyISPortName', - 'cy_port_speed' => 'cyISPortSpeed', - 'cy_port_cd' => 'cyISPortSigCD', + 'cy_port_tty' => 'CYCLADES_ACS_INFO_MIB__cyISPortTty', + 'cy_port_name' => 'CYCLADES_ACS_INFO_MIB__cyISPortName', + 'cy_port_speed' => 'CYCLADES_ACS_INFO_MIB__cyISPortSpeed', + 'cy_port_cd' => 'CYCLADES_ACS_INFO_MIB__cyISPortSigCD', # CYCLADES-ACS-CONF-MIB::cySerialPortTable - 'cy_port_socket' => 'cySPortSocketPort', + 'cy_port_socket' => 'CYCLADES_ACS_CONF_MIB__cySPortSocketPort', + + # CYCLADES-ACS5K-INFO-MIB::cyInfoSerialTable + 'cy5k_port_tty' => 'CYCLADES_ACS5K_INFO_MIB__cyISPortTty', + 'cy5k_port_name' => 'CYCLADES_ACS5K_INFO_MIB__cyISPortName', + 'cy5k_port_speed' => 'CYCLADES_ACS5K_INFO_MIB__cyISPortSpeed', + 'cy5k_port_cd' => 'CYCLADES_ACS5K_INFO_MIB__cyISPortSigCD', + + # CYCLADES-ACS5K-CONF-MIB::cySerialPortTable + 'cy5k_port_socket' => 'CYCLADES_ACS5K_CONF_MIB__cySPortSocketPort', + + # ACS-MIB::acsSerialPortTable + 'acs_port_tty' => 'ACS_MIB__acsSerialPortTableDeviceName', + 'acs_port_name' => 'ACS_MIB__acsSerialPortTableName', + 'acs_port_speed' => 'ACS_MIB__acsSerialPortTableComSpeed', + 'acs_port_cd' => 'ACS_MIB__acsSerialPortTableSignalStateDCD', + + # Equivalent to cySPortSocketPort doesn't exist in ACS-MIB + # Use 'acsSerialPortTableDeviceName' as an equivalent, it just needs + # to be unique so that we can differentiate between the index in the + # acsSerialPortTable from ifIndex which are both integers + # ACS-MIB::acsSerialPortTableEntry + 'acs_port_socket' => 'ACS_MIB__acsSerialPortTableDeviceName', + + # ACS8000-MIB::acsSerialPortTable + 'acs8k_port_tty' => 'ACS8000_MIB__acsSerialPortTableDeviceName', + 'acs8k_port_name' => 'ACS8000_MIB__acsSerialPortTableName', + 'acs8k_port_speed' => 'ACS8000_MIB__acsSerialPortTableComSpeed', + 'acs8k_port_cd' => 'ACS8000_MIB__acsSerialPortTableSignalStateDCD', + + # Equivalent to cySPortSocketPort doesn't exist in ACS-MIB + # Use 'acsSerialPortTableDeviceName' as an equivalent, it just needs + # to be unique so that we can differentiate between the index in the + # acsSerialPortTable from ifIndex which are both integers + # ACS8000-MIB::acsSerialPortTableEntry + 'acs8k_port_socket' => 'ACS8000_MIB__acsSerialPortTableDeviceName', ); %MUNGE = ( %SNMP::Info::Layer1::MUNGE, ); @@ -82,21 +149,85 @@ sub layers { } sub os { - return 'cyclades'; + return 'avocent'; +} + +# Use "short circuit" to return the first MIB instance that returns data to +# reduce network communications +# We'll try newest (acs*) first assuming those are most likely deployed +sub os_ver { + my $cyclades = shift; + + return + $cyclades->acs_os_ver() + || $cyclades->acs8k_os_ver() + || $cyclades->cy5k_os_ver() + || $cyclades->cy_os_ver() + || undef; } sub vendor { - return 'cyclades'; + return 'vertiv'; } sub model { my $cyclades = shift; - my $model = $cyclades->cy_model(); + my $model + = $cyclades->acs_model() + || $cyclades->acs8k_model() + || $cyclades->cy5k_model() + || $cyclades->cy_model() + || undef; - return unless defined $model; + return lc($model) if ( defined $model ); - return lc($model); + my $id = $cyclades->id(); + my $prod = SNMP::translateObj($id); + + return $prod || $id; +} + +sub serial { + my $cyclades = shift; + + return + $cyclades->acs_serial() + || $cyclades->acs8k_serial() + || $cyclades->cy5k_serial() + || $cyclades->cy_serial() + || undef; +} + +sub root_ip { + my $cyclades = shift; + + return + $cyclades->cy5k_root_ip() + || $cyclades->cy_root_ip() + || undef; +} + +sub ps1_status { + my $cyclades = shift; + + return + $cyclades->acs_ps1_status() + || $cyclades->acs8k_ps1_status() + || $cyclades->cy5k_ps1_status() + || $cyclades->cy_ps1_status() + || undef; +} + +sub ps2_status { + my $cyclades = shift; + + return + $cyclades->acs_ps2_status() + || $cyclades->acs8k_ps2_status() + || $cyclades->cy5k_ps2_status() + || $cyclades->cy_ps2_status() + || undef; } # Extend interface methods to include serial ports @@ -109,7 +240,12 @@ sub i_index { my $partial = shift; my $orig_index = $cyclades->orig_i_index($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; + my $cy_index + = $cyclades->acs_port_socket() + || $cyclades->acs8k_port_socket() + || $cyclades->cy5k_port_socket() + || $cyclades->cy_port_socket() + || {}; my %i_index; foreach my $iid ( keys %$orig_index ) { @@ -136,9 +272,19 @@ sub interfaces { my $cyclades = shift; my $partial = shift; - my $i_descr = $cyclades->orig_i_description($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; - my $cy_p_tty = $cyclades->cy_port_tty() || {}; + my $i_descr = $cyclades->orig_i_description($partial) || {}; + my $cy_index + = $cyclades->acs_port_socket() + || $cyclades->acs8k_port_socket() + || $cyclades->cy5k_port_socket() + || $cyclades->cy_port_socket() + || {}; + my $cy_p_tty + = $cyclades->acs_port_tty() + || $cyclades->acs8k_port_tty() + || $cyclades->cy5k_port_tty() + || $cyclades->cy_port_tty() + || {}; my %if; foreach my $iid ( keys %$i_descr ) { @@ -166,8 +312,18 @@ sub i_speed { my $partial = shift; my $i_speed = $cyclades->orig_i_speed($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; - my $cy_p_speed = $cyclades->cy_port_speed() || {}; + my $cy_index + = $cyclades->acs_port_socket() + || $cyclades->acs8k_port_socket() + || $cyclades->cy5k_port_socket() + || $cyclades->cy_port_socket() + || {}; + my $cy_p_speed + = $cyclades->acs_port_speed() + || $cyclades->acs8k_port_speed() + || $cyclades->cy5k_port_speed() + || $cyclades->cy_port_speed() + || {}; my %i_speed; foreach my $iid ( keys %$i_speed ) { @@ -195,8 +351,18 @@ sub i_up { my $partial = shift; my $i_up = $cyclades->orig_i_up($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; - my $cy_p_up = $cyclades->cy_port_cd() || {}; + my $cy_index + = $cyclades->acs_port_socket() + || $cyclades->acs8k_port_socket() + || $cyclades->cy5k_port_socket() + || $cyclades->cy_port_socket() + || {}; + my $cy_p_up + = $cyclades->acs_port_cd() + || $cyclades->acs8k_port_cd() + || $cyclades->cy5k_port_cd() + || $cyclades->cy_port_cd() + || {}; my %i_up; foreach my $iid ( keys %$i_up ) { @@ -224,8 +390,18 @@ sub i_description { my $partial = shift; my $i_desc = $cyclades->orig_i_description($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; - my $cy_p_desc = $cyclades->cy_port_name() || {}; + my $cy_index + = $cyclades->acs_port_socket() + || $cyclades->acs8k_port_socket() + || $cyclades->cy5k_port_socket() + || $cyclades->cy_port_socket() + || {}; + my $cy_p_desc + = $cyclades->acs_port_name() + || $cyclades->acs8k_port_name() + || $cyclades->cy5k_port_name() + || $cyclades->cy_port_name() + || {}; my %descr; foreach my $iid ( keys %$i_desc ) { @@ -253,8 +429,18 @@ sub i_name { my $partial = shift; my $i_name = $cyclades->orig_i_name($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; - my $cy_p_desc = $cyclades->cy_port_name() || {}; + my $cy_index + = $cyclades->acs_port_socket() + || $cyclades->acs8k_port_socket() + || $cyclades->cy5k_port_socket() + || $cyclades->cy_port_socket() + || {}; + my $cy_p_desc + = $cyclades->acs_port_name() + || $cyclades->acs8k_port_name() + || $cyclades->cy5k_port_name() + || $cyclades->cy_port_name() + || {}; my %i_name; foreach my $iid ( keys %$i_name ) { @@ -282,7 +468,8 @@ __END__ =head1 NAME -SNMP::Info::Layer1::Cyclades - SNMP Interface to Cyclades terminal servers +SNMP::Info::Layer1::Cyclades - SNMP Interface to Cyclades/Avocent terminal +servers =head1 AUTHOR @@ -309,7 +496,7 @@ Eric Miller =head1 DESCRIPTION Provides abstraction to the configuration information obtainable from a -Cyclades device through SNMP. +Cyclades/Avocent 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. @@ -334,6 +521,14 @@ my $cyclades = new SNMP::Info::Layer1::Cyclades(...); =item F +=item F + +=item F + +=item F + +=item F + =back =head2 Inherited MIBs @@ -348,11 +543,11 @@ These are methods that return scalar value from SNMP =item $cyclades->os_ver() -(C) +(C), (C), or (C) =item $cyclades->serial() -(C) +(C), (C), or (C) =item $cyclades->root_ip() @@ -360,11 +555,11 @@ These are methods that return scalar value from SNMP =item $cyclades->ps1_status() -(C) +(C), (C), or (C) =item $cyclades->ps2_status() -(C) +(C), (C), or (C) =back @@ -379,15 +574,16 @@ to poll for an ARP cache so turn off reported Layer 2 and Layer 3. =item $cyclades->vendor() -Returns 'cyclades' +Returns 'vertiv' =item $cyclades->os() -Returns 'cyclades' +Returns 'avocent' =item $cyclades->model() -Returns lower case (C) +Returns lower case (C) or (C) if it exists +otherwise tries to reference $cyclades->id() to one of the MIBs listed above =back @@ -409,31 +605,34 @@ to a hash. Returns reference to map of IIDs to Interface index. Extended to include serial ports. Serial ports are indexed with the -alternative labeling system for the serial port, the listening socket port -C to avoid conflicts with C. +alternative labeling system for the serial port, either the listening socket +port C or C name to avoid +conflicts with C. =item $cyclades->interfaces() Returns reference to map of IIDs to physical ports. Extended to include -serial ports, C. +serial ports, C or C. =item $cyclades->i_speed() -Returns interface speed. Extended to include serial ports, C. +Returns interface speed. Extended to include serial ports, +C or C. =item $cyclades->i_up() Returns link status for each port. Extended to include serial ports, -C. +C or C. =item $cyclades->i_description() Returns description of each port. Extended to include serial ports, -C. +C or C. =item $cyclades->i_name() -Returns name of each port. Extended to include serial ports, C. +Returns name of each port. Extended to include serial ports, +C or C. =back diff --git a/lib/SNMP/Info/Layer1/S3000.pm b/lib/SNMP/Info/Layer1/S3000.pm index 8b82dc53..950d96b1 100644 --- a/lib/SNMP/Info/Layer1/S3000.pm +++ b/lib/SNMP/Info/Layer1/S3000.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer2.pm b/lib/SNMP/Info/Layer2.pm index fef8185d..641cad51 100644 --- a/lib/SNMP/Info/Layer2.pm +++ b/lib/SNMP/Info/Layer2.pm @@ -46,7 +46,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS, diff --git a/lib/SNMP/Info/Layer2/3Com.pm b/lib/SNMP/Info/Layer2/3Com.pm index 775adc57..4fa0a374 100644 --- a/lib/SNMP/Info/Layer2/3Com.pm +++ b/lib/SNMP/Info/Layer2/3Com.pm @@ -11,7 +11,7 @@ use SNMP::Info::CDP; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::LLDP::MIBS, @@ -49,6 +49,7 @@ sub serial { return $e_serial->{$e}; } } + return; } sub os_ver { @@ -61,6 +62,7 @@ sub os_ver { return $e_swver->{$e}; } } + return; } sub vendor { @@ -76,6 +78,7 @@ sub model { } else { return $descr; } + return; } 1; diff --git a/lib/SNMP/Info/Layer2/Adtran.pm b/lib/SNMP/Info/Layer2/Adtran.pm index 7131976e..62f767bd 100644 --- a/lib/SNMP/Info/Layer2/Adtran.pm +++ b/lib/SNMP/Info/Layer2/Adtran.pm @@ -11,7 +11,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # This will be filled in with the device's index into the EntPhysicalEntry # table by the serial() function. diff --git a/lib/SNMP/Info/Layer2/Airespace.pm b/lib/SNMP/Info/Layer2/Airespace.pm index 1e8726a7..26014363 100644 --- a/lib/SNMP/Info/Layer2/Airespace.pm +++ b/lib/SNMP/Info/Layer2/Airespace.pm @@ -40,7 +40,7 @@ use SNMP::Info::Airespace; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS, diff --git a/lib/SNMP/Info/Layer2/Aironet.pm b/lib/SNMP/Info/Layer2/Aironet.pm index d9a746ea..7b41dbf3 100644 --- a/lib/SNMP/Info/Layer2/Aironet.pm +++ b/lib/SNMP/Info/Layer2/Aironet.pm @@ -49,7 +49,7 @@ use SNMP::Info::IEEE802dot11; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %GLOBALS = ( %SNMP::Info::IEEE802dot11::GLOBALS, diff --git a/lib/SNMP/Info/Layer2/Allied.pm b/lib/SNMP/Info/Layer2/Allied.pm index 722fc947..85db0756 100644 --- a/lib/SNMP/Info/Layer2/Allied.pm +++ b/lib/SNMP/Info/Layer2/Allied.pm @@ -40,7 +40,7 @@ use SNMP::Info::Layer1; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS ); @@ -73,6 +73,7 @@ sub os_ver { if ( $descr =~ m/version (\d+\.\d+)/ ) { return $1; } + return; } sub model { diff --git a/lib/SNMP/Info/Layer2/Baystack.pm b/lib/SNMP/Info/Layer2/Baystack.pm index 0a1a7067..cc0be572 100644 --- a/lib/SNMP/Info/Layer2/Baystack.pm +++ b/lib/SNMP/Info/Layer2/Baystack.pm @@ -46,7 +46,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, %SNMP::Info::LLDP::MIBS, diff --git a/lib/SNMP/Info/Layer2/C1900.pm b/lib/SNMP/Info/Layer2/C1900.pm index 274855e6..149509f9 100644 --- a/lib/SNMP/Info/Layer2/C1900.pm +++ b/lib/SNMP/Info/Layer2/C1900.pm @@ -48,7 +48,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, diff --git a/lib/SNMP/Info/Layer2/C2900.pm b/lib/SNMP/Info/Layer2/C2900.pm index 2899b007..905c900f 100644 --- a/lib/SNMP/Info/Layer2/C2900.pm +++ b/lib/SNMP/Info/Layer2/C2900.pm @@ -41,7 +41,7 @@ use SNMP::Info::Layer2::Cisco; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %GLOBALS = ( %SNMP::Info::Layer2::Cisco::GLOBALS, diff --git a/lib/SNMP/Info/Layer2/Catalyst.pm b/lib/SNMP/Info/Layer2/Catalyst.pm index 9dfc3a57..54dc4147 100644 --- a/lib/SNMP/Info/Layer2/Catalyst.pm +++ b/lib/SNMP/Info/Layer2/Catalyst.pm @@ -42,7 +42,7 @@ use SNMP::Info::Layer2::Cisco; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::Cisco::MIBS, diff --git a/lib/SNMP/Info/Layer2/Centillion.pm b/lib/SNMP/Info/Layer2/Centillion.pm index c1307668..e94a831b 100644 --- a/lib/SNMP/Info/Layer2/Centillion.pm +++ b/lib/SNMP/Info/Layer2/Centillion.pm @@ -43,7 +43,7 @@ use SNMP::Info::SONMP; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Layer2/Cisco.pm b/lib/SNMP/Info/Layer2/Cisco.pm index aad01702..c3a63387 100644 --- a/lib/SNMP/Info/Layer2/Cisco.pm +++ b/lib/SNMP/Info/Layer2/Cisco.pm @@ -52,7 +52,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer2/CiscoSB.pm b/lib/SNMP/Info/Layer2/CiscoSB.pm index 6059b885..fc944921 100644 --- a/lib/SNMP/Info/Layer2/CiscoSB.pm +++ b/lib/SNMP/Info/Layer2/CiscoSB.pm @@ -50,7 +50,7 @@ use SNMP::Info::CDP; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, diff --git a/lib/SNMP/Info/Layer2/HP.pm b/lib/SNMP/Info/Layer2/HP.pm index 58983255..ebb0d721 100644 --- a/lib/SNMP/Info/Layer2/HP.pm +++ b/lib/SNMP/Info/Layer2/HP.pm @@ -50,7 +50,7 @@ use SNMP::Info::Aggregate 'agg_ports_ifstack'; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer2/HP4000.pm b/lib/SNMP/Info/Layer2/HP4000.pm index 8ec19cc8..f312f5ae 100644 --- a/lib/SNMP/Info/Layer2/HP4000.pm +++ b/lib/SNMP/Info/Layer2/HP4000.pm @@ -44,7 +44,7 @@ use SNMP::Info::CDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer2/HPVC.pm b/lib/SNMP/Info/Layer2/HPVC.pm index 1ec42c93..db587250 100644 --- a/lib/SNMP/Info/Layer2/HPVC.pm +++ b/lib/SNMP/Info/Layer2/HPVC.pm @@ -41,7 +41,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer2/Kentrox.pm b/lib/SNMP/Info/Layer2/Kentrox.pm index 5a7dad6a..dd8aa4a3 100644 --- a/lib/SNMP/Info/Layer2/Kentrox.pm +++ b/lib/SNMP/Info/Layer2/Kentrox.pm @@ -36,7 +36,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer2/N2270.pm b/lib/SNMP/Info/Layer2/N2270.pm index fe607c67..8082ded2 100644 --- a/lib/SNMP/Info/Layer2/N2270.pm +++ b/lib/SNMP/Info/Layer2/N2270.pm @@ -43,7 +43,7 @@ use SNMP::Info::Airespace; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS, diff --git a/lib/SNMP/Info/Layer2/NAP222x.pm b/lib/SNMP/Info/Layer2/NAP222x.pm index 3fba7513..4b5d771d 100644 --- a/lib/SNMP/Info/Layer2/NAP222x.pm +++ b/lib/SNMP/Info/Layer2/NAP222x.pm @@ -42,7 +42,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, %SNMP::Info::IEEE802dot11::MIBS, diff --git a/lib/SNMP/Info/Layer2/NWSS2300.pm b/lib/SNMP/Info/Layer2/NWSS2300.pm index e51e2d46..25d095d5 100644 --- a/lib/SNMP/Info/Layer2/NWSS2300.pm +++ b/lib/SNMP/Info/Layer2/NWSS2300.pm @@ -39,7 +39,7 @@ use SNMP::Info::Bridge; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Layer2/Netgear.pm b/lib/SNMP/Info/Layer2/Netgear.pm index 361e3ff6..0fbfc989 100644 --- a/lib/SNMP/Info/Layer2/Netgear.pm +++ b/lib/SNMP/Info/Layer2/Netgear.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # This will be filled in with the device's index into the EntPhysicalEntry # table by the serial() function. diff --git a/lib/SNMP/Info/Layer2/Orinoco.pm b/lib/SNMP/Info/Layer2/Orinoco.pm index 8adf1025..b267bafe 100644 --- a/lib/SNMP/Info/Layer2/Orinoco.pm +++ b/lib/SNMP/Info/Layer2/Orinoco.pm @@ -41,7 +41,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer2/Trapeze.pm b/lib/SNMP/Info/Layer2/Trapeze.pm index f33e7be6..a73a4903 100644 --- a/lib/SNMP/Info/Layer2/Trapeze.pm +++ b/lib/SNMP/Info/Layer2/Trapeze.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Layer2/Ubiquiti.pm b/lib/SNMP/Info/Layer2/Ubiquiti.pm index 16339414..f603412a 100644 --- a/lib/SNMP/Info/Layer2/Ubiquiti.pm +++ b/lib/SNMP/Info/Layer2/Ubiquiti.pm @@ -18,7 +18,7 @@ use SNMP::Info::Layer3; # only used in sub mac() use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, diff --git a/lib/SNMP/Info/Layer2/ZyXEL_DSLAM.pm b/lib/SNMP/Info/Layer2/ZyXEL_DSLAM.pm index f9ac518c..e525d347 100644 --- a/lib/SNMP/Info/Layer2/ZyXEL_DSLAM.pm +++ b/lib/SNMP/Info/Layer2/ZyXEL_DSLAM.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer2; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # Set for No CDP %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS ); diff --git a/lib/SNMP/Info/Layer3.pm b/lib/SNMP/Info/Layer3.pm index 676701d5..ab77d87c 100644 --- a/lib/SNMP/Info/Layer3.pm +++ b/lib/SNMP/Info/Layer3.pm @@ -53,7 +53,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Layer3/Aironet.pm b/lib/SNMP/Info/Layer3/Aironet.pm index 21f0a94a..3aa596e5 100644 --- a/lib/SNMP/Info/Layer3/Aironet.pm +++ b/lib/SNMP/Info/Layer3/Aironet.pm @@ -41,7 +41,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/AlcatelLucent.pm b/lib/SNMP/Info/Layer3/AlcatelLucent.pm index c25b00a3..261a26ae 100644 --- a/lib/SNMP/Info/Layer3/AlcatelLucent.pm +++ b/lib/SNMP/Info/Layer3/AlcatelLucent.pm @@ -49,7 +49,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/AlteonAD.pm b/lib/SNMP/Info/Layer3/AlteonAD.pm index 02ab6d64..a5411a74 100644 --- a/lib/SNMP/Info/Layer3/AlteonAD.pm +++ b/lib/SNMP/Info/Layer3/AlteonAD.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Altiga.pm b/lib/SNMP/Info/Layer3/Altiga.pm index 61728021..fb6481b7 100644 --- a/lib/SNMP/Info/Layer3/Altiga.pm +++ b/lib/SNMP/Info/Layer3/Altiga.pm @@ -40,7 +40,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE $int_include_vpn $fake_idx $type_class/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Arista.pm b/lib/SNMP/Info/Layer3/Arista.pm index 1e253e55..8b51329c 100644 --- a/lib/SNMP/Info/Layer3/Arista.pm +++ b/lib/SNMP/Info/Layer3/Arista.pm @@ -48,7 +48,7 @@ use SNMP::Info::Aggregate 'agg_ports_ifstack'; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Aruba.pm b/lib/SNMP/Info/Layer3/Aruba.pm index d849212a..23dbf17f 100644 --- a/lib/SNMP/Info/Layer3/Aruba.pm +++ b/lib/SNMP/Info/Layer3/Aruba.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/BayRS.pm b/lib/SNMP/Info/Layer3/BayRS.pm index 1ae45d33..f0da454a 100644 --- a/lib/SNMP/Info/Layer3/BayRS.pm +++ b/lib/SNMP/Info/Layer3/BayRS.pm @@ -43,7 +43,7 @@ use SNMP::Info::Bridge; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE %MODEL_MAP %MODID_MAP %PROCID_MAP/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Layer3/BlueCoatSG.pm b/lib/SNMP/Info/Layer3/BlueCoatSG.pm index d3ac3d35..f75a4fc7 100644 --- a/lib/SNMP/Info/Layer3/BlueCoatSG.pm +++ b/lib/SNMP/Info/Layer3/BlueCoatSG.pm @@ -36,7 +36,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/C3550.pm b/lib/SNMP/Info/Layer3/C3550.pm index 556b913f..8641241e 100644 --- a/lib/SNMP/Info/Layer3/C3550.pm +++ b/lib/SNMP/Info/Layer3/C3550.pm @@ -47,7 +47,7 @@ use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; @SNMP::Info::Layer3::C3550::EXPORT_OK = qw//; -$VERSION = '3.53'; +$VERSION = '3.54'; # NOTE: Order creates precedence # Example: v_name exists in Bridge.pm and CiscoVTP.pm diff --git a/lib/SNMP/Info/Layer3/C4000.pm b/lib/SNMP/Info/Layer3/C4000.pm index ec740ea4..5cc6b624 100644 --- a/lib/SNMP/Info/Layer3/C4000.pm +++ b/lib/SNMP/Info/Layer3/C4000.pm @@ -44,7 +44,7 @@ use SNMP::Info::MAU; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MAU::MIBS, diff --git a/lib/SNMP/Info/Layer3/C6500.pm b/lib/SNMP/Info/Layer3/C6500.pm index eaa5ecc6..d8ef2993 100644 --- a/lib/SNMP/Info/Layer3/C6500.pm +++ b/lib/SNMP/Info/Layer3/C6500.pm @@ -51,7 +51,7 @@ use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # NOTE: Order creates precedence # Example: v_name exists in Bridge.pm and CiscoVTP.pm diff --git a/lib/SNMP/Info/Layer3/CheckPoint.pm b/lib/SNMP/Info/Layer3/CheckPoint.pm index d5ce65d7..0797016a 100644 --- a/lib/SNMP/Info/Layer3/CheckPoint.pm +++ b/lib/SNMP/Info/Layer3/CheckPoint.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Cisco.pm b/lib/SNMP/Info/Layer3/Cisco.pm index 29d053ee..f256c1f2 100644 --- a/lib/SNMP/Info/Layer3/Cisco.pm +++ b/lib/SNMP/Info/Layer3/Cisco.pm @@ -55,7 +55,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/CiscoASA.pm b/lib/SNMP/Info/Layer3/CiscoASA.pm index ab3e0966..b4a93edd 100644 --- a/lib/SNMP/Info/Layer3/CiscoASA.pm +++ b/lib/SNMP/Info/Layer3/CiscoASA.pm @@ -45,7 +45,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoStats::MIBS, ); diff --git a/lib/SNMP/Info/Layer3/CiscoFWSM.pm b/lib/SNMP/Info/Layer3/CiscoFWSM.pm index 925b73a4..0665bf9f 100644 --- a/lib/SNMP/Info/Layer3/CiscoFWSM.pm +++ b/lib/SNMP/Info/Layer3/CiscoFWSM.pm @@ -43,7 +43,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoStats::MIBS, ); diff --git a/lib/SNMP/Info/Layer3/CiscoSwitch.pm b/lib/SNMP/Info/Layer3/CiscoSwitch.pm index ca4ea164..6eabe98c 100644 --- a/lib/SNMP/Info/Layer3/CiscoSwitch.pm +++ b/lib/SNMP/Info/Layer3/CiscoSwitch.pm @@ -50,7 +50,7 @@ use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::Cisco::MIBS, diff --git a/lib/SNMP/Info/Layer3/Contivity.pm b/lib/SNMP/Info/Layer3/Contivity.pm index 10ed4699..ed922e1b 100644 --- a/lib/SNMP/Info/Layer3/Contivity.pm +++ b/lib/SNMP/Info/Layer3/Contivity.pm @@ -42,7 +42,7 @@ use SNMP::Info::Entity; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::Entity::MIBS, diff --git a/lib/SNMP/Info/Layer3/Cumulus.pm b/lib/SNMP/Info/Layer3/Cumulus.pm index 759bcd35..12170012 100644 --- a/lib/SNMP/Info/Layer3/Cumulus.pm +++ b/lib/SNMP/Info/Layer3/Cumulus.pm @@ -46,7 +46,7 @@ use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/DLink.pm b/lib/SNMP/Info/Layer3/DLink.pm index 755219fb..45ee0608 100644 --- a/lib/SNMP/Info/Layer3/DLink.pm +++ b/lib/SNMP/Info/Layer3/DLink.pm @@ -10,7 +10,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Dell.pm b/lib/SNMP/Info/Layer3/Dell.pm index 8c4a7fc4..9d6928f2 100644 --- a/lib/SNMP/Info/Layer3/Dell.pm +++ b/lib/SNMP/Info/Layer3/Dell.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Enterasys.pm b/lib/SNMP/Info/Layer3/Enterasys.pm index 71c879d3..1b6a8069 100644 --- a/lib/SNMP/Info/Layer3/Enterasys.pm +++ b/lib/SNMP/Info/Layer3/Enterasys.pm @@ -44,7 +44,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, %SNMP::Info::CDP::MIBS, diff --git a/lib/SNMP/Info/Layer3/Extreme.pm b/lib/SNMP/Info/Layer3/Extreme.pm index 288dbae1..307d9fdd 100644 --- a/lib/SNMP/Info/Layer3/Extreme.pm +++ b/lib/SNMP/Info/Layer3/Extreme.pm @@ -46,7 +46,7 @@ use SNMP::Info::EDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/F5.pm b/lib/SNMP/Info/Layer3/F5.pm index 6b116cea..61030577 100644 --- a/lib/SNMP/Info/Layer3/F5.pm +++ b/lib/SNMP/Info/Layer3/F5.pm @@ -38,7 +38,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Force10.pm b/lib/SNMP/Info/Layer3/Force10.pm index ea5ca279..f9d5617e 100644 --- a/lib/SNMP/Info/Layer3/Force10.pm +++ b/lib/SNMP/Info/Layer3/Force10.pm @@ -43,7 +43,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Fortinet.pm b/lib/SNMP/Info/Layer3/Fortinet.pm index cffeb472..379b4be4 100644 --- a/lib/SNMP/Info/Layer3/Fortinet.pm +++ b/lib/SNMP/Info/Layer3/Fortinet.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Foundry.pm b/lib/SNMP/Info/Layer3/Foundry.pm index 0b8038d2..17d625bf 100644 --- a/lib/SNMP/Info/Layer3/Foundry.pm +++ b/lib/SNMP/Info/Layer3/Foundry.pm @@ -48,7 +48,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/H3C.pm b/lib/SNMP/Info/Layer3/H3C.pm index d42449e0..1e3f0c1e 100644 --- a/lib/SNMP/Info/Layer3/H3C.pm +++ b/lib/SNMP/Info/Layer3/H3C.pm @@ -47,7 +47,7 @@ use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/HP9300.pm b/lib/SNMP/Info/Layer3/HP9300.pm index f0d19bb8..6dd654ab 100644 --- a/lib/SNMP/Info/Layer3/HP9300.pm +++ b/lib/SNMP/Info/Layer3/HP9300.pm @@ -42,7 +42,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Huawei.pm b/lib/SNMP/Info/Layer3/Huawei.pm index 04eb03b4..bd62bd35 100644 --- a/lib/SNMP/Info/Layer3/Huawei.pm +++ b/lib/SNMP/Info/Layer3/Huawei.pm @@ -47,7 +47,7 @@ use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/IBMGbTor.pm b/lib/SNMP/Info/Layer3/IBMGbTor.pm index aa9338d7..27b463d4 100644 --- a/lib/SNMP/Info/Layer3/IBMGbTor.pm +++ b/lib/SNMP/Info/Layer3/IBMGbTor.pm @@ -41,7 +41,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Juniper.pm b/lib/SNMP/Info/Layer3/Juniper.pm index 7fa20f0c..490ececf 100644 --- a/lib/SNMP/Info/Layer3/Juniper.pm +++ b/lib/SNMP/Info/Layer3/Juniper.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Lantronix.pm b/lib/SNMP/Info/Layer3/Lantronix.pm index c23a9ee9..ac77d369 100644 --- a/lib/SNMP/Info/Layer3/Lantronix.pm +++ b/lib/SNMP/Info/Layer3/Lantronix.pm @@ -41,7 +41,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Microsoft.pm b/lib/SNMP/Info/Layer3/Microsoft.pm index b079fc47..aa91cc3c 100644 --- a/lib/SNMP/Info/Layer3/Microsoft.pm +++ b/lib/SNMP/Info/Layer3/Microsoft.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, ); diff --git a/lib/SNMP/Info/Layer3/Mikrotik.pm b/lib/SNMP/Info/Layer3/Mikrotik.pm index ebd35a35..bf40c9bc 100644 --- a/lib/SNMP/Info/Layer3/Mikrotik.pm +++ b/lib/SNMP/Info/Layer3/Mikrotik.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/N1600.pm b/lib/SNMP/Info/Layer3/N1600.pm index eb316928..dd24daee 100644 --- a/lib/SNMP/Info/Layer3/N1600.pm +++ b/lib/SNMP/Info/Layer3/N1600.pm @@ -41,7 +41,7 @@ use SNMP::Info::SONMP; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/NetSNMP.pm b/lib/SNMP/Info/Layer3/NetSNMP.pm index deb70ad2..1b31d4ee 100644 --- a/lib/SNMP/Info/Layer3/NetSNMP.pm +++ b/lib/SNMP/Info/Layer3/NetSNMP.pm @@ -40,7 +40,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Netscreen.pm b/lib/SNMP/Info/Layer3/Netscreen.pm index fc5909c8..7e901cdc 100644 --- a/lib/SNMP/Info/Layer3/Netscreen.pm +++ b/lib/SNMP/Info/Layer3/Netscreen.pm @@ -40,7 +40,7 @@ use SNMP::Info::IEEE802dot11; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Nexus.pm b/lib/SNMP/Info/Layer3/Nexus.pm index 40dd55f5..8004f311 100644 --- a/lib/SNMP/Info/Layer3/Nexus.pm +++ b/lib/SNMP/Info/Layer3/Nexus.pm @@ -46,7 +46,7 @@ use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; # NOTE: Order creates precedence # Example: v_name exists in Bridge.pm and CiscoVTP.pm diff --git a/lib/SNMP/Info/Layer3/PacketFront.pm b/lib/SNMP/Info/Layer3/PacketFront.pm index 8fe089f2..46f16e2a 100644 --- a/lib/SNMP/Info/Layer3/PacketFront.pm +++ b/lib/SNMP/Info/Layer3/PacketFront.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/PaloAlto.pm b/lib/SNMP/Info/Layer3/PaloAlto.pm index e658f5ce..b054917f 100644 --- a/lib/SNMP/Info/Layer3/PaloAlto.pm +++ b/lib/SNMP/Info/Layer3/PaloAlto.pm @@ -38,7 +38,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Passport.pm b/lib/SNMP/Info/Layer3/Passport.pm index c3c99930..aa4b041b 100644 --- a/lib/SNMP/Info/Layer3/Passport.pm +++ b/lib/SNMP/Info/Layer3/Passport.pm @@ -43,7 +43,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, %SNMP::Info::RapidCity::MIBS, diff --git a/lib/SNMP/Info/Layer3/Pf.pm b/lib/SNMP/Info/Layer3/Pf.pm index 7441e212..80932f91 100644 --- a/lib/SNMP/Info/Layer3/Pf.pm +++ b/lib/SNMP/Info/Layer3/Pf.pm @@ -41,7 +41,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Pica8.pm b/lib/SNMP/Info/Layer3/Pica8.pm index 414ade56..85a85a87 100644 --- a/lib/SNMP/Info/Layer3/Pica8.pm +++ b/lib/SNMP/Info/Layer3/Pica8.pm @@ -39,7 +39,7 @@ use SNMP::Info::LLDP; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/SonicWALL.pm b/lib/SNMP/Info/Layer3/SonicWALL.pm index f30e77a0..ee845e01 100644 --- a/lib/SNMP/Info/Layer3/SonicWALL.pm +++ b/lib/SNMP/Info/Layer3/SonicWALL.pm @@ -36,7 +36,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Steelhead.pm b/lib/SNMP/Info/Layer3/Steelhead.pm index 11a478e6..125c2ce5 100644 --- a/lib/SNMP/Info/Layer3/Steelhead.pm +++ b/lib/SNMP/Info/Layer3/Steelhead.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Sun.pm b/lib/SNMP/Info/Layer3/Sun.pm index ccc97316..ab86b402 100644 --- a/lib/SNMP/Info/Layer3/Sun.pm +++ b/lib/SNMP/Info/Layer3/Sun.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, ); diff --git a/lib/SNMP/Info/Layer3/Tasman.pm b/lib/SNMP/Info/Layer3/Tasman.pm index 9d43983a..0488cf8f 100644 --- a/lib/SNMP/Info/Layer3/Tasman.pm +++ b/lib/SNMP/Info/Layer3/Tasman.pm @@ -42,7 +42,7 @@ use SNMP::Info::MAU; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer3/Timetra.pm b/lib/SNMP/Info/Layer3/Timetra.pm index 081eac67..54a46d6c 100644 --- a/lib/SNMP/Info/Layer3/Timetra.pm +++ b/lib/SNMP/Info/Layer3/Timetra.pm @@ -35,63 +35,149 @@ use Exporter; use SNMP::Info::Layer3; @SNMP::Info::Layer3::Timetra::ISA = qw/SNMP::Info::Layer3 - Exporter/; + Exporter/; @SNMP::Info::Layer3::Timetra::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, 'TIMETRA-GLOBAL-MIB' => 'timetraReg', ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + 'TIMETRA-GLOBAL-MIB' => 'timetraReg', + 'TIMETRA-LLDP-MIB' => 'tmnxLldpAdminStatus', +); -%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, ); +%GLOBALS = (%SNMP::Info::Layer3::GLOBALS,); -%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, -%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); + # For some reason LLDP-MIB::lldpLocManAddrTable is populated + # but LLDP-MIB::lldpRemTable is not and we need to use the + # proprietary TIMETRA-LLDP-MIB Note: these tables are + # indexed differently than LLDP-MIB + # TIMETRA-LLDP-MIB::tmnxLldpRemTable + 'lldp_rem_id_type' => 'tmnxLldpRemChassisIdSubtype', + 'lldp_rem_id' => 'tmnxLldpRemChassisId', + 'lldp_rem_pid_type' => 'tmnxLldpRemPortIdSubtype', + 'lldp_rem_pid' => 'tmnxLldpRemPortId', + 'lldp_rem_desc' => 'tmnxLldpRemPortDesc', + 'lldp_rem_sysname' => 'tmnxLldpRemSysName', + 'lldp_rem_sysdesc' => 'tmnxLldpRemSysDesc', + 'lldp_rem_sys_cap' => 'tmnxLldpRemSysCapEnabled', + 'lldp_rem_cap_spt' => 'tmnxLldpRemSysCapSupported', + + # TIMETRA-LLDP-MIB::tmnxLldpRemManAddrTable + 'lldp_rman_addr' => 'tmnxLldpRemManAddrIfSubtype', +); + +%MUNGE = (%SNMP::Info::Layer3::MUNGE,); sub model { - my $timetra = shift; - my $id = $timetra->id(); - my $model = &SNMP::translateObj($id); - - return $id unless defined $model; + my $timetra = shift; + my $id = $timetra->id(); + my $model = SNMP::translateObj($id); + my $descr = $timetra->description(); + if (defined $model && $model =~ /^tmnxModel/) { $model =~ s/^tmnxModel//; - + $model =~ s/Reg$//; return $model; + } + + if ($descr =~ /\s+(7\d{3})/) { + return $1; + } + + return $model || $id; } sub os { - return 'TiMOS'; + return 'TiMOS'; } sub vendor { - return 'alcatel-lucent'; + return 'nokia'; } sub os_ver { - my $timetra = shift; + my $timetra = shift; - my $descr = $timetra->description(); - if ( $descr =~ m/^TiMOS-(\S+)/ ) { - return $1; - } - - # No clue what this will try but hey - return $timetra->SUPER::os_ver(); + my $descr = $timetra->description(); + if ($descr =~ m/^TiMOS-(\S+)/) { + return $1; + } + return; } # The interface description contains the SFP type, so # to avoid losing historical information through a configuration change # we use interface name instead. sub interfaces { - my $alu = shift; - my $partial = shift; + my $alu = shift; + my $partial = shift; - return $alu->orig_i_name($partial); + return $alu->orig_i_name($partial); } +# The TIMETRA-LLDP-MIB::tmnxLldpRemTable unambiguously states it uses ifIndex +# Trying to cross reference to ifDescr or ifAlias would cause unpredictable +# results based upon how the device names ports. +sub lldp_if { + my $alu = shift; + my $partial = shift; + + my $addr = $alu->lldp_rem_pid($partial) || {}; + + my %lldp_if; + foreach my $key (keys %$addr) { + my @aOID = split('\.', $key); + my $port = $aOID[1]; + next unless $port; + + $lldp_if{$key} = $port; + } + return \%lldp_if; +} + +# The proprietary TIMETRA-LLDP-MIB tables are indexed differently than LLDP-MIB +# We overwrite the private function so that the we don't have to replicate +# the code in SNMP::Info::LLDP that uses it. +# +# We can't use inheritance to override since it is a function, not a method +# in SNMP::Info::LLDP. This brute force redefines the code in the symbol table. + +*SNMP::Info::LLDP::_lldp_addr_index = sub { + my $idx = shift; + my @oids = split(/\./, $idx); + + # Index has extra field compared to LLDP-MIB + my $index = join('.', splice(@oids, 0, 4)); + my $proto = shift(@oids); + shift(@oids) if scalar @oids > 4; # $length + + # IPv4 + if ($proto == 1) { + return ($index, $proto, join('.', @oids)); + } + + # IPv6 + elsif ($proto == 2) { + return ($index, $proto, join(':', unpack('(H4)*', pack('C*', @oids)))); + } + + # MAC + elsif ($proto == 6) { + return ($index, $proto, join(':', map { sprintf "%02x", $_ } @oids)); + } + + # TODO - Other protocols may be used as well; implement when needed? + else { + return; + } +}; + 1; __END__ @@ -137,6 +223,8 @@ Subclass for Alcatel-Lucent Service Routers =item F +=item F + =item Inherited Classes' MIBs See L for its own MIB requirements. @@ -178,6 +266,8 @@ See documentation in L for details. These are methods that return tables of information in the form of a reference to a hash. +=head2 Overrides + =over =item $alu->interfaces() @@ -185,6 +275,50 @@ to a hash. Returns C, since the default Layer3 C varies based upon the transceiver inserted. +=item $alu->lldp_if() + +Returns the mapping to the SNMP Interface Table. Utilizes (C) +from the (C) index. + + +=back + +=head2 LLDP Remote Table (C) uses (C) + +=over + +=item $lldp->lldp_rem_id_type() + +(C) + +=item $lldp->lldp_rem_id() + +(C) + +=item $lldp->lldp_rem_pid_type() + +(C) + +=item $lldp->lldp_rem_pid() + +(C) + +=item $lldp->lldp_rem_desc() + +(C) + +=item $lldp->lldp_rem_sysname() + +(C) + +=item $lldp->lldp_rem_sysdesc() + +(C) + +=item $lldp->lldp_rem_sys_cap() + +(C) + =back =head2 Table Methods imported from SNMP::Info::Layer3 diff --git a/lib/SNMP/Info/Layer3/VMware.pm b/lib/SNMP/Info/Layer3/VMware.pm index de80875e..c2361106 100644 --- a/lib/SNMP/Info/Layer3/VMware.pm +++ b/lib/SNMP/Info/Layer3/VMware.pm @@ -39,7 +39,7 @@ use SNMP::Info::IEEE802dot3ad 'agg_ports_lag'; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::IEEE802dot3ad::MIBS, diff --git a/lib/SNMP/Info/Layer3/VyOS.pm b/lib/SNMP/Info/Layer3/VyOS.pm index bc09f247..3552b31e 100644 --- a/lib/SNMP/Info/Layer3/VyOS.pm +++ b/lib/SNMP/Info/Layer3/VyOS.pm @@ -39,7 +39,7 @@ use SNMP::Info::Layer3; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer3::MIBS, diff --git a/lib/SNMP/Info/Layer7.pm b/lib/SNMP/Info/Layer7.pm index ab6255fd..e3aa632f 100644 --- a/lib/SNMP/Info/Layer7.pm +++ b/lib/SNMP/Info/Layer7.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::MIBS, diff --git a/lib/SNMP/Info/Layer7/APC.pm b/lib/SNMP/Info/Layer7/APC.pm index f884b090..49bb22db 100644 --- a/lib/SNMP/Info/Layer7/APC.pm +++ b/lib/SNMP/Info/Layer7/APC.pm @@ -40,7 +40,7 @@ use SNMP::Info::Layer7; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer7::MIBS, diff --git a/lib/SNMP/Info/Layer7/CiscoIPS.pm b/lib/SNMP/Info/Layer7/CiscoIPS.pm index 35903f5b..0112ddf2 100644 --- a/lib/SNMP/Info/Layer7/CiscoIPS.pm +++ b/lib/SNMP/Info/Layer7/CiscoIPS.pm @@ -46,7 +46,7 @@ use SNMP::Info::Entity; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer7::MIBS, %SNMP::Info::Entity::MIBS, ); diff --git a/lib/SNMP/Info/Layer7/Gigamon.pm b/lib/SNMP/Info/Layer7/Gigamon.pm index dcce74ac..9cd0c50b 100644 --- a/lib/SNMP/Info/Layer7/Gigamon.pm +++ b/lib/SNMP/Info/Layer7/Gigamon.pm @@ -38,7 +38,7 @@ use SNMP::Info::Layer7; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer7::MIBS, diff --git a/lib/SNMP/Info/Layer7/Neoteris.pm b/lib/SNMP/Info/Layer7/Neoteris.pm index 25f943af..3a3ca68e 100644 --- a/lib/SNMP/Info/Layer7/Neoteris.pm +++ b/lib/SNMP/Info/Layer7/Neoteris.pm @@ -38,7 +38,7 @@ use SNMP::Info::Layer7; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer7::MIBS, diff --git a/lib/SNMP/Info/Layer7/Netscaler.pm b/lib/SNMP/Info/Layer7/Netscaler.pm index e336eb46..bbaf1736 100644 --- a/lib/SNMP/Info/Layer7/Netscaler.pm +++ b/lib/SNMP/Info/Layer7/Netscaler.pm @@ -38,7 +38,7 @@ use SNMP::Info::Layer7; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( %SNMP::Info::Layer7::MIBS, diff --git a/lib/SNMP/Info/MAU.pm b/lib/SNMP/Info/MAU.pm index 509cdaa2..c0a78ef5 100644 --- a/lib/SNMP/Info/MAU.pm +++ b/lib/SNMP/Info/MAU.pm @@ -41,7 +41,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'MAU-MIB' => 'mauMod', 'IANA-MAU-MIB' => 'dot3MauType' ); diff --git a/lib/SNMP/Info/MRO.pm b/lib/SNMP/Info/MRO.pm index 2c013362..ddf20a4d 100644 --- a/lib/SNMP/Info/MRO.pm +++ b/lib/SNMP/Info/MRO.pm @@ -4,7 +4,7 @@ use warnings; use strict; use vars qw/$VERSION/; -$VERSION = '3.53'; +$VERSION = '3.54'; use PPI; use Class::ISA; ## no critic diff --git a/lib/SNMP/Info/NortelStack.pm b/lib/SNMP/Info/NortelStack.pm index 93751636..3d89a7e9 100644 --- a/lib/SNMP/Info/NortelStack.pm +++ b/lib/SNMP/Info/NortelStack.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( diff --git a/lib/SNMP/Info/PowerEthernet.pm b/lib/SNMP/Info/PowerEthernet.pm index 0d943dd3..e0571151 100644 --- a/lib/SNMP/Info/PowerEthernet.pm +++ b/lib/SNMP/Info/PowerEthernet.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus' ); diff --git a/lib/SNMP/Info/RapidCity.pm b/lib/SNMP/Info/RapidCity.pm index 11357cf6..674bde5b 100644 --- a/lib/SNMP/Info/RapidCity.pm +++ b/lib/SNMP/Info/RapidCity.pm @@ -39,7 +39,7 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'RAPID-CITY' => 'rapidCity', diff --git a/lib/SNMP/Info/SONMP.pm b/lib/SNMP/Info/SONMP.pm index 41978315..ac70c4b3 100644 --- a/lib/SNMP/Info/SONMP.pm +++ b/lib/SNMP/Info/SONMP.pm @@ -39,11 +39,11 @@ use SNMP::Info; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '3.53'; +$VERSION = '3.54'; %MIBS = ( 'SYNOPTICS-ROOT-MIB' => 'synoptics', - 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop', + 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTopInfo', ); %GLOBALS = ( diff --git a/xt/lib/My/Test/Class.pm b/xt/lib/My/Test/Class.pm index 2e1300c5..83d3ec0f 100644 --- a/xt/lib/My/Test/Class.pm +++ b/xt/lib/My/Test/Class.pm @@ -29,25 +29,30 @@ package My::Test::Class; -use Test::Class::Most attributes => [qw/class mock_session test_obj/]; +use Test::Class::Most attributes => [qw/class mock_session todo_methods/]; use Test::MockObject::Extends; use File::Find 'find'; use Path::Class 'dir'; use File::Slurper 'read_lines'; +use Class::Inspector; use base qw; +# Don't run the base tests defined in this class, run them in subclasses only +My::Test::Class->SKIP_CLASS(1); + INIT { Test::Class->runtests } my $EMPTY = q{}; sub startup : Tests( startup => 1 ) { my $test = shift; - (my $class = ref $test) =~ s/::Test$//x; + (my $class = ref $test) =~ s/^Test:://x; return ok 1, "$class loaded" if $class eq __PACKAGE__; use_ok $class or die; $test->class($class); $test->mock_session(create_mock_session()); + $test->todo_methods(0); return; } @@ -58,11 +63,179 @@ sub setup : Tests(setup) { my $class = $test->class; my $sess = $test->mock_session; - $test->{info} - = $class->new('AutoSpecify' => 0, 'BulkWalk' => 0, 'Session' => $sess,); + $test->{info} = $class->new( + 'AutoSpecify' => 0, + 'BulkWalk' => 0, + 'UseEnums' => 1, + 'RetryNoSuch' => 1, + 'DestHost' => '127.0.0.1', + 'Community' => 'public', + 'Version' => 2, + 'Session' => $sess, + ); } -sub teardown : Tests(teardown) { my $test = shift; $test->{info} = undef; } +sub teardown : Tests(teardown) { + my $test = shift; + my $sess = $test->mock_session; + + # Make sure we start clear object and any mocked session data after each test + $test->{info} = undef; + $sess->{Data} = {}; +} + +sub constructor : Tests(8) { + my $test = shift; + my $class = $test->class; + + can_ok $class, 'new'; + isa_ok $test->{info}, $class, '... and the object it returns'; + + is(defined $test->{info}{init}, 1, 'MIBs initialized'); + ok(exists $test->{info}{mibs}, 'MIBs subclass data structure initialized'); + ok(exists $test->{info}{globals}, + 'Globals subclass data structure initialized'); + ok(exists $test->{info}{funcs}, 'Funcs subclass data structure initialized'); + ok(exists $test->{info}{munge}, 'Munge subclass data structure initialized'); + ok(exists $test->{info}{store}, 'Store initialized'); +} + +sub device_type : Tests(2) { + my $test = shift; + my $class = $test->class; + + can_ok($test->{info}, 'device_type'); + +SKIP: { + skip "Device type not applicable to $class", 1 + if $class !~ /Layer\d::\w+$/x; + + # This depends on cache or mocked session data being provided. + # Recommendation is to extend the existing setup method in the + # subclass to provide the common data. + is($test->{info}->device_type(), $class, qq(Device type is $class)); + } +} + +sub globals : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'globals'); + + subtest 'Globals can() subtest' => sub { + + my $test_globals = $test->{info}->globals; + + if (scalar keys %$test_globals) { + foreach my $key (sort (keys %$test_globals)) { + can_ok($test->{info}, $key); + } + } + else { + $test->builder->skip("No globals to test"); + } + }; +} + +sub funcs : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'funcs'); + + subtest 'Funcs can() subtest' => sub { + + my $test_funcs = $test->{info}->funcs; + + if (scalar keys %$test_funcs) { + foreach my $key (sort (keys %$test_funcs)) { + can_ok($test->{info}, $key); + } + } + else { + $test->builder->skip("No funcs to test"); + } + }; +} + +sub mibs : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'mibs'); + + subtest 'MIBs loaded subtest' => sub { + + my $mibs = $test->{info}->mibs(); + + if (scalar keys %$mibs) { + foreach my $key (sort(keys %$mibs)) { + my $qual_name = "$key" . '::' . "$mibs->{$key}"; + ok(defined $SNMP::MIB{$mibs->{$key}}, "$qual_name defined"); + like(SNMP::translateObj($qual_name), + qr/^(\.\d+)+$/, "$qual_name translates to a OID"); + } + } + else { + $test->builder->skip("No MIBs to test"); + } + }; +} + +sub munge : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge'); + + subtest 'Munges subtest' => sub { + + my $test_munges = $test->{info}->munge(); + + if (scalar keys %$test_munges) { + foreach my $key (sort (keys %$test_munges)) { + isa_ok($test_munges->{$key}, 'CODE', "$key munge"); + } + } + else { + $test->builder->skip("No munge to test"); + } + }; +} + +sub method_coverage : Tests(1) { + my $test = shift; + my $class = $test->class; + my $class_regex = $class . '::'; + my $test_class = "Test::$class"; + my $test_class_regex = $test_class . '::'; + +TODO: { + # SNMP::Info is returning unexpected methods, investigate at some point + # SNMP::Info has methods which must be renamed in test classes, i.e. + # AUTOLOAD, DESTROY, can, etc. + todo_skip 'Base class', 1 if ($class eq 'SNMP::Info'); + + # Skip if we have marked TODO, methods that need coverage will be + # identified with verbose output + local $TODO = "$class method coverage not complete" if $test->todo_methods; + + my $methods = Class::Inspector->methods($class, 'full', 'public'); + my @local_methods = grep { $_ =~ /^$class/ } @$methods; + s/$class_regex//x for @local_methods; + + my $test_methods = Class::Inspector->methods($test_class, 'full', 'public'); + my @local_test_methods = grep { $_ =~ /^$test_class/x } @$test_methods; + s/$test_class_regex//x for @local_test_methods; + + cmp_deeply( + \@local_methods, + subsetof(@local_test_methods), + qq(All public $class methods have coverage) + ); + } +} + +# +# Utility methods / functions +# sub create_mock_session { @@ -137,10 +310,14 @@ sub mock_get { ($leaf, $iid) = $oid_name =~ /^(\S+::\w+)[.]?(\S+)*$/x; } + # This is a lot of indirection, but we need the base OID, it may be + # passed with a zero for non table leaf + my $oid_base = SNMP::translateObj($leaf); + $iid ||= 0; my $new_iid = $iid; my $val = $EMPTY; - my $data = $c_data->{$leaf} || {}; + my $data = $c_data->{$leaf} || $c_data->{$oid_base} || {}; my $count = scalar keys %{$data} || 0; if ($count > 1) { my $found = 0; @@ -233,7 +410,17 @@ sub mock_getnext { } # For testing purposes assume sets worked -sub mock_set {1} +sub mock_set { + my $mock_session = shift; + + $mock_session->mock( + 'set', + sub { + return 1; + } + ); + return; +} # Utility to load snmpwalk from a file to use for mock sessions sub load_snmpdata { @@ -257,15 +444,20 @@ sub load_snmpdata { return $snmp_data; } -# Grab the symbol table for verification that -# dynamic methods via AUTOLOAD and can() have been inserted -sub symbols { - my $test = shift; - my $class = $test->class; +# Returns 1 if the method is defined in the symbol table 0 otherwise, used for +# verification that dynamic methods via AUTOLOAD and can() have been inserted +# into the symbol table +sub symbol_test { + my $test = shift; + my $method = shift; + + my $class = $test->class; + my %symbols = (); { no strict 'refs'; ## no critic (ProhibitNoStrict) - return \%{$class . '::'}; + %symbols = %{$class . '::'}; } + return (defined($symbols{$method}) ? 1 : 0); } 1; diff --git a/xt/lib/SNMP/Info/Test.pm b/xt/lib/SNMP/Info/Test.pm deleted file mode 100644 index 4df66c6e..00000000 --- a/xt/lib/SNMP/Info/Test.pm +++ /dev/null @@ -1,767 +0,0 @@ -# SNMP::Info::Test -# -# Copyright (c) 2018 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::Test; - -use Test::Class::Most parent => 'My::Test::Class'; - -use SNMP::Info; - -sub _constructor : Tests(11) { - my $test = shift; - my $class = $test->class; - my $sess = $test->mock_session; - - can_ok $class, 'new'; - isa_ok $test->{info}, $class, '... and the object it returns'; - - is(defined $test->{info}{init}, 1, 'mibs initialized'); - ok( - scalar keys %{$test->{info}{mibs}}, - 'mibs subclass data structure initialized' - ); - ok( - scalar keys %{$test->{info}{globals}}, - 'globals subclass data structure initialized' - ); - ok( - scalar keys %{$test->{info}{funcs}}, - 'funcs subclass data structure initialized' - ); - ok( - scalar keys %{$test->{info}{munge}}, - 'munge subclass data structure initialized' - ); - is_deeply($test->{info}{store}, {}, 'store initialized'); - - is($test->{info}{snmp_comm}, 'public', 'snmp comm arg saved'); - is($test->{info}{snmp_ver}, 2, 'snmp version arg saved'); - is($test->{info}{snmp_user}, 'initial', 'snmp user arg saved'); -} - -sub globals : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'globals'); - - subtest 'Globals can() subtest' => sub { - - my $test_globals = $test->{info}->globals; - foreach my $key (keys %$test_globals) { - can_ok($test->{info}, $key); - } - }; -} - -sub funcs : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'funcs'); - - subtest 'Funcs can() subtest' => sub { - - my $test_funcs = $test->{info}->funcs; - foreach my $key (keys %$test_funcs) { - can_ok($test->{info}, $key); - } - }; -} - -# update() needs to be reworked to discard all args except community -# or context as described in documentation - -sub update : Tests(4) { - my $test = shift; - - # Starting community - is($test->{info}{sess}{Community}, 'public', 'original community'); - -TODO: { - todo_skip "CI issues with update() tests", 3 if 1; - - # Change community - my %update_args = ('Community' => 'new_community',); - $test->{info}->update(%update_args); - is($test->{info}{sess}{Community}, 'new_community', 'community changed'); - - # Starting context - is($test->{info}{sess}{Context}, '', 'original context'); - - # Change context - %update_args = ('Context' => 'new_context',); - $test->{info}->update(%update_args); - is($test->{info}->{sess}->{Context}, 'new_context', 'context changed'); - } -} - -sub cache_and_clear_cache : Tests(9) { - my $test = shift; - - # Isolate tests to cache method. Populated structure of global 'name' and - # func 'i_description' - my $cache_data = { - '_name' => 'Test-Name', - '_i_description' => 1, - 'store' => { - 'i_description' => - {10 => 'Test-Description-10', 20 => 'Test-Description-20'} - } - }; - - # The empty store hash exists upon initialization and remains when the cache - # is cleared. - my $empty_cache = {'store' => {}}; - - can_ok($test->{info}, 'cache'); - cmp_deeply($empty_cache, $test->{info}->cache(), 'cache starts empty'); - ok($test->{info}->cache($cache_data), 'insert test data into cache'); - cmp_deeply( - $cache_data, - $test->{info}->cache(), - 'cache method returns test data' - ); - is($test->{info}->name(), - 'Test-Name', 'global method call returned cached data'); - cmp_deeply( - $test->{info}->i_description(), - $cache_data->{store}{i_description}, - 'funcs method call returned cached data' - ); - can_ok($test->{info}, 'clear_cache'); - ok($test->{info}->clear_cache(), 'cache cleared'); - cmp_deeply( - $empty_cache, - $test->{info}->cache(), - 'no cached data returned after clear_cache method call' - ); -} - -sub debug : Tests(4) { - my $test = shift; - - can_ok($test->{info}, 'debug'); - - ok( - defined $test->{info}{debug} - && $test->{info}{debug} == 0 - && $test->{info}->debug() == 0, - 'debug initialized off' - ); - $test->{info}->debug(1); - ok($test->{info}{debug} && $test->{info}->debug(), 'debug on'); - $test->{info}->debug(0); - ok($test->{info}{debug} == 0 && $test->{info}->debug() == 0, 'debug off'); -} - -sub offline : Tests(4) { - my $test = shift; - - can_ok($test->{info}, 'offline'); - - ok(!defined $test->{info}{Offline}, 'offline not initialized'); - $test->{info}->offline(1); - ok($test->{info}{Offline} && $test->{info}->offline(), 'offline mode on'); - $test->{info}->offline(0); - ok($test->{info}{Offline} == 0 && $test->{info}->offline() == 0, - 'offline off'); -} - -sub bulkwalk : Tests(4) { - my $test = shift; - - can_ok $test->{info}, 'bulkwalk'; - - # Test harness initalizes BulkWalk off, if we didn't provide an arg - # it would not be defined. - ok( - !defined $test->{info}{BulkWalk} - || ($test->{info}{BulkWalk} == 0 && $test->{info}->bulkwalk() == 0), - 'bulkwalk initialized off' - ); - $test->{info}->bulkwalk(1); - ok($test->{info}{BulkWalk} && $test->{info}->bulkwalk(), 'bulkwalk on'); - $test->{info}->bulkwalk(0); - ok($test->{info}{BulkWalk} == 0 && $test->{info}->bulkwalk() == 0, - 'bulkwalk off'); -} - -sub loopdetect : Tests(4) { - my $test = shift; - - can_ok $test->{info}, 'loopdetect'; - - ok(!defined $test->{info}{LoopDetect}, 'loopdetect not initialized'); - $test->{info}->loopdetect(1); - ok($test->{info}{LoopDetect} && $test->{info}->loopdetect(), 'loopdetect on'); - $test->{info}->loopdetect(0); - ok($test->{info}{LoopDetect} == 0 && $test->{info}->loopdetect() == 0, - 'loopdetect off'); -} - -sub device_type : Tests(8) { - my $test = shift; - - can_ok($test->{info}, 'device_type'); - - # Empty args and no SNMP data should result in undef - is($test->{info}->device_type(), - undef, 'No sysServices, no sysDescr results in undef'); - - # Populate cache for tests rather than mocking session to limit code hit - # on these tests - my $cache_data - = {'_layers' => '00000000', '_description' => 'My-Test-sysDescr',}; - $test->{info}->cache($cache_data); - - is($test->{info}->device_type(), - 'SNMP::Info', 'No sysServices and unknown sysDescr results in SNMP::Info'); - - $test->{info}->debug(1); - warnings_like { $test->{info}->device_type() } - [{carped => qr/Might give unexpected results/i}], - 'No sysServices and unknown sysDescr with debug on gives warning'; - $test->{info}->debug(0); - $test->{info}->clear_cache(); - - # Test one oid per layer hash just to verify oid mapping, no need to test - # every hash key - chose an id that is unique per layer - - # Layer 3 - $cache_data = { - '_layers' => 4, - '_description' => 'My-Test-sysDescr', - '_id' => '.1.3.6.1.4.1.18' - }; - $test->{info}->cache($cache_data); - is($test->{info}->device_type, - 'SNMP::Info::Layer3::BayRS', 'Layer 3 device type by sysObjectID'); - $test->{info}->clear_cache(); - - # Layer 2 - $cache_data = { - '_layers' => 2, - '_description' => 'My-Test-sysDescr', - '_id' => '.1.3.6.1.4.1.11898' - }; - $test->{info}->cache($cache_data); - is($test->{info}->device_type, - 'SNMP::Info::Layer2::Orinoco', 'Layer 2 device type by sysObjectID'); - $test->{info}->clear_cache(); - - # Layer 1 - $cache_data = { - '_layers' => 1, - '_description' => 'My-Test-sysDescr', - '_id' => '.1.3.6.1.4.1.2925' - }; - $test->{info}->cache($cache_data); - is( - $test->{info}->device_type, - 'SNMP::Info::Layer1::Cyclades', - 'Layer 1 device type by sysObjectID' - ); - $test->{info}->clear_cache(); - - # Layer 7 - $cache_data = { - '_layers' => 64, - '_description' => 'My-Test-sysDescr', - '_id' => '.1.3.6.1.4.1.318' - }; - $test->{info}->cache($cache_data); - is($test->{info}->device_type, - 'SNMP::Info::Layer7::APC', 'Layer 1 device type by sysObjectID'); - $test->{info}->clear_cache(); - - # Add Regex tests if needed -} - -sub error : Tests(7) { - my $test = shift; - - can_ok($test->{info}, 'error'); - ok(!exists $test->{info}{error}, 'Error not present'); - $test->{info}{error} = 'Test Error'; - is($test->{info}->error(), 'Test Error', 'Test Error present'); - is($test->{info}->error(), undef, 'Test Error cleared upon read'); - $test->{info}{error} = 'Test Error 2'; - is($test->{info}->error(1), - 'Test Error 2', 'Test Error 2 present and no clear flag set'); - is($test->{info}->error(0), - 'Test Error 2', 'Test Error 2 still present on next read'); - is($test->{info}->error(), - undef, 'Test Error 2 cleared upon read with flag set to false'); -} - -sub has_layer : Tests(6) { - my $test = shift; - - can_ok $test->{info}, 'has_layer'; - $test->{info}->clear_cache(); - - # Populate cache, one key/value so don't bother going through the - # cache() method. - # Layers holds the unmunged value (decimal) - $test->{info}{'_layers'} = 1; - is($test->{info}->has_layer(1), 1, 'Has layer 1'); - - $test->{info}{'_layers'} = 2; - is($test->{info}->has_layer(2), 1, 'Has layer 2'); - - $test->{info}{'_layers'} = 4; - is($test->{info}->has_layer(3), 1, 'Has layer 3'); - - # We don't use layers 4-6 for classification, skip testing - - $test->{info}{'_layers'} = 64; - is($test->{info}->has_layer(7), 1, 'Has layer 7'); - - # Check for undef layers - $test->{info}{'_layers'} = undef; - is($test->{info}->has_layer(7), undef, 'Undef layers returns undef'); -} - -sub snmp_comm : Tests(4) { - my $test = shift; - - can_ok $test->{info}, 'snmp_comm'; - - # Define before test to be sure instead of relying on initalization - $test->{info}{snmp_comm} = 'publicv1'; - $test->{info}{snmp_ver} = 1; - is($test->{info}->snmp_comm(), 'publicv1', - 'Version 1 returns SNMP community'); - - $test->{info}{snmp_comm} = 'publicv2'; - $test->{info}{snmp_ver} = 2; - is($test->{info}->snmp_comm(), 'publicv2', - 'Version 2 returns SNMP community'); - - $test->{info}{snmp_user} = 'initialv3'; - $test->{info}{snmp_ver} = 3; - is($test->{info}->snmp_comm(), 'initialv3', 'Version 3 returns SNMP user'); -} - -sub snmp_ver : Tests(2) { - my $test = shift; - - can_ok $test->{info}, 'snmp_ver'; - - # Define before test to be sure instead of relying on initalization - $test->{info}{snmp_ver} = 1; - is($test->{info}->snmp_ver(), 1, 'SNMP version returned'); -} - -sub specify : Tests(4) { - my $test = shift; - - can_ok $test->{info}, 'specify'; - $test->{info}->cache_clear(); - - # Specify uses device_type(), use same data as that test to setup - # test cases here since return values from device_type() with them - # have been tested - - # device_type returns undef - $test->{info}->specify(); - is( - $test->{info}->error(), - 'SNMP::Info::specify() - Could not get info from device', - 'Undef device type throws error' - ); - $test->{info}->cache_clear(); - - # Populate cache for following tests - my $cache_data - = {'_layers' => '00000000', '_description' => 'My-Test-sysDescr',}; - $test->{info}->cache($cache_data); - - isa_ok($test->{info}->specify(), - 'SNMP::Info', 'SNMP::Info device_type returns self'); - $test->{info}->cache_clear(); - - # Layer 7 - SNMP::Info::Layer7::APC - $cache_data = { - '_layers' => 64, - '_description' => 'My-Test-sysDescr', - '_id' => '.1.3.6.1.4.1.318' - }; - $test->{info}->cache($cache_data); - isa_ok($test->{info}->specify(), - 'SNMP::Info::Layer7::APC', - 'Layer 7 device type returns new object of same type'); - $test->{info}->clear_cache(); -} - -sub cisco_comm_indexing : Tests(2) { - my $test = shift; - - can_ok $test->{info}, 'cisco_comm_indexing'; - is($test->{info}->cisco_comm_indexing(), 0, 'Cisco community indexing off'); -} - -sub if_ignore : Tests(2) { - my $test = shift; - - can_ok $test->{info}, 'if_ignore'; - is_deeply($test->{info}->if_ignore(), - {}, 'No ignored interfaces for this class'); -} - -sub bulkwalk_no : Tests(2) { - my $test = shift; - - can_ok $test->{info}, 'bulkwalk_no'; - is($test->{info}->bulkwalk_no(), 0, 'Bulkwalk not turned off in this class'); -} - -sub i_speed : Tests(2) { - my $test = shift; - - can_ok $test->{info}, 'i_speed'; - - # Method uses partial fetches which ignores the cache and reloads data - # therefore we must use the mocked session. Populate the session data - # so that the mock_getnext() has data to fetch. - my $data = { - - # Need to use OID for ifSpeed since it could resolve to a fully qualified - # name as either RFC1213-MIB::ifSpeed or IF-MIB::ifSpeed dependent upon - # which MIB got loaded last which is based upon random hash ordering. Using - # a fully qualified name with mock session we would need to know which MIB - # "owned" the OID since the MIB hash is indexed by OID. This is not an - # issue in live code since what is fed to getnext for a fully qualified - # name is what is returned. - '.1.3.6.1.2.1.2.2.1.5' => {38 => 0, 49 => 4294967295, 501 => 1000000000,}, - 'IF-MIB::ifHighSpeed' => {38 => 0, 49 => 32000, 501 => 1000,}, - }; - my $expected = {38 => 0, 49 => '32 Gbps', 501 => '1.0 Gbps',}; - $test->{info}{sess}{Data} = $data; - is_deeply($test->{info}->i_speed(), - $expected, 'High speed interface reported accurately'); -} - -sub i_speed_raw : Tests(3) { - my $test = shift; - - can_ok $test->{info}, 'i_speed_raw'; - - # Method uses partial fetches which ignores the cache and reloads data - # therefore we must use the mocked session. Populate the session data - # so that the mock_getnext() has data to fetch. - my $data = { - - # Need to use OID for ifSpeed since it could resolve to a fully qualified - # name as either RFC1213-MIB::ifSpeed or IF-MIB::ifSpeed dependent upon - # which MIB got loaded last which is based upon random hash ordering. Using - # a fully qualified name with mock session we would need to know which MIB - # "owned" the OID since the MIB hash is indexed by OID. This is not an - # issue in live code since what is fed to getnext for a fully qualified - # name is what is returned. - '.1.3.6.1.2.1.2.2.1.5' => {38 => 0, 49 => 4294967295, 501 => 1000000000,}, - 'IF-MIB::ifHighSpeed' => {38 => 0, 49 => 32000, 501 => 1000,}, - }; - my $expected = {38 => 0, 49 => '32 Gbps', 501 => '1.0 Gbps',}; - my $expected_raw = {38 => 0, 49 => 32000000000, 501 => 1000000000,}; - $test->{info}{sess}{Data} = $data; - is_deeply($test->{info}->i_speed_raw(), - $expected_raw, 'Raw high speed interface reported accurately'); - - # Note the cache is populated unmunged data now - not sure if that is - # expected behavior. Clear cache to get data to test that munges are restored. - $test->{info}->clear_cache(); - is_deeply($test->{info}->i_speed(), - $expected, 'Munges restored after i_speed_raw() call'); -} - -# Topo routines will need to be tested in sub classes for conditionals -sub has_topo : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'has_topo'); - is($test->{info}->has_topo(), undef, 'Base class has no topo'); -} - -sub get_topo_data : Tests(2) { - my $test = shift; - - can_ok($test->{info}, '_get_topo_data'); - is($test->{info}->_get_topo_data(), undef, 'Base class has no topo data'); -} - -sub c_ip : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'c_ip'); - is($test->{info}->c_ip(), undef, 'Base class has no topo'); -} - -sub c_if : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'c_if'); - is($test->{info}->c_if(), undef, 'Base class has no topo'); -} - -sub c_port : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'c_port'); - is($test->{info}->c_port(), undef, 'Base class has no topo'); -} - -sub c_id : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'c_id'); - is($test->{info}->c_id(), undef, 'Base class has no topo'); -} - -sub c_platform : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'c_platform'); - is($test->{info}->c_platform(), undef, 'Base class has no topo'); -} - -sub c_cap : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'c_cap'); - is($test->{info}->c_cap(), undef, 'Base class has no topo'); -} - -# Munges aren't methods, the are functions so calling convention is different -sub munge_speed : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_speed'); - is(SNMP::Info::munge_speed('2488000000'), - 'OC-48', 'Speed munged according to map'); -} - -sub munge_highspeed : Tests(6) { - my $test = shift; - - can_ok($test->{info}, 'munge_highspeed'); - is(SNMP::Info::munge_highspeed('15000000'), '15 Tbps', 'Tbps munge'); - is(SNMP::Info::munge_highspeed('1500000'), - '1.5 Tbps', 'Fractional Tbps munge'); - is(SNMP::Info::munge_highspeed('15000'), '15 Gbps', 'Gbps munge'); - is(SNMP::Info::munge_highspeed('1500'), '1.5 Gbps', 'Fractional Gbps munge'); - is(SNMP::Info::munge_highspeed('100'), '100 Mbps', 'Mbps munge'); -} - -sub munge_ip : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_ip'); - my $test_ip = pack("C4", split /\./, "123.4.5.6"); - is(SNMP::Info::munge_ip($test_ip), - "123.4.5.6", 'Binary IP to dotted ASCII munge'); -} - -sub munge_mac : Tests(3) { - my $test = shift; - - can_ok($test->{info}, 'munge_mac'); - - # The munge expects an octet string, pack a decimal string into - # representation munge is expecting - my $test_mac = pack("C*", split /\./, "01.35.69.103.137.171"); - is(SNMP::Info::munge_mac($test_mac), - "01:23:45:67:89:ab", 'Octet string to colon separated ASCII hex string'); - my $bogus_mac = pack("C*", split /\./, "01.35.69.103.137.171.02"); - is(SNMP::Info::munge_mac($bogus_mac), undef, - 'Bad octet string returns undef'); -} - -sub munge_prio_mac : Tests(3) { - my $test = shift; - - can_ok($test->{info}, 'munge_prio_mac'); - - # The munge expects an octet string, pack a decimal string into - # representation munge is expecting - my $test_mac = pack("C*", split /\./, "01.35.69.103.137.171.205.239"); - is(SNMP::Info::munge_prio_mac($test_mac), - "01:23:45:67:89:ab:cd:ef", - 'Octet string to colon separated ASCII hex string'); - my $bogus_mac = pack("C*", split /\./, "01.35.69.103.137.171.205.239.02"); - is(SNMP::Info::munge_prio_mac($bogus_mac), - undef, 'Bad octet string returns undef'); -} - -sub munge_prio_port : Tests(3) { - my $test = shift; - - can_ok($test->{info}, 'munge_prio_port'); - - # The munge expects an octet string, pack a decimal string into - # representation munge is expecting - my $test_mac = pack("C*", split /\./, "171.205"); - is(SNMP::Info::munge_prio_port($test_mac), - "ab:cd", 'Octet string to colon separated ASCII hex string'); - my $bogus_mac = pack("C*", split /\./, "171.205.02"); - is(SNMP::Info::munge_prio_port($bogus_mac), - undef, 'Bad octet string returns undef'); -} - -# Can't see where this code is actually used, remove? -sub munge_octet2hex : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_octet2hex'); - - # The munge expects an octet string, pack a decimal string into - # representation munge is expecting - my $test_mac = pack("C*", split /\./, "171.205"); - is(SNMP::Info::munge_octet2hex($test_mac), - "abcd", 'Octet string to ASCII hex string'); -} - -sub munge_dec2bin : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_dec2bin'); - - # This is layers munge, use L3 test case - is(SNMP::Info::munge_dec2bin(4), '00000100', 'Binary char to ASCII binary'); -} - -sub munge_bits : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_bits'); - - my $bits = pack("B*", '00010110'); - - is(SNMP::Info::munge_bits($bits), - '00010110', 'SNMP2 BITS field to ASCII bit string'); -} - -# TODO -#sub munge_counter64 : Tests() { -# my $test = shift; -# -#} - -sub munge_i_up : Tests(4) { - my $test = shift; - - can_ok($test->{info}, 'munge_i_up'); - - is(SNMP::Info::munge_i_up(), undef, 'No arg returns undef'); - is(SNMP::Info::munge_i_up(4), 'unknown', 'Unknown status'); - is(SNMP::Info::munge_i_up(7), 'lowerLayerDown', 'Lower layer down status'); -} - -sub munge_port_list : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_port_list'); - - # These are typically longer bit strings to cover the all ports in a switch - my $bit_string = '01010101010101010101010101010101'; - my $bits = pack("B*", $bit_string); - - # We are going to get a reference of array of bits back so convert the - # string to an array - my $expected = []; - for my $value (split //, $bit_string) { - $expected->[++$#$expected] = $value; - } - is_deeply(SNMP::Info::munge_port_list($bits), - $expected, 'Portlist octet string coverted to ASCII bit array'); -} - -sub munge_null : Tests(2) { - my $test = shift; - - can_ok($test->{info}, 'munge_null'); - - # See if all possible control characters and nulls are removed - my $cntl_string = "Test\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09"; - $cntl_string .= "This\x0A\x0B\x0C\x0D\x0E\x0F"; - $cntl_string .= "Crazy\x11\x12\x13\x14\x15\x16\x17\x18\x19"; - $cntl_string .= "Cntl\x1A\x1B\x1C\x1D\x1E\x1F"; - $cntl_string .= "\x7FString"; - - # This is layers munge, use L3 test case - is(SNMP::Info::munge_null($cntl_string), - 'TestThisCrazyCntlString', 'Null and control characters removed'); -} - -sub munge_e_type : Tests(3) { - my $test = shift; - - can_ok($test->{info}, 'munge_e_type'); - - # This is just calling SNMP::translateOb, so rather than loading another MIB - # let's just resolve an OID we don't use from a loaded MIB. - is(SNMP::Info::munge_e_type('.1.3.6.1.2.1.11.4'), - 'snmpInBadCommunityNames', 'OID translated properly'); - - # Bogus OID - is(SNMP::Info::munge_e_type('.100.3.6.1.2.1.11.4'), - '.100.3.6.1.2.1.11.4', 'OID returned when unable to translate'); -} - -sub init : Tests(4) { - my $test = shift; - - can_ok($test->{info}, 'init'); - - # When the test info object was created init() was called so all of the - # entries in %MIBS should be loaded - subtest 'Base MIBs loaded subtest' => sub { - - my $base_mibs = $test->{info}->mibs(); - - foreach my $key (keys %$base_mibs) { - my $qual_name = "$key" . '::' . "$base_mibs->{$key}"; - ok(defined $SNMP::MIB{$base_mibs->{$key}}, "$qual_name defined"); - like(SNMP::translateObj($qual_name), - qr/^(\.\d+)+$/, "$qual_name translates to a OID"); - } - }; - - # Get SNMP::Version so we can restore - my $netsnmp_ver = $SNMP::VERSION; - local $SNMP::VERSION = '5.0.1'; - - warnings_like { $test->{info}->init() } - [{carped => qr/Net-SNMP\s5.0.1\sseems\sto\sbe\srather\sbuggy/x}], - 'Use of bad Net-SNMP gives warning'; - - $SNMP::VERSION = $netsnmp_ver; -} - - -1; diff --git a/xt/lib/Test/SNMP/Info.pm b/xt/lib/Test/SNMP/Info.pm new file mode 100644 index 00000000..7fd8b538 --- /dev/null +++ b/xt/lib/Test/SNMP/Info.pm @@ -0,0 +1,1689 @@ +# Test::SNMP::Info +# +# Copyright (c) 2018 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 Test::SNMP::Info; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info; + +sub constructor : Tests(+3) { + my $test = shift; + $test->SUPER::constructor; + + is($test->{info}{snmp_comm}, 'public', 'SNMP comm arg saved'); + is($test->{info}{snmp_ver}, 2, 'SNMP version arg saved'); + is($test->{info}{snmp_user}, 'initial', 'SNMP user arg saved'); +} + +sub update : Tests(9) { + my $test = shift; + + can_ok($test->{info}, 'update'); + + # Starting community + is($test->{info}{sess}{Community}, 'public', q(Original community 'public')); + + # Change community + my %update_args = ('Community' => 'new_community',); + delete $test->{info}{args}{Session}; + ok($test->{info}->update(%update_args), 'Update community'); + is($test->{info}->error(), undef, '... and no error'); + is($test->{info}{sess}{Community}, 'new_community', 'Community changed'); + +TODO: { + # The update() method creates a new SNMP::Session, v1/2 do not actually + # need to contact the DestHost for session creation while v3 does. + # It appears that Net-SNMP 5.8 changes the behavior of v3 session creation + # so that it doesn't require contact with the DestHost to pass these tests + # We also could connect to http://snmplabs.com v3 simulator but would + # prefer to keep those tests isolated to 10_remote_snmplabs.t - we could + # also move the update() tests to that file. + todo_skip "Revisit v3 Context update() tests when using Net-SNMP 5.8+", 4 + if 1; + + # Starting context + ok(!defined $test->{info}{sess}{Context}, q(Context doesn't exist)); + + # Change context + # Since update() is actually creating new SNMP::Session we can put + # whatever session arguments needed in %update_args + %update_args = ('Context' => 'vlan-100', 'Version' => 3,); + ok($test->{info}->update(%update_args), 'Update Context'); + is($test->{info}->error(), undef, '... and no error'); + is($test->{info}->{sess}{Context}, 'vlan-100', 'Context changed'); + + } +} + +sub cache_and_clear_cache : Tests(9) { + my $test = shift; + + # Isolate tests to cache method. Populated structure of global 'name' and + # func 'i_description' + my $cache_data = { + '_name' => 'Test-Name', + '_i_description' => 1, + 'store' => { + 'i_description' => + {10 => 'Test-Description-10', 20 => 'Test-Description-20'} + } + }; + + # The empty store hash exists upon initialization and remains when the cache + # is cleared. + my $empty_cache = {'store' => {}}; + + can_ok($test->{info}, 'cache'); + cmp_deeply($empty_cache, $test->{info}->cache(), 'Cache starts empty'); + ok($test->{info}->cache($cache_data), 'Insert test data into cache'); + cmp_deeply( + $cache_data, + $test->{info}->cache(), + 'Cache method returns test data' + ); + is($test->{info}->name(), + 'Test-Name', 'Global method call returned cached data'); + cmp_deeply( + $test->{info}->i_description(), + $cache_data->{store}{i_description}, + 'Funcs method call returned cached data' + ); + can_ok($test->{info}, 'clear_cache'); + ok($test->{info}->clear_cache(), 'cache cleared'); + cmp_deeply( + $empty_cache, + $test->{info}->cache(), + 'No cached data returned after clear_cache method call' + ); +} + +sub debug : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'debug'); + + ok( + defined $test->{info}{debug} + && $test->{info}{debug} == 0 + && $test->{info}->debug() == 0, + 'Debug initialized off' + ); + $test->{info}->debug(1); + ok($test->{info}{debug} && $test->{info}->debug(), 'Debug on'); + $test->{info}->debug(0); + ok($test->{info}{debug} == 0 && $test->{info}->debug() == 0, 'Debug off'); +} + +sub offline : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'offline'); + + ok(!defined $test->{info}{Offline}, 'Offline not initialized'); + $test->{info}->offline(1); + ok($test->{info}{Offline} && $test->{info}->offline(), 'Offline mode on'); + $test->{info}->offline(0); + ok($test->{info}{Offline} == 0 && $test->{info}->offline() == 0, + 'Offline off'); +} + +sub bulkwalk : Tests(4) { + my $test = shift; + + can_ok $test->{info}, 'bulkwalk'; + + # Test harness initalizes BulkWalk off, if we didn't provide an arg + # it would not be defined. + ok( + !defined $test->{info}{BulkWalk} + || ($test->{info}{BulkWalk} == 0 && $test->{info}->bulkwalk() == 0), + 'Bulkwalk initialized off' + ); + $test->{info}->bulkwalk(1); + ok($test->{info}{BulkWalk} && $test->{info}->bulkwalk(), 'Bulkwalk on'); + $test->{info}->bulkwalk(0); + ok($test->{info}{BulkWalk} == 0 && $test->{info}->bulkwalk() == 0, + 'Bulkwalk off'); +} + +sub loopdetect : Tests(4) { + my $test = shift; + + can_ok $test->{info}, 'loopdetect'; + + ok(!defined $test->{info}{LoopDetect}, 'Loopdetect not initialized'); + $test->{info}->loopdetect(1); + ok($test->{info}{LoopDetect} && $test->{info}->loopdetect(), 'Loopdetect on'); + $test->{info}->loopdetect(0); + ok($test->{info}{LoopDetect} == 0 && $test->{info}->loopdetect() == 0, + 'Loopdetect off'); +} + +sub device_type : Tests(+6) { + my $test = shift; + $test->SUPER::device_type(); + + # No sysServices and unknown sysDescr results in SNMP::Info + my $cache_data + = {'_layers' => '00000000', '_description' => 'My-Test-sysDescr',}; + $test->{info}->cache($cache_data); + + $test->{info}->debug(1); + warnings_like { $test->{info}->device_type() } + [{carped => qr/Might give unexpected results/i}], + 'No sysServices and unknown sysDescr with debug on gives warning'; + $test->{info}->debug(0); + $test->{info}->clear_cache(); + + # Cache has been cleared, empty args and no SNMP data result in undef + is($test->{info}->device_type(), + undef, 'No sysServices, no sysDescr results in undef'); + + # Test one oid per layer hash just to verify oid mapping, no need to test + # every hash key - chose an id that is unique per layer + + # Layer 3 + $cache_data = { + '_layers' => 4, + '_description' => 'My-Test-sysDescr', + '_id' => '.1.3.6.1.4.1.18' + }; + $test->{info}->cache($cache_data); + is($test->{info}->device_type, + 'SNMP::Info::Layer3::BayRS', 'Layer 3 device type by sysObjectID'); + $test->{info}->clear_cache(); + + # Layer 2 + $cache_data = { + '_layers' => 2, + '_description' => 'My-Test-sysDescr', + '_id' => '.1.3.6.1.4.1.11898' + }; + $test->{info}->cache($cache_data); + is($test->{info}->device_type, + 'SNMP::Info::Layer2::Orinoco', 'Layer 2 device type by sysObjectID'); + $test->{info}->clear_cache(); + + # Layer 1 + $cache_data = { + '_layers' => 1, + '_description' => 'My-Test-sysDescr', + '_id' => '.1.3.6.1.4.1.2925' + }; + $test->{info}->cache($cache_data); + is( + $test->{info}->device_type, + 'SNMP::Info::Layer1::Cyclades', + 'Layer 1 device type by sysObjectID' + ); + $test->{info}->clear_cache(); + + # Layer 7 + $cache_data = { + '_layers' => 64, + '_description' => 'My-Test-sysDescr', + '_id' => '.1.3.6.1.4.1.318' + }; + $test->{info}->cache($cache_data); + is($test->{info}->device_type, + 'SNMP::Info::Layer7::APC', 'Layer 7 device type by sysObjectID'); + $test->{info}->clear_cache(); + + # We will test each specific subclass, so no need to check that logic here +} + +sub error : Tests(7) { + my $test = shift; + + can_ok($test->{info}, 'error'); + ok(!exists $test->{info}{error}, 'Error not present'); + $test->{info}{error} = 'Test Error'; + is($test->{info}->error(), 'Test Error', 'Test Error present'); + is($test->{info}->error(), undef, 'Test Error cleared upon read'); + $test->{info}{error} = 'Test Error 2'; + is($test->{info}->error(1), + 'Test Error 2', 'Test Error 2 present and no clear flag set'); + is($test->{info}->error(0), + 'Test Error 2', 'Test Error 2 still present on next read'); + is($test->{info}->error(), + undef, 'Test Error 2 cleared upon read with flag set to false'); +} + +sub has_layer : Tests(6) { + my $test = shift; + + can_ok $test->{info}, 'has_layer'; + $test->{info}->clear_cache(); + + # Populate cache, one key/value so don't bother going through the + # cache() method. + # Layers holds the unmunged value (decimal) + $test->{info}{'_layers'} = 1; + is($test->{info}->has_layer(1), 1, 'Has layer 1'); + + $test->{info}{'_layers'} = 2; + is($test->{info}->has_layer(2), 1, 'Has layer 2'); + + $test->{info}{'_layers'} = 4; + is($test->{info}->has_layer(3), 1, 'Has layer 3'); + + # We don't use layers 4-6 for classification, skip testing + + $test->{info}{'_layers'} = 64; + is($test->{info}->has_layer(7), 1, 'Has layer 7'); + + # Check for undef layers + $test->{info}{'_layers'} = undef; + is($test->{info}->has_layer(7), undef, 'Undef layers returns undef'); +} + +sub snmp_comm : Tests(4) { + my $test = shift; + + can_ok $test->{info}, 'snmp_comm'; + + # Define before test to be sure instead of relying on initalization + $test->{info}{snmp_comm} = 'publicv1'; + $test->{info}{snmp_ver} = 1; + is($test->{info}->snmp_comm(), 'publicv1', + 'Version 1 returns SNMP community'); + + $test->{info}{snmp_comm} = 'publicv2'; + $test->{info}{snmp_ver} = 2; + is($test->{info}->snmp_comm(), 'publicv2', + 'Version 2 returns SNMP community'); + + $test->{info}{snmp_user} = 'initialv3'; + $test->{info}{snmp_ver} = 3; + is($test->{info}->snmp_comm(), 'initialv3', 'Version 3 returns SNMP user'); +} + +sub snmp_ver : Tests(2) { + my $test = shift; + + can_ok $test->{info}, 'snmp_ver'; + + # Define before test to be sure instead of relying on initalization + $test->{info}{snmp_ver} = 1; + is($test->{info}->snmp_ver(), 1, 'SNMP version returned'); +} + +sub specify : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'specify'); + $test->{info}->cache_clear(); + + # Specify uses device_type(), use same data as that test to setup + # test cases here since return values from device_type() with them + # have been tested + + # device_type returns undef + $test->{info}->specify(); + is( + $test->{info}->error(), + 'SNMP::Info::specify() - Could not get info from device', + 'Undef device type throws error' + ); + $test->{info}->cache_clear(); + + # Populate cache for following tests + my $cache_data + = {'_layers' => '00000000', '_description' => 'My-Test-sysDescr',}; + $test->{info}->cache($cache_data); + + isa_ok($test->{info}->specify(), + 'SNMP::Info', 'SNMP::Info device_type returns self'); + $test->{info}->cache_clear(); + + # Layer 7 - SNMP::Info::Layer7::APC + $cache_data = { + '_layers' => 64, + '_description' => 'My-Test-sysDescr', + '_id' => '.1.3.6.1.4.1.318' + }; + $test->{info}->cache($cache_data); + isa_ok($test->{info}->specify(), + 'SNMP::Info::Layer7::APC', + 'Layer 7 device type returns new object of same type'); + $test->{info}->clear_cache(); +} + +sub cisco_comm_indexing : Tests(2) { + my $test = shift; + + can_ok $test->{info}, 'cisco_comm_indexing'; + is($test->{info}->cisco_comm_indexing(), 0, 'Cisco community indexing off'); +} + +sub if_ignore : Tests(2) { + my $test = shift; + + can_ok $test->{info}, 'if_ignore'; + cmp_deeply($test->{info}->if_ignore(), + {}, 'No ignored interfaces for this class'); +} + +sub bulkwalk_no : Tests(2) { + my $test = shift; + + can_ok $test->{info}, 'bulkwalk_no'; + is($test->{info}->bulkwalk_no(), 0, 'Bulkwalk not turned off in this class'); +} + +sub i_speed : Tests(2) { + my $test = shift; + + can_ok $test->{info}, 'i_speed'; + + # Method uses partial fetches which ignores the cache and reloads data + # therefore we must use the mocked session. Populate the session data + # so that the mock_getnext() has data to fetch. + my $data = { + + # Need to use OID for ifSpeed since it could resolve to a fully qualified + # name as either RFC1213-MIB::ifSpeed or IF-MIB::ifSpeed dependent upon + # which MIB got loaded last which is based upon random hash ordering. Using + # a fully qualified name with mock session we would need to know which MIB + # "owned" the OID since the MIB hash is indexed by OID. This is not an + # issue in live code since what is fed to getnext for a fully qualified + # name is what is returned. + '.1.3.6.1.2.1.2.2.1.5' => {38 => 0, 49 => 4294967295, 501 => 1000000000,}, + 'IF-MIB::ifHighSpeed' => {38 => 0, 49 => 32000, 501 => 1000,}, + }; + my $expected = {38 => 0, 49 => '32 Gbps', 501 => '1.0 Gbps',}; + $test->{info}{sess}{Data} = $data; + cmp_deeply($test->{info}->i_speed(), + $expected, 'High speed interface reported accurately'); +} + +sub i_speed_raw : Tests(3) { + my $test = shift; + + can_ok $test->{info}, 'i_speed_raw'; + + # Method uses partial fetches which ignores the cache and reloads data + # therefore we must use the mocked session. Populate the session data + # so that the mock_getnext() has data to fetch. + my $data = { + + # Need to use OID for ifSpeed since it could resolve to a fully qualified + # name as either RFC1213-MIB::ifSpeed or IF-MIB::ifSpeed dependent upon + # which MIB got loaded last which is based upon random hash ordering. Using + # a fully qualified name with mock session we would need to know which MIB + # "owned" the OID since the MIB hash is indexed by OID. This is not an + # issue in live code since what is fed to getnext for a fully qualified + # name is what is returned. + '.1.3.6.1.2.1.2.2.1.5' => {38 => 0, 49 => 4294967295, 501 => 1000000000,}, + 'IF-MIB::ifHighSpeed' => {38 => 0, 49 => 32000, 501 => 1000,}, + }; + my $expected = {38 => 0, 49 => '32 Gbps', 501 => '1.0 Gbps',}; + my $expected_raw = {38 => 0, 49 => 32000000000, 501 => 1000000000,}; + $test->{info}{sess}{Data} = $data; + cmp_deeply($test->{info}->i_speed_raw(), + $expected_raw, 'Raw high speed interface reported accurately'); + + # Note the cache is populated unmunged data now - not sure if that is + # expected behavior. Clear cache to get data to test that munges are restored. + $test->{info}->clear_cache(); + cmp_deeply($test->{info}->i_speed(), + $expected, 'Munges restored after i_speed_raw() call'); +} + +# Topo routines will need to be tested in sub classes for conditionals +sub has_topo : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'has_topo'); + is($test->{info}->has_topo(), undef, 'Base class has no topo'); +} + +sub get_topo_data : Tests(2) { + my $test = shift; + + can_ok($test->{info}, '_get_topo_data'); + is($test->{info}->_get_topo_data(), undef, 'Base class has no topo data'); +} + +sub c_ip : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'c_ip'); + is($test->{info}->c_ip(), undef, 'Base class has no topo'); +} + +sub c_if : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'c_if'); + is($test->{info}->c_if(), undef, 'Base class has no topo'); +} + +sub c_port : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'c_port'); + is($test->{info}->c_port(), undef, 'Base class has no topo'); +} + +sub c_id : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'c_id'); + is($test->{info}->c_id(), undef, 'Base class has no topo'); +} + +sub c_platform : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'c_platform'); + is($test->{info}->c_platform(), undef, 'Base class has no topo'); +} + +sub c_cap : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'c_cap'); + is($test->{info}->c_cap(), undef, 'Base class has no topo'); +} + +# Munges aren't methods, the are functions so calling convention is different +sub munge_speed : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge_speed'); + is(SNMP::Info::munge_speed('2488000000'), + 'OC-48', 'Speed munged according to map'); +} + +sub munge_highspeed : Tests(6) { + my $test = shift; + + can_ok($test->{info}, 'munge_highspeed'); + is(SNMP::Info::munge_highspeed('15000000'), '15 Tbps', 'Tbps munge'); + is(SNMP::Info::munge_highspeed('1500000'), + '1.5 Tbps', 'Fractional Tbps munge'); + is(SNMP::Info::munge_highspeed('15000'), '15 Gbps', 'Gbps munge'); + is(SNMP::Info::munge_highspeed('1500'), '1.5 Gbps', 'Fractional Gbps munge'); + is(SNMP::Info::munge_highspeed('100'), '100 Mbps', 'Mbps munge'); +} + +sub munge_ip : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge_ip'); + my $test_ip = pack("C4", split /\./, "123.4.5.6"); + is(SNMP::Info::munge_ip($test_ip), + "123.4.5.6", 'Binary IP to dotted ASCII munge'); +} + +sub munge_mac : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'munge_mac'); + + # This is how these MACs look in a snmpwalk + my $test_mac = "01 23 45 67 89 AB"; + my $long_test_mac = "01 23 45 67 89 AB CD"; + my $short_test_mac = "01 23 45 67 89"; + + # However, they come across the wire as octet string, so we need to pack + # them. Before packing, we need to remove the whitespace + foreach ($test_mac, $long_test_mac, $short_test_mac) { + $_ =~ s/\s//g; + $_ = pack("H*", $_); + } + + is(SNMP::Info::munge_mac($test_mac), + "01:23:45:67:89:ab", 'Octet string to colon separated ASCII hex string'); + is(SNMP::Info::munge_mac($long_test_mac), + undef, 'Too long of an octet string returns undef'); + is(SNMP::Info::munge_mac($short_test_mac), + undef, 'Too short of an octet string returns undef'); +} + +sub munge_prio_mac : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'munge_prio_mac'); + + # This is how these look in a snmpwalk + my $test_mac = "01 23 45 67 89 AB CD EF"; + my $long_test_mac = "01 23 45 67 89 AB CD EF 02"; + my $short_test_mac = "01 23 45 67 89"; + + # However, they come across the wire as octet string, so we need to pack + # them. Before packing, we need to remove the whitespace + foreach ($test_mac, $long_test_mac, $short_test_mac) { + $_ =~ s/\s//g; + $_ = pack("H*", $_); + } + + is(SNMP::Info::munge_prio_mac($test_mac), + "01:23:45:67:89:ab:cd:ef", + 'Octet string to colon separated ASCII hex string'); + is(SNMP::Info::munge_prio_mac($long_test_mac), + undef, 'Too long of an octet string returns undef'); + is(SNMP::Info::munge_mac($short_test_mac), + undef, 'Too short of an octet string returns undef'); +} + +sub munge_prio_port : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'munge_prio_port'); + + # This is how these look in a snmpwalk + my $test_mac = "AB CD"; + my $long_test_mac = "AB CD EF"; + my $short_test_mac = "AB"; + + # However, they come across the wire as octet string, so we need to pack + # them. Before packing, we need to remove the whitespace + foreach ($test_mac, $long_test_mac, $short_test_mac) { + $_ =~ s/\s//g; + $_ = pack("H*", $_); + } + + is(SNMP::Info::munge_prio_port($test_mac), + "ab:cd", 'Octet string to colon separated ASCII hex string'); + is(SNMP::Info::munge_prio_port($long_test_mac), + undef, 'Too long of an octet string returns undef'); + is(SNMP::Info::munge_prio_port($short_test_mac), + undef, 'Too short of an string returns undef'); +} + +# Can't see where this code is actually used, remove? +sub munge_octet2hex : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge_octet2hex'); + + # This is how this looks in a snmpwalk + my $test_mac = "AB CD"; + + # However, is comes across the wire as octet string, so we need to pack + # it. Before packing, we need to remove the whitespace + $test_mac =~ s/\s//g; + $test_mac = pack("H*", $test_mac); + + is(SNMP::Info::munge_octet2hex($test_mac), + "abcd", 'Octet string to ASCII hex string'); +} + +sub munge_dec2bin : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge_dec2bin'); + + # This is layers munge, use L3 test case + is(SNMP::Info::munge_dec2bin(4), '00000100', 'Binary char to ASCII binary'); +} + +sub munge_bits : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge_bits'); + + my $bits = pack("B*", '00010110'); + + is(SNMP::Info::munge_bits($bits), + '00010110', 'SNMP2 BITS field to ASCII bit string'); +} + +sub munge_counter64 : Tests(4) { + my $test = shift; + + my $hc_octets = 744002524365; + + can_ok($test->{info}, 'munge_counter64'); + is(SNMP::Info::munge_counter64(), undef, 'No arg returns undef'); + + # Default is no BigInt + is(SNMP::Info::munge_counter64(744002524365), + 744002524365, 'No BIGINT returns counter'); + +SKIP: { + eval { + require Math::BigInt; + 1; + } or do { + skip "Math::BigInt not installed", 1; + }; + + my $class = $test->class; + my $sess = $test->mock_session; + my $big_int_info + = $class->new('AutoSpecify' => 0, 'BigInt' => 1, 'Session' => $sess,); + + my $obj = SNMP::Info::munge_counter64(744002524365); + isa_ok($obj, 'Math::BigInt', 'Test counter64'); + + } +} + +sub munge_i_up : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'munge_i_up'); + + is(SNMP::Info::munge_i_up(), undef, 'No arg returns undef'); + is(SNMP::Info::munge_i_up(4), 'unknown', 'Unknown status'); + is(SNMP::Info::munge_i_up(7), 'lowerLayerDown', 'Lower layer down status'); +} + +sub munge_port_list : Tests(6) { + my $test = shift; + + can_ok($test->{info}, 'munge_port_list'); + + # Start with the bit string since in a portlist each port is represented as + # a bit. + # These are typically longer bit strings to cover the all ports in a switch + my $bit_string = '01010101010101010101010101010101'; + my $bits_packed = pack("B*", $bit_string); + + # This is more for documentation than test code. When performing a snmpwalk + # the output will typically be a hex string. This converts the packed bit + # string above into a hex string as would be seen in the snmpwalk output. + my $unpacked_hex_string + = join(' ', map { sprintf "%02X", $_ } unpack('C*', $bits_packed)); + + # This should be the same as $unpacked_hex_string + my $hex_string = '55 55 55 55'; + + # Remove the spaces so we can pack, but preserve $hex_string for comparison + # testing with $unpacked_hex_string + (my $new_hex_string = $hex_string) =~ s/\s//g; + + # Pack the hex string for comparison with $bits_packed + my $new_hex_string_packed = pack("H*", $new_hex_string); + + # Finally unpack again to compare with original $bit_string + my $new_bit_string = unpack("B*", $new_hex_string_packed); + + # String comparison testing + is($unpacked_hex_string, $hex_string, + 'Unpacking binary bits into hex string is same as expected hex string'); + is($new_hex_string_packed, $bits_packed, + 'Packed hex string is equivalent to packed bit string'); + is($new_bit_string, $bit_string, + 'Unpacking packed hex string as binary results in original bit string'); + + # We are going to get a reference of array of bits back so convert the + # string to an array + my $expected = []; + for my $value (split //, $bit_string) { + $expected->[++$#$expected] = $value; + } + cmp_deeply(SNMP::Info::munge_port_list($bits_packed), + $expected, 'Portlist packed bit string coverted to ASCII bit array'); + cmp_deeply(SNMP::Info::munge_port_list($new_hex_string_packed), + $expected, 'Portlist packed hex string coverted to ASCII bit array'); +} + +sub munge_null : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'munge_null'); + + # See if all possible control characters and nulls are removed + my $cntl_string = "Test\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09"; + $cntl_string .= "This\x0A\x0B\x0C\x0D\x0E\x0F"; + $cntl_string .= "Crazy\x11\x12\x13\x14\x15\x16\x17\x18\x19"; + $cntl_string .= "Cntl\x1A\x1B\x1C\x1D\x1E\x1F"; + $cntl_string .= "\x7FString"; + + # This is layers munge, use L3 test case + is(SNMP::Info::munge_null($cntl_string), + 'TestThisCrazyCntlString', 'Null and control characters removed'); +} + +sub munge_e_type : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'munge_e_type'); + + # This is just calling SNMP::translateOb, so rather than loading another MIB + # let's just resolve an OID we don't use from a loaded MIB. + is(SNMP::Info::munge_e_type('.1.3.6.1.2.1.11.4'), + 'snmpInBadCommunityNames', 'OID translated properly'); + + # Bogus OID + is(SNMP::Info::munge_e_type('.100.3.6.1.2.1.11.4'), + '.100.3.6.1.2.1.11.4', 'OID returned when unable to translate'); +} + +sub init : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'init'); + + # When the test info object was created init() was called so all of the + # entries in %MIBS should be loaded + subtest 'Base MIBs loaded subtest' => sub { + + my $base_mibs = $test->{info}->mibs(); + + foreach my $key (keys %$base_mibs) { + my $qual_name = "$key" . '::' . "$base_mibs->{$key}"; + ok(defined $SNMP::MIB{$base_mibs->{$key}}, "$qual_name defined"); + like(SNMP::translateObj($qual_name), + qr/^(\.\d+)+$/, "$qual_name translates to a OID"); + } + }; + + # Get SNMP::Version so we can restore + my $netsnmp_ver = $SNMP::VERSION; + local $SNMP::VERSION = '5.0.1'; + + warnings_like { $test->{info}->init() } + [{carped => qr/Net-SNMP\s5.0.1\sseems\sto\sbe\srather\sbuggy/x}], + 'Use of bad Net-SNMP gives warning'; + + $SNMP::VERSION = $netsnmp_ver; +} + +sub args : Tests(2) { + my $test = shift; + + # Match args passed to new() in My::Test::Class + my $sess = $test->mock_session; + my $args = { + 'AutoSpecify' => 0, + 'BulkWalk' => 0, + 'UseEnums' => 1, + 'RetryNoSuch' => 1, + 'DestHost' => '127.0.0.1', + 'Community' => 'public', + 'Version' => 2, + 'Session' => $sess, + }; + + can_ok($test->{info}, 'args'); + cmp_deeply($test->{info}->args(), + $args, 'Args returned match those passed to new()'); +} + +# Rename this test to prevent conflicts/recursion within test class +sub class_call : Tests(2) { + my $test = shift; + my $class = $test->class; + + can_ok($test->{info}, 'class'); + is($test->{info}->class(), $class, 'Class method returns object class'); +} + +sub error_throw : Tests(7) { + my $test = shift; + + my $error_str = "Test Error String\n"; + + can_ok($test->{info}, 'error_throw'); + + is($test->{info}->error_throw(), undef, 'No error provided returns undef'); + is($test->{info}->error(), undef, '... and no error()'); + is($test->{info}->error_throw($error_str), + undef, 'Error provided returns undef'); + + # Since we don't call with no_clear flag the error is cleared + is( + $test->{info}->error(), + "Test Error String\n", + '... and error() returns error string of call' + ); + + # Turn on debug to check carp of error + $test->{info}->debug(1); + warning_is { $test->{info}->error_throw($error_str) } + [{carped => 'Test Error String'}], 'Error carped when debug turned on'; + $test->{info}->debug(0); + is( + $test->{info}->error(), + "Test Error String\n", + '... and error() returns error string of call' + ); +} + +sub nosuch : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'nosuch'); + is($test->{info}->nosuch(), 1, 'RetryNoSuch on by default'); +} + +sub session : Tests(4) { + my $test = shift; + my $sess = $test->mock_session; + + can_ok($test->{info}, 'session'); + cmp_deeply($test->{info}->session(), $sess, 'Session returned'); + + # This will not be a mocked_session so object type and session will be + # different + my $new_sess = SNMP::Session->new( + DestHost => '127.0.0.1', + Community => 'new_public', + Version => 2, + ); + cmp_deeply($test->{info}->session($new_sess), + $new_sess, 'New session returned'); + isa_ok($test->{info}->session(), 'SNMP::Session', 'New session object'); +} + + +sub store : Tests(4) { + my $test = shift; + + # The store method itself doesn't enforce the naming, so we'll test + # with some totally made up data for 2nd attribute + my $store_data = { + 'i_description' => + {10 => 'Test-Description-10', 20 => 'Test-Description-20'}, + 'test_attribute' => {Key1 => 'Value 1', Key2 => 'Value 2'} + }; + + can_ok($test->{info}, 'store'); + + cmp_deeply($test->{info}->store(), {}, 'Store starts empty'); + ok($test->{info}->store($store_data), 'Insert test data into store'); + cmp_deeply( + $store_data, + $test->{info}->store(), + 'Store method returns test data' + ); +} + +sub private_global : Tests(14) { + my $test = shift; + + can_ok($test->{info}, '_global'); + + # This private method and dynamic creation of global methods is covered in + # can() tests. Use these tests to exercise code path for the load_, orig_, + # _raw, as well as, 'NOSUCHOBJECT' and 'NOSUCHINSTANCE' returns so the method + # calls will be indirect. + + # Some of these are defined in both SNMPv2-MIB and RFC1213-MIB so use + # OIDs to to make sure no issues with which one was loaded during tests + # Data for load_ + my $data = { + + # SNMPv2-MIB::sysContact OID = .1.3.6.1.2.1.1.4 + '.1.3.6.1.2.1.1.4' => {0 => 'NOSUCHOBJECT'}, + + # SNMPv2-MIB::sysName OID = .1.3.6.1.2.1.1.5 + '.1.3.6.1.2.1.1.5' => {0 => 'NOSUCHINSTANCE'}, + + # We'll use this to check _raw + # SNMPv2-MIB::sysServices OID = .1.3.6.1.2.1.1.7 + '.1.3.6.1.2.1.1.7' => {0 => 64}, + + # This is a leaf that we don't reference in %GLOBALS + # SNMPv2-MIB::snmpOutTraps OID = .1.3.6.1.2.1.11.29 + '.1.3.6.1.2.1.11.29' => {0 => 245}, + }; + + # Lets load cache with data to for initial tests + my $cache_data = {'_layers' => 4, '_name' => 'CacheTestName',}; + + # Cache expected after running tests + my $expected_cache = { + '_layers' => 64, + '_snmpOutTraps' => 245, + '_contact' => undef, + '_name' => undef, + 'store' => {}, + }; + + # Load the data for use in the mock session + $test->{info}{sess}{Data} = $data; + + # Load the cache + $test->{info}->cache($cache_data); + + is($test->{info}->name(), 'CacheTestName', + 'Call to name() loads cached data'); + is($test->{info}->layers(), + '00000100', 'Call to layers() loads cached data and munges'); + is($test->{info}->layers_raw(), + 4, 'Call to layers_raw() loads cached data without munge'); + is($test->{info}->load_layers(), + '01000000', 'Call to load_layers loads new data and munges'); + is($test->{info}->layers_raw(), + 64, 'Call to layers_raw() loads new data without munge'); + is($test->{info}->snmpOutTraps(), + 245, 'Call to snmpOutTraps() resolves MIB leaf and returns data'); + + is($test->{info}->load_contact(), + undef, 'Call to load_contact() returns undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_global(load_contact) NOSUCHOBJECT', + '... and throws error indicating NOSUCHOBJECT' + ); + is($test->{info}->load_name(), undef, 'Call to load_name() returns undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_global(load_name) NOSUCHINSTANCE', + '... and throws error indicating NOSUCHINSTANCE' + ); + cmp_deeply($test->{info}->cache(), + $expected_cache, 'Cache contains expected data'); + + # Simulate session error, i.e. get fails + $test->{info}{sess}{ErrorStr} = 'Get Failed'; + + # We need to force load to make it to error + is($test->{info}->load_name(), undef, 'Upon session error returned undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_global(load_name) Get Failed', + '... and error was thrown' + ); + + # Clear error or will impact future tests + $test->{info}{sess}{ErrorStr} = undef; +} + +sub private_set : Tests(12) { + my $test = shift; + + can_ok($test->{info}, '_set'); + + # Load cache with data so we can check that _set clears + my $cache_data = {'_name' => 'CacheTestName',}; + + $test->{info}->cache($cache_data); + is($test->{info}{_name}, 'CacheTestName', 'Cache has a name'); + + # Simple set + is($test->{info}->_set('name', 'TestName', 0), + 1, 'Valid non-array ref name _set() returned 1'); + is($test->{info}{_name}, undef, '... and now cache is cleared'); + + # 4 element array + my $arg_array = ['name', 'TestName', 0]; + is($test->{info}->_set($arg_array), + 1, 'Valid array reference name _set() returned 1'); + + # Reference to an array of 4 element arrays, also see set_multi + my $arg_aoa = [['name', 'TestName', 0]]; + is($test->{info}->_set($arg_aoa), + 1, 'Valid array of arrays reference name _set() returned 1'); + + # Bogus args + my $bogus_args = {'name' => 'TestName'}; + is($test->{info}->_set($bogus_args), undef, 'Invalid args returned undef'); + like( + $test->{info}->error(), + qr/SNMP::Info::_set.+-\sFailed/x, + '... and error was thrown' + ); + + # Bogus attr + is($test->{info}->_set('no_name', 'TestName', 0), + undef, 'Invalid attr returned undef'); + like( + $test->{info}->error(), + qr/SNMP::Info::_set.+-\sFailed\sto\sfind/x, + '... and error was thrown' + ); + + # Simulate session error, i.e. set fails + $test->{info}{sess}{ErrorStr} = 'Set Failed'; + is($test->{info}->_set('name', 'TestName', 0), + undef, 'Upon session error returned undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_set Set Failed', + '... and error was thrown' + ); + + # Clear error or will impact future tests + $test->{info}{sess}{ErrorStr} = undef; +} + +sub private_make_setter : Tests(10) { + my $test = shift; + + # This private method is covered in other tests + can_ok($test->{info}, '_make_setter'); + + # This private method and dynamic creation of methods is covered in + # can() tests. Use these tests to exercise code path for non-multi SNMP sets + # so the method calls will be indirect. This will indirectly exercise the + # AUTOLOAD and can methods as well. + + # Load cache with data so we can check that _set clears + my $cache_data = {'_name' => 'CacheTestName',}; + + $test->{info}->cache($cache_data); + is($test->{info}{_name}, 'CacheTestName', 'Cache has a name'); + + # Set on %GLOBALS entry name + is($test->{info}->set_name('TestName'), + 1, 'SNMP set on global name with no iid returned 1'); + is($test->{info}{_name}, undef, '... and now cache is cleared'); + + # Same set on the MIB leaf + is($test->{info}->set_sysName('TestName'), + 1, 'SNMP set on MIB leaf sysName with no iid returned 1'); + + # Can provide IID to global if wanted + is($test->{info}->set_name('TestName', 0), + 1, 'SNMP set on global name with iid returned 1'); + + # Set on a %FUNCS table method + is($test->{info}->set_i_alias('TestPortName', 3), + 1, 'SNMP set on func i_description with iid returned 1'); + + # Same set on the table MIB leaf + is($test->{info}->set_ifAlias('TestPortName', 3), + 1, 'SNMP set on MIB leaf ifAlias with iid returned 1'); + + # Simulate session error, i.e. set fails + $test->{info}{sess}{ErrorStr} = 'Set Failed'; + is($test->{info}->set_i_alias('TestPortName', 3), + undef, 'Upon session error returned undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_set Set Failed', + '... and error was thrown' + ); + + # Clear error or will impact future tests + $test->{info}{sess}{ErrorStr} = undef; +} + +sub set_multi : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'set_multi'); + + # This is contrived and mock set always returns true, so this test case + # could be improved. The multi_set method is meant for use similar to a + # database transaction where all sets must be completed in one atomic operation + my $multi_set = [ + ['i_up_admin', 2, 3], + ['i_description', 'Port Down', 3], + ['ifDescr', 'Test Descr', 4], + ]; + + is($test->{info}->set_multi($multi_set), 1, 'Valid multi_set() returned 1'); + + $multi_set = [ + ['i_up_admin', 2, 3], + ['i_description', 'Port Down', 3], + ['bogus_set', 'What?', 4], + ]; + + is($test->{info}->set_multi($multi_set), + undef, 'Invalid multi_set() returned undef'); + +} + +sub load_all : Tests(6) { + my $test = shift; + + can_ok($test->{info}, 'load_all'); + + # This method uses load_ and will not utilize the cache so we need to define + # data for the mocked session's get/getnext methods + + # Use OIDs to prevent resolution conflicts of fully qualified names between + # RFC1213-MIB and IF-MIB dependant upon which was loaded first via random + # hash ordering. We only need a subset of data to verify the method is + # working, no need to have data for all funcs the method calls. Use a subset + # of the IF-MIB::ifTable and IF-MIB::ifXTable + my $data = { + '.1.3.6.1.2.1.2.2.1.1' => {1 => 1, 2 => 2, 3 => 3,}, + '.1.3.6.1.2.1.2.2.1.2' => { + 1 => 'Loopback', + 2 => '1/3/1, 10/100 Ethernet TX', + 3 => '1/3/2, 10/100 Ethernet TX' + }, + '.1.3.6.1.2.1.2.2.1.3' => {1 => 24, 2 => 6, 3 => 6}, + '.1.3.6.1.2.1.2.2.1.4' => {1 => 1500, 2 => 1514, 3 => 1514}, + '.1.3.6.1.2.1.2.2.1.5' => {1 => 0, 2 => 100000000, 3 => 1000000000,}, + '.1.3.6.1.2.1.31.1.1.1.1' => {1 => 'system', 2 => '1/3/1', 3 => '1/3/2'}, + '.1.3.6.1.2.1.31.1.1.1.15' => {1 => 0, 2 => 100, 3 => 1000,}, + }; + + # Data is stored unmunged, OID's will be resolved and cache entries stored + # under %FUNCS names + my $expected_data = { + 'i_index' => {1 => 1, 2 => 2, 3 => 3,}, + 'i_description' => { + 1 => 'Loopback', + 2 => '1/3/1, 10/100 Ethernet TX', + 3 => '1/3/2, 10/100 Ethernet TX' + }, + 'i_type' => {1 => 24, 2 => 6, 3 => 6}, + 'i_mtu' => {1 => 1500, 2 => 1514, 3 => 1514}, + 'i_speed' => {1 => 0, 2 => 100000000, 3 => 1000000000,}, + 'i_name' => {1 => 'system', 2 => '1/3/1', 3 => '1/3/2'}, + 'i_speed_high' => {1 => 0, 2 => 100, 3 => 1000,}, + + # In base class defined as ifIndex + 'interfaces' => {1 => 1, 2 => 2, 3 => 3,}, + }; + + # Start with some data in store to verify it is overwritten + my $store_data + = {'i_description' => + {10 => 'Test-Description-10', 20 => 'Test-Description-20'}, + }; + + cmp_deeply($test->{info}->store(), {}, 'Store starts empty'); + ok($test->{info}->store($store_data), 'Insert test data into store'); + cmp_deeply($test->{info}->store(), $store_data, + '... store now has test data'); + + # Load the data for use in the mock session + $test->{info}{sess}{Data} = $data; + + cmp_deeply($test->{info}->load_all(), + $expected_data, 'Call to load_all() returns expected data'); + cmp_deeply($test->{info}->store(), + $expected_data, '... and store now has expected data from load_all()'); +} + +# Need to rename from all to prevent name conflict +sub my_all : Tests(9) { + my $test = shift; + + can_ok($test->{info}, 'all'); + + # Use OIDs to prevent resolution conflicts of fully qualified names between + # RFC1213-MIB and IF-MIB dependant upon which was loaded first via random + # hash ordering. We only need a bare minimum of data to verify the method is + # working since it relies on load_all() which has its own tests. + my $data = { + '.1.3.6.1.2.1.2.2.1.2' => { + 1 => 'Loopback', + 2 => '1/3/1, 10/100 Ethernet TX', + 3 => '1/3/2, 10/100 Ethernet TX' + }, + }; + + # Data is stored unmunged, OID's will be resolved and cache entries stored + # under %FUNCS names + my $expected_data = { + 'i_description' => { + 1 => 'Loopback', + 2 => '1/3/1, 10/100 Ethernet TX', + 3 => '1/3/2, 10/100 Ethernet TX' + }, + }; + + # Start with some data in store to verify it is overwritten on first call + # and whatever is in store() is returned on subsequent calls to all + my $store_data + = {'i_description' => + {10 => 'Test-Description-10', 20 => 'Test-Description-20'}, + }; + + cmp_deeply($test->{info}->store(), {}, 'Store starts empty'); + ok($test->{info}->store($store_data), 'Insert test data into store'); + cmp_deeply($test->{info}->store(), $store_data, + '... store now has test data'); + + # Load the data for use in the mock session + $test->{info}{sess}{Data} = $data; + + cmp_deeply($test->{info}->all(), + $expected_data, 'Call to all() returns expected data'); + cmp_deeply($test->{info}->store(), + $expected_data, '... and store now has expected data from all()'); + + ok($test->{info}->store($store_data), 'Re-insert test data into store'); + cmp_deeply($test->{info}->store(), + $store_data, '... store again has test data'); + + cmp_deeply($test->{info}->all(), + $expected_data, + '... call to all() returns test data, no call to load_all()'); +} + +sub private_load_attr : Tests(16) { + my $test = shift; + + can_ok($test->{info}, '_load_attr'); + + # This private method and dynamic creation of table aka func methods is + # covered in can() tests. Use these tests to exercise code path for + # the load_, orig_, _raw, as well as, 'NOSUCHOBJECT', 'NOSUCHINSTANCE', + # and 'ENDOFMIBVIEW' returns so the method calls will be indirect. + + # Currently mocked session in test harness doesn't support bulkwalk, so + # that code path is not tested + + # Some of these are defined in both SNMPv2-MIB and RFC1213-MIB so use + # OIDs to to make sure no issues with which one was loaded during tests + # Data for load_ + my $data = { + '.1.3.6.1.2.1.2.2.1.2' => { + 1 => 'Loopback', + 2 => '1/3/1, 10/100 Ethernet TX', + 3 => '1/3/2, 10/100 Ethernet TX' + }, + '.1.3.6.1.2.1.2.2.1.8' => {1 => 4, 2 => 'up', 3 => 7}, + 'IF-MIB::ifPromiscuousMode' => {1 => 'false', 2 => 'true', 3 => 'false'}, + 'IF-MIB::ifConnectorPresent' => {0 => 'NOSUCHOBJECT'}, + 'IF-MIB::ifCounterDiscontinuityTime' => {0 => 'NOSUCHINSTANCE'}, + 'IF-MIB::ifHCOutOctets' => + {1 => 0, 2 => 1828306359704, 3 => 1002545943585, 4 => 'ENDOFMIBVIEW'}, + }; + + # Load cache with data to for initial tests + my $cache_data = { + '_i_description' => 1, + '_i_up' => 1, + 'store' => { + 'i_description' => + {10 => 'Test-Description-10', 20 => 'Test-Description-20'}, + 'i_up' => {10 => 6, 20 => 7} + } + }; + + # Cache expected after running tests + # Note: i_up starts in cache and call to load_i_up for new data increments + # the cache counter + # Note: We don't call load_i_description so the data from cache never gets + # replaced + # Note: munge_i_up only munges integers 4-7 as 1-3 are already enumerated + my $expected_cache = { + '_i_description' => 1, + '_i_up' => 2, + '_ifPromiscuousMode' => 1, + '_ifConnectorPresent' => undef, + '_ifCounterDiscontinuityTime' => undef, + '_i_octet_out64' => 1, + 'store' => { + 'i_description' => + {10 => 'Test-Description-10', 20 => 'Test-Description-20'}, + 'i_up' => {1 => 4, 2 => 'up', 3 => 7}, + 'ifPromiscuousMode' => {1 => 'false', 2 => 'true', 3 => 'false'}, + 'i_octet_out64' => {1 => 0, 2 => 1828306359704, 3 => 1002545943585} + } + }; + + my $expected_cache_munge_iup = {10 => 'notPresent', 20 => 'lowerLayerDown'}; + my $expected_load_munge_iup + = {1 => 'unknown', 2 => 'up', 3 => 'lowerLayerDown'}; + + my $expected_load_raw_iftype = {1 => 24, 2 => 6, 3 => 6}; + + # Load the data for use in the mock session + $test->{info}{sess}{Data} = $data; + + # Load the cache + $test->{info}->cache($cache_data); + + cmp_deeply( + $test->{info}->i_description(), + $cache_data->{'store'}{'i_description'}, + 'Call to i_description() loads cached data' + ); + cmp_deeply($test->{info}->i_up(), + $expected_cache_munge_iup, 'Call to i_up() loads cached data and munges'); + cmp_deeply( + $test->{info}->i_up_raw(), + $cache_data->{'store'}{'i_up'}, + 'Call to i_up_raw() loads cached data without munge' + ); + cmp_deeply($test->{info}->load_i_up(), + $expected_load_munge_iup, 'Call to load_i_up() loads new data and munges'); + cmp_deeply( + $test->{info}->i_up_raw(), + $expected_cache->{'store'}{'i_up'}, + 'Call to i_up_raw() loads new data without munge' + ); + + # Test ability to use MIB leaf + cmp_deeply( + $test->{info}->ifPromiscuousMode(), + $data->{'IF-MIB::ifPromiscuousMode'}, + 'Call to ifPromiscuousMode() resolves MIB leaf and returns data' + ); + + # Test error conditions + is($test->{info}->load_ifConnectorPresent(), + undef, 'Call to load_ifConnectorPresent() returns undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_load_attr: load_ifConnectorPresent : NOSUCHOBJECT', + '... and throws error indicating NOSUCHOBJECT' + ); + is($test->{info}->load_ifCounterDiscontinuityTime(), + undef, 'Call to load_ifCounterDiscontinuityTime() returns undef'); + is( + $test->{info}->error(), + 'SNMP::Info::_load_attr: load_ifCounterDiscontinuityTime : NOSUCHINSTANCE', + '... and throws error indicating NOSUCHINSTANCE' + ); + + # 'ENDOFMIBVIEW' isn't an error condition, it just stops the walk + # Ask for raw since don't want munge_counter64 to turn results into objects + # and want to compare to what will be stored in cache at the end + cmp_deeply( + $test->{info}->i_octet_out64_raw(), + $expected_cache->{'store'}{'i_octet_out64'}, + 'Call to i_up_raw() loads new data without munge' + ); + + # Test partial fetches + cmp_deeply( + $test->{info}->i_octet_out64_raw(3), + +{3 => 1002545943585}, + 'Partial call to i_octet_out64_raw(3) data without munge' + ); + cmp_deeply( + $test->{info}->i_description(2), + +{2 => '1/3/1, 10/100 Ethernet TX'}, + 'Partial call to i_description(2) loads new data' + ); + ok(!exists $test->{info}{store}{i_description}{2}, + '... and does not store it in cache'); + + cmp_deeply($test->{info}->cache(), + $expected_cache, 'Cache contains expected data'); +} + +sub private_show_attr : Tests(3) { + my $test = shift; + + can_ok($test->{info}, '_show_attr'); + + # Load cache with data + my $cache_data = {'_i_up' => 1, 'store' => {'i_up' => {10 => 6, 20 => 7}}}; + + # Load the cache + $test->{info}->cache($cache_data); + + my $expected_munge = {10 => 'notPresent', 20 => 'lowerLayerDown'}; + + # Minimal tests as this method is heavily covered in other testing + cmp_deeply($test->{info}->_show_attr('i_up'), + $expected_munge, 'Shows munged data from cache without raw flag'); + cmp_deeply( + $test->{info}->_show_attr('i_up', 1), + $cache_data->{'store'}{'i_up'}, + 'Shows unmunged data from cache with raw flag' + ); +} + +sub snmp_connect_ip : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'snmp_connect_ip'); + + is($test->{info}->snmp_connect_ip('127.0.0.1', 2, 'public'), + undef, 'Connect to loopback returns undef'); + is($test->{info}->snmp_connect_ip('0.0.0.0', 2, 'public'), + undef, 'Connect to zeros returns undef'); + + is($test->{info}->snmp_connect_ip('demo.snmplabs.com', 2, 'public'), + 1, 'Connect to demo.snmplabs.com returns 1'); +} + +sub modify_port_list : Tests(4) { + my $test = shift; + + can_ok($test->{info}, 'modify_port_list'); + + # Let munge_port_list do the work of converting this into the portlist array + my $orig_plist = SNMP::Info::munge_port_list(pack("B*", '01010101')); + my $new_plist_1 = pack("B*", '01110101'); + my $new_plist_0 = pack("B*", '01110001'); + my $expanded_plist = pack("B*", '0111000100000001'); + + # This call will actually modify $orig_plist + is($test->{info}->modify_port_list($orig_plist, 2, 1), + $new_plist_1, 'Bit in offset position 2 changed to on'); + + # Here we start with modified $orig_plist, now '01110101' + is($test->{info}->modify_port_list($orig_plist, 5, 0), + $new_plist_0, 'Bit in offset position 5 changed to off'); + + # Modified $orig_plist, now '01110001' + is($test->{info}->modify_port_list($orig_plist, 15, 1), + $expanded_plist, + 'Bit in offset position 15 changed to on and portlist array expanded'); +} + +sub private_cache : Tests(1) { + my $test = shift; + + # This method is covered in private_global and private_load_attr + # tests so just cover with can() here + can_ok($test->{info}, '_cache'); +} + +sub private_munge : Tests(1) { + my $test = shift; + + # This method is covered in private_global and private_load_attr + # tests so just cover with can() here + can_ok($test->{info}, '_munge'); +} + +sub private_validate_autoload_method : Tests(8) { + my $test = shift; + + can_ok($test->{info}, '_validate_autoload_method'); + + subtest '%GLOBALS _validate_autoload_method() subtest' => sub { + + foreach my $prefix ('', 'load_', 'orig_') { + my $test_global = "$prefix" . 'contact'; + cmp_deeply( + $test->{info}->_validate_autoload_method("$test_global"), + ['.1.3.6.1.2.1.1.4.0', 0], + qq(Global '$test_global' validates) + ); + } + cmp_deeply( + $test->{info}->_validate_autoload_method('set_contact'), + ['.1.3.6.1.2.1.1.4', 0], + q(Global 'set_contact' validates) + ); + cmp_deeply( + $test->{info}->_validate_autoload_method('contact_raw'), + ['.1.3.6.1.2.1.1.4.0', 0], + q(Global 'contact_raw' validates) + ); + }; + + # Use a leaf we don't have defined in %GLOBALS that is read/write to pass + # all tests, we'll test access separately + subtest 'Single instance MIB leaf _validate_autoload_method() subtest' => + sub { + + foreach my $prefix ('', 'load_', 'orig_') { + my $test_global = "$prefix" . 'snmpEnableAuthenTraps'; + cmp_deeply( + $test->{info}->_validate_autoload_method("$test_global"), + ['.1.3.6.1.2.1.11.30.0', 0], + qq(MIB leaf '$test_global' validates) + ); + } + cmp_deeply( + $test->{info}->_validate_autoload_method('set_snmpEnableAuthenTraps'), + ['.1.3.6.1.2.1.11.30', 0], + q(MIB leaf 'set_snmpEnableAuthenTraps' validates) + ); + cmp_deeply( + $test->{info}->_validate_autoload_method('snmpEnableAuthenTraps_raw'), + ['.1.3.6.1.2.1.11.30.0', 0], + q(MIB leaf 'snmpEnableAuthenTraps_raw' validates) + ); + }; + + subtest '%FUNCS _validate_autoload_method() subtest' => sub { + + foreach my $prefix ('', 'load_', 'orig_') { + my $test_global = "$prefix" . 'i_alias'; + cmp_deeply( + $test->{info}->_validate_autoload_method("$test_global"), + ['.1.3.6.1.2.1.31.1.1.1.18', 1], + qq(Func '$test_global' validates) + ); + } + cmp_deeply( + $test->{info}->_validate_autoload_method('set_i_alias'), + ['.1.3.6.1.2.1.31.1.1.1.18', 1], + q(Func 'set_i_alias' validates) + ); + cmp_deeply( + $test->{info}->_validate_autoload_method('i_alias_raw'), + ['.1.3.6.1.2.1.31.1.1.1.18', 1], + q(Func 'i_alias_raw' validates) + ); + }; + + # Use a leaf we don't have defined in %FUNCS that is read/write to pass + # all tests, we'll test access separately + subtest 'Table MIB leaf _validate_autoload_method() subtest' => sub { + + foreach my $prefix ('', 'load_', 'orig_') { + my $test_global = "$prefix" . 'ifPromiscuousMode'; + cmp_deeply( + $test->{info}->_validate_autoload_method("$test_global"), + ['.1.3.6.1.2.1.31.1.1.1.16', 1], + qq(Func '$test_global' validates) + ); + } + cmp_deeply( + $test->{info}->_validate_autoload_method('set_ifPromiscuousMode'), + ['.1.3.6.1.2.1.31.1.1.1.16', 1], + q(Func 'set_ifPromiscuousMode' validates) + ); + cmp_deeply( + $test->{info}->_validate_autoload_method('ifPromiscuousMode_raw'), + ['.1.3.6.1.2.1.31.1.1.1.16', 1], + q(Func 'ifPromiscuousMode_raw' validates) + ); + }; +TODO: { + local $TODO + = "Check MIB access for non set methods in _validate_autoload_method" + if 1; + + # Test that not-accessible leaf returns undef IF-MIB::ifStackHigherLayer + is($test->{info}->_validate_autoload_method('ifStackHigherLayer'), + undef, q(MIB leaf 'ifStackHigherLayer' not-accessible, returns undef)); + } + + # Test that read-only leaf won't validate set_ + is($test->{info}->_validate_autoload_method('set_i_lastchange'), + undef, + q(Func 'i_lastchange' is read-only, 'set_i_lastchange' returns undef)); + + # Check fully qualified MIB leaf w substitutions validates + cmp_deeply( + $test->{info}->_validate_autoload_method('IF_MIB__ifConnectorPresent'), + ['.1.3.6.1.2.1.31.1.1.1.17', 1], + q(Fully qualified 'IF_MIB__ifConnectorPresent' validates) + ); +} + +# Prefix with private as we don't want to accidentally override in test class +sub private_can : Tests(9) { + my $test = shift; + + # This method is heavily covered across tests, just verify here that + # a successful call places the method in the symbol table + + # See perldoc Symbol, specifically Symbol::delete_package. We can't assume + # symbols are deleted with the object between tests. Since we can() all + # globals and funcs during tests use MIB leafs to test table and scalar + # methods. The symbol_test() method is defined in My::Test::Class + # Note: if these tests start to fail make sure we aren't using the leaf + # in other tests + + # This leaf tests the global path SNMPv2-MIB::snmpInBadCommunityNames + is($test->symbol_test('snmpInBadCommunityNames'), + 0, q(Method 'snmpInBadCommunityNames' is not defined in the symbol table)); + can_ok($test->{info}, 'snmpInBadCommunityNames'); + is($test->symbol_test('snmpInBadCommunityNames'), + 1, q(Method 'snmpInBadCommunityNames' is now defined in the symbol table)); + + # This leaf tests the table path IF-MIB::ifCounterDiscontinuityTime + is($test->symbol_test('ifCounterDiscontinuityTime'), + 0, + q(Method 'ifCounterDiscontinuityTime' is not defined in the symbol table)); + can_ok($test->{info}, 'ifCounterDiscontinuityTime'); + is($test->symbol_test('ifCounterDiscontinuityTime'), + 1, + q(Method 'ifCounterDiscontinuityTime' is now defined in the symbol table)); + + # This leaf tests the set_ path SNMPv2-MIB::snmpSetSerialNo + is($test->symbol_test('set_snmpSetSerialNo'), + 0, q(Method 'set_snmpSetSerialNo' is not defined in the symbol table)); + can_ok($test->{info}, 'set_snmpSetSerialNo'); + is($test->symbol_test('set_snmpSetSerialNo'), + 1, q(Method 'set_snmpSetSerialNo' is now defined in the symbol table)); +} + +# Prefix with private as we don't want to accidentally override in test class +sub private_autoload : Tests(3) { + my $test = shift; + + # This method is covered in other tests, just verify here that + # a successful call places the method in the symbol table. Since can() does + # the majority of the work call a method without calling can() first. Same + # as noted in the private_can test we need to use a leaf not used elsewhere + # (IP-MIB::ipDefaultTTL) to make sure method isn't in the symbol table first. + # AUTOLOAD calls the method after inserted in the symbol table, so we + # populate cache to return some data + + # Load the cache + my $cache_data = {'_ipDefaultTTL' => 64}; + $test->{info}->cache($cache_data); + + is($test->symbol_test('ipDefaultTTL'), + 0, q(Method 'ipDefaultTTL' is not defined in the symbol table)); + is($test->{info}->ipDefaultTTL(), + 64, q(Method 'ipDefaultTTL' called and returned expected data')); + is($test->symbol_test('ipDefaultTTL'), + 1, q(Method 'ipDefaultTTL' is now defined in the symbol table)); +} + +# Prefix with private as we don't want to accidentally override in test class +sub private_destroy : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'DESTROY'); + is($test->{info}->DESTROY(), undef, 'DESTROY returns undef'); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/AdslLine.pm b/xt/lib/Test/SNMP/Info/AdslLine.pm new file mode 100644 index 00000000..4718b75e --- /dev/null +++ b/xt/lib/Test/SNMP/Info/AdslLine.pm @@ -0,0 +1,36 @@ +# Test::SNMP::Info::AdslLine +# +# Copyright (c) 2018 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 COPYRSNMP::Info::AdslLineIGHT 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 Test::SNMP::Info::AdslLine; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::AdslLine; + +1; diff --git a/xt/lib/Test/SNMP/Info/Aggregate.pm b/xt/lib/Test/SNMP/Info/Aggregate.pm new file mode 100644 index 00000000..74928d7d --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Aggregate.pm @@ -0,0 +1,86 @@ +# Test::SNMP::Info::Aggregate +# +# Copyright (c) 2018 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 COPYRSNMP::Info::AdslLineIGHT 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 Test::SNMP::Info::Aggregate; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Aggregate; + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + # ieee8023adLag example from Cisco 65xx VSS snmpwalk + my $cache_data = { + '_ifStackStatus' => 1, + '_ifType' => 1, + 'store' => { + 'ifStackStatus' => { + '0.1' => 'active', + '1.0' => 'active', + '10.0' => 'active', + '20.0' => 'active', + '80.0' => 'active', + '90.0' => 'active', + '0.163' => 'active', + '163.10' => 'active', + '163.90' => 'active', + '0.8193' => 'active', + '8193.20' => 'active', + '8193.80' => 'active', + }, + 'ifType' => { + '1' => 'ethernetCsmacd', + '10' => 'ethernetCsmacd', + '20' => 'ethernetCsmacd', + '80' => 'ethernetCsmacd', + '90' => 'ethernetCsmacd', + '163' => 'ieee8023adLag', + '8193' => 'propMultiplexor', + }, + } + }; + $test->{info}->cache($cache_data); +} + +sub agg_ports_ifstack : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'agg_ports_ifstack'); + + my $expected + = {'10' => '163', '90' => '163', '20' => '8193', '80' => '8193',}; + + cmp_deeply($test->{info}->agg_ports_ifstack(), + $expected, q(Aggregated links have expected values)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Airespace.pm b/xt/lib/Test/SNMP/Info/Airespace.pm new file mode 100644 index 00000000..42002bbd --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Airespace.pm @@ -0,0 +1,226 @@ +# Test::SNMP::Info::Airespace +# +# Copyright (c) 2018 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 COPYRSNMP::Info::AdslLineIGHT 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 Test::SNMP::Info::Airespace; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Airespace; + +# Remove this startup override once we have full method coverage +sub startup : Tests(startup => 1) { + my $test = shift; + $test->SUPER::startup(); + + $test->todo_methods(1); +} + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup(); + + # Start with a common cache that will serve most tests + # ieee8023adLag example from Cisco 65xx VSS snmpwalk + my $cache_data = { + '_airespace_serial' => 'ABC1234567D', + '_i_index' => 1, + '_i_name' => 1, + '_i_description' => 1, + '_i_type' => 1, + '_i_up' => 1, + '_airespace_apif_slot' => 1, + '_airespace_if_name' => 1, + '_airespace_ap_name' => 1, + '_airespace_ap_loc' => 1, + '_airespace_apif_type' => 1, + '_airespace_if_type' => 1, + '_airespace_apif' => 1, + '_airespace_apif_admin' => 1, + 'store' => { + 'i_index' => {'1' => 1,}, + 'i_name' => {'1' => 'Unit - 0 Slot - 1 Port - 1',}, + 'i_description' => + {'1' => 'Unit: 0 Slot: 1 Port: 1 Gigabit - Level 0x50a0001',}, + 'i_type' => {'1' => 'ethernetCsmacd',}, + 'i_up' => {'1' => 'up',}, + 'airespace_apif_slot' => + {'0.11.133.20.89.48.0' => 0, '0.11.133.20.89.48.1' => 1,}, + 'airespace_if_name' => { + '10.109.97.110.97.103.101.109.101.110.116' => 'management', + '9.115.116.118.45.100.104.99.112.97' => 'ssid-int', + }, + 'airespace_ap_name' => {'0.11.133.20.89.48' => 'My AP Name',}, + 'airespace_ap_loc' => {'0.11.133.20.89.48' => 'My AP location',}, + 'airespace_apif_type' => + {'0.11.133.20.89.48.0' => 'dot11a', '0.11.133.20.89.48.1' => 'dot11b',}, + 'airespace_if_type' => { + '10.109.97.110.97.103.101.109.101.110.116' => 'static', + '9.115.116.118.45.100.104.99.112.97' => 'dynamic', + }, + 'airespace_apif' => + {'0.11.133.20.89.48.0' => 'up', '0.11.133.20.89.48.1' => 'down',}, + 'airespace_apif_admin' => { + '0.11.133.20.89.48.0' => 'enable', + '0.11.133.20.89.48.1' => 'disable', + }, + } + }; + $test->{info}->cache($cache_data); +} + +sub layers : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'layers'); + is($test->{info}->layers(), '00000111', q(Layers returns '00000111')); +} + +sub serial : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'serial'); + is($test->{info}->serial(), 'ABC1234567D', q(Serial returns expected value)); +} + +sub i_index : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_index'); + + my $expected = { + '1' => 1, + '0.11.133.20.89.48.0' => '00:0b:85:14:59:30.0', + '0.11.133.20.89.48.1' => '00:0b:85:14:59:30.1', + '10.109.97.110.97.103.101.109.101.110.116' => 'management', + '9.115.116.118.45.100.104.99.112.97' => 'ssid-int', + }; + + cmp_deeply($test->{info}->i_index(), + $expected, q(Interface indices have expected values)); +} + +sub interfaces : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'interfaces'); + + my $expected = { + '1' => '1.1', + '0.11.133.20.89.48.0' => '00:0b:85:14:59:30.0', + '0.11.133.20.89.48.1' => '00:0b:85:14:59:30.1', + '10.109.97.110.97.103.101.109.101.110.116' => 'management', + '9.115.116.118.45.100.104.99.112.97' => 'ssid-int', + }; + + cmp_deeply($test->{info}->interfaces(), + $expected, q(Interfaces have expected values)); +} + +sub i_name : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_name'); + + my $expected = { + '1' => 'Unit - 0 Slot - 1 Port - 1', + '0.11.133.20.89.48.0' => 'My AP Name', + '0.11.133.20.89.48.1' => 'My AP Name', + '10.109.97.110.97.103.101.109.101.110.116' => 'management', + '9.115.116.118.45.100.104.99.112.97' => 'ssid-int', + }; + + cmp_deeply($test->{info}->i_name(), + $expected, q(Interface names have expected values)); +} + +sub i_description : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_description'); + + my $expected = { + '1' => 'Unit: 0 Slot: 1 Port: 1 Gigabit - Level 0x50a0001', + '0.11.133.20.89.48.0' => 'My AP location', + '0.11.133.20.89.48.1' => 'My AP location', + '10.109.97.110.97.103.101.109.101.110.116' => 'management', + '9.115.116.118.45.100.104.99.112.97' => 'ssid-int', + }; + + cmp_deeply($test->{info}->i_description(), + $expected, q(Interface descriptions have expected values)); +} + +sub i_type : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_type'); + + my $expected = { + '1' => 'ethernetCsmacd', + '0.11.133.20.89.48.0' => 'dot11a', + '0.11.133.20.89.48.1' => 'dot11b', + '10.109.97.110.97.103.101.109.101.110.116' => 'static', + '9.115.116.118.45.100.104.99.112.97' => 'dynamic', + }; + + cmp_deeply($test->{info}->i_type(), + $expected, q(Interface types have expected values)); +} + +sub i_up : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_up'); + + my $expected = { + '1' => 'up', + '0.11.133.20.89.48.0' => 'up', + '0.11.133.20.89.48.1' => 'down', + }; + + cmp_deeply($test->{info}->i_up(), + $expected, q(Interface types have expected values)); +} + +sub i_up_admin : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_up_admin'); + + my $expected = { + '1' => 'up', + '0.11.133.20.89.48.0' => 'enable', + '0.11.133.20.89.48.1' => 'disable', + }; + + cmp_deeply($test->{info}->i_up_admin(), + $expected, q(Interface types have expected values)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer1/Allied.pm b/xt/lib/Test/SNMP/Info/Layer1/Allied.pm new file mode 100644 index 00000000..7b82cde0 --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer1/Allied.pm @@ -0,0 +1,121 @@ +# Test::SNMP::Info::Layer1::Allied +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer1::Allied; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer1::Allied; + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 1, + '_description' => 'My Allied hub AT-1234T version 3.10', + '_id' => '.1.3.6.1.4.1.207.1.2.1', + '_i_name' => 1, + '_i_up' => 1, + '_ati_p_name' => 1, + '_ati_up' => 1, + '_rptr_up' => 1, + 'store' => { + 'i_name' => {'1' => '1 Port Name'}, + 'i_up' => {'1' => 'up'}, + 'ati_p_name' => {'1.1' => "", '1.2' => '1.2 Port Name', '1.3' => ""}, + 'ati_up' => {'1.2' => 'nolinktesterror', '1.3' => 'linktesterror'}, + 'rptr_up' => { + '1.1' => 'operational', + '1.2' => 'operational', + '1.3' => 'operational' + }, + } + }; + $test->{info}->cache($cache_data); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'allied', q(Vendor returns 'allied')); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'allied', q(Vendor returns 'allied')); +} + +sub os_ver : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'os_ver'); + is($test->{info}->os_ver(), '3.10', q(OS version is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->os_ver(), undef, q(No description returns undef os_ver)); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), 'AT-1234T', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No description returns undef model)); +} + +sub i_name : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_name'); + + my $expected = {'1' => '1 Port Name', '1.2' => '1.2 Port Name',}; + + cmp_deeply($test->{info}->i_name(), + $expected, q(Interface names have expected values)); +} + +sub i_up : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_up'); + + my $expected = {'1' => 'up', '1.1' => 'up', '1.2' => 'up', '1.3' => 'down'}; + + cmp_deeply($test->{info}->i_up(), + $expected, q(Interface operational statuses have expected values)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer1/Asante.pm b/xt/lib/Test/SNMP/Info/Layer1/Asante.pm new file mode 100644 index 00000000..8e1a05f0 --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer1/Asante.pm @@ -0,0 +1,177 @@ +# Test::SNMP::Info::Layer1::Asante +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer1::Asante; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer1::Asante; + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + my $phy_addr = pack("H*", '0000944037B3'); + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 1, + '_description' => + 'AsanteHub 1012 with SNMP agent and TELNET software v3.0.Compiled ', + '_id' => '.1.3.6.1.4.1.298.2.2.1', + '_rptr_port' => 1, + '_asante_up' => 1, + '_i_speed' => 1, + '_i_mac' => 1, + '_i_description' => 1, + 'store' => { + 'rptr_port' => {'1.1' => '1', '1.2' => '2', '2.1' => '1', '2.2' => '2'}, + 'asante_up' => { + '1.1' => 'others', + '1.2' => 'linkoff', + '2.1' => 'linkon', + '2.2' => 'linkon' + }, + 'i_speed' => {'1' => 10000000}, + 'i_mac' => {'1' => $phy_addr}, + 'i_description' => {'1' => 'AsanteHub 1012 SNMP port'}, + } + }; + $test->{info}->cache($cache_data); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'asante', q(Vendor returns 'asante')); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'asante', q(Vendor returns 'asante')); +} + + +sub os_ver : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'os_ver'); + is($test->{info}->os_ver(), '3.0', q(OS version is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->os_ver(), undef, q(No description returns undef os_ver)); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), 'hub1012', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No id returns undef model)); +} + +sub interfaces : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'interfaces'); + my $expected + = {'1.1' => '1.1', '1.2' => '1.2', '2.1' => '2.1', '2.2' => '2.2'}; + + cmp_deeply($test->{info}->interfaces(), + $expected, q(Interface indices have expected values)); + + $test->{info}->clear_cache(); + cmp_deeply($test->{info}->interfaces(), + {}, q(Empty SNMP table results in empty hash)); +} + +sub i_up : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'i_up'); + my $expected = {'1.2' => 'down', '2.1' => 'up', '2.2' => 'up'}; + + cmp_deeply($test->{info}->i_up(), + $expected, q(Interface operational statuses have expected values)); + + $test->{info}->clear_cache(); + cmp_deeply($test->{info}->i_up(), + {}, q(Empty SNMP table results in empty hash)); +} + +sub i_speed : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_speed'); + + # Munge in effect + my $expected = {'1.2' => '10 Mbps'}; + + cmp_deeply($test->{info}->i_speed(), + $expected, q(Interface speeds have expected values)); +} + +sub i_mac : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_mac'); + + # Munge in effect + my $expected = {'1.2' => '00:00:94:40:37:b3'}; + + cmp_deeply($test->{info}->i_mac(), + $expected, q(Interface speeds have expected values)); +} + +sub i_description : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_description'); + + is($test->{info}->i_description(), undef, q(Interfaces have no descriptions)); +} + +sub i_name : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'i_name'); + + # Munge in effect + my $expected = {'1.2' => 'AsanteHub 1012 SNMP port'}; + + cmp_deeply($test->{info}->i_name(), + $expected, q(Interface names have expected values)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer1/Bayhub.pm b/xt/lib/Test/SNMP/Info/Layer1/Bayhub.pm new file mode 100644 index 00000000..fda80fce --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer1/Bayhub.pm @@ -0,0 +1,90 @@ +# Test::SNMP::Info::Layer1::Bayhub +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer1::Bayhub; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer1::Bayhub; + +# Remove this startup override once we have full method coverage +sub startup : Tests(startup => 1) { + my $test = shift; + $test->SUPER::startup(); + + $test->todo_methods(1); +} + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 1, + '_description' => + 'Bay Stack 250 Dual Speed Stackable Hub SNMP/Telnet Agent v3.2.1', + '_id' => '.1.3.6.1.4.1.45.3.34.1', + 'store' => {}, + }; + $test->{info}->cache($cache_data); +} + +sub layers : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'layers'); + is($test->{info}->layers(), '00000011', q(Layers returns '00000011')); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'bay_hub', q(Vendor returns 'bay_hub')); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'avaya', q(Vendor returns 'avaya')); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), 'Baystack Hub', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No id returns undef model)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer1/Cyclades.pm b/xt/lib/Test/SNMP/Info/Layer1/Cyclades.pm new file mode 100644 index 00000000..69d0b98f --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer1/Cyclades.pm @@ -0,0 +1,617 @@ +# Test::SNMP::Info::Layer1::Cyclades +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer1::Cyclades; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer1::Cyclades; + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + my $phy_addr = pack( "H*", '0000944037B3' ); + + # Start with a common cache that will serve most tests + # Just define all alternatives to start with and alternatives in sequence to + # test short circuits, we can verify conditional coverage with Devel::Cover + my $cache_data = { + '_layers' => 1, + '_description' => 'My Bogus ACS6008 Description', + + # ACS-MIB::acs6008 + '_id' => '.1.3.6.1.4.1.10418.16.1.5', + + '_acs_os_ver' => '6.00', + '_acs8k_os_ver' => '8.00', + '_cy5k_os_ver' => '2.02', + '_cy_os_ver' => '3.00', + '_acs_model' => 'ACS6032', + '_acs8k_model' => 'ACS8032', + '_cy5k_model' => 'ACS5024', + '_cy_model' => 'TS3000', + '_acs_serial' => 'ABC6000', + '_acs8k_serial' => 'ABC8000', + '_cy5k_serial' => 'ABC5000', + '_cy_serial' => 'ABC3000', + '_acs_ps1_status' => 'statePowerOn', + '_acs8k_ps1_status' => 'statePowerOff', + '_cy5k_ps1_status' => 'powerOFF', + '_cy_ps1_status' => 'powerON', + '_acs_ps2_status' => 'powerNotInstaled', + '_acs8k_ps2_status' => 'statePowerOn', + '_cy5k_ps2_status' => 'powerON', + '_cy_ps2_status' => 'noinstalled', + '_cy5k_root_ip' => '2.3.4.5', + '_cy_root_ip' => '1.2.3.4', + '_acs_port_tty' => 1, + '_acs8k_port_tty' => 1, + '_cy5k_port_tty' => 1, + '_cy_port_tty' => 1, + '_acs_port_name' => 1, + '_acs8k_port_name' => 1, + '_cy5k_port_name' => 1, + '_cy_port_name' => 1, + '_acs_port_speed' => 1, + '_acs8k_port_speed' => 1, + '_cy5k_port_speed' => 1, + '_cy_port_speed' => 1, + '_acs_port_cd' => 1, + '_acs8k_port_cd' => 1, + '_cy5k_port_cd' => 1, + '_cy_port_cd' => 1, + '_acs_port_socket' => 1, + '_acs8k_port_socket' => 1, + '_cy5k_port_socket' => 1, + '_cy_port_socket' => 1, + '_i_index' => 1, + '_i_description' => 1, + '_i_speed' => 1, + '_i_up' => 1, + '_i_name' => 1, + + 'store' => { + 'i_index' => { 1 => 1 }, + 'i_speed' => { 1 => 10000000 }, + 'i_description' => { 1 => 'Interface 1 Description' }, + 'i_name' => { 1 => 'Interface 1 Name' }, + 'i_up' => { 1 => 'up' }, + 'acs_port_socket' => { 1 => 'ACS 1 Name', 2 => 'ACS 2 Name' }, + 'acs8k_port_socket' => { 1 => '8K 1 Name', 2 => '8K 2 Name' }, + 'cy5k_port_socket' => { 1 => '5K 1 Sock', 2 => '5K 2 Sock' }, + 'cy_port_socket' => { 1 => 'Port 1 Sock', 2 => 'Port 2 Sock' }, + 'acs_port_tty' => { 1 => 'ACS 1 TTY', 2 => 'ACS 2 TTY' }, + 'acs8k_port_tty' => { 1 => '8K 1 TTY', 2 => '8K 2 TTY' }, + 'cy5k_port_tty' => { 1 => '5K 1 TTY', 2 => '5K 2 TTY' }, + 'cy_port_tty' => { 1 => 'Port 1 TTY', 2 => 'Port 2 TTY' }, + 'acs_port_name' => { 1 => 'ACS 1 Name', 2 => 'ACS 2 Name' }, + 'acs8k_port_name' => { 1 => '8K 1 Name', 2 => '8K 2 Name' }, + 'cy5k_port_name' => { 1 => '5K 1 Name', 2 => '5K 2 Name' }, + 'cy_port_name' => { 1 => 'Port 1 Name', 2 => 'Port 2 Name' }, + 'acs_port_speed' => { 1 => 56000, 2 => 112000 }, + 'acs8k_port_speed' => { 1 => 112000, 2 => 384000 }, + 'cy5k_port_speed' => { 1 => 9600, 2 => 56000 }, + 'cy_port_speed' => { 1 => 2400, 2 => 9600 }, + 'acs_port_cd' => { 1 => 'down', 2 => 'up' }, + 'acs8k_port_cd' => { 1 => 'up', 2 => 'down' }, + 'cy5k_port_cd' => { 1 => 'down', 2 => 'down' }, + 'cy_port_cd' => { 1 => 'down', 2 => 'up' }, + } + }; + $test->{info}->cache($cache_data); +} + +sub layers : Tests(2) { + my $test = shift; + + can_ok( $test->{info}, 'layers' ); + is( $test->{info}->layers(), '01000001', q(Layers returns '01000001') ); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok( $test->{info}, 'os' ); + is( $test->{info}->os(), 'avocent', q(Vendor returns 'avocent') ); +} + +sub os_ver : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'os_ver' ); + is( $test->{info}->os_ver(), '6.00', q(ACS version is expected value) ); + + delete $test->{info}{_acs_os_ver}; + is( $test->{info}->os_ver(), '8.00', + q(ACS 8K version is expected value) ); + + delete $test->{info}{_acs8k_os_ver}; + is( $test->{info}->os_ver(), '2.02', + q(ACS 5K version is expected value) ); + + delete $test->{info}{_cy5k_os_ver}; + is( $test->{info}->os_ver(), + '3.00', q(Original Cyclades version is expected value) ); + + delete $test->{info}{_cy_os_ver}; + is( $test->{info}->os_ver(), + undef, q(No MIB leaf data returns undef os_ver) ); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok( $test->{info}, 'vendor' ); + is( $test->{info}->vendor(), 'vertiv', q(Vendor returns 'vertiv') ); +} + +sub model : Tests(7) { + my $test = shift; + + can_ok( $test->{info}, 'model' ); + is( $test->{info}->model(), 'acs6032', q(ACS model is expected value) ); + + delete $test->{info}{_acs_model}; + is( $test->{info}->model(), 'acs8032', + q(ACS 8K model is expected value) ); + + delete $test->{info}{_acs8k_model}; + is( $test->{info}->model(), 'acs5024', + q(ACS 5K model is expected value) ); + + delete $test->{info}{_cy5k_model}; + is( $test->{info}->model(), + 'ts3000', q(Original Cyclades model is expected value) ); + + delete $test->{info}{_cy_model}; + is( $test->{info}->model(), + 'acs6008', q(No MIB leaf data returns translated id) ); + + # We won't get to class without sysObjectID that matches enterprise id, + # so use one that isn't defined in MIB + $test->{info}{_id} = '.1.3.6.1.4.1.10418.16.1.6'; + is( $test->{info}->model(), + 'acsProducts.6', + q(Unknown id returns partially translated id) ); +} + +sub serial : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'serial' ); + is( $test->{info}->serial(), 'ABC6000', q(ACS serial is expected value) ); + + delete $test->{info}{_acs_serial}; + is( $test->{info}->serial(), + 'ABC8000', q(ACS 8K serial is expected value) ); + + delete $test->{info}{_acs8k_serial}; + is( $test->{info}->serial(), + 'ABC5000', q(ACS 5K serial is expected value) ); + + delete $test->{info}{_cy5k_serial}; + is( $test->{info}->serial(), + 'ABC3000', q(Original Cyclades serial is expected value) ); + + delete $test->{info}{_cy_serial}; + is( $test->{info}->serial(), + undef, q(No MIB leaf data returns undef serial) ); +} + +sub root_ip : Tests(4) { + my $test = shift; + + can_ok( $test->{info}, 'root_ip' ); + is( $test->{info}->root_ip(), + '2.3.4.5', q(ACS 5K root IP is expected value) ); + + delete $test->{info}{_cy5k_root_ip}; + is( $test->{info}->root_ip(), + '1.2.3.4', q(Original Cyclades root IP is expected value) ); + + delete $test->{info}{_cy_root_ip}; + is( $test->{info}->root_ip(), + undef, q(No MIB leaf data returns undef root IP) ); +} + +sub ps1_status : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'ps1_status' ); + is( $test->{info}->ps1_status(), + 'statePowerOn', q(ACS power supply 1 status is expected value) ); + + delete $test->{info}{_acs_ps1_status}; + is( $test->{info}->ps1_status(), + 'statePowerOff', q(ACS 8K power supply 1 status is expected value) ); + + delete $test->{info}{_acs8k_ps1_status}; + is( $test->{info}->ps1_status(), + 'powerOFF', q(ACS 5K power supply 1 status is expected value) ); + + delete $test->{info}{_cy5k_ps1_status}; + is( $test->{info}->ps1_status(), + 'powerON', + q(Original Cyclades power supply 1 status is expected value) ); + + delete $test->{info}{_cy_ps1_status}; + is( $test->{info}->ps1_status(), + undef, q(No MIB leaf data returns undef power supply 1 status) ); +} + +sub ps2_status : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'ps2_status' ); + is( $test->{info}->ps2_status(), + 'powerNotInstaled', q(ACS power supply 2 status is expected value) ); + + delete $test->{info}{_acs_ps2_status}; + is( $test->{info}->ps2_status(), + 'statePowerOn', q(ACS 8K power supply 2 status is expected value) ); + + delete $test->{info}{_acs8k_ps2_status}; + is( $test->{info}->ps2_status(), + 'powerON', q(ACS 5K power supply 2 status is expected value) ); + + delete $test->{info}{_cy5k_ps2_status}; + is( $test->{info}->ps2_status(), + 'noinstalled', + q(Original Cyclades power supply 2 status is expected value) ); + + delete $test->{info}{_cy_ps2_status}; + is( $test->{info}->ps2_status(), + undef, q(No MIB leaf data returns undef power supply 2 status) ); +} + +sub i_index : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'i_index' ); + + my $expected = { + '1' => '1', + 'ACS 1 Name' => 'ACS 1 Name', + 'ACS 2 Name' => 'ACS 2 Name' + }; + cmp_deeply( $test->{info}->i_index(), + $expected, q(ACS interface indices have expected values) ); + + delete $test->{info}{_acs_port_socket}; + delete $test->{info}{store}{acs_port_socket}; + $expected = { + '1' => '1', + '8K 1 Name' => '8K 1 Name', + '8K 2 Name' => '8K 2 Name' + }; + cmp_deeply( $test->{info}->i_index(), + $expected, q(ACS 8K interface indices have expected values) ); + + delete $test->{info}{_acs8k_port_socket}; + delete $test->{info}{store}{acs8k_port_socket}; + $expected = { + '1' => '1', + '5K 1 Sock' => '5K 1 Sock', + '5K 2 Sock' => '5K 2 Sock' + }; + cmp_deeply( $test->{info}->i_index(), + $expected, q(ACS 5K interface indices have expected values) ); + + delete $test->{info}{_cy5k_port_socket}; + delete $test->{info}{store}{cy5k_port_socket}; + $expected = { + '1' => '1', + 'Port 1 Sock' => 'Port 1 Sock', + 'Port 2 Sock' => 'Port 2 Sock' + }; + cmp_deeply( $test->{info}->i_index(), + $expected, + q(Original Cyclades interface indices have expected values) ); + + $test->{info}->clear_cache(); + cmp_deeply( $test->{info}->interfaces(), + {}, q(Empty SNMP table results in empty hash) ); +} + +sub interfaces : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'interfaces' ); + my $expected = { + '1' => 'Interface 1 Description', + 'ACS 1 Name' => 'ACS 1 TTY', + 'ACS 2 Name' => 'ACS 2 TTY' + }; + cmp_deeply( $test->{info}->interfaces(), + $expected, q(ACS interfaces have expected values) ); + + delete $test->{info}{_acs_port_socket}; + delete $test->{info}{store}{acs_port_socket}; + delete $test->{info}{_acs_port_tty}; + delete $test->{info}{store}{acs_port_tty}; + $expected = { + '1' => 'Interface 1 Description', + '8K 1 Name' => '8K 1 TTY', + '8K 2 Name' => '8K 2 TTY' + }; + cmp_deeply( $test->{info}->interfaces(), + $expected, q(ACS 8K interfaces have expected values) ); + + delete $test->{info}{_acs8k_port_socket}; + delete $test->{info}{store}{acs8k_port_socket}; + delete $test->{info}{_acs8k_port_tty}; + delete $test->{info}{store}{acs8k_port_tty}; + $expected = { + '1' => 'Interface 1 Description', + '5K 1 Sock' => '5K 1 TTY', + '5K 2 Sock' => '5K 2 TTY' + }; + cmp_deeply( $test->{info}->interfaces(), + $expected, q(ACS 5K interfaces have expected values) ); + + delete $test->{info}{_cy5k_port_socket}; + delete $test->{info}{store}{cy5k_port_socket}; + delete $test->{info}{_cy5k_port_tty}; + delete $test->{info}{store}{cy5k_port_tty}; + $expected = { + '1' => 'Interface 1 Description', + 'Port 1 Sock' => 'Port 1 TTY', + 'Port 2 Sock' => 'Port 2 TTY' + }; + cmp_deeply( $test->{info}->interfaces(), + $expected, q(Original Cyclades interfaces have expected values) ); + + $test->{info}->clear_cache(); + cmp_deeply( $test->{info}->interfaces(), + {}, q(Empty SNMP table results in empty hash) ); +} + +sub i_speed : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'i_speed' ); + + # Munge in effect + my $expected = { + '1' => '10 Mbps', + 'ACS 1 Name' => 56000, + 'ACS 2 Name' => 112000 + }; + cmp_deeply( $test->{info}->i_speed(), + $expected, q(ACS interface speeds have expected values) ); + + delete $test->{info}{_acs_port_socket}; + delete $test->{info}{store}{acs_port_socket}; + delete $test->{info}{_acs_port_speed}; + delete $test->{info}{store}{acs_port_speed}; + $expected = { + '1' => '10 Mbps', + '8K 1 Name' => 112000, + '8K 2 Name' => 384000 + }; + cmp_deeply( $test->{info}->i_speed(), + $expected, q(ACS 8K interface speeds have expected values) ); + + delete $test->{info}{_acs8k_port_socket}; + delete $test->{info}{store}{acs8k_port_socket}; + delete $test->{info}{_acs8k_port_speed}; + delete $test->{info}{store}{acs8k_port_speed}; + $expected = { + '1' => '10 Mbps', + '5K 1 Sock' => 9600, + '5K 2 Sock' => 56000 + }; + cmp_deeply( $test->{info}->i_speed(), + $expected, q(ACS 5K interface speeds have expected values) ); + + delete $test->{info}{_cy5k_port_socket}; + delete $test->{info}{store}{cy5k_port_socket}; + delete $test->{info}{_cy5k_port_speed}; + delete $test->{info}{store}{cy5k_port_speed}; + $expected = { + '1' => '10 Mbps', + 'Port 1 Sock' => 2400, + 'Port 2 Sock' => 9600 + }; + cmp_deeply( $test->{info}->i_speed(), + $expected, + q(Original Cyclades interface speeds have expected values) ); + + $test->{info}->clear_cache(); + cmp_deeply( $test->{info}->i_speed(), + {}, q(Empty SNMP table results in empty hash) ); +} + +sub i_up : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'i_up' ); + + my $expected = { + '1' => 'up', + 'ACS 1 Name' => 'down', + 'ACS 2 Name' => 'up' + }; + cmp_deeply( $test->{info}->i_up(), + $expected, q(ACS interface statuses have expected values) ); + + delete $test->{info}{_acs_port_socket}; + delete $test->{info}{store}{acs_port_socket}; + delete $test->{info}{_acs_port_cd}; + delete $test->{info}{store}{acs_port_cd}; + $expected = { + '1' => 'up', + '8K 1 Name' => 'up', + '8K 2 Name' => 'down' + }; + cmp_deeply( $test->{info}->i_up(), + $expected, q(ACS 8K interface statuses have expected values) ); + + delete $test->{info}{_acs8k_port_socket}; + delete $test->{info}{store}{acs8k_port_socket}; + delete $test->{info}{_acs8k_port_cd}; + delete $test->{info}{store}{acs8k_port_cd}; + $expected = { + '1' => 'up', + '5K 1 Sock' => 'down', + '5K 2 Sock' => 'down' + }; + cmp_deeply( $test->{info}->i_up(), + $expected, q(ACS 5K interface statuses have expected values) ); + + delete $test->{info}{_cy5k_port_socket}; + delete $test->{info}{store}{cy5k_port_socket}; + delete $test->{info}{_cy5k_port_cd}; + delete $test->{info}{store}{cy5k_port_cd}; + $expected = { + '1' => 'up', + 'Port 1 Sock' => 'down', + 'Port 2 Sock' => 'up' + }; + cmp_deeply( $test->{info}->i_up(), + $expected, + q(Original Cyclades interface statuses have expected values) ); + + $test->{info}->clear_cache(); + cmp_deeply( $test->{info}->i_up(), + {}, q(Empty SNMP table results in empty hash) ); +} + +sub i_description : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'i_description' ); + + my $expected = { + '1' => 'Interface 1 Description', + 'ACS 1 Name' => 'ACS 1 Name', + 'ACS 2 Name' => 'ACS 2 Name' + }; + cmp_deeply( $test->{info}->i_description(), + $expected, q(ACS interface descriptions have expected values) ); + + delete $test->{info}{_acs_port_socket}; + delete $test->{info}{store}{acs_port_socket}; + delete $test->{info}{_acs_port_name}; + delete $test->{info}{store}{acs_port_name}; + $expected = { + '1' => 'Interface 1 Description', + '8K 1 Name' => '8K 1 Name', + '8K 2 Name' => '8K 2 Name' + }; + cmp_deeply( $test->{info}->i_description(), + $expected, q(ACS 8K interface descriptions have expected values) ); + + delete $test->{info}{_acs8k_port_socket}; + delete $test->{info}{store}{acs8k_port_socket}; + delete $test->{info}{_acs8k_port_name}; + delete $test->{info}{store}{acs8k_port_name}; + $expected = { + '1' => 'Interface 1 Description', + '5K 1 Sock' => '5K 1 Name', + '5K 2 Sock' => '5K 2 Name' + }; + cmp_deeply( $test->{info}->i_description(), + $expected, q(ACS 5K interface descriptions have expected values) ); + + delete $test->{info}{_cy5k_port_socket}; + delete $test->{info}{store}{cy5k_port_socket}; + delete $test->{info}{_cy5k_port_name}; + delete $test->{info}{store}{cy5k_port_name}; + $expected = { + '1' => 'Interface 1 Description', + 'Port 1 Sock' => 'Port 1 Name', + 'Port 2 Sock' => 'Port 2 Name' + }; + cmp_deeply( $test->{info}->i_description(), + $expected, + q(Original Cyclades interface descriptions have expected values) ); + + $test->{info}->clear_cache(); + cmp_deeply( $test->{info}->i_description(), + {}, q(Empty SNMP table results in empty hash) ); +} + +sub i_name : Tests(6) { + my $test = shift; + + can_ok( $test->{info}, 'i_name' ); + + my $expected = { + '1' => 'Interface 1 Name', + 'ACS 1 Name' => 'ACS 1 Name', + 'ACS 2 Name' => 'ACS 2 Name' + }; + cmp_deeply( $test->{info}->i_name(), + $expected, q(ACS interface descriptions have expected values) ); + + delete $test->{info}{_acs_port_socket}; + delete $test->{info}{store}{acs_port_socket}; + delete $test->{info}{_acs_port_name}; + delete $test->{info}{store}{acs_port_name}; + $expected = { + '1' => 'Interface 1 Name', + '8K 1 Name' => '8K 1 Name', + '8K 2 Name' => '8K 2 Name' + }; + cmp_deeply( $test->{info}->i_name(), + $expected, q(ACS 8K interface descriptions have expected values) ); + + delete $test->{info}{_acs8k_port_socket}; + delete $test->{info}{store}{acs8k_port_socket}; + delete $test->{info}{_acs8k_port_name}; + delete $test->{info}{store}{acs8k_port_name}; + $expected = { + '1' => 'Interface 1 Name', + '5K 1 Sock' => '5K 1 Name', + '5K 2 Sock' => '5K 2 Name' + }; + cmp_deeply( $test->{info}->i_name(), + $expected, q(ACS 5K interface descriptions have expected values) ); + + delete $test->{info}{_cy5k_port_socket}; + delete $test->{info}{store}{cy5k_port_socket}; + delete $test->{info}{_cy5k_port_name}; + delete $test->{info}{store}{cy5k_port_name}; + $expected = { + '1' => 'Interface 1 Name', + 'Port 1 Sock' => 'Port 1 Name', + 'Port 2 Sock' => 'Port 2 Name' + }; + cmp_deeply( $test->{info}->i_name(), + $expected, + q(Original Cyclades interface descriptions have expected values) ); + + $test->{info}->clear_cache(); + cmp_deeply( $test->{info}->i_name(), + {}, q(Empty SNMP table results in empty hash) ); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer1/S3000.pm b/xt/lib/Test/SNMP/Info/Layer1/S3000.pm new file mode 100644 index 00000000..5489fb8a --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer1/S3000.pm @@ -0,0 +1,89 @@ +# Test::SNMP::Info::Layer1::S3000 +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer1::S3000; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer1::S3000; + +# Remove this startup override once we have full method coverage +sub startup : Tests(startup => 1) { + my $test = shift; + $test->SUPER::startup(); + + $test->todo_methods(1); +} + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 1, + '_description' => 'NMM 3000 Hub SNMP/Telnet Agent v3.2.1', + '_id' => '.1.3.6.1.4.1.45.3.2.1', + 'store' => {}, + }; + $test->{info}->cache($cache_data); +} + +sub layers : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'layers'); + is($test->{info}->layers(), '00000011', q(Layers returns '00000111')); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'synoptics', q(Vendor returns 'synoptics')); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'nortel', q(Vendor returns 'nortel')); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), '3000', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No id returns undef model)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer2/3Com.pm b/xt/lib/Test/SNMP/Info/Layer2/3Com.pm new file mode 100644 index 00000000..19614f46 --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer2/3Com.pm @@ -0,0 +1,103 @@ +# Test::SNMP::Info::Layer2::3Com +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer2::3Com; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer2::3Com; + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 2, + '_description' => 'Super Stack Switch 3812 Software', + '_e_serial' => 1, + '_e_swver' => 1, + '_id' => '.1.3.6.1.4.1.43.1.8.40', + 'store' => { + 'e_serial' => {1 => '123456ABC', 2 => '234567ABC', 3 => undef}, + 'e_swver' => {1 => undef, 2 => '3.0.3', 3 => undef}, + } + }; + $test->{info}->cache($cache_data); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), '3Com', q(Vendor returns '3Com')); +} + +sub serial : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'serial'); + is($test->{info}->serial(), '123456ABC', q(Serial has expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->serial(), undef, q(No serial returns undef model)); +} + +sub os_ver : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'os_ver'); + is($test->{info}->os_ver(), '3.0.3', q(OS version has expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->os_ver(), undef, q(No OS version returns undef model)); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), '3Com', q(Vendor returns '3Com')); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is( + $test->{info}->model(), + 'Super Stack Switch 3812', + q(Model is expected value) + ); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No description returns undef model)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer2/Airespace.pm b/xt/lib/Test/SNMP/Info/Layer2/Airespace.pm new file mode 100644 index 00000000..a449a545 --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer2/Airespace.pm @@ -0,0 +1,84 @@ +# Test::SNMP::Info::Layer2::Airespace +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer2::Airespace; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer2::Airespace; + +# Remove this startup override once we have full method coverage +sub startup : Tests(startup => 1) { + my $test = shift; + $test->SUPER::startup(); + + $test->todo_methods(1); +} + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 2, + '_description' => + 'Cisco Controller', + '_id' => '.1.3.6.1.4.1.14179.1.1.4.2', + '_airespace_model' => 'AIR-WLC2006-K9', + 'store' => {}, + }; + $test->{info}->cache($cache_data); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'cisco', q(Vendor returns 'cisco')); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'cisco', q(Vendor returns 'cisco')); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), 'AIR-WLC2006-K9', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No id returns undef model)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer2/Allied.pm b/xt/lib/Test/SNMP/Info/Layer2/Allied.pm new file mode 100644 index 00000000..e72da1b0 --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer2/Allied.pm @@ -0,0 +1,97 @@ +# Test::SNMP::Info::Layer2::Allied +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer2::Allied; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer2::Allied; + +# Remove this startup override once we have full method coverage +sub startup : Tests(startup => 1) { + my $test = shift; + $test->SUPER::startup(); + + $test->todo_methods(1); +} + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 2, + + # This is made up as no snmpwalk of device + '_description' => 'Allied Telesis AT-8000S/48POE version 3.0.0.45', + + # AT-PRODUCT-MIB::atGS970M10 + '_id' => '.1.3.6.1.4.1.207.1.4.317', + 'store' => {}, + }; + $test->{info}->cache($cache_data); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'allied', q(Vendor returns 'allied')); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'allied', q(Vendor returns 'allied')); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), 'AT-8000S/48POE', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No description returns undef model)); +} + +sub os_ver : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'os_ver'); + is($test->{info}->os_ver(), '3.0', q(OS version is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->os_ver(), undef, + q(No description returns undef OS version)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer2/Baystack.pm b/xt/lib/Test/SNMP/Info/Layer2/Baystack.pm new file mode 100644 index 00000000..7b764aa8 --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer2/Baystack.pm @@ -0,0 +1,85 @@ +# Test::SNMP::Info::Layer2::Baystack +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer2::Baystack; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer2::Baystack; + +# Remove this startup override once we have full method coverage +sub startup : Tests(startup => 1) { + my $test = shift; + $test->SUPER::startup(); + + $test->todo_methods(1); +} + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 2, + '_description' => + 'Ethernet Routing Switch 4826GTS-PWR+ HW:04 FW:5.6.0.18 SW:v5.6.1.053', + + # SYNOPTICS-ROOT-MIB::sreg-ERS-4826GTS-PWR-PLUS + '_id' => '.1.3.6.1.4.1.45.3.78.1', + 'store' => {}, + }; + $test->{info}->cache($cache_data); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'boss', q(Vendor returns 'boss')); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'avaya', q(Vendor returns 'avaya')); +} + +sub model : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), '4826GTS-PWR-PLUS', q(Model is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->model(), undef, q(No id returns undef model)); +} + +1; diff --git a/xt/lib/Test/SNMP/Info/Layer3/Timetra.pm b/xt/lib/Test/SNMP/Info/Layer3/Timetra.pm new file mode 100644 index 00000000..73f8151c --- /dev/null +++ b/xt/lib/Test/SNMP/Info/Layer3/Timetra.pm @@ -0,0 +1,191 @@ +# Test::SNMP::Info::Layer3::Timetra +# +# Copyright (c) 2018 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 Test::SNMP::Info::Layer3::Timetra; + +use Test::Class::Most parent => 'My::Test::Class'; + +use SNMP::Info::Layer3::Timetra; + +sub setup : Tests(setup) { + my $test = shift; + $test->SUPER::setup; + + # Start with a common cache that will serve most tests + my $cache_data = { + '_layers' => 79, + '_description' => 'TiMOS-B-6.1.R4 both/hops ALCATEL-LUCENT SAR 7705 ', + '_id' => '.1.3.6.1.4.1.6527.6.1.1.2.2', + '_lldp_sys_cap' => pack("H*", '2800'), + '_i_description' => 1, + '_i_name' => 1, + '_lldp_rem_cap_spt' => 1, + '_lldp_rem_sys_cap' => 1, + '_lldp_rem_id_type' => 1, + '_lldp_rem_id' => 1, + '_lldp_rem_pid_type' => 1, + '_lldp_rem_pid' => 1, + '_lldp_rem_desc' => 1, + '_lldp_rem_sysname' => 1, + '_lldp_rman_addr' => 1, + 'store' => { + 'i_description' => { + '1' => 'system, Loopback IP interface', + '40108032' => '1/3/8, 10/100/Gig Ethernet SFP', + }, + 'i_name' => {'1' => 'system', '40108032' => '1/3/8',}, + 'lldp_rem_cap_spt' => {'230425271.40108032.1.2' => pack("H*", '2800')}, + 'lldp_rem_sys_cap' => {'230425271.40108032.1.2' => pack("H*", '2800')}, + 'lldp_rem_id_type' => {'230425271.40108032.1.2' => 'macAddress'}, + 'lldp_rem_id' => {'230425271.40108032.1.2' => pack("H*", '34AA99C89AA1')}, + 'lldp_rem_pid_type' => {'230425271.40108032.1.2' => 'local'}, + 'lldp_rem_pid' => {'230425271.40108032.1.2' => '44072960'}, + 'lldp_rem_desc' => {'230425271.40108032.1.2' => 'Another-7705-Port'}, + 'lldp_rem_sysname' => {'230425271.40108032.1.2' => 'Another-7705'}, + 'lldp_rman_addr' => {'230425271.40108032.1.2.1.4.1.2.3.4' => 'unknown'}, + } + }; + $test->{info}->cache($cache_data); +} + +sub vendor : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'vendor'); + is($test->{info}->vendor(), 'nokia', q(Vendor returns 'nokia')); +} + +sub os : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'os'); + is($test->{info}->os(), 'TiMOS', q(Vendor returns 'TiMOS')); +} + +sub os_ver : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'os_ver'); + is($test->{info}->os_ver(), 'B-6.1.R4', q(OS version is expected value)); + + $test->{info}->clear_cache(); + is($test->{info}->os_ver(), undef, q(No description returns undef os_ver)); +} + +sub model : Tests(5) { + my $test = shift; + + can_ok($test->{info}, 'model'); + is($test->{info}->model(), '7705', q(Model uses description)); + + delete $test->{info}{_description}; + is($test->{info}->model(), + 'timetra.6.1.1.2.2', q(Model partially translated id)); + + $test->{info}{_id} = '.1.3.6.1.4.1.6527.1.3.1'; + is($test->{info}->model(), 'SR1', q(Model translates id)); + + $test->{info}{_id} = '.100.3.6.1.4.1.6527.1.3.1'; + is($test->{info}->model(), '.100.3.6.1.4.1.6527.1.3.1', q(Model uses id)); +} + +sub interfaces : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'interfaces'); + + my $expected = {'1' => 'system', '40108032' => '1/3/8',}; + + cmp_deeply($test->{info}->interfaces(), + $expected, q(Interface names have expected values)); +} + +sub lldp_if : Tests(2) { + my $test = shift; + + can_ok($test->{info}, 'lldp_if'); + + my $expected = {'230425271.40108032.1.2' => '40108032',}; + + cmp_deeply($test->{info}->lldp_if(), + $expected, q(Mapping of LLDP interfaces have expected values)); +} + +# This test will cover that the overwritten private _lldp_addr_index function +# is working properly +sub lldp_addr : Tests(3) { + my $test = shift; + + can_ok($test->{info}, 'lldp_addr'); + + my $expected = {'230425271.40108032.1.2' => '1.2.3.4'}; + + cmp_deeply($test->{info}->lldp_addr(), + $expected, q(Remote LLDP IP has expected value)); + + # Exchange the IPv4 address with the same IPv6 address + $test->{info}{store}{lldp_rman_addr} + = {'230425271.40108032.1.2.2.16.0.0.0.0.0.0.0.0.0.0.255.255.1.2.3.4' => + 'unknown' + }; + $expected + = {'230425271.40108032.1.2' => '0000:0000:0000:0000:0000:ffff:0102:0304'}; + + cmp_deeply($test->{info}->lldp_ipv6(), + $expected, q(Remote LLDP IPv6 has expected value)); +} + +# Example from LLDP documentation +# Used as verification that we can map essential L2 topo information +sub topo_example_test : Tests(1) { + my $test = shift; + + # Print out a map of device ports with LLDP neighbors: + my $interfaces = $test->{info}->interfaces(); + my $lldp_if = $test->{info}->lldp_if(); + my $lldp_ip = $test->{info}->lldp_ip(); + my $lldp_port = $test->{info}->lldp_port(); + + # We only have one entry/key otherwise this should be in a subtest + foreach my $lldp_key (keys %$lldp_ip) { + my $iid = $lldp_if->{$lldp_key}; + my $port = $interfaces->{$iid}; + my $neighbor = $lldp_ip->{$lldp_key}; + my $neighbor_port = $lldp_port->{$lldp_key}; + + my $string = qq(Port : $port connected to $neighbor / $neighbor_port); + my $expected_string + = qq(Port : 1/3/8 connected to 1.2.3.4 / Another-7705-Port); + + is($string, $expected_string, + q(LLDP example maps device ports with LLDP neighbors)); + } +} + +1;