diff --git a/Info.pm b/Info.pm index 0032d4f3..48b5d7b6 100644 --- a/Info.pm +++ b/Info.pm @@ -1,10 +1,10 @@ # SNMP::Info - Max Baker # $Id$ # -# Copyright (c) 2003,2004 Max Baker -# All rights reserved. -# Portions Copyright (c) 2002-3, Regents of the University of California -# All rights reserved. +# Copyright (c) 2003-2008 Max Baker +# All rights reserved. +# Portions Copyright (c) 2002-2003, Regents of the University of California +# All rights reserved. # # See COPYRIGHT at bottom @@ -16,18 +16,18 @@ use SNMP; use Carp; use Math::BigInt; -@SNMP::Info::ISA = qw/Exporter/; +@SNMP::Info::ISA = qw/Exporter/; @SNMP::Info::EXPORT_OK = qw//; -use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG %SPEED_MAP - $NOSUCH $BIGINT $REPEATERS/; +use vars + qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG %SPEED_MAP + $NOSUCH $BIGINT $REPEATERS/; $VERSION = '1.09'; =head1 NAME -SNMP::Info - Object Oriented Perl5 Interface to Network devices and MIBs through -SNMP. +SNMP::Info - Object Oriented Perl5 Interface to Network devices and MIBs through SNMP. =head1 VERSION @@ -38,8 +38,8 @@ SNMP::Info - Version 1.09 SNMP::Info was created at UCSC for the netdisco project (www.netdisco.org) and was originally written by Max Baker. -Currently being maintained by team of Open Source authors headed by Eric Miller -and Bill Fenner. +Currently being maintained by team of Open Source authors headed by +Eric Miller and Bill Fenner. =head1 SYNOPSIS @@ -107,11 +107,11 @@ Mailing List at . SNMP::Info gives an object oriented interface to information obtained through SNMP. -This module lives at http://snmp-info.sourceforge.net Check for newest version -and documentation. +This module lives at http://snmp-info.sourceforge.net Check for newest +version and documentation. -This module is geared towards network devices. Subclasses exist for a number of -network devices and common MIBs. +This module is geared towards network devices. Subclasses exist for a number +of network devices and common MIBs. The idea behind this module is to give a common interface to data from network devices, leaving the device-specific hacks behind the scenes in subclasses. @@ -125,8 +125,8 @@ specific. SNMP::Info provides you a common method for all supported devices. Adding support for your own device is easy, and takes little SNMP 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 +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. =head1 REQUIREMENTS @@ -157,8 +157,9 @@ on the Perl side. Versions 5.0301 and 5.0203 have issues with bulkwalk, turn off bulkwalk. -B: Some versions that come with certain versions of Redhat/Fedora -don't have the Perl library installed. Uninstall the RPM and install by hand. +B: Some versions that come with certain versions of +Redhat/Fedora don't have the Perl library installed. Uninstall the RPM and +install by hand. =item 2. MIBS @@ -184,8 +185,8 @@ and that the MIBs are world-readable. =item * 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. =item * Data returned is in the enumerated value form. @@ -206,8 +207,8 @@ subroutine. 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. +the developers (via Source Forge or the mailing list) for inclusion in the +next version. =back @@ -228,8 +229,8 @@ For more info run C on any of the following module names. =item SNMP::Info::Airespace -F and F. Inherited by devices -based on the Airespace wireless platform. +F and F. Inherited by +devices based on the Airespace wireless platform. See documentation in L for details. @@ -242,8 +243,8 @@ See documentation in L for details. =item SNMP::Info::CDP -F. Cisco Discovery Protocol (CDP) Support. Inherited by Cisco, -Enterasys, and HP devices. +F. Cisco Discovery Protocol (CDP) Support. Inherited by +Cisco, Enterasys, and HP devices. See documentation in L for details. @@ -289,7 +290,8 @@ See documentation in L for details. =item SNMP::Info::CiscoStats F, F, and F. -Provides common interfaces for memory, cpu, and os statistics for Cisco devices. +Provides common interfaces for memory, cpu, and os statistics for Cisco +devices. See documentation in L for details. @@ -308,8 +310,8 @@ See documentation in L for details. =item SNMP::Info::EtherLike -F (RFC1398) - Some Layer3 devices implement this MIB, as well as -some Aironet Layer 2 devices (non Cisco). +F (RFC1398) - Some Layer3 devices implement this MIB, as well +as some Aironet Layer 2 devices (non Cisco). See documentation in L for details. @@ -321,8 +323,8 @@ See documentation in L for details. =item SNMP::Info::IEEE802dot11 -F. A collection of OIDs providing information about standards -based 802.11 wireless devices. +F. A collection of OIDs providing information about +standards based 802.11 wireless devices. See documentation in L for details. @@ -364,8 +366,8 @@ See documentation in L for details. =head2 Device Subclasses -These subclasses inherit from one or more classes to provide a common interface -to data obtainable from network devices. +These subclasses inherit from one or more classes to provide a common +interface to data obtainable from network devices. All the required MIB files are included in the netdisco-mib package. (See Above). @@ -682,12 +684,13 @@ See documentation in L for details. =head1 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, Carlos Vicente, -Dana Watanabe, David Pinkoski, David Sieborger, Douglas McKeown, Greg King, -Ivan Auger, Jean-Philippe Luiggi, Jeroen van Ingen, Justin Hunter, -Kent Hamilton, Matthew Tuttle, Michael Robbert, Mike Hunter, Nicolai Petri, -Ralf Gross, Robert Kerr and people listed on the Netdisco README! +Alexander Barthel, Andy Ford, Alexander Hartmaier, Andrew Herrick, Alex +Kramarov, Bernhard Augenstein, Bradley Baetz, Brian Chow, Brian Wilson, +Carlos Vicente, Dana Watanabe, David Pinkoski, David Sieborger, Douglas +McKeown, Greg King, Ivan Auger, Jean-Philippe Luiggi, Jeroen van Ingen, +Justin Hunter, Kent Hamilton, Matthew Tuttle, Michael Robbert, Mike Hunter, +Nicolai Petri, Ralf Gross, Robert Kerr and people listed on the Netdisco +README! =head1 USAGE @@ -777,9 +780,9 @@ be in addition to the ones setup in snmp.conf at the system level. =item 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. +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. (default true) @@ -800,9 +803,10 @@ 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. +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 : @@ -818,69 +822,70 @@ then fallback to version 1. =cut sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my %args = @_; + my $proto = shift; + my $class = ref($proto) || $proto; + my %args = @_; my %sess_args = %args; - my $new_obj = {}; - bless $new_obj,$class; + my $new_obj = {}; + bless $new_obj, $class; $new_obj->{class} = $class; # load references to all the subclass data structures { - no strict 'refs'; ## no critic - $new_obj->{init} = \${$class . '::INIT'}; - $new_obj->{mibs} = \%{$class . '::MIBS'}; - $new_obj->{globals} = \%{$class . '::GLOBALS'}; - $new_obj->{funcs} = \%{$class . '::FUNCS'}; - $new_obj->{munge} = \%{$class . '::MUNGE'}; + no strict 'refs'; ## no critic + $new_obj->{init} = \${ $class . '::INIT' }; + $new_obj->{mibs} = \%{ $class . '::MIBS' }; + $new_obj->{globals} = \%{ $class . '::GLOBALS' }; + $new_obj->{funcs} = \%{ $class . '::FUNCS' }; + $new_obj->{munge} = \%{ $class . '::MUNGE' }; } # SNMP::Info specific args : - if (defined $args{Debug}){ - $new_obj->debug($args{Debug}); + if ( defined $args{Debug} ) { + $new_obj->debug( $args{Debug} ); delete $sess_args{Debug}; - } else { - $new_obj->debug(defined $DEBUG ? $DEBUG : 0); + } + else { + $new_obj->debug( defined $DEBUG ? $DEBUG : 0 ); } - if (defined $args{DebugSNMP}){ + if ( defined $args{DebugSNMP} ) { $SNMP::debugging = $args{DebugSNMP}; delete $sess_args{DebugSNMP}; } my $auto_specific = 0; - if (defined $args{AutoSpecify}){ + if ( defined $args{AutoSpecify} ) { $auto_specific = $args{AutoSpecify} || 0; delete $sess_args{AutoSpecify}; } - if (defined $args{BulkRepeaters}){ + if ( defined $args{BulkRepeaters} ) { $new_obj->{BulkRepeaters} = $args{BulkRepeaters}; delete $sess_args{BulkRepeaters}; } - if (defined $args{BulkWalk}){ + if ( defined $args{BulkWalk} ) { $new_obj->{BulkWalk} = $args{BulkWalk}; delete $sess_args{BulkWalk}; } - if (defined $args{LoopDetect}){ + if ( defined $args{LoopDetect} ) { $new_obj->{LoopDetect} = $args{LoopDetect}; delete $sess_args{LoopDetect}; } my $sess = undef; - if (defined $args{Session}){ + if ( defined $args{Session} ) { $sess = $args{Session}; delete $sess_args{Session}; } - if (defined $args{BigInt}){ + if ( defined $args{BigInt} ) { $BIGINT = $args{BigInt}; delete $sess_args{BigInt}; } - if (defined $args{MibDirs}){ + if ( defined $args{MibDirs} ) { $new_obj->{mibdirs} = $args{MibDirs}; delete $sess_args{MibDirs}; } @@ -891,23 +896,26 @@ sub new { my $init_ref = $new_obj->{init}; unless ( defined $$init_ref and $$init_ref ) { $new_obj->init(); - $$init_ref=1; + $$init_ref = 1; } - # Connects to device unless open session is provided. - $sess = new SNMP::Session( 'UseEnums' => 1, %sess_args , 'RetryNoSuch' => $new_obj->{nosuch}) - unless defined $sess; + # Connects to device unless open session is provided. + $sess = new SNMP::Session( + 'UseEnums' => 1, + %sess_args, 'RetryNoSuch' => $new_obj->{nosuch} + ) unless defined $sess; # No session object created - unless (defined $sess){ + unless ( defined $sess ) { $new_obj->error_throw("SNMP::Info::new() Failed to Create Session. "); return; } - + # Session object created but SNMP connection failed. my $sess_err = $sess->{ErrorStr} || ''; - if ($sess_err){ - $new_obj->error_throw("SNMP::Info::new() Net-SNMP session creation failed. $sess_err"); + if ($sess_err) { + $new_obj->error_throw( + "SNMP::Info::new() Net-SNMP session creation failed. $sess_err"); return; } @@ -918,12 +926,11 @@ sub new { $new_obj->{store} = $store; $new_obj->{sess} = $sess; $new_obj->{args} = \%args; - $new_obj->{snmp_ver} = $args{Version} || 2; + $new_obj->{snmp_ver} = $args{Version} || 2; $new_obj->{snmp_comm} = $args{Community} || 'public'; - $new_obj->{snmp_user} = $args{SecName} || 'initial'; + $new_obj->{snmp_user} = $args{SecName} || 'initial'; - return $auto_specific ? - $new_obj->specify() : $new_obj; + return $auto_specific ? $new_obj->specify() : $new_obj; } =item update() @@ -943,9 +950,9 @@ the device. =cut sub update { - my $obj = shift; + my $obj = shift; my %update_args = @_; - my %sess_args = (%{$obj->{args}}, %update_args); + my %sess_args = ( %{ $obj->{args} }, %update_args ); # silently only update "the right" args delete $sess_args{Debug}; @@ -957,16 +964,22 @@ sub update { delete $sess_args{BigInt}; delete $sess_args{MibDirs}; - my $sess = new SNMP::Session( 'UseEnums' => 1, %sess_args , 'RetryNoSuch' => $obj->{nosuch}); - unless (defined $sess){ - $obj->error_throw("SNMP::Info::update() Failed to Create new Session. "); + my $sess = new SNMP::Session( + 'UseEnums' => 1, + %sess_args, 'RetryNoSuch' => $obj->{nosuch} + ); + unless ( defined $sess ) { + $obj->error_throw( + "SNMP::Info::update() Failed to Create new Session. "); return; } # Session object created but SNMP connection failed. my $sess_err = $sess->{ErrorStr} || ''; - if ($sess_err){ - $obj->error_throw("SNMP::Info::update() Net-SNMP session creation failed. $sess_err"); + if ($sess_err) { + $obj->error_throw( + "SNMP::Info::update() Net-SNMP session creation failed. $sess_err" + ); return; } $obj->clear_cache(); @@ -1003,16 +1016,16 @@ sub clear_cache { my $self = shift; print "SNMP::Info::clear_cache() - Cache Cleared.\n" if $self->debug(); - + # Clear cached global values and table method flag for being cached - foreach my $key (keys %$self){ + foreach my $key ( keys %$self ) { next unless defined $key; next unless $key =~ /^_/; delete $self->{$key}; } # Clear store for tables - return $self->store({}); + return $self->store( {} ); } @@ -1024,13 +1037,13 @@ object. =cut sub debug { - my $self = shift; + my $self = shift; my $debug = shift; - if (defined $debug){ + if ( defined $debug ) { $self->{debug} = $debug; } - + return $self->{debug}; } @@ -1046,12 +1059,11 @@ sub bulkwalk { my $self = shift; my $bw = shift; - if (defined $bw){ + if ( defined $bw ) { $self->{BulkWalk} = $bw; - } + } return $self->{BulkWalk}; } - =item $info->loopdetect([1|0]) @@ -1065,16 +1077,16 @@ sub loopdetect { my $self = shift; my $ld = shift; - if (defined $ld){ + if ( defined $ld ) { $self->{LoopDetect} = $ld; - } + } return $self->{LoopDetect}; } =item $info->device_type() -Returns the Subclass name for this device. C is returned if no more -specific class is available. +Returns the Subclass name for this device. C 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. @@ -1156,167 +1168,248 @@ sub device_type { my $objtype = "SNMP::Info"; my $layers = $info->layers(); + # if we dont have sysServices, we dont have anything else either probably. - return unless (defined $layers and length($layers)); + return unless ( defined $layers and length($layers) ); - my $desc = $info->description() || 'undef'; + my $desc = $info->description() || 'undef'; $desc =~ s/[\r\n\l]+/ /g; - my $id = $info->id() || 'undef'; + my $id = $info->id() || 'undef'; - $info->debug() and print "SNMP::Info::device_type() layers:$layers id:$id sysDescr:\"$desc\"\n"; + $info->debug() + and print + "SNMP::Info::device_type() layers:$layers id:$id sysDescr:\"$desc\"\n"; # Hash for generic fallback to a device class if unable to determine using # the sysDescr regex. my %l3sysoidmap = ( - 9 => 'SNMP::Info::Layer3::Cisco', - 11 => 'SNMP::Info::Layer2::HP', - 18 => 'SNMP::Info::Layer3::BayRS', - 42 => 'SNMP::Info::Layer3::Sun', - 171 => 'SNMP::Info::Layer3::Dell', - 311 => 'SNMP::Info::Layer3::Microsoft', - 674 => 'SNMP::Info::Layer3::Dell', - 1916 => 'SNMP::Info::Layer3::Extreme', - 1991 => 'SNMP::Info::Layer3::Foundry', - 2021 => 'SNMP::Info::Layer3::NetSNMP', - 2272 => 'SNMP::Info::Layer3::Passport', - 2636 => 'SNMP::Info::Layer3::Juniper', - 2925 => 'SNMP::Info::Layer1::Cyclades', - 5624 => 'SNMP::Info::Layer3::Enterasys', - 8072 => 'SNMP::Info::Layer3::NetSNMP', - ); + 9 => 'SNMP::Info::Layer3::Cisco', + 11 => 'SNMP::Info::Layer2::HP', + 18 => 'SNMP::Info::Layer3::BayRS', + 42 => 'SNMP::Info::Layer3::Sun', + 171 => 'SNMP::Info::Layer3::Dell', + 311 => 'SNMP::Info::Layer3::Microsoft', + 674 => 'SNMP::Info::Layer3::Dell', + 1916 => 'SNMP::Info::Layer3::Extreme', + 1991 => 'SNMP::Info::Layer3::Foundry', + 2021 => 'SNMP::Info::Layer3::NetSNMP', + 2272 => 'SNMP::Info::Layer3::Passport', + 2636 => 'SNMP::Info::Layer3::Juniper', + 2925 => 'SNMP::Info::Layer1::Cyclades', + 5624 => 'SNMP::Info::Layer3::Enterasys', + 8072 => 'SNMP::Info::Layer3::NetSNMP', + ); my %l2sysoidmap = ( - 9 => 'SNMP::Info::Layer2::Cisco', - 11 => 'SNMP::Info::Layer2::HP', - 171 => 'SNMP::Info::Layer3::Dell', - 207 => 'SNMP::Info::Layer2::Allied', - 674 => 'SNMP::Info::Layer3::Dell', - 1916 => 'SNMP::Info::Layer3::Extreme', - 1991 => 'SNMP::Info::Layer3::Foundry', - 2272 => 'SNMP::Info::Layer3::Passport', - 2925 => 'SNMP::Info::Layer1::Cyclades', - 4526 => 'SNMP::Info::Layer2::Netgear', - 5624 => 'SNMP::Info::Layer3::Enterasys', - 14179 => 'SNMP::Info::Layer2::Airespace', - 14823 => 'SNMP::Info::Layer2::Aruba', - ); + 9 => 'SNMP::Info::Layer2::Cisco', + 11 => 'SNMP::Info::Layer2::HP', + 171 => 'SNMP::Info::Layer3::Dell', + 207 => 'SNMP::Info::Layer2::Allied', + 674 => 'SNMP::Info::Layer3::Dell', + 1916 => 'SNMP::Info::Layer3::Extreme', + 1991 => 'SNMP::Info::Layer3::Foundry', + 2272 => 'SNMP::Info::Layer3::Passport', + 2925 => 'SNMP::Info::Layer1::Cyclades', + 4526 => 'SNMP::Info::Layer2::Netgear', + 5624 => 'SNMP::Info::Layer3::Enterasys', + 14179 => 'SNMP::Info::Layer2::Airespace', + 14823 => 'SNMP::Info::Layer2::Aruba', + ); # Get just the enterprise number for generic mapping - $id = $1 if (defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/); - - # Layer 3 Supported + $id = $1 if ( defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/ ); + + # Layer 3 Supported # (usually has layer2 as well, so we check for 3 first) - if ($info->has_layer(3)) { + if ( $info->has_layer(3) ) { $objtype = 'SNMP::Info::Layer3'; # Device Type Overrides - return $objtype unless (defined $desc and length($desc)); + return $objtype unless ( defined $desc and length($desc) ); + + $objtype = 'SNMP::Info::Layer3::C3550' if $desc =~ /(C3550|C3560)/; + $objtype = 'SNMP::Info::Layer3::C4000' if $desc =~ /Catalyst 4[05]00/; + $objtype = 'SNMP::Info::Layer3::Foundry' if $desc =~ /foundry/i; - $objtype = 'SNMP::Info::Layer3::C3550' if $desc =~ /(C3550|C3560)/ ; - $objtype = 'SNMP::Info::Layer3::C4000' if $desc =~ /Catalyst 4[05]00/; - $objtype = 'SNMP::Info::Layer3::Foundry' if $desc =~ /foundry/i ; # Aironet - older non-IOS - $objtype = 'SNMP::Info::Layer3::Aironet' if ($desc =~ /Cisco/ and $desc =~ /\D(CAP340|AP340|CAP350|350|1200)\D/) ; - $objtype = 'SNMP::Info::Layer3::Aironet' if ($desc =~ /Aironet/ and $desc =~ /\D(AP4800)\D/) ; - $objtype = 'SNMP::Info::Layer3::C6500' if $desc =~ /(c6sup2|c6sup1)/; + $objtype = 'SNMP::Info::Layer3::Aironet' + if ($desc =~ /Cisco/ + and $desc =~ /\D(CAP340|AP340|CAP350|350|1200)\D/ ); + $objtype = 'SNMP::Info::Layer3::Aironet' + if ( $desc =~ /Aironet/ and $desc =~ /\D(AP4800)\D/ ); + $objtype = 'SNMP::Info::Layer3::C6500' if $desc =~ /(c6sup2|c6sup1)/; + # Next one untested. Reported working by DA - $objtype = 'SNMP::Info::Layer3::C6500' if ($desc =~ /cisco/i and $desc =~ /3750/); - $objtype = 'SNMP::Info::Layer3::C6500' if $desc =~ /(s72033_rp|s3223_rp|s222_rp)/; + $objtype = 'SNMP::Info::Layer3::C6500' + if ( $desc =~ /cisco/i and $desc =~ /3750/ ); + $objtype = 'SNMP::Info::Layer3::C6500' + if $desc =~ /(s72033_rp|s3223_rp|s222_rp)/; + # HP, Foundry OEM - $objtype = 'SNMP::Info::Layer3::HP9300' if $desc =~ /\b(J4874A|J4138A|J4139A|J4840A|J4841A)\b/ ; + $objtype = 'SNMP::Info::Layer3::HP9300' + if $desc =~ /\b(J4874A|J4138A|J4139A|J4840A|J4841A)\b/; + # Nortel ERS (Passport) 1600 Series < version 2.1 - $objtype = 'SNMP::Info::Layer3::N1600' if $desc =~ /(Passport|Ethernet\s+Routing\s+Switch)-16/i; - # ERS - BayStack Numbered - $objtype = 'SNMP::Info::Layer2::Baystack' if ($desc =~ /^(BayStack|Ethernet\s+Routing\s+Switch)\s[2345](\d){2,3}/i); + $objtype = 'SNMP::Info::Layer3::N1600' + if $desc =~ /(Passport|Ethernet\s+Routing\s+Switch)-16/i; + + # ERS - BayStack Numbered + $objtype = 'SNMP::Info::Layer2::Baystack' + if ( $desc + =~ /^(BayStack|Ethernet\s+Routing\s+Switch)\s[2345](\d){2,3}/i ); + # Nortel Alteon AD Series - $objtype = 'SNMP::Info::Layer3::AlteonAD' if $desc =~ /Alteon\s[1A][8D]/; + $objtype = 'SNMP::Info::Layer3::AlteonAD' + if $desc =~ /Alteon\s[1A][8D]/; + # Nortel Contivity $objtype = 'SNMP::Info::Layer3::Contivity' if $desc =~ /\bCES\b/; - # Allied Telesyn Layer2 managed switches. They report they have L3 support - $objtype = 'SNMP::Info::Layer2::Allied' if ($desc =~ /Allied.*AT-80\d{2}\S*/i); + + # Allied Telesyn Layer2 managed switches. They report they have L3 support + $objtype = 'SNMP::Info::Layer2::Allied' + if ( $desc =~ /Allied.*AT-80\d{2}\S*/i ); + # Generic device classification based upon sysObjectID - if (($objtype eq 'SNMP::Info::Layer3') and (defined($id)) and (exists($l3sysoidmap{$id}))) { + if ( ( $objtype eq 'SNMP::Info::Layer3' ) + and ( defined($id) ) + and ( exists( $l3sysoidmap{$id} ) ) ) + { $objtype = $l3sysoidmap{$id}; } - # Layer 2 Supported - } elsif ($info->has_layer(2)) { - $objtype = 'SNMP::Info::Layer2'; + # Layer 2 Supported + } + elsif ( $info->has_layer(2) ) { + $objtype = 'SNMP::Info::Layer2'; - return $objtype unless (defined $desc and $desc !~ /^\s*$/); + return $objtype unless ( defined $desc and $desc !~ /^\s*$/ ); # Device Type Overrides # Catalyst 1900 series override - $objtype = 'SNMP::Info::Layer2::C1900' if ($desc =~ /catalyst/i and $desc =~ /\D19\d{2}/); + $objtype = 'SNMP::Info::Layer2::C1900' + if ( $desc =~ /catalyst/i and $desc =~ /\D19\d{2}/ ); + # Catalyst 2900 and 3500XL (IOS) series override - $objtype = 'SNMP::Info::Layer2::C2900' if ($desc =~ /(C2900XL|C2950|C3500XL|C2940|CGESM)/i ); + $objtype = 'SNMP::Info::Layer2::C2900' + if ( $desc =~ /(C2900XL|C2950|C3500XL|C2940|CGESM)/i ); + # Catalyst WS-C series override 2926,4k,5k,6k in Hybrid - $objtype = 'SNMP::Info::Layer2::Catalyst' if ($desc =~ /WS-C\d{4}/); + $objtype = 'SNMP::Info::Layer2::Catalyst' if ( $desc =~ /WS-C\d{4}/ ); + # Catalyst 3550 / 3548 Layer2 only switches # Cisco 3400 w/ MetroBase Image - $objtype = 'SNMP::Info::Layer3::C3550' if ($desc =~ /(C3550|ME340x)/); - # Cisco 2970 - $objtype = 'SNMP::Info::Layer3::C6500' if ($desc =~ /(C2970|C2960)/); + $objtype = 'SNMP::Info::Layer3::C3550' + if ( $desc =~ /(C3550|ME340x)/ ); + + # Cisco 2970 + $objtype = 'SNMP::Info::Layer3::C6500' + if ( $desc =~ /(C2970|C2960)/ ); + # HP, Foundry OEM - $objtype = 'SNMP::Info::Layer3::HP9300' if $desc =~ /\b(J4874A|J4138A|J4139A|J4840A|J4841A)\b/ ; + $objtype = 'SNMP::Info::Layer3::HP9300' + if $desc =~ /\b(J4874A|J4138A|J4139A|J4840A|J4841A)\b/; + # IBM BladeCenter 4-Port GB Ethernet Switch Module - $objtype = 'SNMP::Info::Layer3::Dell' if ($desc =~ /^IBM Gigabit Ethernet Switch Module$/); + $objtype = 'SNMP::Info::Layer3::Dell' + if ( $desc =~ /^IBM Gigabit Ethernet Switch Module$/ ); + # Linksys 2048 - $objtype = 'SNMP::Info::Layer3::Dell' if ($desc =~ /^48-Port 10\/100\/1000 Gigabit Switch with WebView$/); + $objtype = 'SNMP::Info::Layer3::Dell' + if ( + $desc =~ /^48-Port 10\/100\/1000 Gigabit Switch with WebView$/ ); + # Centillion ATM - $objtype = 'SNMP::Info::Layer2::Centillion' if ($desc =~ /MCP/); + $objtype = 'SNMP::Info::Layer2::Centillion' if ( $desc =~ /MCP/ ); + # BPS - $objtype = 'SNMP::Info::Layer2::Baystack' if ($desc =~ /Business\sPolicy\sSwitch/i); + $objtype = 'SNMP::Info::Layer2::Baystack' + if ( $desc =~ /Business\sPolicy\sSwitch/i ); + # BayStack Numbered - $objtype = 'SNMP::Info::Layer2::Baystack' if ($desc =~ /^(BayStack|Ethernet\s+(Routing\s+)??Switch)\s[2345](\d){2,3}/i); + $objtype = 'SNMP::Info::Layer2::Baystack' + if ( $desc + =~ /^(BayStack|Ethernet\s+(Routing\s+)??Switch)\s[2345](\d){2,3}/i + ); + # Nortel Business Ethernet Switch - $objtype = 'SNMP::Info::Layer2::Baystack' if ($desc =~ /^Business Ethernet Switch\s[12]\d\d/i); + $objtype = 'SNMP::Info::Layer2::Baystack' + if ( $desc =~ /^Business Ethernet Switch\s[12]\d\d/i ); + # Nortel AP 222X - $objtype = 'SNMP::Info::Layer2::NAP222x' if ($desc =~ /Access\s+Point\s+222/); + $objtype = 'SNMP::Info::Layer2::NAP222x' + if ( $desc =~ /Access\s+Point\s+222/ ); + # Orinco - $objtype = 'SNMP::Info::Layer2::Orinoco' if ($desc =~ /(AP-\d{3}|WavePOINT)/); + $objtype = 'SNMP::Info::Layer2::Orinoco' + if ( $desc =~ /(AP-\d{3}|WavePOINT)/ ); + # Aironet - IOS - $objtype = 'SNMP::Info::Layer2::Aironet' if ($desc =~ /\b(C1100|C1130|AP1200|C350|C1200|C1240|C1250)\b/ and $desc =~ /\bIOS\b/); + $objtype = 'SNMP::Info::Layer2::Aironet' + if ($desc =~ /\b(C1100|C1130|AP1200|C350|C1200|C1240|C1250)\b/ + and $desc =~ /\bIOS\b/ ); + # Aironet - non IOS - $objtype = 'SNMP::Info::Layer3::Aironet' if ($desc =~ /Cisco/ and $desc =~ /\D(BR500)\D/) ; + $objtype = 'SNMP::Info::Layer3::Aironet' + if ( $desc =~ /Cisco/ and $desc =~ /\D(BR500)\D/ ); + #Nortel 2270 - $objtype = 'SNMP::Info::Layer2::N2270' if ($desc =~ /Nortel\s+(Networks\s+)??WLAN\s+-\s+Security\s+Switch/) ; + $objtype = 'SNMP::Info::Layer2::N2270' + if ( + $desc =~ /Nortel\s+(Networks\s+)??WLAN\s+-\s+Security\s+Switch/ ); # Generic device classification based upon sysObjectID - if (($objtype eq 'SNMP::Info::Layer2') and (defined($id)) and (exists($l2sysoidmap{$id}))) { + if ( ( $objtype eq 'SNMP::Info::Layer2' ) + and ( defined($id) ) + and ( exists( $l2sysoidmap{$id} ) ) ) + { $objtype = $l2sysoidmap{$id}; } - } elsif ($info->has_layer(1)) { + } + elsif ( $info->has_layer(1) ) { $objtype = 'SNMP::Info::Layer1'; + # Allied crap-o-hub - $objtype = 'SNMP::Info::Layer1::Allied' if ($desc =~ /allied/i); - $objtype = 'SNMP::Info::Layer1::Asante' if ($desc =~ /asante/i); + $objtype = 'SNMP::Info::Layer1::Allied' if ( $desc =~ /allied/i ); + $objtype = 'SNMP::Info::Layer1::Asante' if ( $desc =~ /asante/i ); # Bay Hub - $objtype = 'SNMP::Info::Layer1::Bayhub' if ($desc =~ /\bNMM.*Agent/); - $objtype = 'SNMP::Info::Layer1::Bayhub' if ($desc =~ /\bBay\s*Stack.*Hub/i); + $objtype = 'SNMP::Info::Layer1::Bayhub' + if ( $desc =~ /\bNMM.*Agent/ ); + $objtype = 'SNMP::Info::Layer1::Bayhub' + if ( $desc =~ /\bBay\s*Stack.*Hub/i ); - # Synoptics Hub - # This will override Bay Hub only for specific devices supported by this class - $objtype = 'SNMP::Info::Layer1::S3000' if ($desc =~ /\bNMM\s+(281|3000|3030)/i); +# Synoptics Hub +# This will override Bay Hub only for specific devices supported by this class + $objtype = 'SNMP::Info::Layer1::S3000' + if ( $desc =~ /\bNMM\s+(281|3000|3030)/i ); + + # These devices don't claim to have Layer1-3 but we like em anyways. + } + else { + $objtype = 'SNMP::Info::Layer2::ZyXEL_DSLAM' + if ( $desc =~ /8-port .DSL Module\(Annex .\)/i ); - # These devices don't claim to have Layer1-3 but we like em anyways. - } else { - $objtype = 'SNMP::Info::Layer2::ZyXEL_DSLAM' if ($desc =~ /8-port .DSL Module\(Annex .\)/i); # Aruba wireless switches - $objtype = 'SNMP::Info::Layer2::Aruba' if ($desc =~ /(ArubaOS|AirOS)/); - #Juniper NetScreen - $objtype = 'SNMP::Info::Layer3::Netscreen' if ($desc =~ /NetScreen/i); - # Cisco PIX - $objtype = 'SNMP::Info::Layer3::Cisco' if ($desc =~ /Cisco PIX Security Appliance/i); - # Cisco ASA - $objtype = 'SNMP::Info::Layer3::Cisco' if ($desc =~ /Cisco Adaptive Security Appliance/i); - } + $objtype = 'SNMP::Info::Layer2::Aruba' + if ( $desc =~ /(ArubaOS|AirOS)/ ); - return $objtype; + #Juniper NetScreen + $objtype = 'SNMP::Info::Layer3::Netscreen' + if ( $desc =~ /NetScreen/i ); + + # Cisco PIX + $objtype = 'SNMP::Info::Layer3::Cisco' + if ( $desc =~ /Cisco PIX Security Appliance/i ); + + # Cisco ASA + $objtype = 'SNMP::Info::Layer3::Cisco' + if ( $desc =~ /Cisco Adaptive Security Appliance/i ); + } + + return $objtype; } =item $info->error(no_clear) @@ -1345,13 +1438,13 @@ Returns if the device doesn't support the layers() call. =cut sub has_layer { - my $self = shift; + my $self = shift; my $check_for = shift; my $layers = $self->layers(); return unless defined $layers; return unless length($layers); - return substr($layers,8-$check_for, 1); + return substr( $layers, 8 - $check_for, 1 ); } =item $info->snmp_comm() @@ -1362,10 +1455,11 @@ Returns SNMP Community string used in connection. sub snmp_comm { my $self = shift; - if ($self->{snmp_ver} == 3) { - return $self->{snmp_user}; - } else { - return $self->{snmp_comm}; + if ( $self->{snmp_ver} == 3 ) { + return $self->{snmp_user}; + } + else { + return $self->{snmp_comm}; } } @@ -1378,7 +1472,7 @@ Returns SNMP Version used for this connection sub snmp_ver { my $self = shift; return $self->{snmp_ver}; -} +} =item $info->specify() @@ -1398,29 +1492,37 @@ sub specify { my $self = shift; my $device_type = $self->device_type(); - unless (defined $device_type) { - $self->error_throw("SNMP::Info::specify() - Could not get info from device"); + unless ( defined $device_type ) { + $self->error_throw( + "SNMP::Info::specify() - Could not get info from device"); return; } return $self if $device_type eq 'SNMP::Info'; # Load Subclass - # By evaling a string the contents of device_type now becomes a bareword. - eval "require $device_type;"; ## no critic + # By evaling a string the contents of device_type now becomes a bareword. + eval "require $device_type;"; ## no critic if ($@) { croak "SNMP::Info::specify() Loading $device_type Failed. $@\n"; } my $args = $self->args(); my $session = $self->session(); - my $sub_obj = $device_type->new(%$args,'Session'=>$session,'AutoSpecify' => 0); + my $sub_obj = $device_type->new( + %$args, + 'Session' => $session, + 'AutoSpecify' => 0 + ); - unless (defined $sub_obj) { - $self->error_throw("SNMP::Info::specify() - Could not connect with new class ($device_type)"); + unless ( defined $sub_obj ) { + $self->error_throw( + "SNMP::Info::specify() - Could not connect with new class ($device_type)" + ); return $self; } - $self->debug() and print "SNMP::Info::specify() - Changed Class to $device_type.\n"; + $self->debug() + and print "SNMP::Info::specify() - Changed Class to $device_type.\n"; return $sub_obj; } @@ -1433,7 +1535,7 @@ See Lorig_i_speed($partial); my $i_speed_high = undef; - foreach my $i (keys %$i_speed) { - if ($i_speed->{$i} eq "4294967295") { - $i_speed_high = $info->i_speed_high($partial) unless defined($i_speed_high); - $i_speed->{$i} = $i_speed_high->{$i} if ($i_speed_high->{$i}); - } + foreach my $i ( keys %$i_speed ) { + if ( $i_speed->{$i} eq "4294967295" ) { + $i_speed_high = $info->i_speed_high($partial) + unless defined($i_speed_high); + $i_speed->{$i} = $i_speed_high->{$i} if ( $i_speed_high->{$i} ); + } } return $i_speed; } @@ -1614,17 +1717,19 @@ If i_speed_high is available it will be used and multiplied by 1_000_000. =cut sub i_speed_raw { - my $info = shift; + my $info = shift; my $partial = shift; my $i_speed_raw = $info->orig_i_speed($partial); my $i_speed_high = undef; - foreach my $i (keys %$i_speed_raw) { - if ($i_speed_raw->{$i} eq "4294967295") { - $i_speed_high = $info->i_speed_high($partial) unless defined($i_speed_high); - $i_speed_raw->{$i} = ($i_speed_high->{$i} * 1_000_000) if ($i_speed_high->{$i}); - } + foreach my $i ( keys %$i_speed_raw ) { + if ( $i_speed_raw->{$i} eq "4294967295" ) { + $i_speed_high = $info->i_speed_high($partial) + unless defined($i_speed_high); + $i_speed_raw->{$i} = ( $i_speed_high->{$i} * 1_000_000 ) + if ( $i_speed_high->{$i} ); + } } return $i_speed_raw; } @@ -1977,9 +2082,9 @@ Returns if failed, or the return value from SNMP::Session::set() (snmp_errno) NOTE: You must be connected to your device with a C community string in order for set operations to work. -NOTE: This will only set data listed in %FUNCS and %GLOBALS. For data acquired -from overridden methods (subroutines) specific set_METHOD() subroutines will -need to be added if they haven't been already. +NOTE: This will only set data listed in %FUNCS and %GLOBALS. For data +acquired from overridden methods (subroutines) specific set_METHOD() +subroutines will need to be added if they haven't been already. =head1 Quiet Mode @@ -2010,7 +2115,7 @@ Used to flag if the MIBs have been loaded yet. =cut -$INIT = 0; +$INIT = 0; =item %GLOBALS @@ -2031,17 +2136,18 @@ the SNMP::Info methods. =cut %GLOBALS = ( - # from SNMPv2-MIB - 'id' => 'sysObjectID', - 'description' => 'sysDescr', - 'uptime' => 'sysUpTime', - 'contact' => 'sysContact', - 'name' => 'sysName', - 'location' => 'sysLocation', - 'layers' => 'sysServices', - 'ports' => 'ifNumber', - 'ipforwarding' => 'ipForwarding', - ); + + # from SNMPv2-MIB + 'id' => 'sysObjectID', + 'description' => 'sysDescr', + 'uptime' => 'sysUpTime', + 'contact' => 'sysContact', + 'name' => 'sysName', + 'location' => 'sysLocation', + 'layers' => 'sysServices', + 'ports' => 'ifNumber', + 'ipforwarding' => 'ipForwarding', +); =item %FUNCS @@ -2056,67 +2162,71 @@ ALTEON-TS-PHYSICAL-MIB::agPortCurCfgPortName. =cut -%FUNCS = ( - 'interfaces' => 'ifIndex', - 'i_name' => 'ifName', - # IF-MIB::IfEntry - 'i_index' => 'ifIndex', - 'i_description' => 'ifDescr', - 'i_type' => 'ifType', - 'i_mtu' => 'ifMtu', - 'i_speed' => 'ifSpeed', - 'i_mac' => 'ifPhysAddress', - 'i_up_admin' => 'ifAdminStatus', - 'i_up' => 'ifOperStatus', - 'i_lastchange' => 'ifLastChange', - 'i_octet_in' => 'ifInOctets', - 'i_pkts_ucast_in' => 'ifInUcastPkts', - 'i_pkts_nucast_in' => 'ifInNUcastPkts', - 'i_discards_in' => 'ifInDiscards', - 'i_errors_in' => 'ifInErrors', - 'i_bad_proto_in' => 'ifInUnknownProtos', - 'i_octet_out' => 'ifOutOctets', - 'i_pkts_ucast_out' => 'ifOutUcastPkts', - 'i_pkts_nucast_out' => 'ifOutNUcastPkts', - 'i_discards_out' => 'ifOutDiscards', - 'i_errors_out' => 'ifOutErrors', - 'i_qlen_out' => 'ifOutQLen', - 'i_specific' => 'ifSpecific', - # IP Address Table - 'ip_index' => 'ipAdEntIfIndex', - 'ip_table' => 'ipAdEntAddr', - 'ip_netmask' => 'ipAdEntNetMask', - 'ip_broadcast' => 'ipAdEntBcastAddr', - # ifXTable - Extension Table - 'i_speed_high' => 'ifHighSpeed', - 'i_pkts_multi_in' => 'ifInMulticastPkts', - 'i_pkts_multi_out' => 'ifOutMulticastPkts', - 'i_pkts_bcast_in' => 'ifInBroadcastPkts', - 'i_pkts_bcast_out' => 'ifOutBroadcastPkts', - 'i_octet_in64' => 'ifHCInOctets', - 'i_octet_out64' => 'ifHCOutOctets', - 'i_pkts_ucast_in64' => 'ifHCInUcastPkts', - 'i_pkts_ucast_out64' => 'ifHCOutUcastPkts', - 'i_pkts_multi_in64' => 'ifHCInMulticastPkts', - 'i_pkts_multi_out64' => 'ifHCOutMulticastPkts', - 'i_pkts_bcast_in64' => 'ifHCInBroadcastPkts', - 'i_pkts_bcast_out64' => 'ifHCOutBroadcastPkts', - 'i_alias' => 'ifAlias', - # IP Routing Table - 'ipr_route'=> 'ipRouteDest', - 'ipr_if' => 'ipRouteIfIndex', - 'ipr_1' => 'ipRouteMetric1', - 'ipr_2' => 'ipRouteMetric2', - 'ipr_3' => 'ipRouteMetric3', - 'ipr_4' => 'ipRouteMetric4', - 'ipr_5' => 'ipRouteMetric5', - 'ipr_dest' => 'ipRouteNextHop', - 'ipr_type' => 'ipRouteType', - 'ipr_proto'=> 'ipRouteProto', - 'ipr_age' => 'ipRouteAge', - 'ipr_mask' => 'ipRouteMask', - 'ipr_info' => 'ipRouteInfo', - ); +%FUNCS = ( + 'interfaces' => 'ifIndex', + 'i_name' => 'ifName', + + # IF-MIB::IfEntry + 'i_index' => 'ifIndex', + 'i_description' => 'ifDescr', + 'i_type' => 'ifType', + 'i_mtu' => 'ifMtu', + 'i_speed' => 'ifSpeed', + 'i_mac' => 'ifPhysAddress', + 'i_up_admin' => 'ifAdminStatus', + 'i_up' => 'ifOperStatus', + 'i_lastchange' => 'ifLastChange', + 'i_octet_in' => 'ifInOctets', + 'i_pkts_ucast_in' => 'ifInUcastPkts', + 'i_pkts_nucast_in' => 'ifInNUcastPkts', + 'i_discards_in' => 'ifInDiscards', + 'i_errors_in' => 'ifInErrors', + 'i_bad_proto_in' => 'ifInUnknownProtos', + 'i_octet_out' => 'ifOutOctets', + 'i_pkts_ucast_out' => 'ifOutUcastPkts', + 'i_pkts_nucast_out' => 'ifOutNUcastPkts', + 'i_discards_out' => 'ifOutDiscards', + 'i_errors_out' => 'ifOutErrors', + 'i_qlen_out' => 'ifOutQLen', + 'i_specific' => 'ifSpecific', + + # IP Address Table + 'ip_index' => 'ipAdEntIfIndex', + 'ip_table' => 'ipAdEntAddr', + 'ip_netmask' => 'ipAdEntNetMask', + 'ip_broadcast' => 'ipAdEntBcastAddr', + + # ifXTable - Extension Table + 'i_speed_high' => 'ifHighSpeed', + 'i_pkts_multi_in' => 'ifInMulticastPkts', + 'i_pkts_multi_out' => 'ifOutMulticastPkts', + 'i_pkts_bcast_in' => 'ifInBroadcastPkts', + 'i_pkts_bcast_out' => 'ifOutBroadcastPkts', + 'i_octet_in64' => 'ifHCInOctets', + 'i_octet_out64' => 'ifHCOutOctets', + 'i_pkts_ucast_in64' => 'ifHCInUcastPkts', + 'i_pkts_ucast_out64' => 'ifHCOutUcastPkts', + 'i_pkts_multi_in64' => 'ifHCInMulticastPkts', + 'i_pkts_multi_out64' => 'ifHCOutMulticastPkts', + 'i_pkts_bcast_in64' => 'ifHCInBroadcastPkts', + 'i_pkts_bcast_out64' => 'ifHCOutBroadcastPkts', + 'i_alias' => 'ifAlias', + + # IP Routing Table + 'ipr_route' => 'ipRouteDest', + 'ipr_if' => 'ipRouteIfIndex', + 'ipr_1' => 'ipRouteMetric1', + 'ipr_2' => 'ipRouteMetric2', + 'ipr_3' => 'ipRouteMetric3', + 'ipr_4' => 'ipRouteMetric4', + 'ipr_5' => 'ipRouteMetric5', + 'ipr_dest' => 'ipRouteNextHop', + 'ipr_type' => 'ipRouteType', + 'ipr_proto' => 'ipRouteProto', + 'ipr_age' => 'ipRouteAge', + 'ipr_mask' => 'ipRouteMask', + 'ipr_info' => 'ipRouteInfo', +); =item %MIBS @@ -2131,9 +2241,10 @@ $info->init() will throw an exception if a MIB does not load. =cut -%MIBS = ( - # The "main" MIBs are automagically loaded in Net-SNMP now. - ); +%MIBS = ( + + # The "main" MIBs are automagically loaded in Net-SNMP now. +); =item %MUNGE @@ -2150,22 +2261,23 @@ Sample %MUNGE: =cut -%MUNGE = ('ip' => \&munge_ip, - 'mac' => \&munge_mac, - 'i_mac' => \&munge_mac, - 'layers' => \&munge_dec2bin, - 'i_speed' => \&munge_speed, - 'i_speed_high' => \&munge_highspeed, - 'i_octet_in64' => \&munge_counter64, - 'i_octet_out64' => \&munge_counter64, - 'i_pkts_ucast_in64' => \&munge_counter64, - 'i_pkts_ucast_out64' => \&munge_counter64, - 'i_pkts_mutli_in64' => \&munge_counter64, - 'i_pkts_multi_out64' => \&munge_counter64, - 'i_pkts_bcast_in64' => \&munge_counter64, - 'i_pkts_bcast_out64' => \&munge_counter64, - 'i_up' => \&munge_i_up, - ); +%MUNGE = ( + 'ip' => \&munge_ip, + 'mac' => \&munge_mac, + 'i_mac' => \&munge_mac, + 'layers' => \&munge_dec2bin, + 'i_speed' => \&munge_speed, + 'i_speed_high' => \&munge_highspeed, + 'i_octet_in64' => \&munge_counter64, + 'i_octet_out64' => \&munge_counter64, + 'i_pkts_ucast_in64' => \&munge_counter64, + 'i_pkts_ucast_out64' => \&munge_counter64, + 'i_pkts_mutli_in64' => \&munge_counter64, + 'i_pkts_multi_out64' => \&munge_counter64, + 'i_pkts_bcast_in64' => \&munge_counter64, + 'i_pkts_bcast_out64' => \&munge_counter64, + 'i_up' => \&munge_i_up, +); =back @@ -2281,8 +2393,8 @@ These set the default value for an object upon creation. =item $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(). +debug status in new() unless 'Debug' argument passed in new(). Change +objects' debug status with $info->debug(). =cut @@ -2296,7 +2408,7 @@ instead of scalar string values. See note under Interface Statistics about =cut -$BIGINT = 0; +$BIGINT = 0; =item $NOSUCH @@ -2367,48 +2479,48 @@ Makes human friendly speed ratings using %SPEED_MAP =cut %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', - '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', - '2488000000' => 'OC-48', - ); + '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', + '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', + '2488000000' => 'OC-48', +); sub munge_speed { my $speed = shift; my $map = $SPEED_MAP{$speed}; - #print " $speed -> $map " if (defined $map); + #print " $speed -> $map " if (defined $map); return $map || $speed; } @@ -2420,22 +2532,25 @@ Makes human friendly speed ratings for C sub munge_highspeed { my $speed = shift; - my $fmt = "%d Mbps"; + my $fmt = "%d Mbps"; - if ($speed > 9999999) { + if ( $speed > 9999999 ) { $fmt = "%d Tbps"; - $speed /= 1000000; - } elsif ($speed > 999999) { + $speed /= 1000000; + } + elsif ( $speed > 999999 ) { $fmt = "%.1f Tbps"; $speed /= 1000000.0; - } elsif ($speed > 9999) { - $fmt = "%d Gbps"; - $speed /= 1000; - } elsif ($speed > 999) { - $fmt = "%.1f Gbps"; - $speed /= 1000.0; } - return sprintf($fmt, $speed); + elsif ( $speed > 9999 ) { + $fmt = "%d Gbps"; + $speed /= 1000; + } + elsif ( $speed > 999 ) { + $fmt = "%.1f Gbps"; + $speed /= 1000.0; + } + return sprintf( $fmt, $speed ); } =item munge_ip() @@ -2446,7 +2561,7 @@ Takes a binary IP and makes it dotted ASCII sub munge_ip { my $ip = shift; - return join('.',unpack('C4',$ip)); + return join( '.', unpack( 'C4', $ip ) ); } =item munge_mac() @@ -2460,7 +2575,7 @@ sub munge_mac { my $mac = shift; return unless defined $mac; return unless length $mac; - $mac = join(':',map { sprintf "%02x",$_ } unpack('C*',$mac)); + $mac = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $mac ) ); return $mac if $mac =~ /^([0-9A-F][0-9A-F]:){5}[0-9A-F][0-9A-F]$/i; return; } @@ -2476,7 +2591,7 @@ sub munge_prio_mac { my $mac = shift; return unless defined $mac; return unless length $mac; - $mac = join(':',map { sprintf "%02x",$_ } unpack('C*',$mac)); + $mac = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $mac ) ); return $mac if $mac =~ /^([0-9A-F][0-9A-F]:){7}[0-9A-F][0-9A-F]$/i; return; } @@ -2489,7 +2604,7 @@ Takes a binary octet stream and returns an ASCII hex string sub munge_octet2hex { my $oct = shift; - return join('',map {sprintf "%x",$_} unpack('C*',$oct)); + return join( '', map { sprintf "%x", $_ } unpack( 'C*', $oct ) ); } =item munge_dec2bin() @@ -2501,12 +2616,13 @@ Takes a binary char and returns its ASCII binary representation sub munge_dec2bin { my $num = shift; return unless defined $num; + #return unless length($num); - $num = unpack("B32",pack("N",$num)); + $num = unpack( "B32", pack( "N", $num ) ); # return last 8 characters only $num =~ s/.*(.{8})$/$1/; - return $num + return $num; } =item munge_bits @@ -2519,7 +2635,7 @@ sub munge_bits { my $bits = shift; return unless defined $bits; - return unpack("b*",$bits); + return unpack( "b*", $bits ); } =item munge_caps @@ -2532,7 +2648,7 @@ sub munge_caps { my $caps = shift; return unless defined $caps; - my $bits = substr(unpack("B*",$caps),-7); + my $bits = substr( unpack( "B*", $caps ), -7 ); return $bits; } @@ -2545,7 +2661,7 @@ See Math::BigInt for details. sub munge_counter64 { my $counter = shift; - return unless defined $counter; + return unless defined $counter; return $counter unless $BIGINT; my $bigint = Math::BigInt->new($counter); return $bigint; @@ -2586,7 +2702,7 @@ sub munge_port_list { my $oct = shift; return unless defined $oct; - my $list = [ split(//, unpack("B*", $oct)) ]; + my $list = [ split( //, unpack( "B*", $oct ) ) ]; return $list; } @@ -2600,7 +2716,7 @@ Removes nulls from a string # munge_null() - removes nulls (\0) sub munge_null { my $text = shift || return; - + $text =~ s/\0//g; return $text; } @@ -2635,37 +2751,41 @@ sub init { my $self = shift; &SNMP::initMib; - - my $version = $SNMP::VERSION; - my ($major,$minor,$rev) = split('\.',$version); - if ($major < 5){ + my $version = $SNMP::VERSION; + my ( $major, $minor, $rev ) = split( '\.', $version ); + + if ( $major < 5 ) { + # Seems to work under 4.2.0 - } elsif ($major == 5 and $minor == 0 and $rev < 2){ + } + elsif ( $major == 5 and $minor == 0 and $rev < 2 ) { carp("Net-SNMP 5.0.1 seems to be rather buggy. Upgrade.\n"); + # This is a bug in net-snmp 5.0.1 perl module # see http://groups.google.com/groups?th=47aed6bf7be6a0f5 &SNMP::init_snmp("perl"); } - + # Add MibDirs my $mibdirs = $self->{mibdirs} || []; - - foreach my $d (@$mibdirs){ + + foreach my $d (@$mibdirs) { next unless -d $d; - print "SNMP::Info::init() - Adding new mibdir:$d\n" if $self->debug(); + print "SNMP::Info::init() - Adding new mibdir:$d\n" if $self->debug(); &SNMP::addMibDirs($d); } - + my $mibs = $self->mibs(); - - foreach my $mib (keys %$mibs){ - #print "SNMP::Info::init() - Loading mib:$mib\n" if $self->debug(); + + foreach my $mib ( keys %$mibs ) { + + #print "SNMP::Info::init() - Loading mib:$mib\n" if $self->debug(); &SNMP::loadModules("$mib"); - unless (defined $SNMP::MIB{$mibs->{$mib}}){ + unless ( defined $SNMP::MIB{ $mibs->{$mib} } ) { croak "The $mib did not load. See README for $self->{class}\n"; - } + } } return; } @@ -2688,7 +2808,7 @@ Returns the class name of the object. =cut sub class { - my $self=shift; + my $self = shift; return $self->{class}; } @@ -2701,14 +2821,14 @@ If $info->debug() is true, then the error message is carped too. =cut sub error_throw { - my $self = shift; + my $self = shift; my $error = shift; return unless defined $error; $self->{error} = $error; - if ($self->debug()){ - $error =~ s/\n+$//; + if ( $self->debug() ) { + $error =~ s/\n+$//; carp($error); } return; @@ -2721,7 +2841,7 @@ Returns a reference to the %FUNCS hash. =cut sub funcs { - my $self=shift; + my $self = shift; return $self->{funcs}; } @@ -2732,7 +2852,7 @@ Returns a reference to the %GLOBALS hash. =cut sub globals { - my $self=shift; + my $self = shift; return $self->{globals}; } @@ -2743,7 +2863,7 @@ Returns a reference to the %MIBS hash. =cut sub mibs { - my $self=shift; + my $self = shift; return $self->{mibs}; } @@ -2754,7 +2874,7 @@ Returns a reference of the %MUNGE hash. =cut sub munge { - my $self=shift; + my $self = shift; return $self->{munge}; } @@ -2805,69 +2925,74 @@ Example: $info->name() calls autoload which calls $info->_global('name'). =cut -sub _global{ +sub _global { my $self = shift; my $attr = shift; my $sess = $self->session(); return unless defined $sess; - my $globals = $self->globals(); + my $globals = $self->globals(); my $oid; - if (exists $globals->{$attr}) { + if ( exists $globals->{$attr} ) { $oid = $globals->{$attr}; - unless ($oid =~ /\.\d+$/) { + unless ( $oid =~ /\.\d+$/ ) { $oid .= ".0"; } + # Check for fully qualified attr - if ($oid =~ /__/) { + if ( $oid =~ /__/ ) { $oid =~ s/__/::/; $oid =~ s/_/-/g; + # Need to translate fully qualified attr to full oid $oid = &SNMP::translateObj($oid); - unless (defined $oid) { - $self->error_throw("SNMP::Info::_load_attr: Can't translate $globals->{$attr}. Missing MIB?\n"); + unless ( defined $oid ) { + $self->error_throw( + "SNMP::Info::_load_attr: Can't translate $globals->{$attr}. Missing MIB?\n" + ); return; } } } else { - $oid = $attr; + $oid = $attr; } - + # Tag on .0 unless the leaf ends in .number - unless ($oid =~ /\.\d+$/) { + unless ( $oid =~ /\.\d+$/ ) { $oid .= ".0"; } - + print "SNMP::Info::_global $attr : $oid\n" if $self->debug(); my $val = $sess->get($oid); - + # mark as gotten. Even if it fails below, we don't want to keep failing. - $self->{"_$attr"}=undef; - - if ($sess->{ErrorStr} ){ + $self->{"_$attr"} = undef; + + if ( $sess->{ErrorStr} ) { $self->error_throw("SNMP::Info::_global($attr) $sess->{ErrorStr}"); return; } - - if (defined $val and $val eq 'NOSUCHOBJECT'){ + + if ( defined $val and $val eq 'NOSUCHOBJECT' ) { $self->error_throw("SNMP::Info::_global($attr) NOSUCHOBJECT"); return; } - if (defined $val and $val eq 'NOSUCHINSTANCE'){ + if ( defined $val and $val eq 'NOSUCHINSTANCE' ) { $self->error_throw("SNMP::Info::_global($attr) NOSUCHINSTANCE"); return; } + # Get the callback hash for data munging my $munge = $self->munge(); # Data Munging - if (defined $munge->{$attr}){ + if ( defined $munge->{$attr} ) { my $subref = $munge->{$attr}; $val = &$subref($val); - } + } # Save Cached Value $self->{"_$attr"} = $val; @@ -2891,24 +3016,26 @@ $info->_set('name','dog',3); =cut sub _set { - my ($self,$attr,$val,$iid,$type) = @_; + my ( $self, $attr, $val, $iid, $type ) = @_; my $varbind_list_ref; - if (!ref($attr)) { - $varbind_list_ref = [[$attr, $iid, $val, $type]]; + if ( !ref($attr) ) { + $varbind_list_ref = [ [ $attr, $iid, $val, $type ] ]; } - elsif (ref($attr) =~ /ARRAY/) { + elsif ( ref($attr) =~ /ARRAY/ ) { $varbind_list_ref = [$attr]; - $varbind_list_ref = $attr if ref($$attr[0]) =~ /ARRAY/; + $varbind_list_ref = $attr if ref( $$attr[0] ) =~ /ARRAY/; } else { - $self->error_throw("SNMP::Info::_set($attr,$val) - Failed. Invalid argument for attr."); + $self->error_throw( + "SNMP::Info::_set($attr,$val) - Failed. Invalid argument for attr." + ); } my $sess = $self->session(); return unless defined $sess; - my $funcs = $self->funcs(); + my $funcs = $self->funcs(); my $globals = $self->globals(); foreach my $var_list (@$varbind_list_ref) { @@ -2918,42 +3045,50 @@ sub _set { # Get rid of non-printable chars in $list_val for debug statements $list_val =~ s/\W//; + # Instance is 0 for scalars without a supplied instance $var_list->[1] = $list_iid = defined $list_iid ? $list_iid : '0'; # Check if this method is from a sub or from the tables. - if ($self->can($list_attr)){ - $self->error_throw("SNMP::Info::_set($list_attr,$list_val) - Failed. $list_attr is generated in a sub(). set_$list_attr sub required."); + if ( $self->can($list_attr) ) { + $self->error_throw( + "SNMP::Info::_set($list_attr,$list_val) - Failed. $list_attr is generated in a sub(). set_$list_attr sub required." + ); + # if sub set_attr() existed, we wouldn't have gotten this far. return; } # Lookup oid my $oid = undef; - $oid = $list_attr if SNMP::translateObj($list_attr); + $oid = $list_attr if SNMP::translateObj($list_attr); $oid = $globals->{$list_attr} if defined $globals->{$list_attr}; - $oid = $funcs->{$list_attr} if defined $funcs->{$list_attr}; + $oid = $funcs->{$list_attr} if defined $funcs->{$list_attr}; - unless (defined $oid) { - $self->error_throw("SNMP::Info::_set($list_attr,$list_val) - Failed to find $list_attr in \%GLOBALS or \%FUNCS or loaded MIB."); + unless ( defined $oid ) { + $self->error_throw( + "SNMP::Info::_set($list_attr,$list_val) - Failed to find $list_attr in \%GLOBALS or \%FUNCS or loaded MIB." + ); return; } # Check for fully qualified attr - if ($oid =~ /__/) { + if ( $oid =~ /__/ ) { $oid =~ s/__/::/; $oid =~ s/_/-/g; } - + $var_list->[0] = $oid; - $self->debug() and print "SNMP::Info::_set $list_attr.$list_iid ($oid.$list_iid) = $list_val\n"; + $self->debug() + and print + "SNMP::Info::_set $list_attr.$list_iid ($oid.$list_iid) = $list_val\n"; delete $self->{"_$list_attr"}; } my $rv = $sess->set($varbind_list_ref); - if ($sess->{ErrorStr}){ + if ( $sess->{ErrorStr} ) { $self->error_throw("SNMP::Info::_set $sess->{ErrorStr}"); return; } @@ -2972,7 +3107,8 @@ 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 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. @@ -2996,7 +3132,7 @@ Example: sub set_multi { my $self = shift; - return $self->_set( @_); + return $self->_set(@_); } =item $info->load_all() @@ -3018,16 +3154,16 @@ sub load_all { return unless defined $sess; my $funcs = $self->funcs(); - - foreach my $attrib (keys %$funcs) { - $attrib = "load_$attrib"; - $self->$attrib(); + + foreach my $attrib ( keys %$funcs ) { + $attrib = "load_$attrib"; + $self->$attrib(); } $self->{_all}++; - + return unless defined wantarray; - + return $self->store(); } @@ -3048,7 +3184,7 @@ sub all { $self->load_all() unless defined $self->{_all}; - return $self->store(); + return $self->store(); } =item $info->_load_attr() @@ -3065,7 +3201,7 @@ Called from $info->load_METHOD(); sub _load_attr { my $self = shift; - my ($attr,$leaf,$partial) = @_; + my ( $attr, $leaf, $partial ) = @_; my $ver = $self->snmp_ver(); my $nosuch = $self->nosuch(); @@ -3075,59 +3211,54 @@ sub _load_attr { return unless defined $sess; my $varleaf = $leaf; + # Check for fully qualified attr - if ($leaf =~ /__/) { + if ( $leaf =~ /__/ ) { $leaf =~ s/__/::/; $leaf =~ s/_/-/g; $varleaf = $leaf; } # Deal with partial entries. - if (defined $partial) { + if ( defined $partial ) { + # If we aren't supplied an OID translate - if ($leaf !~ /^[.\d]*$/) { + if ( $leaf !~ /^[.\d]*$/ ) { + # VarBind will not resolve mixed OID and leaf entries like # "ipRouteMask.255.255". So we convert to full OID my $oid = &SNMP::translateObj($leaf); - unless (defined $oid) { - $self->error_throw("SNMP::Info::_load_attr: Can't translate $leaf.$partial. Missing MIB?\n"); + unless ( defined $oid ) { + $self->error_throw( + "SNMP::Info::_load_attr: Can't translate $leaf.$partial. Missing MIB?\n" + ); return; } $varleaf = "$oid.$partial"; - } else { + } + else { $varleaf = "$leaf.$partial"; } } - $self->debug() and print "SNMP::Info::_load_attr $attr : $leaf", + $self->debug() + and print "SNMP::Info::_load_attr $attr : $leaf", defined $partial ? "($partial / $varleaf)" : '', "\n"; - my $var = new SNMP::Varbind([$varleaf]); + my $var = new SNMP::Varbind( [$varleaf] ); - # So devices speaking SNMP v.1 are not supposed to give out - # data from SNMP2, but most do. Net-SNMP, being very precise + # So devices speaking SNMP v.1 are not supposed to give out + # data from SNMP2, but most do. Net-SNMP, being very precise # will tell you that the SNMP OID doesn't exist for the device. # They have a flag RetryNoSuch that is used for get() operations, # but not for getnext(). We set this flag normally, and if we're # using V1, let's try and fetch the data even if we get one of those. -# This code is causing problems if we have an error from any other SNMP -# operation in the same SNMP session, $sess->{ErrorNum} will still contain -# the last error. We have not yet performed a get or getnext operation -# so if this code is needed, not sure it is at the correct location??? -# my $errornum = $sess->{ErrorNum}; -# if ($ver == 1 and $nosuch and $errornum and $sess->{ErrorStr} =~ /nosuch/i){ -# $errornum = 0; -# } elsif ($errornum){ -# $self->error_throw("SNMP::Info::_load_attr: Varbind $varleaf ".$sess->{ErrorStr}."\n"); -# return; -# } - my $localstore = undef; - my $errornum = 0; - my %seen = (); + my $errornum = 0; + my %seen = (); - my $vars = []; + my $vars = []; my $bulkwalk_no = $self->can('bulkwalk_no') ? $self->bulkwalk_no() : 0; my $bulkwalk_on = defined $self->{BulkWalk} ? $self->{BulkWalk} : 1; my $can_bulkwalk = $bulkwalk_on && !$bulkwalk_no; @@ -3135,45 +3266,55 @@ sub _load_attr { my $bulkwalk = $can_bulkwalk && $ver != 1; my $loopdetect = defined $self->{LoopDetect} ? $self->{LoopDetect} : 1; - if (defined $partial) { - # Try a GET, in case the partial is a leaf OID. - # Would like to only do this if we know the OID is - # long enough; implementing that would require a - # lot of MIB mucking. - my $try = $sess->get($var); + if ( defined $partial ) { + + # Try a GET, in case the partial is a leaf OID. + # Would like to only do this if we know the OID is + # long enough; implementing that would require a + # lot of MIB mucking. + my $try = $sess->get($var); $errornum = $sess->{ErrorNum}; - if (defined($try) && $errornum == 0 && $try !~ /^NOSUCH/) { - $var->[2] = $try; - $vars = [ $var ]; - $bulkwalk = 1; # fake a bulkwalk return + if ( defined($try) && $errornum == 0 && $try !~ /^NOSUCH/ ) { + $var->[2] = $try; + $vars = [$var]; + $bulkwalk = 1; # fake a bulkwalk return } + # We want to execute the while loop below for the getnext request. - if ($ver == 1 and $sess->{ErrorNum} and $sess->{ErrorStr} =~ /nosuch/i){ + if ( $ver == 1 + and $sess->{ErrorNum} + and $sess->{ErrorStr} =~ /nosuch/i ) + { $errornum = 0; - } + } } # Use BULKWALK if we can because its faster - if ($bulkwalk && @$vars == 0){ - ($vars) = $sess->bulkwalk(0, $repeaters, $var); - if($sess->{ErrorNum}) { - $self->error_throw("SNMP::Info::_load_atrr: BULKWALK ".$sess->{ErrorStr},"\n"); + if ( $bulkwalk && @$vars == 0 ) { + ($vars) = $sess->bulkwalk( 0, $repeaters, $var ); + if ( $sess->{ErrorNum} ) { + $self->error_throw( + "SNMP::Info::_load_atrr: BULKWALK " . $sess->{ErrorStr}, + "\n" ); return; } } - while (! $errornum ){ - if ($bulkwalk){ + while ( !$errornum ) { + if ($bulkwalk) { $var = shift @$vars or last; - } else { + } + else { + # GETNEXT instead of BULKWALK $sess->getnext($var); $errornum = $sess->{ErrorNum}; } - if ($self->debug() > 1) { + if ( $self->debug() > 1 ) { use Data::Dumper; - print "SNMP::Info::_load_attr $attr : leaf = $leaf , var = ", Dumper($var); + print "SNMP::Info::_load_attr $attr : leaf = $leaf , var = ", + Dumper($var); } # Check if we've left the requested subtree @@ -3181,14 +3322,15 @@ sub _load_attr { my $iid = $var->[1]; my $val = $var->[2]; - unless (defined $iid){ + unless ( defined $iid ) { $self->error_throw("SNMP::Info::_load_attr: $attr not here"); next; } - if ($loopdetect){ - # Check to see if we've already seen this IID (looping) - if (defined $seen{$iid} and $seen{$iid}){ + if ($loopdetect) { + + # Check to see if we've already seen this IID (looping) + if ( defined $seen{$iid} and $seen{$iid} ) { $self->error_throw("Looping on: $attr iid:$iid. "); last; } @@ -3198,46 +3340,52 @@ sub _load_attr { } # Check to make sure we are still in partial land - if (defined $partial and $iid !~ /^$partial$/ and $iid !~ /^$partial\./){ + if ( defined $partial + and $iid !~ /^$partial$/ + and $iid !~ /^$partial\./ ) + { $self->debug() and print "$iid makes us leave partial land.\n"; last; } # Check if last element, V2 devices may report ENDOFMIBVIEW even if # instance or object doesn't exist. - if ($val eq 'ENDOFMIBVIEW'){ - last; - } - # Similarly for SNMPv1 - noSuchName return results in both $iid - # and $val being empty strings. - if ($val eq '' and $iid eq ''){ + if ( $val eq 'ENDOFMIBVIEW' ) { last; } - if ($val eq 'NOSUCHOBJECT'){ - $self->error_throw("SNMP::Info::_load_attr: $attr : NOSUCHOBJECT"); + # Similarly for SNMPv1 - noSuchName return results in both $iid + # and $val being empty strings. + if ( $val eq '' and $iid eq '' ) { + last; + } + + if ( $val eq 'NOSUCHOBJECT' ) { + $self->error_throw( + "SNMP::Info::_load_attr: $attr : NOSUCHOBJECT"); next; } - if ($val eq 'NOSUCHINSTANCE'){ - $self->error_throw("SNMP::Info::_load_attr: $attr : NOSUCHINSTANCE"); + if ( $val eq 'NOSUCHINSTANCE' ) { + $self->error_throw( + "SNMP::Info::_load_attr: $attr : NOSUCHINSTANCE"); next; } # Data Munging # Checks for an entry in %munge and runs the subroutine - if (defined $munge->{$attr}){ + if ( defined $munge->{$attr} ) { my $subref = $munge->{$attr}; $val = &$subref($val); - } + } - $localstore->{$iid}=$val; - } + $localstore->{$iid} = $val; + } # Cache data if we are not getting partial data: - if (!defined $partial){ + if ( !defined $partial ) { $self->{"_${attr}"}++; - $store->{$attr}=$localstore; - } + $store->{$attr} = $localstore; + } return $localstore; } @@ -3258,7 +3406,7 @@ sub _show_attr { my $attr = shift; my $store = $self->store(); - + return $store->{$attr}; } @@ -3270,33 +3418,37 @@ Returns true or false based upon snmp connectivity to an IP. sub snmp_connect_ip { my $self = shift; - my $ip = shift; - my $ver = $self->snmp_ver(); + my $ip = shift; + my $ver = $self->snmp_ver(); my $comm = $self->snmp_comm(); - - return if ($ip eq '0.0.0.0') or ($ip =~ /^127\./); - + + return if ( $ip eq '0.0.0.0' ) or ( $ip =~ /^127\./ ); + # Create session object - my $snmp_test = new SNMP::Session( 'DestHost' => $ip, 'Community' => $comm, 'Version' => $ver); + my $snmp_test = new SNMP::Session( + 'DestHost' => $ip, + 'Community' => $comm, + 'Version' => $ver + ); # No session object created - unless (defined $snmp_test){ + unless ( defined $snmp_test ) { return; } - + # Session object created but SNMP connection failed. my $sess_err = $snmp_test->{ErrorStr} || ''; - if ($sess_err){ + if ($sess_err) { return; } - + # Try to get some data from IP my $layers = $snmp_test->get('sysServices.0'); - + $sess_err = $snmp_test->{ErrorStr} || ''; - if ($sess_err){ + if ($sess_err) { return; - } + } return 1; @@ -3310,18 +3462,19 @@ returns the packed bitmask =cut sub modify_port_list { - my ($self, $portlist, $offset, $replacement) = @_; + my ( $self, $portlist, $offset, $replacement ) = @_; print "Original port list: @$portlist \n" if $self->debug(); @$portlist[$offset] = $replacement; + # Some devices do not populate the portlist with all possible ports. # If we have lengthened the list fill all undefined elements with zero. foreach my $item (@$portlist) { - $item = '0' unless (defined($item)); + $item = '0' unless ( defined($item) ); } print "Modified port list: @$portlist \n" if $self->debug(); - return pack("B*", join('', @$portlist)); + return pack( "B*", join( '', @$portlist ) ); } =back @@ -3368,108 +3521,121 @@ subclass. =cut sub AUTOLOAD { - my $self = shift; + my $self = shift; my $sub_name = $AUTOLOAD; return if $sub_name =~ /DESTROY$/; # package is the first part - (my $package = $sub_name) =~ s/[^:]*$//; + ( my $package = $sub_name ) =~ s/[^:]*$//; + # Sub name is the last part $sub_name =~ s/.*://; + # Enable calls to SUPER class to find autoloaded methods $package =~ s/SUPER::$//; # 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. - if (ref($self) !~ /^SNMP::Info/) { + if ( ref($self) !~ /^SNMP::Info/ ) { + # croak reports one level too high. die reports here. # I would really like to get the place that's likely to # have the typo, but perl doesn't want me to. - croak("SNMP::Info::AUTOLOAD($AUTOLOAD) called with no class (probably typo of function call to $sub_name)"); + croak( + "SNMP::Info::AUTOLOAD($AUTOLOAD) called with no class (probably typo of function call to $sub_name)" + ); } my $attr = $sub_name; $attr =~ s/^(load|set)_//; $attr =~ s/^orig_//; - - # Let's use the %GLOBALS and %FUNCS from the class that + + # Let's use the %GLOBALS and %FUNCS from the class that # inherited us. - my (%funcs,%globals); + my ( %funcs, %globals ); { - no strict 'refs'; ## no critic - %funcs = %{$package.'FUNCS'}; - %globals = %{$package.'GLOBALS'}; + no strict 'refs'; ## no critic + %funcs = %{ $package . 'FUNCS' }; + %globals = %{ $package . 'GLOBALS' }; } - # Check if we were called with a MIB leaf node name + # Check if we were called with a MIB leaf node name my $trans = SNMP::translateObj($attr); - - my $mib_leaf = 0; + + my $mib_leaf = 0; my $table_leaf = 0; if ( defined($trans) ) { my $mib = $SNMP::MIB{$trans}; + # We're not a leaf if we don't have access attribute # Don't bother if not-accessable my $access = $$mib{'access'}; $mib_leaf = 1 if ( defined $access && $access !~ /NoAccess/ ); - if ($self->debug() and !$mib_leaf) { + if ( $self->debug() and !$mib_leaf ) { print "SNMP::Info::AUTOLOAD($attr) Leaf not accessable.\n"; } + # If we're a leaf check to see if we are in a table if ($mib_leaf) { - my $indexes = $$mib{'parent'}{'indexes'}; - $table_leaf = 1 if (defined $indexes && scalar( @{$indexes} ) > 0); + my $indexes = $$mib{'parent'}{'indexes'}; + $table_leaf = 1 + if ( defined $indexes && scalar( @{$indexes} ) > 0 ); } } - unless( defined $funcs{$attr} or - defined $globals{$attr} or - defined $mib_leaf ) { - $self->error_throw("SNMP::Info::AUTOLOAD($attr) Attribute not found in this device class."); + unless ( defined $funcs{$attr} + or defined $globals{$attr} + or defined $mib_leaf ) + { + $self->error_throw( + "SNMP::Info::AUTOLOAD($attr) Attribute not found in this device class." + ); return; } - + # Check for load_ ing. - if ($sub_name =~ /^load_/){ + if ( $sub_name =~ /^load_/ ) { if ( defined $globals{$attr} ) { - return $self->_global( $attr ); + return $self->_global($attr); } if ( defined $funcs{$attr} ) { - return $self->_load_attr( $attr,$funcs{$attr},@_ ); + return $self->_load_attr( $attr, $funcs{$attr}, @_ ); } if ( $mib_leaf and !$table_leaf ) { - return $self->_global( $attr ); - } - if ( $table_leaf ) { - return $self->_load_attr( $attr,$attr,@_ ); + return $self->_global($attr); + } + if ($table_leaf) { + return $self->_load_attr( $attr, $attr, @_ ); } } # Check for set_ ing. - if ($sub_name =~ /^set_/){ - return $self->_set( $attr, @_); + if ( $sub_name =~ /^set_/ ) { + return $self->_set( $attr, @_ ); } # Next check for entry in %GLOBALS - if (defined $globals{$attr} or ( $mib_leaf and !$table_leaf )){ + if ( defined $globals{$attr} or ( $mib_leaf and !$table_leaf ) ) { + # Return Cached Value if exists return $self->{"_${attr}"} if exists $self->{"_${attr}"}; + # Fetch New Value - return $self->_global( $attr ); + return $self->_global($attr); } - # Otherwise we must be listed in %FUNCS + # Otherwise we must be listed in %FUNCS # Load data if it both not cached and we are not requesting partial info. if ( defined $funcs{$attr} ) { - return $self->_load_attr( $attr, $funcs{$attr},@_ ) - unless (defined $self->{"_${attr}"} and !scalar(@_)); + return $self->_load_attr( $attr, $funcs{$attr}, @_ ) + unless ( defined $self->{"_${attr}"} and !scalar(@_) ); } - if ( $table_leaf ) { - return $self->_load_attr( $attr, $attr,@_ ) - unless (defined $self->{"_${attr}"} and !scalar(@_)); + if ($table_leaf) { + return $self->_load_attr( $attr, $attr, @_ ) + unless ( defined $self->{"_${attr}"} and !scalar(@_) ); } return $self->_show_attr($attr); @@ -3479,10 +3645,10 @@ sub AUTOLOAD { =head1 COPYRIGHT AND LICENSE Changes from SNMP::Info Version 0.7 and on are: -Copyright (c)2003, 2004 Max Baker - All rights reserved. +Copyright (c) 2003-2008 Max Baker - All rights reserved. Original Code is: -Copyright (c) 2002-3, Regents of the University of California +Copyright (c) 2002-2003, Regents of the University of California All rights reserved. Redistribution and use in source and binary forms, with or without @@ -3490,22 +3656,22 @@ 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. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Santa Cruz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =cut diff --git a/Info/Airespace.pm b/Info/Airespace.pm index 83ea50bc..bf245b71 100644 --- a/Info/Airespace.pm +++ b/Info/Airespace.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,117 +34,126 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::Airespace::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::Airespace::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Airespace::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::MIBS, - 'AIRESPACE-WIRELESS-MIB' => 'bsnAPName', - 'AIRESPACE-SWITCHING-MIB' => 'agentInventorySerialNumber', - ); +%MIBS = ( + %SNMP::Info::MIBS, + 'AIRESPACE-WIRELESS-MIB' => 'bsnAPName', + 'AIRESPACE-SWITCHING-MIB' => 'agentInventorySerialNumber', +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - 'airespace_type' => 'agentInventoryMachineType', - 'airespace_model' => 'agentInventoryMachineModel', - 'airespace_serial' => 'agentInventorySerialNumber', - 'airespace_maint_ver' => 'agentInventoryMaintenanceLevel', - 'airespace_mac' => 'agentInventoryBurnedInMacAddress', - 'airespace_os' => 'agentInventoryOperatingSystem', - 'airespace_vendor' => 'agentInventoryManufacturerName', - 'airespace_prod_name' => 'agentInventoryProductName', - 'os_ver' => 'agentInventoryProductVersion', - 'airespace_bssid_mode' => 'agentNetworkBroadcastSsidMode', - 'airespace_mc_mode' => 'agentNetworkMulticastMode', - 'airespace_lwapp_mode' => 'agentSwitchLwappTransportMode', - 'airespace_ul_mode' => 'agentTransferUploadMode', - 'airespace_ul_ip' => 'agentTransferUploadServerIP', - 'airespace_ul_path' => 'agentTransferUploadPath', - 'airespace_ul_file' => 'agentTransferUploadFilename', - 'airespace_ul_type' => 'agentTransferUploadDataType', - 'airespace_ul_start' => 'agentTransferUploadStart', - 'airespace_ul_status' => 'agentTransferUploadStatus', - ); + %SNMP::Info::GLOBALS, + 'airespace_type' => 'agentInventoryMachineType', + 'airespace_model' => 'agentInventoryMachineModel', + 'airespace_serial' => 'agentInventorySerialNumber', + 'airespace_maint_ver' => 'agentInventoryMaintenanceLevel', + 'airespace_mac' => 'agentInventoryBurnedInMacAddress', + 'airespace_os' => 'agentInventoryOperatingSystem', + 'airespace_vendor' => 'agentInventoryManufacturerName', + 'airespace_prod_name' => 'agentInventoryProductName', + 'os_ver' => 'agentInventoryProductVersion', + 'airespace_bssid_mode' => 'agentNetworkBroadcastSsidMode', + 'airespace_mc_mode' => 'agentNetworkMulticastMode', + 'airespace_lwapp_mode' => 'agentSwitchLwappTransportMode', + 'airespace_ul_mode' => 'agentTransferUploadMode', + 'airespace_ul_ip' => 'agentTransferUploadServerIP', + 'airespace_ul_path' => 'agentTransferUploadPath', + 'airespace_ul_file' => 'agentTransferUploadFilename', + 'airespace_ul_type' => 'agentTransferUploadDataType', + 'airespace_ul_start' => 'agentTransferUploadStart', + 'airespace_ul_status' => 'agentTransferUploadStatus', +); -%FUNCS = ( - %SNMP::Info::FUNCS, - # AIRESPACE-WIRELESS-MIB::bsnDot11EssTable - 'airespace_ess_idx' => 'bsnDot11EssIndex', - 'airespace_ess_ssid' => 'bsnDot11EssSsid', - 'airespace_ess_macflt' => 'bsnDot11EssMacFiltering', - 'airespace_ess_status' => 'bsnDot11EssAdminStatus', - 'airespace_ess_sec_auth' => 'bsnDot11EssSecurityAuthType', - 'airespace_ess_radio_pol' => 'bsnDot11EssRadioPolicy', - 'airespace_ess_qos' => 'bsnDot11EssQualityOfService', - 'airespace_ess_ifname' => 'bsnDot11EssInterfaceName', - 'airespace_ess_aclname' => 'bsnDot11EssAclName', - # AIRESPACE-WIRELESS-MIB::bsnAPTable - 'airespace_ap_mac' => 'bsnAPDot3MacAddress', - 'airespace_ap_name' => 'bsnAPName', - 'airespace_ap_ip' => 'bsnApIpAddress', - 'airespace_ap_loc' => 'bsnAPLocation', - 'airespace_ap_sw' => 'bsnAPSoftwareVersion', - 'airespace_ap_fw' => 'bsnAPBootVersion', - 'airespace_ap_model' => 'bsnAPModel', - 'airespace_ap_serial' => 'bsnAPSerialNumber', - 'airespace_ap_type' => 'bsnAPType', - 'airespace_ap_status' => 'bsnAPAdminStatus', - # AIRESPACE-WIRELESS-MIB::bsnAPIfTable - 'airespace_apif_slot' => 'bsnAPIfSlotId', - 'airespace_apif_type' => 'bsnAPIfType', - 'airespace_apif_ch_num' => 'bsnAPIfPhyChannelNumber', - 'airespace_apif_power' => 'bsnAPIfPhyTxPowerLevel', - 'airespace_apif' => 'bsnAPIfOperStatus', - 'airespace_apif_oride' => 'bsnAPIfWlanOverride', - 'airespace_apif_admin' => 'bsnAPIfAdminStatus', - # AIRESPACE-WIRELESS-MIB::bsnMobileStationTable - 'airespace_sta_mac' => 'bsnMobileStationAPMacAddr', - 'fw_mac' => 'bsnMobileStationMacAddress', - 'airespace_sta_slot' => 'bsnMobileStationAPIfSlotId', - 'airespace_sta_ess_idx' => 'bsnMobileStationEssIndex', - 'airespace_sta_ssid' => 'bsnMobileStationSsid', - 'airespace_sta_delete' => 'bsnMobileStationDeleteAction', - # AIRESPACE-WIRELESS-MIB::bsnUsersTable - 'airespace_user_name' => 'bsnUserName', - 'airespace_user_pw' => 'bsnUserPassword', - 'airespace_user_ess_idx' => 'bsnUserEssIndex', - 'airespace_user_access' => 'bsnUserAccessMode', - 'airespace_user_type' => 'bsnUserType', - 'airespace_user_ifname' => 'bsnUserInterfaceName', - 'airespace_user_rstat' => 'bsnUserRowStatus', - # AIRESPACE-WIRELESS-MIB::bsnBlackListClientTable - 'airespace_bl_mac' => 'bsnBlackListClientMacAddress', - 'airespace_bl_descr' => 'bsnBlackListClientDescription', - 'airespace_bl_rstat' => 'bsnBlackListClientRowStatus', - # AIRESPACE-WIRELESS-MIB::bsnAPIfWlanOverrideTable - 'airespace_oride_id' => 'bsnAPIfWlanOverrideId', - 'airespace_oride_ssid' => 'bsnAPIfWlanOverrideSsid', - # AIRESPACE-SWITCHING-MIB::agentInterfaceConfigTable - 'airespace_if_name' => 'agentInterfaceName', - 'airespace_if_vlan' => 'agentInterfaceVlanId', - 'airespace_if_type' => 'agentInterfaceType', - 'airespace_if_mac' => 'agentInterfaceMacAddress', - 'airespace_if_ip' => 'agentInterfaceIPAddress', - 'airespace_if_mask' => 'agentInterfaceIPNetmask', - 'airespace_if_acl' => 'agentInterfaceAclName', - 'airespace_if_rstat' => 'agentInterfaceRowStatus', - # AIRESPACE-SWITCHING-MIB::agentPortConfigTable - 'airespace_duplex_admin' => 'agentPortPhysicalMode', - 'airespace_duplex' => 'agentPortPhysicalStatus', - ); +%FUNCS = ( + %SNMP::Info::FUNCS, -%MUNGE = ( - %SNMP::Info::MUNGE, - 'airespace_ap_mac' => \&SNMP::Info::munge_mac, - 'fw_port' => \&SNMP::Info::munge_mac, - 'airespace_bl_mac' => \&SNMP::Info::munge_mac, - 'airespace_if_mac' => \&SNMP::Info::munge_mac, - 'airespace_sta_mac' => \&SNMP::Info::munge_mac, - ); + # AIRESPACE-WIRELESS-MIB::bsnDot11EssTable + 'airespace_ess_idx' => 'bsnDot11EssIndex', + 'airespace_ess_ssid' => 'bsnDot11EssSsid', + 'airespace_ess_macflt' => 'bsnDot11EssMacFiltering', + 'airespace_ess_status' => 'bsnDot11EssAdminStatus', + 'airespace_ess_sec_auth' => 'bsnDot11EssSecurityAuthType', + 'airespace_ess_radio_pol' => 'bsnDot11EssRadioPolicy', + 'airespace_ess_qos' => 'bsnDot11EssQualityOfService', + 'airespace_ess_ifname' => 'bsnDot11EssInterfaceName', + 'airespace_ess_aclname' => 'bsnDot11EssAclName', + + # AIRESPACE-WIRELESS-MIB::bsnAPTable + 'airespace_ap_mac' => 'bsnAPDot3MacAddress', + 'airespace_ap_name' => 'bsnAPName', + 'airespace_ap_ip' => 'bsnApIpAddress', + 'airespace_ap_loc' => 'bsnAPLocation', + 'airespace_ap_sw' => 'bsnAPSoftwareVersion', + 'airespace_ap_fw' => 'bsnAPBootVersion', + 'airespace_ap_model' => 'bsnAPModel', + 'airespace_ap_serial' => 'bsnAPSerialNumber', + 'airespace_ap_type' => 'bsnAPType', + 'airespace_ap_status' => 'bsnAPAdminStatus', + + # AIRESPACE-WIRELESS-MIB::bsnAPIfTable + 'airespace_apif_slot' => 'bsnAPIfSlotId', + 'airespace_apif_type' => 'bsnAPIfType', + 'airespace_apif_ch_num' => 'bsnAPIfPhyChannelNumber', + 'airespace_apif_power' => 'bsnAPIfPhyTxPowerLevel', + 'airespace_apif' => 'bsnAPIfOperStatus', + 'airespace_apif_oride' => 'bsnAPIfWlanOverride', + 'airespace_apif_admin' => 'bsnAPIfAdminStatus', + + # AIRESPACE-WIRELESS-MIB::bsnMobileStationTable + 'airespace_sta_mac' => 'bsnMobileStationAPMacAddr', + 'fw_mac' => 'bsnMobileStationMacAddress', + 'airespace_sta_slot' => 'bsnMobileStationAPIfSlotId', + 'airespace_sta_ess_idx' => 'bsnMobileStationEssIndex', + 'airespace_sta_ssid' => 'bsnMobileStationSsid', + 'airespace_sta_delete' => 'bsnMobileStationDeleteAction', + + # AIRESPACE-WIRELESS-MIB::bsnUsersTable + 'airespace_user_name' => 'bsnUserName', + 'airespace_user_pw' => 'bsnUserPassword', + 'airespace_user_ess_idx' => 'bsnUserEssIndex', + 'airespace_user_access' => 'bsnUserAccessMode', + 'airespace_user_type' => 'bsnUserType', + 'airespace_user_ifname' => 'bsnUserInterfaceName', + 'airespace_user_rstat' => 'bsnUserRowStatus', + + # AIRESPACE-WIRELESS-MIB::bsnBlackListClientTable + 'airespace_bl_mac' => 'bsnBlackListClientMacAddress', + 'airespace_bl_descr' => 'bsnBlackListClientDescription', + 'airespace_bl_rstat' => 'bsnBlackListClientRowStatus', + + # AIRESPACE-WIRELESS-MIB::bsnAPIfWlanOverrideTable + 'airespace_oride_id' => 'bsnAPIfWlanOverrideId', + 'airespace_oride_ssid' => 'bsnAPIfWlanOverrideSsid', + + # AIRESPACE-SWITCHING-MIB::agentInterfaceConfigTable + 'airespace_if_name' => 'agentInterfaceName', + 'airespace_if_vlan' => 'agentInterfaceVlanId', + 'airespace_if_type' => 'agentInterfaceType', + 'airespace_if_mac' => 'agentInterfaceMacAddress', + 'airespace_if_ip' => 'agentInterfaceIPAddress', + 'airespace_if_mask' => 'agentInterfaceIPNetmask', + 'airespace_if_acl' => 'agentInterfaceAclName', + 'airespace_if_rstat' => 'agentInterfaceRowStatus', + + # AIRESPACE-SWITCHING-MIB::agentPortConfigTable + 'airespace_duplex_admin' => 'agentPortPhysicalMode', + 'airespace_duplex' => 'agentPortPhysicalStatus', +); + +%MUNGE = ( + %SNMP::Info::MUNGE, + 'airespace_ap_mac' => \&SNMP::Info::munge_mac, + 'fw_port' => \&SNMP::Info::munge_mac, + 'airespace_bl_mac' => \&SNMP::Info::munge_mac, + 'airespace_if_mac' => \&SNMP::Info::munge_mac, + 'airespace_sta_mac' => \&SNMP::Info::munge_mac, +); sub layers { return '00000011'; @@ -152,7 +161,7 @@ sub layers { sub serial { my $airespace = shift; - my $sn = $airespace->airespace_serial(); + my $sn = $airespace->airespace_serial(); return unless defined $sn; return $sn; @@ -165,12 +174,12 @@ sub i_index { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->orig_i_index($partial) || {}; - my $ap_index = $airespace->airespace_apif_slot($partial) || {}; - my $if_index = $airespace->airespace_if_name($partial) || {}; + my $i_index = $airespace->orig_i_index($partial) || {}; + my $ap_index = $airespace->airespace_apif_slot($partial) || {}; + my $if_index = $airespace->airespace_if_name($partial) || {}; my %if_index; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; @@ -178,20 +187,21 @@ sub i_index { } # Get Attached APs as Interfaces - foreach my $ap_id (keys %$ap_index){ + foreach my $ap_id ( keys %$ap_index ) { - if ($ap_id =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)\.(\d+)/) { - my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$1)); + if ( $ap_id =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)\.(\d+)/ ) { + my $mac = join( ':', + map { sprintf( "%02x", $_ ) } split( /\./, $1 ) ); my $slot = $2; - next unless ( (defined $mac) and (defined $slot) ); + next unless ( ( defined $mac ) and ( defined $slot ) ); $if_index{$ap_id} = "$mac.$slot"; } } # Get Switch Interfaces from Interface Config Table - foreach my $if_id (keys %$if_index){ - my $name = $if_index->{$if_id}; + foreach my $if_id ( keys %$if_index ) { + my $name = $if_index->{$if_id}; next unless defined $name; $if_index{$if_id} = $name; @@ -204,19 +214,19 @@ sub interfaces { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; + my $i_index = $airespace->i_index($partial) || {}; my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { - $if{$iid} = "1.$index"; + if ( $index =~ /^\d+$/ ) { + $if{$iid} = "1.$index"; } else { - $if{$iid} = $index; + $if{$iid} = $index; } } return \%if; @@ -226,22 +236,22 @@ sub i_name { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - my $i_name = $airespace->orig_i_name($partial) || {}; - my $ap_name = $airespace->airespace_ap_name($partial) || {}; - + my $i_index = $airespace->i_index($partial) || {}; + my $i_name = $airespace->orig_i_name($partial) || {}; + my $ap_name = $airespace->airespace_ap_name($partial) || {}; + my %i_name; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { + if ( $index =~ /^\d+$/ ) { my $name = $i_name->{$iid}; next unless defined $name; $i_name{$iid} = $name; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { my $idx = $iid; $idx =~ s/\.\d+$//; my $name = $ap_name->{$idx}; @@ -250,7 +260,7 @@ sub i_name { } else { - $i_name{$iid} = $index; + $i_name{$iid} = $index; } } return \%i_name; @@ -260,22 +270,22 @@ sub i_description { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - my $i_descr = $airespace->orig_i_description($partial) || {}; - my $ap_loc = $airespace->airespace_ap_loc($partial) || {}; + my $i_index = $airespace->i_index($partial) || {}; + my $i_descr = $airespace->orig_i_description($partial) || {}; + my $ap_loc = $airespace->airespace_ap_loc($partial) || {}; my %descr; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { + if ( $index =~ /^\d+$/ ) { my $descr = $i_descr->{$iid}; next unless defined $descr; $descr{$iid} = $descr; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { my $idx = $iid; $idx =~ s/\.\d+$//; my $name = $ap_loc->{$idx}; @@ -294,23 +304,23 @@ sub i_type { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - my $i_descr = $airespace->orig_i_type($partial) || {}; + my $i_index = $airespace->i_index($partial) || {}; + my $i_descr = $airespace->orig_i_type($partial) || {}; my $apif_type = $airespace->airespace_apif_type($partial) || {}; - my $if_type = $airespace->airespace_if_type($partial) || {}; + my $if_type = $airespace->airespace_if_type($partial) || {}; my %i_type; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { + if ( $index =~ /^\d+$/ ) { my $descr = $i_descr->{$iid}; next unless defined $descr; $i_type{$iid} = $descr; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { my $type = $apif_type->{$iid}; next unless defined $type; $i_type{$iid} = $type; @@ -328,80 +338,80 @@ sub i_up { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - my $i_up = $airespace->orig_i_up($partial) || {}; + my $i_index = $airespace->i_index($partial) || {}; + my $i_up = $airespace->orig_i_up($partial) || {}; my $apif_up = $airespace->airespace_apif($partial) || {}; my %i_up; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { + if ( $index =~ /^\d+$/ ) { my $stat = $i_up->{$iid}; next unless defined $stat; $i_up{$iid} = $stat; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { my $stat = $apif_up->{$iid}; next unless defined $stat; - $i_up{$iid} = $stat; + $i_up{$iid} = $stat; } - + else { next; } } - return \%i_up; + return \%i_up; } sub i_up_admin { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - my $i_up = $airespace->orig_i_up($partial) || {}; + my $i_index = $airespace->i_index($partial) || {}; + my $i_up = $airespace->orig_i_up($partial) || {}; my $apif_up = $airespace->airespace_apif_admin($partial) || {}; my %i_up_admin; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { + if ( $index =~ /^\d+$/ ) { my $stat = $i_up->{$iid}; next unless defined $stat; $i_up_admin{$iid} = $stat; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { my $stat = $apif_up->{$iid}; next unless defined $stat; - $i_up_admin{$iid} = $stat; + $i_up_admin{$iid} = $stat; } - + else { next; } } - return \%i_up_admin; + return \%i_up_admin; } sub i_mac { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - my $i_mac = $airespace->orig_i_mac($partial) || {}; - my $if_mac = $airespace->airespace_if_mac($partial) || {}; - + my $i_index = $airespace->i_index($partial) || {}; + my $i_mac = $airespace->orig_i_mac($partial) || {}; + my $if_mac = $airespace->airespace_if_mac($partial) || {}; + my %i_mac; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { + if ( $index =~ /^\d+$/ ) { my $mac = $i_mac->{$iid}; next unless defined $mac; $i_mac{$iid} = $mac; @@ -415,44 +425,44 @@ sub i_mac { my $mac = $if_mac->{$iid}; next unless defined $mac; next if $mac =~ /00:00:00:00:00:00/; - $i_mac{$iid} = $mac; + $i_mac{$iid} = $mac; } } - return \%i_mac; + return \%i_mac; } sub i_vlan { my $airespace = shift; my $partial = shift; - my $if_vlan = $airespace->airespace_if_vlan($partial) || {}; - + my $if_vlan = $airespace->airespace_if_vlan($partial) || {}; + my %i_vlan; - foreach my $iid (keys %$if_vlan){ + foreach my $iid ( keys %$if_vlan ) { my $vlan = $if_vlan->{$iid}; next unless defined $vlan; $i_vlan{$iid} = $vlan; } - return \%i_vlan; + return \%i_vlan; } sub i_duplex { my $airespace = shift; my $partial = shift; - - my $ap_duplex = $airespace->airespace_duplex($partial) || {}; + + my $ap_duplex = $airespace->airespace_duplex($partial) || {}; my %i_duplex; - foreach my $if (keys %$ap_duplex){ + foreach my $if ( keys %$ap_duplex ) { my $duplex = $ap_duplex->{$if}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; $duplex = 'auto' if $duplex =~ /auto/i; - $i_duplex{$if}=$duplex; + $i_duplex{$if} = $duplex; } return \%i_duplex; } @@ -461,17 +471,17 @@ sub i_duplex_admin { my $airespace = shift; my $partial = shift; - my $ap_duplex_admin = $airespace->airespace_duplex_admin($partial) || {}; + my $ap_duplex_admin = $airespace->airespace_duplex_admin($partial) || {}; my %i_duplex_admin; - foreach my $if (keys %$ap_duplex_admin){ + foreach my $if ( keys %$ap_duplex_admin ) { my $duplex = $ap_duplex_admin->{$if}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; $duplex = 'auto' if $duplex =~ /auto/i; - $i_duplex_admin{$if}=$duplex; + $i_duplex_admin{$if} = $duplex; } return \%i_duplex_admin; } @@ -481,20 +491,20 @@ sub ip_index { my $partial = shift; my $ip_index = $airespace->orig_ip_index($partial) || {}; - my $if_ip = $airespace->airespace_if_ip() || {}; + my $if_ip = $airespace->airespace_if_ip() || {}; my %ip_index; - foreach my $ip (keys %$ip_index){ - my $iid = $ip_index->{$ip}; + foreach my $ip ( keys %$ip_index ) { + my $iid = $ip_index->{$ip}; next unless defined $iid; - + $ip_index{$ip} = $iid; } - foreach my $iid (keys %$if_ip){ - my $ip = $if_ip->{$iid}; + foreach my $iid ( keys %$if_ip ) { + my $ip = $if_ip->{$iid}; next unless defined $ip; - next if (defined $partial and $partial !~ /$ip/); + next if ( defined $partial and $partial !~ /$ip/ ); $ip_index{$ip} = $iid; } @@ -507,21 +517,21 @@ sub ip_netmask { my $partial = shift; my $ip_mask = $airespace->orig_ip_netmask($partial) || {}; - my $if_ip = $airespace->airespace_if_ip() || {}; - my $if_mask = $airespace->airespace_if_mask() || {}; + my $if_ip = $airespace->airespace_if_ip() || {}; + my $if_mask = $airespace->airespace_if_mask() || {}; my %ip_netmask; - foreach my $ip (keys %$ip_mask){ - my $mask = $ip_mask->{$ip}; + foreach my $ip ( keys %$ip_mask ) { + my $mask = $ip_mask->{$ip}; next unless defined $mask; $ip_netmask{$ip} = $mask; } - foreach my $iid (keys %$if_mask){ - my $ip = $if_ip->{$iid}; + foreach my $iid ( keys %$if_mask ) { + my $ip = $if_ip->{$iid}; next unless defined $ip; - next if (defined $partial and $partial !~ /$ip/); + next if ( defined $partial and $partial !~ /$ip/ ); my $mask = $if_mask->{$iid}; next unless defined $mask; @@ -536,10 +546,10 @@ sub bp_index { my $airespace = shift; my $partial = shift; - my $i_index = $airespace->i_index($partial) || {}; - + my $i_index = $airespace->i_index($partial) || {}; + my %bp_index; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; @@ -553,11 +563,11 @@ sub fw_port { my $airespace = shift; my $partial = shift; - my $sta_mac = $airespace->airespace_sta_mac($partial) || {}; - my $sta_slot = $airespace->airespace_sta_slot($partial) || {}; + my $sta_mac = $airespace->airespace_sta_mac($partial) || {}; + my $sta_slot = $airespace->airespace_sta_slot($partial) || {}; my %fw_port; - foreach my $iid (keys %$sta_mac){ + foreach my $iid ( keys %$sta_mac ) { my $mac = $sta_mac->{$iid}; next unless defined $mac; my $slot = $sta_slot->{$iid}; @@ -573,30 +583,30 @@ sub i_ssidlist { my $airespace = shift; my $partial = shift; - my $apif_override = $airespace->airespace_apif_oride($partial) || {}; - my $apif_type = $airespace->airespace_apif_type($partial) || {}; - my $ssids = $airespace->airespace_ess_ssid() || {}; - my $ssid_policy = $airespace->airespace_ess_radio_pol() || {}; - my $ssid_status = $airespace->airespace_ess_status() || {}; - my $ovride_ssids = $airespace->airespace_oride_ssid($partial) || {}; + my $apif_override = $airespace->airespace_apif_oride($partial) || {}; + my $apif_type = $airespace->airespace_apif_type($partial) || {}; + my $ssids = $airespace->airespace_ess_ssid() || {}; + my $ssid_policy = $airespace->airespace_ess_radio_pol() || {}; + my $ssid_status = $airespace->airespace_ess_status() || {}; + my $ovride_ssids = $airespace->airespace_oride_ssid($partial) || {}; my %i_ssidlist; - foreach my $iid (keys %$apif_override){ + foreach my $iid ( keys %$apif_override ) { my $override = $apif_override->{$iid}; next unless defined $override; - - next unless $override =~ /disable/i ; + + next unless $override =~ /disable/i; my $ap_type = $apif_type->{$iid}; next unless defined $ap_type; $ap_type =~ s/dot11//; - - foreach my $idx (keys %$ssids){ - my $ssid = $ssids->{$idx}; + + foreach my $idx ( keys %$ssids ) { + my $ssid = $ssids->{$idx}; next unless defined $ssid; - my $status = $ssid_status->{$idx}; + my $status = $ssid_status->{$idx}; next unless defined $status; next if ( $status =~ /disable/ ); - my $policy = $ssid_policy->{$idx}; + my $policy = $ssid_policy->{$idx}; next unless $policy =~ /$ap_type/ or $policy =~ /all/; $i_ssidlist{"$iid.$idx"} = $ssid; @@ -604,10 +614,10 @@ sub i_ssidlist { next; } - foreach my $iid (keys %$ovride_ssids){ + foreach my $iid ( keys %$ovride_ssids ) { my $ssid = $ovride_ssids->{$iid}; next unless $ssid; - + $i_ssidlist{$iid} = $ssid; } @@ -618,14 +628,14 @@ sub i_ssidbcast { my $airespace = shift; my $partial = shift; - my $ssidlist = $airespace->i_ssidlist($partial) || {}; + my $ssidlist = $airespace->i_ssidlist($partial) || {}; my $bc_mode = $airespace->airespace_bssid_mode() || 'enable'; - my %bcmap = qw/enable 1 disable 0/; + my %bcmap = qw/enable 1 disable 0/; my $broadcast = $bcmap{$bc_mode}; my %i_ssidbcast; - foreach my $iid (keys %$ssidlist){ + foreach my $iid ( keys %$ssidlist ) { $i_ssidbcast{$iid} = $broadcast; } @@ -639,7 +649,7 @@ sub i_80211channel { my $ch_list = $airespace->airespace_apif_ch_num($partial) || {}; my %i_80211channel; - foreach my $iid (keys %$ch_list){ + foreach my $iid ( keys %$ch_list ) { my $ch = $ch_list->{$iid}; $ch =~ s/ch//; $i_80211channel{$iid} = $ch; @@ -648,7 +658,6 @@ sub i_80211channel { return \%i_80211channel; } - # Pseudo ENTITY-MIB methods sub e_index { @@ -657,17 +666,20 @@ sub e_index { my $ap_model = $airespace->airespace_ap_model() || {}; my %e_index; + # Chassis $e_index{1} = 1; - # We're going to hack an index to capture APs - foreach my $idx (keys %$ap_model){ - # Create the integer index by joining the last three octets of the MAC. - # Hopefully, this will be unique since the manufacturer should be - # limited to Airespace and Cisco. We can't use the entire MAC since - # we would exceed the intger size limit. - if ($idx =~ /(\d+\.\d+\.\d+)$/) { - my $index = int (join('',map { sprintf "%03d",$_ } split /\./, $1)); + # We're going to hack an index to capture APs + foreach my $idx ( keys %$ap_model ) { + + # Create the integer index by joining the last three octets of the MAC. + # Hopefully, this will be unique since the manufacturer should be + # limited to Airespace and Cisco. We can't use the entire MAC since + # we would exceed the intger size limit. + if ( $idx =~ /(\d+\.\d+\.\d+)$/ ) { + my $index = int( + join( '', map { sprintf "%03d", $_ } split /\./, $1 ) ); $e_index{$idx} = $index; } } @@ -680,11 +692,12 @@ sub e_class { my $e_idx = $airespace->e_index() || {}; my %e_class; - foreach my $iid (keys %$e_idx){ - if ($iid eq 1) { + foreach my $iid ( keys %$e_idx ) { + if ( $iid eq 1 ) { $e_class{$iid} = 'chassis'; } - # This isn't a valid PhysicalClass, but we're hacking this anyway + + # This isn't a valid PhysicalClass, but we're hacking this anyway else { $e_class{$iid} = 'ap'; } @@ -698,11 +711,12 @@ sub e_name { my $ap_name = $airespace->airespace_ap_name() || {}; my %e_name; + # Chassis $e_name{1} = 'WLAN Controller'; # APs - foreach my $iid (keys %$ap_name){ + foreach my $iid ( keys %$ap_name ) { $e_name{$iid} = 'AP'; } return \%e_name; @@ -712,19 +726,20 @@ sub e_descr { my $airespace = shift; my $ap_model = $airespace->airespace_ap_model() || {}; - my $ap_name = $airespace->airespace_ap_name() || {}; - my $ap_loc = $airespace->airespace_ap_loc() || {}; + my $ap_name = $airespace->airespace_ap_name() || {}; + my $ap_loc = $airespace->airespace_ap_loc() || {}; my %e_descr; + # Chassis $e_descr{1} = $airespace->airespace_prod_name(); # APs - foreach my $iid (keys %$ap_name){ + foreach my $iid ( keys %$ap_name ) { my $name = $ap_name->{$iid}; next unless defined $name; my $model = $ap_model->{$iid} || 'AP'; - my $loc = $ap_loc->{$iid} || 'unknown'; + my $loc = $ap_loc->{$iid} || 'unknown'; $e_descr{$iid} = "$model: $name ($loc)"; } @@ -737,11 +752,12 @@ sub e_model { my $ap_model = $airespace->airespace_ap_model() || {}; my %e_model; + # Chassis $e_model{1} = $airespace->airespace_model(); # APs - foreach my $iid (keys %$ap_model){ + foreach my $iid ( keys %$ap_model ) { my $model = $ap_model->{$iid}; next unless defined $model; @@ -756,11 +772,12 @@ sub e_type { my $ap_type = $airespace->airespace_ap_type() || {}; my %e_type; + # Chassis $e_type{1} = $airespace->airespace_type(); # APs - foreach my $iid (keys %$ap_type){ + foreach my $iid ( keys %$ap_type ) { my $type = $ap_type->{$iid}; next unless defined $type; @@ -775,11 +792,12 @@ sub e_fwver { my $ap_fw = $airespace->airespace_ap_fw() || {}; my %e_fwver; + # Chassis $e_fwver{1} = $airespace->airespace_maint_ver(); # APs - foreach my $iid (keys %$ap_fw){ + foreach my $iid ( keys %$ap_fw ) { my $fw = $ap_fw->{$iid}; next unless defined $fw; @@ -791,10 +809,10 @@ sub e_fwver { sub e_vendor { my $airespace = shift; - my $e_idx = $airespace->e_index() || {}; + my $e_idx = $airespace->e_index() || {}; my %e_vendor; - foreach my $iid (keys %$e_idx){ + foreach my $iid ( keys %$e_idx ) { $e_vendor{$iid} = 'cisco'; } return \%e_vendor; @@ -806,11 +824,12 @@ sub e_serial { my $ap_serial = $airespace->airespace_ap_serial() || {}; my %e_serial; + # Chassis $e_serial{1} = $airespace->airespace_serial(); # APs - foreach my $iid (keys %$ap_serial){ + foreach my $iid ( keys %$ap_serial ) { my $serial = $ap_serial->{$iid}; next unless defined $serial; @@ -822,12 +841,12 @@ sub e_serial { sub e_pos { my $airespace = shift; - my $e_idx = $airespace->e_index() || {}; + my $e_idx = $airespace->e_index() || {}; my %e_pos; my $pos = 0; - foreach my $iid (sort keys %$e_idx){ - if ($iid eq 1) { + foreach my $iid ( sort keys %$e_idx ) { + if ( $iid eq 1 ) { $e_pos{$iid} = -1; next; } @@ -845,11 +864,12 @@ sub e_swver { my $ap_sw = $airespace->airespace_ap_sw() || {}; my %e_swver; + # Chassis $e_swver{1} = $airespace->airespace_os(); # APs - foreach my $iid (keys %$ap_sw){ + foreach my $iid ( keys %$ap_sw ) { my $sw = $ap_sw->{$iid}; next unless defined $sw; @@ -861,11 +881,11 @@ sub e_swver { sub e_parent { my $airespace = shift; - my $e_idx = $airespace->e_index() || {}; + my $e_idx = $airespace->e_index() || {}; my %e_parent; - foreach my $iid (sort keys %$e_idx){ - if ($iid eq 1) { + foreach my $iid ( sort keys %$e_idx ) { + if ( $iid eq 1 ) { $e_parent{$iid} = 0; next; } @@ -998,8 +1018,8 @@ Layer3 mode. =item $airespace->airespace_ul_mode() -Transfer upload mode configures the mode to use when uploading from the switch. -Normal usage tftp. +Transfer upload mode configures the mode to use when uploading from the +switch. Normal usage tftp. (C) @@ -1012,8 +1032,8 @@ valid only when the Transfer Mode is tftp. =item $airespace->airespace_ul_path() -Transfer upload tftp path configures the directory path where the file is to be -uploaded to. The switch remembers the last file path used. +Transfer upload tftp path configures the directory path where the file is to +be uploaded to. The switch remembers the last file path used. (C) @@ -1023,7 +1043,8 @@ uploaded to. The switch remembers the last file path used. =item $airespace->airespace_ul_type() -Transfer upload datatype configures the type of file to upload from the switch. +Transfer upload datatype configures the type of file to upload from the +switch. The types for upload are: config(2) @@ -1518,8 +1539,8 @@ only. =item $airespace->i_duplex_admin() -Returns reference to hash of IIDs to admin duplex setting. Ethernet interfaces -only. +Returns reference to hash of IIDs to admin duplex setting. Ethernet +interfaces only. =item $airespace->ip_index() @@ -1548,8 +1569,8 @@ airespace_sta_slot() combined to match the interface iid. =head2 Pseudo F information These methods emulate F Physical Table methods using -F and F. Thin APs are included -as subcomponents of the wireless controller. +F and F. Thin APs are +included as subcomponents of the wireless controller. =over diff --git a/Info/Bridge.pm b/Info/Bridge.pm index b76a649f..0dfa9fcb 100644 --- a/Info/Bridge.pm +++ b/Info/Bridge.pm @@ -1,26 +1,26 @@ # SNMP::Info::Bridge # $Id$ # -# Changes since Version 0.7 Copyright (c) 2004 Max Baker -# All rights reserved. +# Changes since Version 0.7 Copyright (c) 2004 Max Baker +# All rights reserved. # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,122 +37,135 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::Bridge::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::Bridge::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Bridge::EXPORT_OK = qw//; use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/; $VERSION = '1.09'; -%MIBS = ('BRIDGE-MIB' => 'dot1dBaseBridgeAddress', - 'Q-BRIDGE-MIB' => 'dot1qPvid', - ); +%MIBS = ( + 'BRIDGE-MIB' => 'dot1dBaseBridgeAddress', + 'Q-BRIDGE-MIB' => 'dot1qPvid', +); %GLOBALS = ( - 'b_mac' => 'dot1dBaseBridgeAddress', - 'b_ports' => 'dot1dBaseNumPorts', - 'b_type' => 'dot1dBaseType', - # Spanning Tree Protocol - 'stp_ver' => 'dot1dStpProtocolSpecification', - 'stp_time' => 'dot1dStpTimeSinceTopologyChange', - 'stp_root' => 'dot1dStpDesignatedRoot', - # Q-BRIDGE-MIB - 'qb_vlans_max' => 'dot1qMaxSupportedVlans', - 'qb_vlans' => 'dot1qNumVlans', - 'qb_next_vlan_index' => 'dot1qNextFreeLocalVlanIndex', - ); + 'b_mac' => 'dot1dBaseBridgeAddress', + 'b_ports' => 'dot1dBaseNumPorts', + 'b_type' => 'dot1dBaseType', + + # Spanning Tree Protocol + 'stp_ver' => 'dot1dStpProtocolSpecification', + 'stp_time' => 'dot1dStpTimeSinceTopologyChange', + 'stp_root' => 'dot1dStpDesignatedRoot', + + # Q-BRIDGE-MIB + 'qb_vlans_max' => 'dot1qMaxSupportedVlans', + 'qb_vlans' => 'dot1qNumVlans', + 'qb_next_vlan_index' => 'dot1qNextFreeLocalVlanIndex', +); %FUNCS = ( - # Forwarding Table: Dot1dTpFdbEntry - 'fw_mac' => 'dot1dTpFdbAddress', - 'fw_port' => 'dot1dTpFdbPort', - 'fw_status' => 'dot1dTpFdbStatus', - # Bridge Port Table: Dot1dBasePortEntry - 'bp_index' => 'dot1dBasePortIfIndex', - 'bp_port' => 'dot1dBasePortCircuit', - # Bridge Static (Destination-Address Filtering) Database - 'bs_mac' => 'dot1dStaticAddress', - 'bs_port' => 'dot1dStaticReceivePort', - 'bs_to' => 'dot1dStaticAllowedToGoTo', - 'bs_status' => 'dot1dStaticStatus', - # Spanning Tree Protocol Table : dot1dStpPortTable - 'stp_p_id' => 'dot1dStpPort', - 'stp_p_priority' => 'dot1dStpPortPriority', - 'stp_p_state' => 'dot1dStpPortState', - 'stp_p_cost' => 'dot1dStpPortPathCost', - 'stp_p_root' => 'dot1dStpPortDesignatedRoot', - 'stp_p_bridge' => 'dot1dStpPortDesignatedBridge', - 'stp_p_port' => 'dot1dStpPortDesignatedPort', - # Q-BRIDGE-MIB : dot1qPortVlanTable - 'qb_i_vlan' => 'dot1qPvid', - 'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes', - 'qb_i_vlan_in_flt' => 'dot1qPortIngressFiltering', - # Q-BRIDGE-MIB : dot1qVlanCurrentTable - 'qb_cv_egress' => 'dot1qVlanCurrentEgressPorts', - 'qb_cv_untagged' => 'dot1qVlanCurrentUntaggedPorts', - 'qb_cv_stat' => 'dot1qVlanStatus', - # Q-BRIDGE-MIB : dot1qVlanStaticTable - 'v_name' => 'dot1qVlanStaticName', - 'qb_v_egress' => 'dot1qVlanStaticEgressPorts', - 'qb_v_fbdn_egress' => 'dot1qVlanForbiddenEgressPorts', - 'qb_v_untagged' => 'dot1qVlanStaticUntaggedPorts', - 'qb_v_stat' => 'dot1qVlanStaticRowStatus', - # VLAN Forwarding Table: Dot1qTpFdbEntry - 'qb_fw_port' => 'dot1qTpFdbPort', - 'qb_fw_status' => 'dot1qTpFdbStatus', - ); + + # Forwarding Table: Dot1dTpFdbEntry + 'fw_mac' => 'dot1dTpFdbAddress', + 'fw_port' => 'dot1dTpFdbPort', + 'fw_status' => 'dot1dTpFdbStatus', + + # Bridge Port Table: Dot1dBasePortEntry + 'bp_index' => 'dot1dBasePortIfIndex', + 'bp_port' => 'dot1dBasePortCircuit', + + # Bridge Static (Destination-Address Filtering) Database + 'bs_mac' => 'dot1dStaticAddress', + 'bs_port' => 'dot1dStaticReceivePort', + 'bs_to' => 'dot1dStaticAllowedToGoTo', + 'bs_status' => 'dot1dStaticStatus', + + # Spanning Tree Protocol Table : dot1dStpPortTable + 'stp_p_id' => 'dot1dStpPort', + 'stp_p_priority' => 'dot1dStpPortPriority', + 'stp_p_state' => 'dot1dStpPortState', + 'stp_p_cost' => 'dot1dStpPortPathCost', + 'stp_p_root' => 'dot1dStpPortDesignatedRoot', + 'stp_p_bridge' => 'dot1dStpPortDesignatedBridge', + 'stp_p_port' => 'dot1dStpPortDesignatedPort', + + # Q-BRIDGE-MIB : dot1qPortVlanTable + 'qb_i_vlan' => 'dot1qPvid', + 'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes', + 'qb_i_vlan_in_flt' => 'dot1qPortIngressFiltering', + + # Q-BRIDGE-MIB : dot1qVlanCurrentTable + 'qb_cv_egress' => 'dot1qVlanCurrentEgressPorts', + 'qb_cv_untagged' => 'dot1qVlanCurrentUntaggedPorts', + 'qb_cv_stat' => 'dot1qVlanStatus', + + # Q-BRIDGE-MIB : dot1qVlanStaticTable + 'v_name' => 'dot1qVlanStaticName', + 'qb_v_egress' => 'dot1qVlanStaticEgressPorts', + 'qb_v_fbdn_egress' => 'dot1qVlanForbiddenEgressPorts', + 'qb_v_untagged' => 'dot1qVlanStaticUntaggedPorts', + 'qb_v_stat' => 'dot1qVlanStaticRowStatus', + + # VLAN Forwarding Table: Dot1qTpFdbEntry + 'qb_fw_port' => 'dot1qTpFdbPort', + 'qb_fw_status' => 'dot1qTpFdbStatus', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::MUNGE, - # Add ones for our class - 'b_mac' => \&SNMP::Info::munge_mac, - 'fw_mac' => \&SNMP::Info::munge_mac, - 'bs_mac' => \&SNMP::Info::munge_mac, - 'stp_root' => \&SNMP::Info::munge_mac, - 'stp_p_root' => \&SNMP::Info::munge_prio_mac, - 'stp_p_bridge' => \&SNMP::Info::munge_prio_mac, - 'stp_p_port' => \&SNMP::Info::munge_prio_mac, - 'qb_cv_egress' => \&SNMP::Info::munge_port_list, - 'qb_cv_untagged' => \&SNMP::Info::munge_port_list, - 'qb_v_egress' => \&SNMP::Info::munge_port_list, - 'qb_v_fbdn_egress' => \&SNMP::Info::munge_port_list, - 'qb_v_untagged' => \&SNMP::Info::munge_port_list, - ); + # Inherit all the built in munging + %SNMP::Info::MUNGE, + + # Add ones for our class + 'b_mac' => \&SNMP::Info::munge_mac, + 'fw_mac' => \&SNMP::Info::munge_mac, + 'bs_mac' => \&SNMP::Info::munge_mac, + 'stp_root' => \&SNMP::Info::munge_mac, + 'stp_p_root' => \&SNMP::Info::munge_prio_mac, + 'stp_p_bridge' => \&SNMP::Info::munge_prio_mac, + 'stp_p_port' => \&SNMP::Info::munge_prio_mac, + 'qb_cv_egress' => \&SNMP::Info::munge_port_list, + 'qb_cv_untagged' => \&SNMP::Info::munge_port_list, + 'qb_v_egress' => \&SNMP::Info::munge_port_list, + 'qb_v_fbdn_egress' => \&SNMP::Info::munge_port_list, + 'qb_v_untagged' => \&SNMP::Info::munge_port_list, + +); # break up the Dot1qTpFdbEntry INDEX into FDB ID and MAC Address. sub _qb_fdbtable_index { - my $idx = shift; - my @values = split(/\./, $idx); + my $idx = shift; + my @values = split( /\./, $idx ); my $fdb_id = shift(@values); - return ($fdb_id, join(':',map { sprintf "%02x",$_ } @values)); + return ( $fdb_id, join( ':', map { sprintf "%02x", $_ } @values ) ); } sub qb_fw_mac { - my $bridge = shift; + my $bridge = shift; my $partial = shift; my $qb_fw_port = $bridge->qb_fw_port($partial); - my $qb_fw_mac = {}; - foreach my $idx (keys %$qb_fw_port) { - my($fdb_id, $mac) = _qb_fdbtable_index($idx); + my $qb_fw_mac = {}; + foreach my $idx ( keys %$qb_fw_port ) { + my ( $fdb_id, $mac ) = _qb_fdbtable_index($idx); $qb_fw_mac->{$idx} = $mac; } return $qb_fw_mac; } sub qb_i_vlan_t { - my $bridge = shift; + my $bridge = shift; my $partial = shift; my $qb_i_vlan = $bridge->qb_i_vlan($partial); my $qb_i_vlan_type = $bridge->qb_i_vlan_type($partial); - + my $i_vlan = {}; - foreach my $if (keys %$qb_i_vlan){ - my $vlan = $qb_i_vlan->{$if}; + foreach my $if ( keys %$qb_i_vlan ) { + my $vlan = $qb_i_vlan->{$if}; my $tagged = $qb_i_vlan_type->{$if} || ''; next unless defined $vlan; $i_vlan->{$if} = $tagged eq 'admitOnlyVlanTagged' ? 'trunk' : $vlan; @@ -161,46 +174,46 @@ sub qb_i_vlan_t { } sub i_stp_state { - my $bridge = shift; + my $bridge = shift; my $partial = shift; - my $bp_index = $bridge->bp_index($partial); + my $bp_index = $bridge->bp_index($partial); my $stp_p_state = $bridge->stp_p_state($partial); my %i_stp_state; - foreach my $index (keys %$stp_p_state){ + foreach my $index ( keys %$stp_p_state ) { my $state = $stp_p_state->{$index}; my $iid = $bp_index->{$index}; next unless defined $iid; next unless defined $state; - $i_stp_state{$iid}=$state; + $i_stp_state{$iid} = $state; } return \%i_stp_state; } sub i_stp_port { - my $bridge = shift; + my $bridge = shift; my $partial = shift; - my $bp_index = $bridge->bp_index($partial); + my $bp_index = $bridge->bp_index($partial); my $stp_p_port = $bridge->stp_p_port($partial); - + my %i_stp_port; - foreach my $index (keys %$stp_p_port){ - my $bridge = $stp_p_port->{$index}; - my $iid = $bp_index->{$index}; - next unless defined $iid; - next unless defined $bridge; - $i_stp_port{$iid}=$bridge; + foreach my $index ( keys %$stp_p_port ) { + my $bridge = $stp_p_port->{$index}; + my $iid = $bp_index->{$index}; + next unless defined $iid; + next unless defined $bridge; + $i_stp_port{$iid} = $bridge; } return \%i_stp_port; } sub i_stp_id { - my $bridge = shift; + my $bridge = shift; my $partial = shift; my $bp_index = $bridge->bp_index($partial); @@ -208,43 +221,43 @@ sub i_stp_id { my %i_stp_id; - foreach my $index (keys %$stp_p_id){ + foreach my $index ( keys %$stp_p_id ) { my $bridge = $stp_p_id->{$index}; - my $iid = $bp_index->{$index}; + my $iid = $bp_index->{$index}; next unless defined $iid; next unless defined $bridge; - $i_stp_id{$iid}=$bridge; + $i_stp_id{$iid} = $bridge; } return \%i_stp_id; } sub i_stp_bridge { - my $bridge = shift; + my $bridge = shift; my $partial = shift; - my $bp_index = $bridge->bp_index($partial); + my $bp_index = $bridge->bp_index($partial); my $stp_p_bridge = $bridge->stp_p_bridge($partial); my %i_stp_bridge; - foreach my $index (keys %$stp_p_bridge){ + foreach my $index ( keys %$stp_p_bridge ) { my $bridge = $stp_p_bridge->{$index}; - my $iid = $bp_index->{$index}; + my $iid = $bp_index->{$index}; next unless defined $iid; next unless defined $bridge; - $i_stp_bridge{$iid}=$bridge; + $i_stp_bridge{$iid} = $bridge; } return \%i_stp_bridge; } # Non-accessible, but needed for consistency with other classes sub v_index { - my $bridge = shift; + my $bridge = shift; my $partial = shift; my $v_name = $bridge->v_name($partial); my %v_index; - foreach my $idx (keys %$v_name) { + foreach my $idx ( keys %$v_name ) { $v_index{$idx} = $idx; } return \%v_index; @@ -253,70 +266,70 @@ sub v_index { sub i_vlan { my $bridge = shift; my $partial = shift; - - my $index = $bridge->bp_index(); - + + my $index = $bridge->bp_index(); + # If given a partial it will be an ifIndex, we need to use dot1dBasePort if ($partial) { my %r_index = reverse %$index; $partial = $r_index{$partial}; } - my $i_pvid = $bridge->qb_i_vlan($partial) || {}; + my $i_pvid = $bridge->qb_i_vlan($partial) || {}; my $i_vlan = {}; - foreach my $bport (keys %$i_pvid) { + foreach my $bport ( keys %$i_pvid ) { my $vlan = $i_pvid->{$bport}; my $ifindex = $index->{$bport}; - unless (defined $ifindex) { + unless ( defined $ifindex ) { print " Port $bport has no bp_index mapping. Skipping.\n" if $DEBUG; next; } $i_vlan->{$ifindex} = $vlan; } - + return $i_vlan; } sub i_vlan_membership { - my $bridge = shift; + my $bridge = shift; my $partial = shift; - my $index = $bridge->bp_index(); + my $index = $bridge->bp_index(); # Use VlanCurrentTable if available since it will include dynamic # VLANs. However, some devices do not populate the table. - + # 11/07 - Todo: Issue with some devices trying to query VlanCurrentTable # as table may grow very large with frequent VLAN changes. # 06/08 - VlanCurrentTable may be due to timefilter, should query with # zero partial for no time filter. # my $v_ports = $bridge->qb_cv_egress() || $bridge->qb_v_egress(); - my $v_ports = $bridge->qb_v_egress() || {}; my $i_vlan_membership = {}; - foreach my $idx (keys %$v_ports) { - next unless (defined $v_ports->{$idx}); + foreach my $idx ( keys %$v_ports ) { + next unless ( defined $v_ports->{$idx} ); my $portlist = $v_ports->{$idx}; - my $ret = []; + my $ret = []; my $vlan; + # Strip TimeFilter if we're using VlanCurrentTable - ($vlan = $idx) =~ s/^\d+\.//; + ( $vlan = $idx ) =~ s/^\d+\.//; # Convert portlist bit array to bp_index array - for (my $i = 0; $i <= $#$portlist; $i++) { - push(@{$ret}, $i+1) if (@$portlist[$i]); + for ( my $i = 0; $i <= $#$portlist; $i++ ) { + push( @{$ret}, $i + 1 ) if ( @$portlist[$i] ); } #Create HoA ifIndex -> VLAN array - foreach my $port (@{$ret}) { + foreach my $port ( @{$ret} ) { my $ifindex = $index->{$port}; - next unless (defined($ifindex)); # shouldn't happen - next if (defined $partial and $ifindex !~ /^$partial$/); - push(@{$i_vlan_membership->{$ifindex}}, $vlan); + next unless ( defined($ifindex) ); # shouldn't happen + next if ( defined $partial and $ifindex !~ /^$partial$/ ); + push( @{ $i_vlan_membership->{$ifindex} }, $vlan ); } } return $i_vlan_membership; @@ -351,19 +364,23 @@ sub set_remove_i_vlan_tagged { } # -# These are internal methods and are not documented. Do not use directly. +# These are internal methods and are not documented. Do not use directly. # sub _check_forbidden_ports { my $bridge = shift; - my ($vlan_id, $index) = @_; - return unless ($vlan_id =~ /\d+/ and $index =~ /\d+/); + my ( $vlan_id, $index ) = @_; + return unless ( $vlan_id =~ /\d+/ and $index =~ /\d+/ ); my $iv_forbidden = $bridge->qb_v_fbdn_egress($vlan_id); my $forbidden_ports = $iv_forbidden->{$vlan_id}; print "Forbidden ports: @$forbidden_ports\n" if $bridge->debug(); - if ( defined(@$forbidden_ports[$index-1]) and (@$forbidden_ports[$index-1] eq "1")) { - print "Error: Index: $index in forbidden list for VLAN: $vlan_id unable to add.\n" if $bridge->debug(); + if ( defined( @$forbidden_ports[ $index - 1 ] ) + and ( @$forbidden_ports[ $index - 1 ] eq "1" ) ) + { + print + "Error: Index: $index in forbidden list for VLAN: $vlan_id unable to add.\n" + if $bridge->debug(); return; } return 1; @@ -371,15 +388,18 @@ sub _check_forbidden_ports { sub _validate_vlan_param { my $bridge = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; # VID and ifIndex should both be numeric - unless ( defined $vlan_id and defined $ifindex and - $vlan_id =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { + unless (defined $vlan_id + and defined $ifindex + and $vlan_id =~ /^\d+$/ + and $ifindex =~ /^\d+$/ ) + { $bridge->error_throw("Invalid parameter."); return; } - + # Check that ifIndex exists on device my $index = $bridge->interfaces($ifindex); @@ -389,21 +409,22 @@ sub _validate_vlan_param { } #Check that VLAN exists on device - my $vtp_vlans = $bridge->load_qb_cv_stat() || $bridge->load_qb_v_stat(); + my $vtp_vlans = $bridge->load_qb_cv_stat() || $bridge->load_qb_v_stat(); my $vlan_exists = 0; - - foreach my $iid (keys %$vtp_vlans) { - my $vlan = 0; + + foreach my $iid ( keys %$vtp_vlans ) { + my $vlan = 0; my $state = $vtp_vlans->{$iid}; next unless defined $state; - if ($iid =~ /(\d+)$/ ) { - $vlan = $1; + if ( $iid =~ /(\d+)$/ ) { + $vlan = $1; } - + $vlan_exists = 1 if ( $vlan_id eq $vlan ); } - unless ( $vlan_exists ) { - $bridge->error_throw("VLAN $vlan_id does not exist or is not operational."); + unless ($vlan_exists) { + $bridge->error_throw( + "VLAN $vlan_id does not exist or is not operational."); return; } @@ -457,8 +478,8 @@ Max Baker F is used by most Layer 2 devices, and holds information like the MAC Forwarding Table and Spanning Tree Protocol info. -F holds 802.1q information -- VLANs and Trunking. Cisco tends not -to use this MIB, but some proprietary ones. HP and some nicer vendors use +F holds 802.1q information -- VLANs and Trunking. Cisco tends +not to use this MIB, but some proprietary ones. HP and some nicer vendors use this. This is from C. Create or use a subclass of SNMP::Info that inherits this class. Do not use diff --git a/Info/CDP.pm b/Info/CDP.pm index 12dbbd5d..23c6ff21 100644 --- a/Info/CDP.pm +++ b/Info/CDP.pm @@ -1,26 +1,26 @@ # SNMP::Info::CDP # $Id$ # -# Changes since Version 0.7 Copyright (c) 2004 Max Baker -# All rights reserved. +# Changes since Version 0.7 Copyright (c) 2004 Max Baker +# All rights reserved. # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,7 +37,7 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CDP::EXPORT_OK = qw//; use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/; @@ -45,47 +45,47 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/; $VERSION = '1.09'; # Five data structures required by SNMP::Info -%MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' ); +%MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' ); # Notice we dont inherit the default GLOBALS and FUNCS # only the default MUNGE. %GLOBALS = ( - 'cdp_run' => 'cdpGlobalRun', - 'cdp_interval' => 'cdpGlobalMessageInterval', - 'cdp_holdtime' => 'cdpGlobalHoldTime', - 'cdp_id' => 'cdpGlobalDeviceId', - ); + 'cdp_run' => 'cdpGlobalRun', + 'cdp_interval' => 'cdpGlobalMessageInterval', + 'cdp_holdtime' => 'cdpGlobalHoldTime', + 'cdp_id' => 'cdpGlobalDeviceId', +); -%FUNCS = ( - 'c_index' => 'cdpCacheIfIndex', - 'c_proto' => 'cdpCacheAddressType', - 'c_addr' => 'cdpCacheAddress', - 'c_ver' => 'cdpCacheVersion', - 'c_id' => 'cdpCacheDeviceId', - 'c_port' => 'cdpCacheDevicePort', - 'c_platform' => 'cdpCachePlatform', - 'c_capabilities' => 'cdpCacheCapabilities', - 'c_domain' => 'cdpCacheVTPMgmtDomain', - 'c_vlan' => 'cdpCacheNativeVLAN', - 'c_duplex' => 'cdpCacheDuplex', - 'c_power' => 'cdpCachePowerConsumption', - ); +%FUNCS = ( + 'c_index' => 'cdpCacheIfIndex', + 'c_proto' => 'cdpCacheAddressType', + 'c_addr' => 'cdpCacheAddress', + 'c_ver' => 'cdpCacheVersion', + 'c_id' => 'cdpCacheDeviceId', + 'c_port' => 'cdpCacheDevicePort', + 'c_platform' => 'cdpCachePlatform', + 'c_capabilities' => 'cdpCacheCapabilities', + 'c_domain' => 'cdpCacheVTPMgmtDomain', + 'c_vlan' => 'cdpCacheNativeVLAN', + 'c_duplex' => 'cdpCacheDuplex', + 'c_power' => 'cdpCachePowerConsumption', +); %MUNGE = ( - 'c_capabilities' => \&SNMP::Info::munge_caps, - 'c_platform' => \&SNMP::Info::munge_null, - 'c_domain' => \&SNMP::Info::munge_null, - 'c_port' => \&SNMP::Info::munge_null, - 'c_id' => \&SNMP::Info::munge_null, - 'c_ver' => \&SNMP::Info::munge_null, - 'c_ip' => \&SNMP::Info::munge_ip, - 'c_power' => \&munge_power, + 'c_capabilities' => \&SNMP::Info::munge_caps, + 'c_platform' => \&SNMP::Info::munge_null, + 'c_domain' => \&SNMP::Info::munge_null, + 'c_port' => \&SNMP::Info::munge_null, + 'c_id' => \&SNMP::Info::munge_null, + 'c_ver' => \&SNMP::Info::munge_null, + 'c_ip' => \&SNMP::Info::munge_ip, + 'c_power' => \&munge_power, - ); +); sub munge_power { my $power = shift; - my $decimal = substr($power, -3); + my $decimal = substr( $power, -3 ); $power =~ s/$decimal$/\.$decimal/; return $power; } @@ -95,59 +95,62 @@ sub hasCDP { my $ver = $cdp->{_version}; - # SNMP v1 clients dont have the globals - if (defined $ver and $ver == 1){ + if ( defined $ver and $ver == 1 ) { my $c_ip = $cdp->c_ip(); + # See if anything in cdp cache, if so we have cdp - return 1 if (defined $c_ip and scalar(keys %$c_ip)) ; + return 1 if ( defined $c_ip and scalar( keys %$c_ip ) ); return; } - + return $cdp->cdp_run(); } sub c_if { - my $cdp = shift; + my $cdp = shift; # See if by some miracle Cisco implemented the cdpCacheIfIndex entry - my $c_index = $cdp->c_index(); + my $c_index = $cdp->c_index(); return $c_index if defined $c_index; # Nope, didn't think so. Now we fake it. my $c_ip = $cdp->c_ip(); - unless (defined $c_ip){ - $cdp->error_throw("SNMP::Info::CDP:c_if() - Device doesn't have cdp_ip() data. Can't fake cdp_index()"); + unless ( defined $c_ip ) { + $cdp->error_throw( + "SNMP::Info::CDP:c_if() - Device doesn't have cdp_ip() data. Can't fake cdp_index()" + ); return; } my %c_if; - foreach my $key (keys %$c_ip){ - next unless defined $key; - my $iid = $key; - # Truncate .1 from cdp cache entry - $iid =~ s/\.\d+$//; - $c_if{$key} = $iid; + foreach my $key ( keys %$c_ip ) { + next unless defined $key; + my $iid = $key; + + # Truncate .1 from cdp cache entry + $iid =~ s/\.\d+$//; + $c_if{$key} = $iid; } return \%c_if; } sub c_ip { - my $cdp = shift; + my $cdp = shift; my $partial = shift; - my $c_addr = $cdp->c_addr($partial) || {}; + my $c_addr = $cdp->c_addr($partial) || {}; my $c_proto = $cdp->c_proto($partial) || {}; - - my %c_ip; - foreach my $key (keys %$c_addr) { + + my %c_ip; + foreach my $key ( keys %$c_addr ) { my $addr = $c_addr->{$key}; my $proto = $c_proto->{$key}; next unless defined $addr; - next if (defined $proto and $proto ne 'ip'); + next if ( defined $proto and $proto ne 'ip' ); - my $ip = join('.',unpack('C4',$addr)); + my $ip = join( '.', unpack( 'C4', $addr ) ); $c_ip{$key} = $ip; } return \%c_ip; diff --git a/Info/CiscoConfig.pm b/Info/CiscoConfig.pm index 6483f41b..3f53fea4 100644 --- a/Info/CiscoConfig.pm +++ b/Info/CiscoConfig.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -42,43 +42,45 @@ use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - 'CISCO-CONFIG-COPY-MIB' => 'ccCopyTable', - 'CISCO-FLASH-MIB' => 'ciscoFlashCopyTable', - 'OLD-CISCO-SYS-MIB' => 'writeMem', - ); + 'CISCO-CONFIG-COPY-MIB' => 'ccCopyTable', + 'CISCO-FLASH-MIB' => 'ciscoFlashCopyTable', + 'OLD-CISCO-SYS-MIB' => 'writeMem', +); %GLOBALS = ( - # OLD-CISCO-SYS-MIB - 'old_write_mem' => 'writeMem', - 'old_write_net' => 'writeNet', - ); + + # OLD-CISCO-SYS-MIB + 'old_write_mem' => 'writeMem', + 'old_write_net' => 'writeNet', +); %FUNCS = ( - # CISCO-COPY-CONFIG-MIB::ccCopyTable - 'config_protocol' => 'ccCopyProtocol', - 'config_source_type' => 'ccCopySourceFileType', - 'config_dest_type' => 'ccCopyDestFileType', - 'config_server_addr' => 'ccCopyServerAddress', - 'config_filename' => 'ccCopyFileName', - 'config_username' => 'ccCopyUserName', - 'config_password' => 'ccCopyUserPassword', - 'config_notify_complete' => 'ccCopyNotificationOnCompletion', - 'config_copy_state' => 'ccCopyState', - 'config_copy_start_time' => 'ccCopyTimeStarted', - 'config_copy_complete_time' => 'ccCopyTimeCompleted', - 'config_fail_cause' => 'ccCopyFailCause', - 'config_row_status' => 'ccCopyEntryRowStatus', - # CISCO-FLASH-MIB::ciscoFlashCopyTable - 'flash_copy_cmd' => 'ciscoFlashCopyCommand', - 'flash_copy_protocol' => 'ciscoFlashCopyProtocol', - 'flash_copy_address' => 'ciscoFlashCopyServerAddress', - 'flash_copy_source' => 'ciscoFlashCopySourceName', - 'flash_copy_dest' => 'ciscoFlashCopyDestinationName', - 'flash_copy_row_status' => 'ciscoFlashCopyEntryStatus', - ); -%MUNGE = ( - ); + # CISCO-COPY-CONFIG-MIB::ccCopyTable + 'config_protocol' => 'ccCopyProtocol', + 'config_source_type' => 'ccCopySourceFileType', + 'config_dest_type' => 'ccCopyDestFileType', + 'config_server_addr' => 'ccCopyServerAddress', + 'config_filename' => 'ccCopyFileName', + 'config_username' => 'ccCopyUserName', + 'config_password' => 'ccCopyUserPassword', + 'config_notify_complete' => 'ccCopyNotificationOnCompletion', + 'config_copy_state' => 'ccCopyState', + 'config_copy_start_time' => 'ccCopyTimeStarted', + 'config_copy_complete_time' => 'ccCopyTimeCompleted', + 'config_fail_cause' => 'ccCopyFailCause', + 'config_row_status' => 'ccCopyEntryRowStatus', + + # CISCO-FLASH-MIB::ciscoFlashCopyTable + 'flash_copy_cmd' => 'ciscoFlashCopyCommand', + 'flash_copy_protocol' => 'ciscoFlashCopyProtocol', + 'flash_copy_address' => 'ciscoFlashCopyServerAddress', + 'flash_copy_source' => 'ciscoFlashCopySourceName', + 'flash_copy_dest' => 'ciscoFlashCopyDestinationName', + 'flash_copy_row_status' => 'ciscoFlashCopyEntryStatus', +); + +%MUNGE = (); sub copy_run_tftp { my $ciscoconfig = shift; @@ -87,72 +89,85 @@ sub copy_run_tftp { srand( time() ^ ( $$ + ( $$ << 15 ) ) ); my $rand = int( rand( 1 << 24 ) ); - print "Saving running config to $tftphost as $tftpfile\n" if $ciscoconfig->debug(); + print "Saving running config to $tftphost as $tftpfile\n" + if $ciscoconfig->debug(); - #Try new method first fall back to old method + #Try new method first fall back to old method if ( $ciscoconfig->set_config_protocol( 1, $rand ) ) { print "Using new method, row iid: $rand\n" if $ciscoconfig->debug(); + #Check each set, delete created row if any fail unless ( $ciscoconfig->set_config_source_type( 4, $rand ) ) { $ciscoconfig->error_throw("Setting source type failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Setting source type failed and failed to delete row $rand"); + $ciscoconfig->error_throw( + "Setting source type failed and failed to delete row $rand" + ); } return; } unless ( $ciscoconfig->set_config_dest_type( 1, $rand ) ) { $ciscoconfig->error_throw("Setting destination type failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Setting dest type failed and failed to delete row $rand"); + $ciscoconfig->error_throw( + "Setting dest type failed and failed to delete row $rand" + ); } return; } unless ( $ciscoconfig->set_config_server_addr( $tftphost, $rand ) ) { $ciscoconfig->error_throw("Setting tftp server failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Setting tftp server failed and failed to delete row $rand"); + $ciscoconfig->error_throw( + "Setting tftp server failed and failed to delete row $rand" + ); } return; } unless ( $ciscoconfig->set_config_filename( $tftpfile, $rand ) ) { $ciscoconfig->error_throw("Setting file name failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Setting file name failed and failed to delete row $rand"); + $ciscoconfig->error_throw( + "Setting file name failed and failed to delete row $rand" + ); } return; } unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) { $ciscoconfig->error_throw("Initiating transfer failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Initiating transfer failed and failed to delete row $rand"); + $ciscoconfig->error_throw( + "Initiating transfer failed and failed to delete row $rand" + ); } return; - } + } my $status = 0; my $timer = 0; - # Hard-coded timeout of approximately 5 minutes, we can wrap this in an - # option later if needed - my $timeout = 300; + + # Hard-coded timeout of approximately 5 minutes, we can wrap this in an + # option later if needed + my $timeout = 300; while ( $status !~ /successful|failed/ ) { my $t = $ciscoconfig->config_copy_state($rand); $status = $t->{$rand}; last if $status =~ /successful|failed/; $timer += 1; - if ($timer >= $timeout) { + if ( $timer >= $timeout ) { $status = 'failed'; last; } sleep 1; - } + } unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug(); + print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug(); } if ( $status eq 'successful' ) { print "Save operation successful\n" if $ciscoconfig->debug(); return 1; - } + } if ( $status eq 'failed' ) { $ciscoconfig->error_throw("Save operation failed"); return; @@ -162,8 +177,8 @@ sub copy_run_tftp { print "Using old method\n" if $ciscoconfig->debug(); unless ( $ciscoconfig->set_old_write_net( $tftpfile, $tftphost ) ) { - $ciscoconfig->error_throw("Save operation failed"); - return; + $ciscoconfig->error_throw("Save operation failed"); + return; } return 1; @@ -179,32 +194,37 @@ sub copy_run_start { if ( $ciscoconfig->set_config_source_type( 4, $rand ) ) { print "Using new method, row iid: $rand\n" if $ciscoconfig->debug(); + #Check each set, delete created row if any fail unless ( $ciscoconfig->set_config_dest_type( 3, $rand ) ) { $ciscoconfig->error_throw("Setting dest type failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Setting dest type failed and failed to delete row $rand"); + $ciscoconfig->error_throw( + "Setting dest type failed and failed to delete row $rand" + ); } return; } unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) { $ciscoconfig->error_throw("Initiating save failed"); unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - $ciscoconfig->error_throw("Initiating save failed and failed to delete row $rand"); - } + $ciscoconfig->error_throw( + "Initiating save failed and failed to delete row $rand"); + } return; } my $status = 0; my $timer = 0; - # Hard-coded timeout of approximately 5 minutes, we can wrap this in an - # option later if needed - my $timeout = 300; + + # Hard-coded timeout of approximately 5 minutes, we can wrap this in an + # option later if needed + my $timeout = 300; while ( $status !~ /successful|failed/ ) { my $t = $ciscoconfig->config_copy_state($rand); $status = $t->{$rand}; last if $status =~ /successful|failed/; $timer += 1; - if ($timer >= $timeout) { + if ( $timer >= $timeout ) { $status = 'failed'; last; } @@ -212,13 +232,13 @@ sub copy_run_start { } unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { - print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug(); + print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug(); } if ( $status eq 'successful' ) { print "Save operation successful\n" if $ciscoconfig->debug(); return 1; - } + } if ( $status eq 'failed' ) { $ciscoconfig->error_throw("Save operation failed"); return; @@ -227,9 +247,9 @@ sub copy_run_start { } print "Using old method\n" if $ciscoconfig->debug(); - unless ( $ciscoconfig->set_old_write_mem( 1 ) ) { - $ciscoconfig->error_throw("Save operation failed"); - return; + unless ( $ciscoconfig->set_old_write_mem(1) ) { + $ciscoconfig->error_throw("Save operation failed"); + return; } return 1; @@ -408,9 +428,10 @@ Table of Flash copy operation entries. =head1 SET METHODS -These are methods that provide SNMP set functionality for overridden methods or -provide a simpler interface to complex set operations. See -L for general information on set operations. +These are methods that provide SNMP set functionality for overridden methods +or provide a simpler interface to complex set operations. See +L for general information on set +operations. =over @@ -420,9 +441,9 @@ Store the running configuration on a TFTP server. Equivalent to the CLI commands "copy running-config tftp" or "write net". This method attempts to use newer "copy running-config tftp" procedure first -and then the older "write net" procedure if that fails. The newer procedure is -supported Cisco devices with the F available, Cisco IOS -software release 12.0 or on some devices as early as release 11.2P. The +and then the older "write net" procedure if that fails. The newer procedure +is supported Cisco devices with the F available, Cisco +IOS software release 12.0 or on some devices as early as release 11.2P. The older procedure has been depreciated by Cisco and is utilized only to support devices running older code revisions. @@ -436,11 +457,12 @@ Copy the running configuration to the start up configuration. Equivalent to the CLI command C<"copy running-config startup-config"> or C<"write mem">. This method attempts to use newer C<"copy running-config startup-config"> -procedure first and then the older C<"write mem"> procedure if that fails. The -newer procedure is supported Cisco devices with the F -available, Cisco IOS software release 12.0 or on some devices as early as -release 11.2P. The older procedure has been depreciated by Cisco and is -utilized only to support devices running older code revisions. +procedure first and then the older C<"write mem"> procedure if that fails. +The newer procedure is supported Cisco devices with the +F available, Cisco IOS software release 12.0 or on +some devices as early as release 11.2P. The older procedure has been +depreciated by Cisco and is utilized only to support devices running older +code revisions. Example: $ciscoconfig->copy_run_start() diff --git a/Info/CiscoImage.pm b/Info/CiscoImage.pm index 4d19983d..5af8e69a 100644 --- a/Info/CiscoImage.pm +++ b/Info/CiscoImage.pm @@ -1,23 +1,22 @@ -package SNMP::Info::CiscoImage; # $Id$ # # Copyright (c) 2005 Matt Tuttle # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -28,30 +27,26 @@ package SNMP::Info::CiscoImage; # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +package SNMP::Info::CiscoImage; + use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoImage::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'CISCO-IMAGE-MIB' => 'ciscoImageString', - ); +%MIBS = ( 'CISCO-IMAGE-MIB' => 'ciscoImageString', ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - 'ci_images' => 'ciscoImageString', - ); +%FUNCS = ( 'ci_images' => 'ciscoImageString', ); -%MUNGE = ( - ); +%MUNGE = (); 1; __END__ @@ -68,13 +63,13 @@ Matt Tuttle (C) # Let SNMP::Info determine the correct subclass for you. my $ci = new SNMP::Info( - AutoSpecify => 1, - Debug => 1, - # These arguments are passed directly on to SNMP::Session - DestHost => 'myswitch', - Community => 'public', - Version => 2 - ) + AutoSpecify => 1, + Debug => 1, + # These arguments are passed directly on to SNMP::Session + DestHost => 'myswitch', + Community => 'public', + Version => 2 + ) or die "Can't connect to DestHost.\n"; my $class = $ci->class(); diff --git a/Info/CiscoPortSecurity.pm b/Info/CiscoPortSecurity.pm index d5953c14..8fddc7d7 100644 --- a/Info/CiscoPortSecurity.pm +++ b/Info/CiscoPortSecurity.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -33,85 +33,94 @@ package SNMP::Info::CiscoPortSecurity; use strict; use Exporter; -@SNMP::Info::CiscoPortSecurity::ISA = qw/Exporter/; +@SNMP::Info::CiscoPortSecurity::ISA = qw/Exporter/; @SNMP::Info::CiscoPortSecurity::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PAECAPABILITIES/; $VERSION = '1.09'; -%MIBS = ( - 'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB', - 'CISCO-PAE-MIB' => 'ciscoPaeMIB', - 'IEEE8021-PAE-MIB' => 'dot1xAuthLastEapolFrameSource', - ); +%MIBS = ( + 'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB', + 'CISCO-PAE-MIB' => 'ciscoPaeMIB', + 'IEEE8021-PAE-MIB' => 'dot1xAuthLastEapolFrameSource', +); %GLOBALS = ( - # CISCO-PORT-SECURITY-MIB - 'cps_clear' => 'cpsGlobalClearSecureMacAddresses', - 'cps_notify' => 'cpsGlobalSNMPNotifControl', - 'cps_rate' => 'cpsGlobalSNMPNotifRate', - 'cps_enable' => 'cpsGlobalPortSecurityEnable', - 'cps_mac_count' => 'cpsGlobalTotalSecureAddress', - 'cps_mac_max' => 'cpsGlobalMaxSecureAddress', - ); -%FUNCS = ( - # CISCO-PORT-SECURITY-MIB::cpsIfConfigTable - 'cps_i_limit_val' => 'cpsIfInvalidSrcRateLimitValue', - 'cps_i_limit' => 'cpsIfInvalidSrcRateLimitEnable', - 'cps_i_sticky' => 'cpsIfStickyEnable', - 'cps_i_clear_type' => 'cpsIfClearSecureMacAddresses', - 'cps_i_shutdown' => 'cpsIfShutdownTimeout', - 'cps_i_flood' => 'cpsIfUnicastFloodingEnable', - 'cps_i_clear' => 'cpsIfClearSecureAddresses', - 'cps_i_mac' => 'cpsIfSecureLastMacAddress', - 'cps_i_count' => 'cpsIfViolationCount', - 'cps_i_action' => 'cpsIfViolationAction', - 'cps_i_mac_static' => 'cpsIfStaticMacAddrAgingEnable', - 'cps_i_mac_type' => 'cpsIfSecureMacAddrAgingType', - 'cps_i_mac_age' => 'cpsIfSecureMacAddrAgingTime', - 'cps_i_mac_count' => 'cpsIfCurrentSecureMacAddrCount', - 'cps_i_mac_max' => 'cpsIfMaxSecureMacAddr', - 'cps_i_status' => 'cpsIfPortSecurityStatus', - 'cps_i_enable' => 'cpsIfPortSecurityEnable', - # CISCO-PORT-SECURITY-MIB::cpsIfVlanTable - 'cps_i_v_mac_count' => 'cpsIfVlanCurSecureMacAddrCount', - 'cps_i_v_mac_max' => 'cpsIfVlanMaxSecureMacAddr', - 'cps_i_v' => 'cpsIfVlanIndex', - # CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable - 'cps_i_v_mac_status' => 'cpsIfVlanSecureMacAddrRowStatus', - 'cps_i_v_mac_age' => 'cpsIfVlanSecureMacAddrRemainAge', - 'cps_i_v_mac_type' => 'cpsIfVlanSecureMacAddrType', - 'cps_i_v_vlan' => 'cpsIfVlanSecureVlanIndex', - 'cps_i_v_mac' => 'cpsIfVlanSecureMacAddress', - # CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable - 'cps_m_status' => 'cpsSecureMacAddrRowStatus', - 'cps_m_age' => 'cpsSecureMacAddrRemainingAge', - 'cps_m_type' => 'cpsSecureMacAddrType', - 'cps_m_mac' => 'cpsSecureMacAddress', - # IEEE8021-PAE-MIB::dot1xPaePortEntry - 'pae_i_capabilities' => 'dot1xPaePortCapabilities', - 'pae_i_last_eapol_frame_source' => 'dot1xAuthLastEapolFrameSource', - ); + # CISCO-PORT-SECURITY-MIB + 'cps_clear' => 'cpsGlobalClearSecureMacAddresses', + 'cps_notify' => 'cpsGlobalSNMPNotifControl', + 'cps_rate' => 'cpsGlobalSNMPNotifRate', + 'cps_enable' => 'cpsGlobalPortSecurityEnable', + 'cps_mac_count' => 'cpsGlobalTotalSecureAddress', + 'cps_mac_max' => 'cpsGlobalMaxSecureAddress', +); -%MUNGE = ( - 'cps_i_mac' => \&SNMP::Info::munge_mac, - 'cps_m_mac' => \&SNMP::Info::munge_mac, - 'cps_i_v_mac' => \&SNMP::Info::munge_mac, - 'pae_i_last_eapol_frame_source' => \&SNMP::Info::munge_mac, - 'pae_i_capabilities' => \&munge_pae_capabilities, - ); +%FUNCS = ( -%PAECAPABILITIES = (0 => 'dot1xPaePortAuthCapable', - 1 => 'dot1xPaePortSuppCapable'); + # CISCO-PORT-SECURITY-MIB::cpsIfConfigTable + 'cps_i_limit_val' => 'cpsIfInvalidSrcRateLimitValue', + 'cps_i_limit' => 'cpsIfInvalidSrcRateLimitEnable', + 'cps_i_sticky' => 'cpsIfStickyEnable', + 'cps_i_clear_type' => 'cpsIfClearSecureMacAddresses', + 'cps_i_shutdown' => 'cpsIfShutdownTimeout', + 'cps_i_flood' => 'cpsIfUnicastFloodingEnable', + 'cps_i_clear' => 'cpsIfClearSecureAddresses', + 'cps_i_mac' => 'cpsIfSecureLastMacAddress', + 'cps_i_count' => 'cpsIfViolationCount', + 'cps_i_action' => 'cpsIfViolationAction', + 'cps_i_mac_static' => 'cpsIfStaticMacAddrAgingEnable', + 'cps_i_mac_type' => 'cpsIfSecureMacAddrAgingType', + 'cps_i_mac_age' => 'cpsIfSecureMacAddrAgingTime', + 'cps_i_mac_count' => 'cpsIfCurrentSecureMacAddrCount', + 'cps_i_mac_max' => 'cpsIfMaxSecureMacAddr', + 'cps_i_status' => 'cpsIfPortSecurityStatus', + 'cps_i_enable' => 'cpsIfPortSecurityEnable', + + # CISCO-PORT-SECURITY-MIB::cpsIfVlanTable + 'cps_i_v_mac_count' => 'cpsIfVlanCurSecureMacAddrCount', + 'cps_i_v_mac_max' => 'cpsIfVlanMaxSecureMacAddr', + 'cps_i_v' => 'cpsIfVlanIndex', + + # CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable + 'cps_i_v_mac_status' => 'cpsIfVlanSecureMacAddrRowStatus', + 'cps_i_v_mac_age' => 'cpsIfVlanSecureMacAddrRemainAge', + 'cps_i_v_mac_type' => 'cpsIfVlanSecureMacAddrType', + 'cps_i_v_vlan' => 'cpsIfVlanSecureVlanIndex', + 'cps_i_v_mac' => 'cpsIfVlanSecureMacAddress', + + # CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable + 'cps_m_status' => 'cpsSecureMacAddrRowStatus', + 'cps_m_age' => 'cpsSecureMacAddrRemainingAge', + 'cps_m_type' => 'cpsSecureMacAddrType', + 'cps_m_mac' => 'cpsSecureMacAddress', + + # IEEE8021-PAE-MIB::dot1xPaePortEntry + 'pae_i_capabilities' => 'dot1xPaePortCapabilities', + 'pae_i_last_eapol_frame_source' => 'dot1xAuthLastEapolFrameSource', +); + +%MUNGE = ( + 'cps_i_mac' => \&SNMP::Info::munge_mac, + 'cps_m_mac' => \&SNMP::Info::munge_mac, + 'cps_i_v_mac' => \&SNMP::Info::munge_mac, + 'pae_i_last_eapol_frame_source' => \&SNMP::Info::munge_mac, + 'pae_i_capabilities' => \&munge_pae_capabilities, +); + +%PAECAPABILITIES = ( + 0 => 'dot1xPaePortAuthCapable', + 1 => 'dot1xPaePortSuppCapable' +); sub munge_pae_capabilities { my $bits = shift; return unless defined $bits; - my @vals = map($PAECAPABILITIES{$_},sprintf("%x",unpack('b*',$bits))); - return join(' ',@vals); + my @vals + = map( $PAECAPABILITIES{$_}, sprintf( "%x", unpack( 'b*', $bits ) ) ); + return join( ' ', @vals ); } 1; diff --git a/Info/CiscoPower.pm b/Info/CiscoPower.pm index 13077140..212d909e 100644 --- a/Info/CiscoPower.pm +++ b/Info/CiscoPower.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Bill Fenner # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,41 +34,37 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoPower::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoPower::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoPower::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ('CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex'); +%MIBS = ( 'CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex' ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - 'cpeth_ent_phy' => 'cpeExtPsePortEntPhyIndex', - ); +%FUNCS = ( 'cpeth_ent_phy' => 'cpeExtPsePortEntPhyIndex', ); -%MUNGE = ( - ); +%MUNGE = (); # Cisco overcame the limitation of the module.port index of the # pethPsePortTable by adding another mapping table, which maps # a pethPsePortTable row to an entPhysicalTable index, which can # then be mapped to ifIndex. sub peth_port_ifindex { - my $cpeth = shift; + my $cpeth = shift; my $partial = shift; my $ent_phy = $cpeth->cpeth_ent_phy($partial); - my $e_port = $cpeth->e_port(); + my $e_port = $cpeth->e_port(); my $peth_port_ifindex = {}; - foreach my $i (keys %$ent_phy) { - if ($e_port->{$ent_phy->{$i}}) { - $peth_port_ifindex->{$i} = $e_port->{$ent_phy->{$i}}; - } + foreach my $i ( keys %$ent_phy ) { + if ( $e_port->{ $ent_phy->{$i} } ) { + $peth_port_ifindex->{$i} = $e_port->{ $ent_phy->{$i} }; + } } return $peth_port_ifindex; } @@ -111,7 +107,8 @@ contains. Create or use a device subclass that inherit this class. Do not use directly. -For debugging purposes you can call this class directly as you would SNMP::Info +For debugging purposes you can call this class directly as you would +SNMP::Info my $poe = new SNMP::Info::CiscoPower (...); diff --git a/Info/CiscoQOS.pm b/Info/CiscoQOS.pm index 694fe704..de114995 100644 --- a/Info/CiscoQOS.pm +++ b/Info/CiscoQOS.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2005 Alexander Hartmaier # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,43 +34,44 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoQOS::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoQOS::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoQOS::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex', - ); +%MIBS = ( 'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex', ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - # CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable - 'qos_i_index' => 'cbQosIfIndex', - 'qos_i_type' => 'cbQosIfType', - 'qos_pol_direction' => 'cbQosPolicyDirection', - # CISCO-CLASS-BASED-QOS-MIB::cbQosObjectsTable - 'qos_obj_conf_index' => 'cbQosConfigIndex', - 'qos_obj_type' => 'cbQosObjectsType', - 'qos_obj_parent' => 'cbQosParentObjectsIndex', - # CISCO-CLASS-BASED-QOS-MIB::cbQosCMCfgTable - 'qos_cm_name' => 'cbQosCMName', - 'qos_cm_desc' => 'cbQosCMDesc', - 'qos_cm_info' => 'cbQosCMInfo', - # CISCO-CLASS-BASED-QOS-MIB::cbQosCMStatsTable - 'qos_octet_pre' => 'cbQosCMPrePolicyByte', - 'qos_octet_post' => 'cbQosCMPostPolicyByte', - # CISCO-CLASS-BASED-QOS-MIB::cbQosQueueingCfgTable - 'qos_queueingcfg_bw' => 'cbQosQueueingCfgBandwidth', - 'qos_queueingcfg_bw_units' => 'cbQosQueueingCfgBandwidthUnits', - ); +%FUNCS = ( -%MUNGE = ( - ); + # CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable + 'qos_i_index' => 'cbQosIfIndex', + 'qos_i_type' => 'cbQosIfType', + 'qos_pol_direction' => 'cbQosPolicyDirection', + + # CISCO-CLASS-BASED-QOS-MIB::cbQosObjectsTable + 'qos_obj_conf_index' => 'cbQosConfigIndex', + 'qos_obj_type' => 'cbQosObjectsType', + 'qos_obj_parent' => 'cbQosParentObjectsIndex', + + # CISCO-CLASS-BASED-QOS-MIB::cbQosCMCfgTable + 'qos_cm_name' => 'cbQosCMName', + 'qos_cm_desc' => 'cbQosCMDesc', + 'qos_cm_info' => 'cbQosCMInfo', + + # CISCO-CLASS-BASED-QOS-MIB::cbQosCMStatsTable + 'qos_octet_pre' => 'cbQosCMPrePolicyByte', + 'qos_octet_post' => 'cbQosCMPostPolicyByte', + + # CISCO-CLASS-BASED-QOS-MIB::cbQosQueueingCfgTable + 'qos_queueingcfg_bw' => 'cbQosQueueingCfgBandwidth', + 'qos_queueingcfg_bw_units' => 'cbQosQueueingCfgBandwidthUnits', +); + +%MUNGE = (); 1; __END__ diff --git a/Info/CiscoRTT.pm b/Info/CiscoRTT.pm index e3e4a9f3..b8b7228f 100644 --- a/Info/CiscoRTT.pm +++ b/Info/CiscoRTT.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2005 Alexander Hartmaier # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,28 +34,25 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoRTT::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoRTT::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoRTT::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner', - ); +%MIBS = ( 'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner', ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - # CISCO-RTTMON-MIB - 'rtt_desc' => 'rttMonCtrlAdminOwner', - 'rtt_last' => 'rttMonLatestRttOperCompletionTime', - ); +%FUNCS = ( -%MUNGE = ( - ); + # CISCO-RTTMON-MIB + 'rtt_desc' => 'rttMonCtrlAdminOwner', + 'rtt_last' => 'rttMonLatestRttOperCompletionTime', +); + +%MUNGE = (); 1; __END__ diff --git a/Info/CiscoStack.pm b/Info/CiscoStack.pm index e30643bf..74e2ee22 100644 --- a/Info/CiscoStack.pm +++ b/Info/CiscoStack.pm @@ -1,23 +1,23 @@ # SNMP::Info::CiscoStack # $Id$ # -# Copyright (c) 2008 Max Baker -# All rights reserved. +# Copyright (c) 2008 Max Baker +# All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,87 +34,91 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoStack::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT/; $VERSION = '1.09'; -%MIBS = ( - 'CISCO-STACK-MIB' => 'ciscoStackMIB', - ); +%MIBS = ( 'CISCO-STACK-MIB' => 'ciscoStackMIB', ); %GLOBALS = ( - 'sysip' => 'sysIpAddr', - 'netmask' => 'sysNetMask', - 'broadcast' => 'sysBroadcast', - 'serial1' => 'chassisSerialNumber', - 'serial2' => 'chassisSerialNumberString', - 'model1' => 'chassisModel', - 'ps1_type' => 'chassisPs1Type', - 'ps1_status' => 'chassisPs1Status', - 'ps2_type' => 'chassisPs2Type', - 'ps2_status' => 'chassisPs2Status', - 'slots' => 'chassisNumSlots', - 'fan' => 'chassisFanStatus', - ); + 'sysip' => 'sysIpAddr', + 'netmask' => 'sysNetMask', + 'broadcast' => 'sysBroadcast', + 'serial1' => 'chassisSerialNumber', + 'serial2' => 'chassisSerialNumberString', + 'model1' => 'chassisModel', + 'ps1_type' => 'chassisPs1Type', + 'ps1_status' => 'chassisPs1Status', + 'ps2_type' => 'chassisPs2Type', + 'ps2_status' => 'chassisPs2Status', + 'slots' => 'chassisNumSlots', + 'fan' => 'chassisFanStatus', +); -%FUNCS = ( - # CISCO-STACK-MIB::moduleEntry - # These are blades in a catalyst device - 'm_type' => 'moduleType', - 'm_model' => 'moduleModel', - 'm_serial' => 'moduleSerialNumber', - 'm_status' => 'moduleStatus', - 'm_name' => 'moduleName', - 'm_ports' => 'moduleNumPorts', - 'm_ports_status' => 'modulePortStatus', - 'm_hwver' => 'moduleHwVersion', - 'm_fwver' => 'moduleFwVersion', - 'm_swver' => 'moduleSwVersion', - # Router Blades : - 'm_ip' => 'moduleIPAddress', - 'm_sub1' => 'moduleSubType', - 'm_sub2' => 'moduleSubType2', - # CISCO-STACK-MIB::portEntry - 'p_name' => 'portName', - 'p_type' => 'portType', - 'p_status' => 'portOperStatus', - 'p_status2' => 'portAdditionalStatus', - 'p_speed' => 'portAdminSpeed', - 'p_duplex' => 'portDuplex', - 'p_port' => 'portIfIndex', - 'p_rx_flow_control' => 'portOperRxFlowControl', - 'p_tx_flow_control' => 'portOperTxFlowControl', - 'p_rx_flow_control_admin' => 'portAdminRxFlowControl', - 'p_tx_flow_control_admin' => 'portAdminTxFlowControl', - 'p_oidx' => 'portCrossIndex', - # CISCO-STACK-MIB::PortCpbEntry - 'p_speed_admin' => 'portCpbSpeed', - 'p_duplex_admin' => 'portCpbDuplex', - ); +%FUNCS = ( -%MUNGE = ( - 'm_ports_status' => \&munge_port_status, - 'p_duplex_admin' => \&SNMP::Info::munge_bits, - ); + # CISCO-STACK-MIB::moduleEntry + # These are blades in a catalyst device + 'm_type' => 'moduleType', + 'm_model' => 'moduleModel', + 'm_serial' => 'moduleSerialNumber', + 'm_status' => 'moduleStatus', + 'm_name' => 'moduleName', + 'm_ports' => 'moduleNumPorts', + 'm_ports_status' => 'modulePortStatus', + 'm_hwver' => 'moduleHwVersion', + 'm_fwver' => 'moduleFwVersion', + 'm_swver' => 'moduleSwVersion', -%PORTSTAT = (1 => 'other', - 2 => 'ok', - 3 => 'minorFault', - 4 => 'majorFault'); + # Router Blades : + 'm_ip' => 'moduleIPAddress', + 'm_sub1' => 'moduleSubType', + 'm_sub2' => 'moduleSubType2', + + # CISCO-STACK-MIB::portEntry + 'p_name' => 'portName', + 'p_type' => 'portType', + 'p_status' => 'portOperStatus', + 'p_status2' => 'portAdditionalStatus', + 'p_speed' => 'portAdminSpeed', + 'p_duplex' => 'portDuplex', + 'p_port' => 'portIfIndex', + 'p_rx_flow_control' => 'portOperRxFlowControl', + 'p_tx_flow_control' => 'portOperTxFlowControl', + 'p_rx_flow_control_admin' => 'portAdminRxFlowControl', + 'p_tx_flow_control_admin' => 'portAdminTxFlowControl', + 'p_oidx' => 'portCrossIndex', + + # CISCO-STACK-MIB::PortCpbEntry + 'p_speed_admin' => 'portCpbSpeed', + 'p_duplex_admin' => 'portCpbDuplex', +); + +%MUNGE = ( + 'm_ports_status' => \&munge_port_status, + 'p_duplex_admin' => \&SNMP::Info::munge_bits, +); + +%PORTSTAT = ( + 1 => 'other', + 2 => 'ok', + 3 => 'minorFault', + 4 => 'majorFault' +); # Changes binary byte describing each port into ascii, and returns # an ascii list separated by spaces. sub munge_port_status { my $status = shift; - my @vals = map($PORTSTAT{$_},unpack('C*',$status)); - return join(' ',@vals); + my @vals = map( $PORTSTAT{$_}, unpack( 'C*', $status ) ); + return join( ' ', @vals ); } sub serial { - my $stack = shift; + my $stack = shift; my $serial1 = $stack->serial1(); my $serial2 = $stack->serial2(); @@ -126,12 +130,12 @@ sub serial { # Rules for older CatOS devices using CiscoStack # # You can configure Ethernet and Fast Ethernet interfaces to either full -# duplex or half duplex. +# duplex or half duplex. # # You cannot configure the duplex mode on Gigabit Ethernet ports (they are # always in full-duplex mode). # -# If you set the port speed to auto, duplex mode is automatically set to auto. +# If you set the port speed to auto, duplex mode is automatically set to auto. # # For operational duplex if portCpbDuplex is all zeros the port is a gigabit # port and duplex is always full. If the port is not operational and auto @@ -141,31 +145,33 @@ sub serial { # checked in the device class. sub i_duplex { - my $stack = shift; + my $stack = shift; my $partial = shift; - my $p_port = $stack->p_port() || {}; - my $p_duplex = $stack->p_duplex() || {}; + my $p_port = $stack->p_port() || {}; + my $p_duplex = $stack->p_duplex() || {}; my $p_duplex_cap = $stack->p_duplex_admin() || {}; my $i_duplex = {}; - foreach my $port (keys %$p_duplex) { + foreach my $port ( keys %$p_duplex ) { my $iid = $p_port->{$port}; next unless defined $iid; - next if (defined $partial and $iid !~ /^$partial$/); - # Test for gigabit - if ($p_duplex_cap->{$port} == 0) { + next if ( defined $partial and $iid !~ /^$partial$/ ); + + # Test for gigabit + if ( $p_duplex_cap->{$port} == 0 ) { $i_duplex->{$iid} = 'full'; } + # Auto is not a valid operational state - elsif ($p_duplex->{$port} eq 'auto') { + elsif ( $p_duplex->{$port} eq 'auto' ) { next; } else { $i_duplex->{$iid} = $p_duplex->{$port}; } } - return $i_duplex; + return $i_duplex; } # For administrative duplex if portCpbDuplex is all zeros the port is a gigabit @@ -173,63 +179,68 @@ sub i_duplex { # duplex will be auto, otherwise use portDuplex. sub i_duplex_admin { - my $stack = shift; + my $stack = shift; my $partial = shift; - my $p_port = $stack->p_port() || {}; - my $p_duplex = $stack->p_duplex() || {}; + my $p_port = $stack->p_port() || {}; + my $p_duplex = $stack->p_duplex() || {}; my $p_duplex_cap = $stack->p_duplex_admin() || {}; - my $p_speed = $stack->p_speed() || {}; + my $p_speed = $stack->p_speed() || {}; my $i_duplex_admin = {}; - foreach my $port (keys %$p_duplex) { + foreach my $port ( keys %$p_duplex ) { my $iid = $p_port->{$port}; next unless defined $iid; - next if (defined $partial and $iid !~ /^$partial$/); - # Test for gigabit - if ($p_duplex_cap->{$port} == 0) { + next if ( defined $partial and $iid !~ /^$partial$/ ); + + # Test for gigabit + if ( $p_duplex_cap->{$port} == 0 ) { $i_duplex_admin->{$iid} = 'full'; } + # Check admin speed for auto - elsif ($p_speed->{$port} =~ /auto/) { + elsif ( $p_speed->{$port} =~ /auto/ ) { $i_duplex_admin->{$iid} = 'auto'; } else { $i_duplex_admin->{$iid} = $p_duplex->{$port}; } } - return $i_duplex_admin; + return $i_duplex_admin; } sub i_speed_admin { - my $stack = shift; + my $stack = shift; my $partial = shift; my %i_speed_admin; my $p_port = $stack->p_port(); my %mapping = reverse %$p_port; - my $p_speed = $stack->p_speed($mapping{$partial}); + my $p_speed = $stack->p_speed( $mapping{$partial} ); - my %speeds = ('autoDetect' => 'auto', - 'autoDetect10100' => 'auto', - 's10000000' => '10 Mbps', - 's100000000' => '100 Mbps', - 's1000000000' => '1.0 Gbps', - 's10G' => '10 Gbps', - ); + my %speeds = ( + 'autoDetect' => 'auto', + 'autoDetect10100' => 'auto', + 's10000000' => '10 Mbps', + 's100000000' => '100 Mbps', + 's1000000000' => '1.0 Gbps', + 's10G' => '10 Gbps', + ); - %i_speed_admin = map { $p_port->{$_} => $speeds{$p_speed->{$_}} } keys %$p_port; + %i_speed_admin + = map { $p_port->{$_} => $speeds{ $p_speed->{$_} } } keys %$p_port; return \%i_speed_admin; } sub set_i_speed_admin { + # map speeds to those the switch will understand my %speeds = qw/auto 1 10 10000000 100 100000000 1000 1000000000/; my $stack = shift; - my ($speed, $iid) = @_; - my $p_port = $stack->p_port() || {}; + my ( $speed, $iid ) = @_; + my $p_port = $stack->p_port() || {}; my %reverse_p_port = reverse %$p_port; $speed = lc($speed); @@ -238,24 +249,27 @@ sub set_i_speed_admin { $iid = $reverse_p_port{$iid}; - return $stack->set_p_speed ($speeds{$speed}, $iid); + return $stack->set_p_speed( $speeds{$speed}, $iid ); } sub set_i_duplex_admin { + # map a textual duplex to an integer one the switch understands my %duplexes = qw/half 1 full 2 auto 4/; my $stack = shift; - my ($duplex, $iid) = @_; - if ($duplex eq 'auto') { - $stack->error_throw("Software doesn't support setting auto duplex with + my ( $duplex, $iid ) = @_; + if ( $duplex eq 'auto' ) { + $stack->error_throw( + "Software doesn't support setting auto duplex with set_i_duplex_admin() you must use set_i_speed_admin() and set both speed and duplex - to auto"); + to auto" + ); return 0; } - my $p_port = $stack->p_port() || {}; + my $p_port = $stack->p_port() || {}; my %reverse_p_port = reverse %$p_port; $duplex = lc($duplex); @@ -264,7 +278,7 @@ sub set_i_duplex_admin { $iid = $reverse_p_port{$iid}; - return $stack->set_p_duplex($duplexes{$duplex}, $iid); + return $stack->set_p_duplex( $duplexes{$duplex}, $iid ); } 1; @@ -553,9 +567,9 @@ To see the status of port 4 : Can be either C C or C -"Indicates the receive flow control operational status of the port. If the port -could not agree with the far end on a link protocol, its operational status -will be disagree(3)." +"Indicates the receive flow control operational status of the port. If the +port could not agree with the far end on a link protocol, its operational +status will be disagree(3)." C @@ -576,8 +590,8 @@ Can be either C C or C "Indicates the receive flow control administrative status set on the port. If the status is set to on(1), the port will require the far end to send flow control. If the status is set to off(2), the port will not allow far end to -send flow control. If the status is set to desired(3), the port will allow the -far end to send the flow control." +send flow control. If the status is set to desired(3), the port will allow +the far end to send the flow control." C @@ -585,11 +599,11 @@ C Can be either C C or C -"Indicates the transmit flow control administrative status set on the port. If -the status is set to on(1), the port will send flow control to the far end. If +"Indicates the transmit flow control administrative status set on the port. +If the status is set to on(1), the port will send flow control to the far end. If the status is set to off(2), the port will not send flow control to the far -end. If the status is set to desired(3), the port will send flow control to the -far end if the far end supports it." +end. If the status is set to desired(3), the port will send flow control to +the far end if the far end supports it." C diff --git a/Info/CiscoStats.pm b/Info/CiscoStats.pm index bf8b60cf..48e6114b 100644 --- a/Info/CiscoStats.pm +++ b/Info/CiscoStats.pm @@ -1,26 +1,26 @@ # SNMP::Info::CiscoStats # $Id$ # -# Changes since Version 0.7 Copyright (c) 2008 Max Baker -# All rights reserved. +# Changes since Version 0.7 Copyright (c) 2008 Max Baker +# All rights reserved. # # Copyright (c) 2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,59 +37,65 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoStats::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'SNMPv2-MIB' => 'sysDescr', - 'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec', - 'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed', - 'OLD-CISCO-SYSTEM-MIB' => 'writeMem', - 'CISCO-PRODUCTS-MIB' => 'sysName', - # some older catalysts live here - 'CISCO-STACK-MIB' => 'wsc1900sysID', - 'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis', - 'CISCO-FLASH-MIB' => 'ciscoFlashDeviceSize', - ); +%MIBS = ( + 'SNMPv2-MIB' => 'sysDescr', + 'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec', + 'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed', + 'OLD-CISCO-SYSTEM-MIB' => 'writeMem', + 'CISCO-PRODUCTS-MIB' => 'sysName', + + # some older catalysts live here + 'CISCO-STACK-MIB' => 'wsc1900sysID', + 'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis', + 'CISCO-FLASH-MIB' => 'ciscoFlashDeviceSize', +); %GLOBALS = ( - 'description' => 'sysDescr', - # We will use the numeric OID's so that we don't require people - # to install v1 MIBs, which can conflict. - # OLD-CISCO-CPU-MIB:avgBusyPer - 'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0', - 'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0', - 'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0', - # CISCO-PROCESS-MIB - 'cat_cpu' => 'cpmCPUTotal5sec.9', - 'cat_cpu_1min' => 'cpmCPUTotal1min.9', - 'cat_cpu_5min' => 'cpmCPUTotal5min.9', - # OLD-CISCO-SYSTEM-MIB - 'write_mem' => 'writeMem', - ); + 'description' => 'sysDescr', -%FUNCS = ( - # CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolTable - 'cisco_mem_free' => 'ciscoMemoryPoolFree', - 'cisco_mem_used' => 'ciscoMemoryPoolUsed', - # CISCO-FLASH-MIB::ciscoFlashDeviceTable - 'cisco_flash_size' => 'ciscoFlashDeviceSize', - ); + # We will use the numeric OID's so that we don't require people + # to install v1 MIBs, which can conflict. + # OLD-CISCO-CPU-MIB:avgBusyPer + 'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0', + 'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0', + 'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0', -%MUNGE = ( - ); + # CISCO-PROCESS-MIB + 'cat_cpu' => 'cpmCPUTotal5sec.9', + 'cat_cpu_1min' => 'cpmCPUTotal1min.9', + 'cat_cpu_5min' => 'cpmCPUTotal5min.9', + + # OLD-CISCO-SYSTEM-MIB + 'write_mem' => 'writeMem', +); + +%FUNCS = ( + + # CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolTable + 'cisco_mem_free' => 'ciscoMemoryPoolFree', + 'cisco_mem_used' => 'ciscoMemoryPoolUsed', + + # CISCO-FLASH-MIB::ciscoFlashDeviceTable + 'cisco_flash_size' => 'ciscoFlashDeviceSize', +); + +%MUNGE = (); sub os { my $l2 = shift; my $descr = $l2->description() || ''; - # order here matters - there are Catalysts that run IOS and have catalyst in their description field. - return 'ios' if ($descr =~ /IOS/); - return 'catalyst' if ($descr =~ /catalyst/i); + # order here matters - there are Catalysts that run IOS and have catalyst + # in their description field. + return 'ios' if ( $descr =~ /IOS/ ); + return 'catalyst' if ( $descr =~ /catalyst/i ); return; } @@ -97,21 +103,27 @@ sub os_ver { my $l2 = shift; my $os = $l2->os(); my $descr = $l2->description(); - + # Older Catalysts - if (defined $os and $os eq 'catalyst' and defined $descr and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/){ + if ( defined $os + and $os eq 'catalyst' + and defined $descr + and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/ ) + { return $1; } - + # Newer Catalysts and IOS devices - if (defined $descr and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ ){ + if ( defined $descr + and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ ) + { return $1; - } + } return; } sub cpu { - my $self = shift; + my $self = shift; my $ios_cpu = $self->ios_cpu(); return $ios_cpu if defined $ios_cpu; my $cat_cpu = $self->cat_cpu(); @@ -119,7 +131,7 @@ sub cpu { } sub cpu_1min { - my $self = shift; + my $self = shift; my $ios_cpu_1min = $self->ios_cpu_1min(); return $ios_cpu_1min if defined $ios_cpu_1min; my $cat_cpu_1min = $self->cat_cpu_1min(); @@ -127,7 +139,7 @@ sub cpu_1min { } sub cpu_5min { - my $self = shift; + my $self = shift; my $ios_cpu_5min = $self->ios_cpu_5min(); return $ios_cpu_5min if defined $ios_cpu_5min; my $cat_cpu_5min = $self->cat_cpu_5min(); @@ -141,7 +153,7 @@ sub mem_free { my $cisco_mem_free = $self->cisco_mem_free() || {}; - foreach my $mem_free_val (values %$cisco_mem_free) { + foreach my $mem_free_val ( values %$cisco_mem_free ) { $mem_free += $mem_free_val; } @@ -154,8 +166,8 @@ sub mem_used { my $mem_used; my $cisco_mem_used = $self->cisco_mem_used() || {}; - - foreach my $mem_used_val (values %$cisco_mem_used) { + + foreach my $mem_used_val ( values %$cisco_mem_used ) { $mem_used += $mem_used_val; } @@ -170,10 +182,10 @@ sub mem_total { my $cisco_mem_free = $self->cisco_mem_free() || {}; my $cisco_mem_used = $self->cisco_mem_used() || {}; - foreach my $mem_entry (keys %$cisco_mem_free){ + foreach my $mem_entry ( keys %$cisco_mem_free ) { my $mem_free = $cisco_mem_free->{$mem_entry} || 0; my $mem_used = $cisco_mem_used->{$mem_entry} || 0; - $mem_total += ($mem_free + $mem_used); + $mem_total += ( $mem_free + $mem_used ); } return $mem_total; } @@ -185,7 +197,7 @@ sub flashmem_total { my $flash_sizes = $self->cisco_flash_size; - foreach my $flash_index (keys %$flash_sizes) { + foreach my $flash_index ( keys %$flash_sizes ) { $flashmem_total += $flash_sizes->{$flash_index}; } @@ -197,7 +209,8 @@ __END__ =head1 NAME -SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco Devices +SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco +Devices =head1 AUTHOR @@ -207,13 +220,13 @@ Max Baker # Let SNMP::Info determine the correct subclass for you. my $ciscostats = new SNMP::Info( - AutoSpecify => 1, - Debug => 1, - # These arguments are passed directly on to SNMP::Session - DestHost => 'myswitch', - Community => 'public', - Version => 2 - ) + AutoSpecify => 1, + Debug => 1, + # These arguments are passed directly on to SNMP::Session + DestHost => 'myswitch', + Community => 'public', + Version => 2 + ) or die "Can't connect to DestHost.\n"; my $class = $ciscostats->class(); @@ -221,8 +234,8 @@ Max Baker =head1 DESCRIPTION -SNMP::Info::CiscoStats is a subclass of SNMP::Info that provides cpu, memory, os and -version information about Cisco Devices. +SNMP::Info::CiscoStats is a subclass of SNMP::Info that provides cpu, memory, +os and version information about Cisco Devices. Use or create in a subclass of SNMP::Info. Do not use directly. diff --git a/Info/CiscoVTP.pm b/Info/CiscoVTP.pm index b9f82963..1e643720 100644 --- a/Info/CiscoVTP.pm +++ b/Info/CiscoVTP.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * 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 +# +# 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 @@ -36,126 +36,133 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoVTP::EXPORT_OK = qw//; - + use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'CISCO-VTP-MIB' => 'vtpVlanName', - 'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry', - 'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex', - ); +%MIBS = ( + 'CISCO-VTP-MIB' => 'vtpVlanName', + 'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry', + 'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex', +); %GLOBALS = ( - 'vtp_version' => 'vtpVersion', - 'vtp_maxstore' => 'vtpMaxVlanStorage', - 'vtp_notify' => 'vtpNotificationsEnabled', - 'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled', - 'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled', - 'vtp_trunk_set_serial' => 'vlanTrunkPortSetSerialNo', - ); + 'vtp_version' => 'vtpVersion', + 'vtp_maxstore' => 'vtpMaxVlanStorage', + 'vtp_notify' => 'vtpNotificationsEnabled', + 'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled', + 'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled', + 'vtp_trunk_set_serial' => 'vlanTrunkPortSetSerialNo', +); -%FUNCS = ( - # CISCO-VTP-MIB::managementDomainTable - 'vtp_d_index' => 'managementDomainIndex', - 'vtp_d_name' => 'managementDomainName', - 'vtp_d_mode' => 'managementDomainLocalMode', - 'vtp_d_rev' => 'managementDomainConfigRevNumber', - 'vtp_d_updater' => 'managementDomainLastUpdater', - 'vtp_d_last' => 'managementDomainLastChange', - 'vtp_d_status' => 'managementDomainRowStatus', - 'vtp_d_tftp' => 'managementDomainTftpServer', - 'vtp_d_tftp_path' => 'managementDomainTftpPathname', - 'vtp_d_pruning' => 'managementDomainPruningState', - 'vtp_d_ver' => 'managementDomainVersionInUse', - # CISCO-VTP-MIB::vtpVlanTable - 'v_state' => 'vtpVlanState', - 'v_type' => 'vtpVlanType', - 'v_name' => 'vtpVlanName', - 'v_mtu' => 'vtpVlanMtu', - 'v_said' => 'vtpVlanDot10Said', - 'v_ring' => 'vtpVlanRingNumber', - 'v_bridge' => 'vtpVlanBridgeNumber', - 'v_stp' => 'vtpVlanStpType', - 'v_parent' => 'vtpVlanParentVlan', - 'v_trans1' => 'vtpVlanTranslationalVlan1', - 'v_trans2' => 'vtpVlanTranslationalVlan2', - 'v_btype' => 'vtpVlanBridgeType', - 'v_hop_are' => 'vtpVlanAreHopCount', - 'v_hop_ste' => 'vtpVlanSteHopCount', - 'v_crf' => 'vtpVlanIsCRFBackup', - 'v_type_ext' => 'vtpVlanTypeExt', - 'v_if' => 'vtpVlanIfIndex', - # CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable - 'i_vlan_type' => 'vmVlanType', - 'i_vlan2' => 'vmVlan', - 'i_vlan_stat' => 'vmPortStatus', - 'i_vlan_1' => 'vmVlans', - 'i_vlan_2' => 'vmVlans2k', - 'i_vlan_3' => 'vmVlans3k', - 'i_vlan_4' => 'vmVlans4k', - # CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable - 'i_voice_vlan' => 'vmVoiceVlanId', - # CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB - 'v_cvi_if' => 'cviRoutedVlanIfIndex', - # CISCO-VTP-MIB::vlanTrunkPortTable - 'vtp_trunk_mgmt_dom' => 'vlanTrunkPortManagementDomain', - 'vtp_trunk_encaps_t' => 'vlanTrunkPortEncapsulationType', - 'vtp_trunk_vlans' => 'vlanTrunkPortVlansEnabled', - 'vtp_trunk_vlans_2k' => 'vlanTrunkPortVlansEnabled2k', - 'vtp_trunk_vlans_3k' => 'vlanTrunkPortVlansEnabled3k', - 'vtp_trunk_vlans_4k' => 'vlanTrunkPortVlansEnabled4k', - 'vtp_trunk_native' => 'vlanTrunkPortNativeVlan', - 'i_pvid' => 'vlanTrunkPortNativeVlan', - 'vtp_trunk_rstat' => 'vlanTrunkPortRowStatus', - 'vtp_trunk_dyn' => 'vlanTrunkPortDynamicState', - 'vtp_trunk_dyn_stat' => 'vlanTrunkPortDynamicStatus', - 'vtp_trunk_vtp' => 'vlanTrunkPortVtpEnabled', - 'vtp_trunk_encaps' => 'vlanTrunkPortEncapsulationOperType', - # TODO Add these tables if someone wants them.. - # vtpEditControlTable - # vtpVlanEditTable - # vtpStatsTable - ); +%FUNCS = ( -%MUNGE = ( - ); + # CISCO-VTP-MIB::managementDomainTable + 'vtp_d_index' => 'managementDomainIndex', + 'vtp_d_name' => 'managementDomainName', + 'vtp_d_mode' => 'managementDomainLocalMode', + 'vtp_d_rev' => 'managementDomainConfigRevNumber', + 'vtp_d_updater' => 'managementDomainLastUpdater', + 'vtp_d_last' => 'managementDomainLastChange', + 'vtp_d_status' => 'managementDomainRowStatus', + 'vtp_d_tftp' => 'managementDomainTftpServer', + 'vtp_d_tftp_path' => 'managementDomainTftpPathname', + 'vtp_d_pruning' => 'managementDomainPruningState', + 'vtp_d_ver' => 'managementDomainVersionInUse', + + # CISCO-VTP-MIB::vtpVlanTable + 'v_state' => 'vtpVlanState', + 'v_type' => 'vtpVlanType', + 'v_name' => 'vtpVlanName', + 'v_mtu' => 'vtpVlanMtu', + 'v_said' => 'vtpVlanDot10Said', + 'v_ring' => 'vtpVlanRingNumber', + 'v_bridge' => 'vtpVlanBridgeNumber', + 'v_stp' => 'vtpVlanStpType', + 'v_parent' => 'vtpVlanParentVlan', + 'v_trans1' => 'vtpVlanTranslationalVlan1', + 'v_trans2' => 'vtpVlanTranslationalVlan2', + 'v_btype' => 'vtpVlanBridgeType', + 'v_hop_are' => 'vtpVlanAreHopCount', + 'v_hop_ste' => 'vtpVlanSteHopCount', + 'v_crf' => 'vtpVlanIsCRFBackup', + 'v_type_ext' => 'vtpVlanTypeExt', + 'v_if' => 'vtpVlanIfIndex', + + # CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable + 'i_vlan_type' => 'vmVlanType', + 'i_vlan2' => 'vmVlan', + 'i_vlan_stat' => 'vmPortStatus', + 'i_vlan_1' => 'vmVlans', + 'i_vlan_2' => 'vmVlans2k', + 'i_vlan_3' => 'vmVlans3k', + 'i_vlan_4' => 'vmVlans4k', + + # CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable + 'i_voice_vlan' => 'vmVoiceVlanId', + + # CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB + 'v_cvi_if' => 'cviRoutedVlanIfIndex', + + # CISCO-VTP-MIB::vlanTrunkPortTable + 'vtp_trunk_mgmt_dom' => 'vlanTrunkPortManagementDomain', + 'vtp_trunk_encaps_t' => 'vlanTrunkPortEncapsulationType', + 'vtp_trunk_vlans' => 'vlanTrunkPortVlansEnabled', + 'vtp_trunk_vlans_2k' => 'vlanTrunkPortVlansEnabled2k', + 'vtp_trunk_vlans_3k' => 'vlanTrunkPortVlansEnabled3k', + 'vtp_trunk_vlans_4k' => 'vlanTrunkPortVlansEnabled4k', + 'vtp_trunk_native' => 'vlanTrunkPortNativeVlan', + 'i_pvid' => 'vlanTrunkPortNativeVlan', + 'vtp_trunk_rstat' => 'vlanTrunkPortRowStatus', + 'vtp_trunk_dyn' => 'vlanTrunkPortDynamicState', + 'vtp_trunk_dyn_stat' => 'vlanTrunkPortDynamicStatus', + 'vtp_trunk_vtp' => 'vlanTrunkPortVtpEnabled', + 'vtp_trunk_encaps' => 'vlanTrunkPortEncapsulationOperType', + + # TODO Add these tables if someone wants them.. + # vtpEditControlTable + # vtpVlanEditTable + # vtpStatsTable +); + +%MUNGE = (); sub v_index { - my $vtp = shift; + my $vtp = shift; my $partial = shift; my $v_name = $vtp->v_name($partial); my %v_index; - foreach my $idx (keys %$v_name) { - my ($mgmtdomain, $vlan) = split(/\./, $idx); + foreach my $idx ( keys %$v_name ) { + my ( $mgmtdomain, $vlan ) = split( /\./, $idx ); $v_index{$idx} = $vlan; } return \%v_index; } sub i_vlan { - my $vtp = shift; + my $vtp = shift; my $partial = shift; - my $port_vlan = $vtp->vtp_trunk_native($partial) || {}; - my $i_vlan = $vtp->i_vlan2($partial) || {}; + my $port_vlan = $vtp->vtp_trunk_native($partial) || {}; + my $i_vlan = $vtp->i_vlan2($partial) || {}; my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {}; my %i_vlans; + # Get access ports - foreach my $port (keys %$i_vlan) { + foreach my $port ( keys %$i_vlan ) { my $vlan = $i_vlan->{$port}; next unless defined $vlan; - + $i_vlans{$port} = $vlan; } # Get trunk ports - foreach my $port (keys %$port_vlan) { + foreach my $port ( keys %$port_vlan ) { my $vlan = $port_vlan->{$port}; next unless defined $vlan; my $stat = $trunk_dyn_stat->{$port}; @@ -167,14 +174,14 @@ sub i_vlan { # Check in CISCO-VLAN-IFTABLE-RELATION-MIB # Is this only for Aironet??? If so, it needs # to be removed from this class - + my $v_cvi_if = $vtp->v_cvi_if(); if ( defined $v_cvi_if ) { # Translate vlan.physical_interface -> iid # to iid -> vlan - foreach my $i (keys %$v_cvi_if){ - my ($vlan,$phys) = split(/\./,$i); + foreach my $i ( keys %$v_cvi_if ) { + my ( $vlan, $phys ) = split( /\./, $i ); my $iid = $v_cvi_if->{$i}; $i_vlans{$iid} = $vlan; @@ -185,59 +192,60 @@ sub i_vlan { } sub i_vlan_membership { - my $vtp = shift; + my $vtp = shift; my $partial = shift; - my $ports_vlans = $vtp->vtp_trunk_vlans($partial) || {}; + my $ports_vlans = $vtp->vtp_trunk_vlans($partial) || {}; my $ports_vlans_2k = $vtp->vtp_trunk_vlans_2k($partial) || {}; my $ports_vlans_3k = $vtp->vtp_trunk_vlans_3k($partial) || {}; my $ports_vlans_4k = $vtp->vtp_trunk_vlans_4k($partial) || {}; my $vtp_vlans = $vtp->v_state(); - my $i_vlan = $vtp->i_vlan2($partial) || {}; + my $i_vlan = $vtp->i_vlan2($partial) || {}; my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {}; my $i_vlan_membership = {}; # Get access ports - foreach my $port (keys %$i_vlan) { + foreach my $port ( keys %$i_vlan ) { my $vlan = $i_vlan->{$port}; next unless defined $vlan; my $stat = $trunk_dyn_stat->{$port}; if ( defined $stat and $stat =~ /notTrunking/ ) { - push(@{$i_vlan_membership->{$port}}, $vlan); + push( @{ $i_vlan_membership->{$port} }, $vlan ); } } # Get trunk ports my %oper_vlans; - foreach my $iid (keys %$vtp_vlans) { - my $vlan = 0; - my $vtp_dom =0; - my $state = $vtp_vlans->{$iid}; + foreach my $iid ( keys %$vtp_vlans ) { + my $vlan = 0; + my $vtp_dom = 0; + my $state = $vtp_vlans->{$iid}; next unless defined $state; next if $state !~ /operational/; - if ($iid =~ /(\d+)\.(\d+)/ ) { + if ( $iid =~ /(\d+)\.(\d+)/ ) { $vtp_dom = $1; $vlan = $2; } $oper_vlans{$vlan}++; } - foreach my $port (keys %$ports_vlans) { + foreach my $port ( keys %$ports_vlans ) { my $stat = $trunk_dyn_stat->{$port}; if ( defined $stat and $stat =~ /^trunking/ ) { - my $k = 0; + my $k = 0; my $list1 = $ports_vlans->{$port} || '0'; my $list2 = $ports_vlans_2k->{$port} || '0'; my $list3 = $ports_vlans_3k->{$port} || '0'; my $list4 = $ports_vlans_4k->{$port} || '0'; - foreach my $list ("$list1", "$list2", "$list3", "$list4") { + foreach my $list ( "$list1", "$list2", "$list3", "$list4" ) { my $offset = 1024 * $k++; next unless $list; - my $vlanlist = [split(//, unpack("B*", $list))]; - foreach my $vlan (keys %oper_vlans) { - push(@{$i_vlan_membership->{$port}}, $vlan) if (@$vlanlist[$vlan-$offset]); + my $vlanlist = [ split( //, unpack( "B*", $list ) ) ]; + foreach my $vlan ( keys %oper_vlans ) { + push( @{ $i_vlan_membership->{$port} }, $vlan ) + if ( @$vlanlist[ $vlan - $offset ] ); } } } @@ -248,18 +256,22 @@ sub i_vlan_membership { sub set_i_pvid { my $vtp = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) ); my $native_vlan = $vtp->vtp_trunk_native($ifindex); - if (defined $native_vlan) { + if ( defined $native_vlan ) { - print "Changing native VLAN from $native_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n" if $vtp->debug(); + print + "Changing native VLAN from $native_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n" + if $vtp->debug(); - my $rv = $vtp->set_vtp_trunk_native($vlan_id, $ifindex); + my $rv = $vtp->set_vtp_trunk_native( $vlan_id, $ifindex ); unless ($rv) { - $vtp->error_throw("Unable to change native VLAN to $vlan_id on IfIndex: $ifindex"); + $vtp->error_throw( + "Unable to change native VLAN to $vlan_id on IfIndex: $ifindex" + ); return; } return $rv; @@ -270,18 +282,21 @@ sub set_i_pvid { sub set_i_vlan { my $vtp = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) ); my $i_vlan = $vtp->i_vlan2($ifindex); - if (defined $i_vlan) { + if ( defined $i_vlan ) { - print "Changing VLAN from $i_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n" if $vtp->debug(); + print + "Changing VLAN from $i_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n" + if $vtp->debug(); - my $rv = $vtp->set_i_vlan2($vlan_id, $ifindex); + my $rv = $vtp->set_i_vlan2( $vlan_id, $ifindex ); unless ($rv) { - $vtp->error_throw("Unable to change VLAN to $vlan_id on IfIndex: $ifindex"); + $vtp->error_throw( + "Unable to change VLAN to $vlan_id on IfIndex: $ifindex"); return; } return $rv; @@ -292,36 +307,44 @@ sub set_i_vlan { sub set_add_i_vlan_tagged { my $vtp = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) ); print "Adding VLAN: $vlan_id to ifIndex: $ifindex\n" if $vtp->debug(); - my $trunk_serial = $vtp->load_vtp_trunk_set_serial(); - my $trunk_members = $vtp->vtp_trunk_vlans($ifindex); + my $trunk_serial = $vtp->load_vtp_trunk_set_serial(); + my $trunk_members = $vtp->vtp_trunk_vlans($ifindex); - unless (defined $trunk_members) { - $vtp->error_throw("Can't find ifIndex: $ifindex - Is it a trunk port?"); + unless ( defined $trunk_members ) { + $vtp->error_throw( + "Can't find ifIndex: $ifindex - Is it a trunk port?"); return; } - my @member_list = split(//, unpack("B*", $trunk_members->{$ifindex})); - - print "Original vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); + my @member_list = split( //, unpack( "B*", $trunk_members->{$ifindex} ) ); + + print "Original vlan list for ifIndex: $ifindex: @member_list \n" + if $vtp->debug(); $member_list[$vlan_id] = '1'; - print "Modified vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); - my $new_list = pack("B*", join('', @member_list)); + print "Modified vlan list for ifIndex: $ifindex: @member_list \n" + if $vtp->debug(); + my $new_list = pack( "B*", join( '', @member_list ) ); + #Add VLAN to member list - my $list_rv = $vtp->set_vtp_trunk_vlans($new_list, $ifindex); + my $list_rv = $vtp->set_vtp_trunk_vlans( $new_list, $ifindex ); unless ($list_rv) { - $vtp->error_throw("Unable to add VLAN: $vlan_id to ifIndex: $ifindex member list"); + $vtp->error_throw( + "Unable to add VLAN: $vlan_id to ifIndex: $ifindex member list"); return; } - #Make sure no other SNMP manager was making modifications at the same time. + + #Make sure no other SNMP manager was making modifications at the same time. my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial); unless ($serial_rv) { - $vtp->error_throw("Unable to increment trunk set serial number - check configuration!"); + $vtp->error_throw( + "Unable to increment trunk set serial number - check configuration!" + ); return; } return 1; @@ -329,54 +352,67 @@ sub set_add_i_vlan_tagged { sub set_remove_i_vlan_tagged { my $vtp = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) ); print "Removing VLAN: $vlan_id from ifIndex: $ifindex\n" if $vtp->debug(); - my $trunk_serial = $vtp->load_vtp_trunk_set_serial(); - my $trunk_members = $vtp->vtp_trunk_vlans($ifindex); + my $trunk_serial = $vtp->load_vtp_trunk_set_serial(); + my $trunk_members = $vtp->vtp_trunk_vlans($ifindex); - unless (defined $trunk_members) { - $vtp->error_throw("Can't find ifIndex: $ifindex - Is it a trunk port?"); + unless ( defined $trunk_members ) { + $vtp->error_throw( + "Can't find ifIndex: $ifindex - Is it a trunk port?"); return; } - my @member_list = split(//, unpack("B*", $trunk_members->{$ifindex})); - - print "Original vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); + my @member_list = split( //, unpack( "B*", $trunk_members->{$ifindex} ) ); + + print "Original vlan list for ifIndex: $ifindex: @member_list \n" + if $vtp->debug(); $member_list[$vlan_id] = '0'; - print "Modified vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); - my $new_list = pack("B*", join('', @member_list)); + print "Modified vlan list for ifIndex: $ifindex: @member_list \n" + if $vtp->debug(); + my $new_list = pack( "B*", join( '', @member_list ) ); + #Remove VLAN to member list - my $list_rv = $vtp->set_vtp_trunk_vlans($new_list, $ifindex); + my $list_rv = $vtp->set_vtp_trunk_vlans( $new_list, $ifindex ); unless ($list_rv) { - $vtp->error_throw("Error: Unable to remove VLAN: $vlan_id from ifIndex: $ifindex member list"); + $vtp->error_throw( + "Error: Unable to remove VLAN: $vlan_id from ifIndex: $ifindex member list" + ); return; } + #Make sure no other manager was making modifications at the same time. my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial); unless ($serial_rv) { - $vtp->error_throw("Error: Unable to increment trunk set serial number - check configuration!"); + $vtp->error_throw( + "Error: Unable to increment trunk set serial number - check configuration!" + ); return; } return 1; } # -# These are internal methods and are not documented. Do not use directly. +# These are internal methods and are not documented. Do not use directly. # sub _validate_vlan_param { my $vtp = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; # VID and ifIndex should both be numeric - unless ( defined $vlan_id and defined $ifindex and $vlan_id =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { + unless (defined $vlan_id + and defined $ifindex + and $vlan_id =~ /^\d+$/ + and $ifindex =~ /^\d+$/ ) + { $vtp->error_throw("Invalid parameter"); return; } - + # Check that ifIndex exists on device my $index = $vtp->interfaces($ifindex); @@ -388,22 +424,23 @@ sub _validate_vlan_param { #Check that VLAN exists on device my $vtp_vlans = $vtp->v_state(); my $vlan_exists = 0; - - foreach my $iid (keys %$vtp_vlans) { - my $vlan = 0; - my $vtp_dom =0; - my $state = $vtp_vlans->{$iid}; + + foreach my $iid ( keys %$vtp_vlans ) { + my $vlan = 0; + my $vtp_dom = 0; + my $state = $vtp_vlans->{$iid}; next unless defined $state; next if $state !~ /operational/; - if ($iid =~ /(\d+)\.(\d+)/ ) { + if ( $iid =~ /(\d+)\.(\d+)/ ) { $vtp_dom = $1; $vlan = $2; } - + $vlan_exists = 1 if ( $vlan_id eq $vlan ); } - unless ( $vlan_exists ) { - $vtp->error_throw("VLAN $vlan_id does not exist or is not operational"); + unless ($vlan_exists) { + $vtp->error_throw( + "VLAN $vlan_id does not exist or is not operational"); return; } @@ -769,9 +806,10 @@ Each bit represents a VLAN. This is 3072 through 4095 =head1 SET METHODS -These are methods that provide SNMP set functionality for overridden methods or -provide a simpler interface to complex set operations. See -L for general information on set operations. +These are methods that provide SNMP set functionality for overridden methods +or provide a simpler interface to complex set operations. See +L for general information on set +operations. =over diff --git a/Info/Entity.pm b/Info/Entity.pm index 51e7f266..7c872e94 100644 --- a/Info/Entity.pm +++ b/Info/Entity.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * 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 +# +# 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 @@ -36,70 +36,67 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::Entity::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::Entity::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Entity::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ('ENTITY-MIB' => 'entPhysicalSerialNum'); +%MIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum' ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - 'e_alias' => 'entPhysicalAlias', - 'e_class' => 'entPhysicalClass', - 'e_descr' => 'entPhysicalDescr', - 'e_fwver' => 'entPhysicalFirmwareRev', - 'e_fru' => 'entPhysicalIsFRU', - 'e_hwver' => 'entPhysicalHardwareRev', - 'e_id' => 'entPhysicalAssetID', - 'e_map' => 'entAliasMappingIdentifier', - 'e_model' => 'entPhysicalModelName', - 'e_name' => 'entPhysicalName', - 'e_parent' => 'entPhysicalContainedIn', - 'e_pos' => 'entPhysicalParentRelPos', - 'e_serial' => 'entPhysicalSerialNum', - 'e_swver' => 'entPhysicalSoftwareRev', - 'e_type' => 'entPhysicalVendorType', - 'e_vendor' => 'entPhysicalMfgName', - ); +%FUNCS = ( + 'e_alias' => 'entPhysicalAlias', + 'e_class' => 'entPhysicalClass', + 'e_descr' => 'entPhysicalDescr', + 'e_fwver' => 'entPhysicalFirmwareRev', + 'e_fru' => 'entPhysicalIsFRU', + 'e_hwver' => 'entPhysicalHardwareRev', + 'e_id' => 'entPhysicalAssetID', + 'e_map' => 'entAliasMappingIdentifier', + 'e_model' => 'entPhysicalModelName', + 'e_name' => 'entPhysicalName', + 'e_parent' => 'entPhysicalContainedIn', + 'e_pos' => 'entPhysicalParentRelPos', + 'e_serial' => 'entPhysicalSerialNum', + 'e_swver' => 'entPhysicalSoftwareRev', + 'e_type' => 'entPhysicalVendorType', + 'e_vendor' => 'entPhysicalMfgName', +); -%MUNGE = ( - 'e_type' => \&SNMP::Info::munge_e_type, - ); +%MUNGE = ( 'e_type' => \&SNMP::Info::munge_e_type, ); # entPhysicalIndex is not-accessible. Create to facilitate emulation methods # in other classes sub e_index { - my $entity = shift; + my $entity = shift; my $partial = shift; # Force use of MIB leaf to avoid inheritance issues in psuedo classes - my $e_descr = $entity->entPhysicalDescr($partial); + my $e_descr = $entity->entPhysicalDescr($partial); return unless ($e_descr); - + my %e_index; - foreach my $iid (keys %$e_descr) { + foreach my $iid ( keys %$e_descr ) { $e_index{$iid} = $iid; } return \%e_index; } sub e_port { - my $entity = shift; + my $entity = shift; my $partial = shift; - my $e_map = $entity->e_map($partial); + my $e_map = $entity->e_map($partial); my %e_port; - foreach my $e_id (keys %$e_map) { + foreach my $e_id ( keys %$e_map ) { my $id = $e_id; $id =~ s/\.0$//; diff --git a/Info/EtherLike.pm b/Info/EtherLike.pm index bf36120e..3e206332 100644 --- a/Info/EtherLike.pm +++ b/Info/EtherLike.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,46 +36,43 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::EtherLike::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'ETHERLIKE-MIB' => 'etherMIB' - ); +%MIBS = ( 'ETHERLIKE-MIB' => 'etherMIB' ); %GLOBALS = (); %FUNCS = ( - # EtherLike StatsTable - 'el_chipset' => 'dot3StatsEtherChipSet', - 'el_coll_excess' => 'dot3StatsExcessiveCollisions', - 'el_coll_late' => 'dot3StatsLateCollisions', - 'el_coll_mult' => 'dot3StatsMultipleCollisionFrames', - 'el_coll_single' => 'dot3StatsSingleCollisionFrames', - 'el_duplex' => 'dot3StatsDuplexStatus', - 'el_error_alignment' => 'dot3StatsAlignmentErrors', - 'el_error_fcs' => 'dot3StatsFCSErrors', - 'el_error_cs' => 'dot3StatsCarrierSenseErrors', - 'el_error_frame' => 'dot3StatsFrameTooLongs', - 'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors', - 'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors', - 'el_error_sqe' => 'dot3StatsSQETestErrors', - 'el_error_symbol' => 'dot3StatsSymbolErrors', - 'el_index' => 'dot3StatsIndex', - 'el_xmit_defer' => 'dot3StatsDeferredTransmissions', - # Ethernet-like Collision Statistics Group - 'el_coll_count' => 'dot3CollCount', - 'el_coll_freq' => 'dot3CollFrequencies' - ); -%MUNGE = ( - %SNMP::Info::MUNGE, - 'el_duplex' => \&munge_el_duplex, - ); + # EtherLike StatsTable + 'el_chipset' => 'dot3StatsEtherChipSet', + 'el_coll_excess' => 'dot3StatsExcessiveCollisions', + 'el_coll_late' => 'dot3StatsLateCollisions', + 'el_coll_mult' => 'dot3StatsMultipleCollisionFrames', + 'el_coll_single' => 'dot3StatsSingleCollisionFrames', + 'el_duplex' => 'dot3StatsDuplexStatus', + 'el_error_alignment' => 'dot3StatsAlignmentErrors', + 'el_error_fcs' => 'dot3StatsFCSErrors', + 'el_error_cs' => 'dot3StatsCarrierSenseErrors', + 'el_error_frame' => 'dot3StatsFrameTooLongs', + 'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors', + 'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors', + 'el_error_sqe' => 'dot3StatsSQETestErrors', + 'el_error_symbol' => 'dot3StatsSymbolErrors', + 'el_index' => 'dot3StatsIndex', + 'el_xmit_defer' => 'dot3StatsDeferredTransmissions', + + # Ethernet-like Collision Statistics Group + 'el_coll_count' => 'dot3CollCount', + 'el_coll_freq' => 'dot3CollFrequencies' +); + +%MUNGE = ( %SNMP::Info::MUNGE, 'el_duplex' => \&munge_el_duplex, ); sub munge_el_duplex { my $duplex = shift; @@ -85,7 +82,6 @@ sub munge_el_duplex { return $duplex; } - 1; __END__ @@ -111,7 +107,8 @@ Max Baker my $class = $cdp->class(); print " Using device sub class : $class\n"; - # Find the duplex setting for a port on a device that implements ETHERLIKE-MIB + # Find the duplex setting for a port on a device that implements + # ETHERLIKE-MIB my $interfaces = $el->interfaces(); my $el_index = $el->el_index(); my $el_duplex = $el->el_duplex(); diff --git a/Info/FDP.pm b/Info/FDP.pm index 8535fff3..de6caea9 100644 --- a/Info/FDP.pm +++ b/Info/FDP.pm @@ -1,26 +1,26 @@ # SNMP::Info::FDP # $Id$ # -# Copyright (c) 2008 Bruce Rodger, Max Baker -# All rights reserved. +# Copyright (c) 2008 Bruce Rodger, Max Baker +# All rights reserved. # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,51 +37,50 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::FDP::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::FDP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::FDP::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' - ); +%MIBS = ( 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' ); %GLOBALS = ( - # CDP-Compatibility - 'cdp_interval' => 'snFdpGlobalMessageInterval', - 'cdp_holdtime' => 'snFdpGlobalHoldTime', - 'cdp_id' => 'snFdpGlobalDeviceId', - # - 'fdp_run' => 'snFdpGlobalRun', - 'fdp_interval' => 'snFdpGlobalMessageInterval', - 'fdp_holdtime' => 'snFdpGlobalHoldTime', - 'fdp_id' => 'snFdpGlobalDeviceId', - ); -%FUNCS = ( - 'c_index' => 'snFdpCacheIfIndex', - 'c_proto' => 'snFdpCacheAddressType', - 'c_ip' => 'snFdpCacheAddress', - 'c_ver' => 'snFdpCacheVersion', - 'c_id' => 'snFdpCacheDeviceId', - 'c_port' => 'snFdpCacheDevicePort', - 'c_platform' => 'snFdpCachePlatform', - 'c_capabilities' => 'snFdpCacheCapabilities', - 'c_domain' => 'snFdpCacheVTPMgmtDomain', - 'c_vlan' => 'snFdpCacheNativeVLAN', - 'c_duplex' => 'snFdpCacheDuplex', - ); + # CDP-Compatibility + 'cdp_interval' => 'snFdpGlobalMessageInterval', + 'cdp_holdtime' => 'snFdpGlobalHoldTime', + 'cdp_id' => 'snFdpGlobalDeviceId', + + # + 'fdp_run' => 'snFdpGlobalRun', + 'fdp_interval' => 'snFdpGlobalMessageInterval', + 'fdp_holdtime' => 'snFdpGlobalHoldTime', + 'fdp_id' => 'snFdpGlobalDeviceId', +); + +%FUNCS = ( + 'c_index' => 'snFdpCacheIfIndex', + 'c_proto' => 'snFdpCacheAddressType', + 'c_ip' => 'snFdpCacheAddress', + 'c_ver' => 'snFdpCacheVersion', + 'c_id' => 'snFdpCacheDeviceId', + 'c_port' => 'snFdpCacheDevicePort', + 'c_platform' => 'snFdpCachePlatform', + 'c_capabilities' => 'snFdpCacheCapabilities', + 'c_domain' => 'snFdpCacheVTPMgmtDomain', + 'c_vlan' => 'snFdpCacheNativeVLAN', + 'c_duplex' => 'snFdpCacheDuplex', +); %MUNGE = ( - 'c_capabilities' => \&SNMP::Info::munge_caps, - 'c_ip' => \&SNMP::Info::munge_ip - ); - + 'c_capabilities' => \&SNMP::Info::munge_caps, + 'c_ip' => \&SNMP::Info::munge_ip +); sub cdp_run { - my $fdp = shift; + my $fdp = shift; my $fdp_run = $fdp->fdp_run(); # if fdp_run isn't implemented on device, assume FDP is on @@ -93,40 +92,45 @@ sub hasFDP { my $fdp = shift; my $ver = $fdp->{_version}; + #my $ver = $fdp->fdp_ver; # SNMP v1 clients dont have the globals - if (defined $ver and $ver == 1){ + if ( defined $ver and $ver == 1 ) { my $fdp_ip = $fdp->fdp_ip(); + # See if anything in fdp cache, if so we have fdp - return 1 if (defined $fdp_ip and scalar(keys %$fdp_ip)) ; + return 1 if ( defined $fdp_ip and scalar( keys %$fdp_ip ) ); return; } - + return $fdp->fdp_run(); } sub c_if { - my $fdp = shift; + my $fdp = shift; # See if by some miracle Cisco implemented the fdpCacheIfIndex entry - my $fdp_index = $fdp->fdp_index(); + my $fdp_index = $fdp->fdp_index(); return $fdp_index if defined $fdp_index; # Nope, didn't think so. Now we fake it. my $fdp_ip = $fdp->c_ip(); - unless (defined $fdp_ip){ - $fdp->error_throw("SNMP::Info::FDP:fdp_if() - Device doesn't have fdp_ip() data. Can't fake fdp_index()"); + unless ( defined $fdp_ip ) { + $fdp->error_throw( + "SNMP::Info::FDP:fdp_if() - Device doesn't have fdp_ip() data. Can't fake fdp_index()" + ); return; } my %fdp_if; - foreach my $key (keys %$fdp_ip){ - next unless defined $key; - my $iid = $key; - # Truncate .1 from fdp cache entry - $iid =~ s/\.\d+$//; - $fdp_if{$key} = $iid; + foreach my $key ( keys %$fdp_ip ) { + next unless defined $key; + my $iid = $key; + + # Truncate .1 from fdp cache entry + $iid =~ s/\.\d+$//; + $fdp_if{$key} = $iid; } return \%fdp_if; diff --git a/Info/IEEE802dot11.pm b/Info/IEEE802dot11.pm index 1cbe485b..6443727a 100644 --- a/Info/IEEE802dot11.pm +++ b/Info/IEEE802dot11.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -33,69 +33,73 @@ package SNMP::Info::IEEE802dot11; use strict; use Exporter; -@SNMP::Info::IEEE802dot11::ISA = qw/Exporter/; +@SNMP::Info::IEEE802dot11::ISA = qw/Exporter/; @SNMP::Info::IEEE802dot11::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'IEEE802dot11-MIB' => 'dot11DesiredSSID', - ); +%MIBS = ( 'IEEE802dot11-MIB' => 'dot11DesiredSSID', ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - # dot11PhyOFDMTable - 'dot11_cur_freq' => 'dot11CurrentFrequency', - # dot11PhyDSSSTable - 'dot11_cur_ch' => 'dot11CurrentChannel', - # dot11PhyOperationTable - 'dot11_phy_type' => 'dot11PHYType', - 'dot11_reg_dom' => 'dot11CurrentRegDomain', - # dot11ResourceInfoTable - 'dot11_prod_ver' => 'dot11manufacturerProductVersion', - 'dot11_prod_name' => 'dot11manufacturerProductName', - 'dot11_man_name' => 'dot11manufacturerName', - # dot11OperationTable - 'dot11_mac' => 'dot11MACAddress', - # dot11StationConfigTable - 'dot11_bss_type' => 'dot11DesiredBSSType', - 'i_ssidlist' => 'dot11DesiredSSID', - 'dot11_pwr_mode' => 'dot11PowerManagementMode', - 'dot11_sta_id' => 'dot11StationID', - # dot11PhyTxPowerTable - 'dot11_cur_tx_pwr' => 'dot11CurrentTxPowerLevel', - 'dot11_tx_pwr_level_1' => 'dot11TxPowerLevel1', - 'dot11_tx_pwr_level_2' => 'dot11TxPowerLevel2', - 'dot11_tx_pwr_level_3' => 'dot11TxPowerLevel3', - 'dot11_tx_pwr_level_4' => 'dot11TxPowerLevel4', - 'dot11_tx_pwr_level_5' => 'dot11TxPowerLevel5', - 'dot11_tx_pwr_level_6' => 'dot11TxPowerLevel6', - 'dot11_tx_pwr_level_7' => 'dot11TxPowerLevel7', - 'dot11_tx_pwr_level_8' => 'dot11TxPowerLevel8', - ); +%FUNCS = ( -%MUNGE = ( - 'dot11_mac' => \&SNMP::Info::munge_mac, - 'dot11_sta_id' => \&SNMP::Info::munge_mac, - ); + # dot11PhyOFDMTable + 'dot11_cur_freq' => 'dot11CurrentFrequency', + + # dot11PhyDSSSTable + 'dot11_cur_ch' => 'dot11CurrentChannel', + + # dot11PhyOperationTable + 'dot11_phy_type' => 'dot11PHYType', + 'dot11_reg_dom' => 'dot11CurrentRegDomain', + + # dot11ResourceInfoTable + 'dot11_prod_ver' => 'dot11manufacturerProductVersion', + 'dot11_prod_name' => 'dot11manufacturerProductName', + 'dot11_man_name' => 'dot11manufacturerName', + + # dot11OperationTable + 'dot11_mac' => 'dot11MACAddress', + + # dot11StationConfigTable + 'dot11_bss_type' => 'dot11DesiredBSSType', + 'i_ssidlist' => 'dot11DesiredSSID', + 'dot11_pwr_mode' => 'dot11PowerManagementMode', + 'dot11_sta_id' => 'dot11StationID', + + # dot11PhyTxPowerTable + 'dot11_cur_tx_pwr' => 'dot11CurrentTxPowerLevel', + 'dot11_tx_pwr_level_1' => 'dot11TxPowerLevel1', + 'dot11_tx_pwr_level_2' => 'dot11TxPowerLevel2', + 'dot11_tx_pwr_level_3' => 'dot11TxPowerLevel3', + 'dot11_tx_pwr_level_4' => 'dot11TxPowerLevel4', + 'dot11_tx_pwr_level_5' => 'dot11TxPowerLevel5', + 'dot11_tx_pwr_level_6' => 'dot11TxPowerLevel6', + 'dot11_tx_pwr_level_7' => 'dot11TxPowerLevel7', + 'dot11_tx_pwr_level_8' => 'dot11TxPowerLevel8', +); + +%MUNGE = ( + 'dot11_mac' => \&SNMP::Info::munge_mac, + 'dot11_sta_id' => \&SNMP::Info::munge_mac, +); sub vendor { my $dot11 = shift; my $names = $dot11->dot11_man_name(); - - foreach my $iid (keys %$names){ + + foreach my $iid ( keys %$names ) { my $vendor = $names->{$iid}; next unless defined $vendor; if ( $vendor =~ /^(\S+)/ ) { return lc($1); } } - + return; } @@ -103,12 +107,12 @@ sub model { my $dot11 = shift; my $names = $dot11->dot11_prod_name(); - - foreach my $iid (keys %$names){ + + foreach my $iid ( keys %$names ) { my $prod = $names->{$iid}; next unless defined $prod; return lc($prod); - } + } return; } @@ -116,15 +120,15 @@ sub os_ver { my $dot11 = shift; my $versions = $dot11->dot11_prod_ver(); - - foreach my $iid (keys %$versions){ + + foreach my $iid ( keys %$versions ) { my $ver = $versions->{$iid}; next unless defined $ver; if ( $ver =~ /([\d\.]+)/ ) { return $1; } } - + return; } @@ -133,18 +137,18 @@ sub i_80211channel { my $phy_type = $dot11->dot11_phy_type() || {}; my $cur_freq = $dot11->dot11_cur_freq() || {}; - my $cur_ch = $dot11->dot11_cur_ch() || {}; + my $cur_ch = $dot11->dot11_cur_ch() || {}; my %i_80211channel; - foreach my $iid (keys %$phy_type){ + foreach my $iid ( keys %$phy_type ) { my $type = $phy_type->{$iid}; next unless defined $type; - if ($type =~ /dsss/) { + if ( $type =~ /dsss/ ) { my $ch = $cur_ch->{$iid}; next unless defined $ch; $i_80211channel{$iid} = $ch; } - elsif ($type =~ /ofdm/) { + elsif ( $type =~ /ofdm/ ) { my $ch = $cur_freq->{$iid}; next unless defined $ch; $i_80211channel{$iid} = $ch; @@ -158,17 +162,20 @@ sub i_80211channel { } sub dot11_cur_tx_pwr_mw { - my $dot11 = shift; - my $partial = shift; - my $cur = $dot11->dot11_cur_tx_pwr($partial); + my $dot11 = shift; + my $partial = shift; + my $cur = $dot11->dot11_cur_tx_pwr($partial); my $dot11_cur_tx_pwr_mw = {}; - foreach my $idx (keys %$cur) { + foreach my $idx ( keys %$cur ) { my $pwr = $cur->{$idx}; - if ($pwr >= 1 && $pwr <= 8) { - # ToDo - Look at string eval - my $mw = eval "\$dot11->dot11_tx_pwr_level_$pwr(\$idx)"; ## no critic + if ( $pwr >= 1 && $pwr <= 8 ) { + + # ToDo - Look at string eval + my $mw + = eval "\$dot11->dot11_tx_pwr_level_$pwr(\$idx)"; ## no critic $dot11_cur_tx_pwr_mw->{$idx} = $mw->{$idx}; - } else { + } + else { next; } } @@ -204,9 +211,9 @@ Eric Miller =head1 DESCRIPTION -SNMP::Info::IEEE802dot11 is a subclass of SNMP::Info that provides an interface -to F. This MIB is used in standards based 802.11 wireless -devices. +SNMP::Info::IEEE802dot11 is a subclass of SNMP::Info that provides an +interface to F. This MIB is used in standards based +802.11 wireless devices. Use or create a subclass of SNMP::Info that inherits this one. Do not use directly. @@ -270,8 +277,8 @@ interface. =item $dot11->dot11_cur_tx_pwr_mw() -Returns reference to hash. Current transmit power, in milliwatts, of the radio -interface. +Returns reference to hash. Current transmit power, in milliwatts, of the +radio interface. =back diff --git a/Info/LLDP.pm b/Info/LLDP.pm index 5a236c4d..22bc2138 100644 --- a/Info/LLDP.pm +++ b/Info/LLDP.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -33,52 +33,54 @@ package SNMP::Info::LLDP; use strict; use Exporter; use SNMP::Info; - -@SNMP::Info::LLDP::ISA = qw/SNMP::Info Exporter/; + +@SNMP::Info::LLDP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::LLDP::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'LLDP-MIB' => 'lldpLocSysCapEnabled', - 'LLDP-EXT-DOT1-MIB' => 'lldpXdot1MIB', - 'LLDP-EXT-DOT3-MIB' => 'lldpXdot3MIB', - ); +%MIBS = ( + 'LLDP-MIB' => 'lldpLocSysCapEnabled', + 'LLDP-EXT-DOT1-MIB' => 'lldpXdot1MIB', + 'LLDP-EXT-DOT3-MIB' => 'lldpXdot3MIB', +); %GLOBALS = ( - 'lldp_sysname' => 'lldpLocSysName', - 'lldp_sysdesc' => 'lldpLocSysDesc', - 'lldp_sys_cap' => 'lldpLocSysCapEnabled', - ); + 'lldp_sysname' => 'lldpLocSysName', + 'lldp_sysdesc' => 'lldpLocSysDesc', + 'lldp_sys_cap' => 'lldpLocSysCapEnabled', +); -%FUNCS = ( - # LLDP-MIB::lldpLocManAddrTable - 'lldp_lman_addr' => 'lldpLocManAddrIfId', - # LLDP-MIB::lldpRemTable - 'lldp_rem_id_type' => 'lldpRemChassisIdSubtype', - 'lldp_rem_id' => 'lldpRemChassisId', - 'lldp_rem_pid_type' => 'lldpRemPortIdSubtype', - 'lldp_rem_pid' => 'lldpRemPortId', - 'lldp_rem_desc' => 'lldpRemPortDesc', - 'lldp_rem_sysname' => 'lldpRemSysName', - 'lldp_rem_sysdesc' => 'lldpRemSysDesc', - 'lldp_rem_sys_cap' => 'lldpRemSysCapEnabled', - # LLDP-MIB::lldpRemManAddrTable - 'lldp_rman_addr' => 'lldpRemManAddrIfSubtype', - ); +%FUNCS = ( + # LLDP-MIB::lldpLocManAddrTable + 'lldp_lman_addr' => 'lldpLocManAddrIfId', + + # LLDP-MIB::lldpRemTable + 'lldp_rem_id_type' => 'lldpRemChassisIdSubtype', + 'lldp_rem_id' => 'lldpRemChassisId', + 'lldp_rem_pid_type' => 'lldpRemPortIdSubtype', + 'lldp_rem_pid' => 'lldpRemPortId', + 'lldp_rem_desc' => 'lldpRemPortDesc', + 'lldp_rem_sysname' => 'lldpRemSysName', + 'lldp_rem_sysdesc' => 'lldpRemSysDesc', + 'lldp_rem_sys_cap' => 'lldpRemSysCapEnabled', + + # LLDP-MIB::lldpRemManAddrTable + 'lldp_rman_addr' => 'lldpRemManAddrIfSubtype', +); %MUNGE = ( - 'lldp_sysdesc' => \&SNMP::Info::munge_null, - 'lldp_sysname' => \&SNMP::Info::munge_null, - 'lldp_rem_sysname' => \&SNMP::Info::munge_null, - 'lldp_rem_sysdesc' => \&SNMP::Info::munge_null, - 'lldp_rem_port_desc' => \&SNMP::Info::munge_null, - 'lldp_sys_cap' => \&SNMP::Info::munge_bits, - 'lldp_rem_sys_cap' => \&SNMP::Info::munge_bits, - ); + 'lldp_sysdesc' => \&SNMP::Info::munge_null, + 'lldp_sysname' => \&SNMP::Info::munge_null, + 'lldp_rem_sysname' => \&SNMP::Info::munge_null, + 'lldp_rem_sysdesc' => \&SNMP::Info::munge_null, + 'lldp_rem_port_desc' => \&SNMP::Info::munge_null, + 'lldp_sys_cap' => \&SNMP::Info::munge_bits, + 'lldp_rem_sys_cap' => \&SNMP::Info::munge_bits, +); sub hasLLDP { my $lldp = shift; @@ -96,25 +98,25 @@ sub lldp_if { my $partial = shift; my $addr = $lldp->lldp_rem_pid($partial) || {}; - + my %lldp_if; - foreach my $key (keys %$addr) { - my @aOID = split ('\.',$key); - my $port = $aOID[1]; - $lldp_if{$key} = $port; + foreach my $key ( keys %$addr ) { + my @aOID = split( '\.', $key ); + my $port = $aOID[1]; + $lldp_if{$key} = $port; } return \%lldp_if; } sub lldp_ip { - my $lldp = shift; + my $lldp = shift; my $partial = shift; my $rman_addr = $lldp->lldp_rman_addr($partial) || {}; - - my %lldp_ip; - foreach my $key (keys %$rman_addr) { - my($index, $proto, $addr) = _lldp_addr_index($key); + + my %lldp_ip; + foreach my $key ( keys %$rman_addr ) { + my ( $index, $proto, $addr ) = _lldp_addr_index($key); next unless defined $index; next unless $proto == 1; $lldp_ip{$index} = $addr; @@ -123,14 +125,14 @@ sub lldp_ip { } sub lldp_addr { - my $lldp = shift; + my $lldp = shift; my $partial = shift; my $rman_addr = $lldp->lldp_rman_addr($partial) || {}; - - my %lldp_ip; - foreach my $key (keys %$rman_addr) { - my($index, $proto, $addr) = _lldp_addr_index($key); + + my %lldp_ip; + foreach my $key ( keys %$rman_addr ) { + my ( $index, $proto, $addr ) = _lldp_addr_index($key); next unless defined $index; $lldp_ip{$index} = $addr; } @@ -138,29 +140,31 @@ sub lldp_addr { } sub lldp_port { - my $lldp = shift; + my $lldp = shift; my $partial = shift; - my $pdesc = $lldp->lldp_rem_desc($partial) || {}; - my $pid = $lldp->lldp_rem_pid($partial) || {}; - my $ptype = $lldp->lldp_rem_pid_type($partial) || {}; + my $pdesc = $lldp->lldp_rem_desc($partial) || {}; + my $pid = $lldp->lldp_rem_pid($partial) || {}; + my $ptype = $lldp->lldp_rem_pid_type($partial) || {}; - my %lldp_port; - foreach my $key (sort keys %$pid) { + my %lldp_port; + foreach my $key ( sort keys %$pid ) { my $port = $pdesc->{$key}; - unless ($port) { + unless ($port) { $port = $pid->{$key}; next unless $port; - my $type = $ptype->{$key}; + my $type = $ptype->{$key}; next unless $type; - # May need to format other types in the future, i.e. Network address - if ($type =~ /mac/) { - $port = join(':',map { sprintf "%02x",$_ } unpack('C*',$port)); + + # May need to format other types in the future, i.e. Network address + if ( $type =~ /mac/ ) { + $port = join( ':', + map { sprintf "%02x", $_ } unpack( 'C*', $port ) ); } } # Nortel lldpRemPortDesc doesn't match ifDescr, but we can still - # figure out slot.port based upon lldpRemPortDesc + # figure out slot.port based upon lldpRemPortDesc if ( $port =~ /^(Unit\s+(\d+)\s+)?Port\s+(\d+)$/ ) { $port = defined $1 ? "$2.$3" : "$3"; } @@ -171,21 +175,22 @@ sub lldp_port { } sub lldp_id { - my $lldp = shift; + my $lldp = shift; my $partial = shift; - - my $ch_type = $lldp->lldp_rem_id_type($partial) || {}; - my $ch = $lldp->lldp_rem_id($partial) || {}; - my %lldp_id; - foreach my $key (keys %$ch) { - my $id = $ch->{$key}; + my $ch_type = $lldp->lldp_rem_id_type($partial) || {}; + my $ch = $lldp->lldp_rem_id($partial) || {}; + + my %lldp_id; + foreach my $key ( keys %$ch ) { + my $id = $ch->{$key}; next unless $id; - my $type = $ch_type->{$key}; + my $type = $ch_type->{$key}; next unless $type; + # May need to format other types in the future - if ($type =~ /mac/) { - $id = join(':',map { sprintf "%02x",$_ } unpack('C*',$id)); + if ( $type =~ /mac/ ) { + $id = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $id ) ); } $lldp_id{$key} = $id; } @@ -213,19 +218,23 @@ sub lldp_id { # Break up the lldpRemManAddrTable INDEX into common index, protocol, # and address. sub _lldp_addr_index { - my $idx = shift; - my @oids = split(/\./, $idx); - my $index = join('.', splice(@oids, 0, 3)); + my $idx = shift; + my @oids = split( /\./, $idx ); + my $index = join( '.', splice( @oids, 0, 3 ) ); my $proto = shift(@oids); my $length = shift(@oids); + # IPv4 - if ($proto == 1) { - return ($index, $proto, join('.',@oids)); + if ( $proto == 1 ) { + return ( $index, $proto, join( '.', @oids ) ); } + # MAC - elsif ($proto == 6) { - return ($index, $proto, join(':',map { sprintf "%02x",$_ } @oids)); + elsif ( $proto == 6 ) { + return ( $index, $proto, + join( ':', map { sprintf "%02x", $_ } @oids ) ); } + # TODO - Need to handle other protocols, i.e. IPv6 else { return; diff --git a/Info/Layer1.pm b/Info/Layer1.pm index 9fac0dff..2bfa2f03 100644 --- a/Info/Layer1.pm +++ b/Info/Layer1.pm @@ -1,25 +1,25 @@ -# SNMP::Info::Layer1 - SNMP Interface to Layer1 Devices +# SNMP::Info::Layer1 - SNMP Interface to Layer1 Devices # $Id$ # # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond. # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,39 +36,38 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Layer1::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::MIBS, - 'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex' - ); +%MIBS = ( %SNMP::Info::MIBS, 'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex' ); %GLOBALS = ( - %SNMP::Info::GLOBALS, - 'ports_managed' => 'ifNumber', - 'rptr_slots' => 'rptrGroupCapacity', - 'slots' => 'rptrGroupCapacity' - ); + %SNMP::Info::GLOBALS, + 'ports_managed' => 'ifNumber', + 'rptr_slots' => 'rptrGroupCapacity', + 'slots' => 'rptrGroupCapacity' +); -%FUNCS = ( - %SNMP::Info::FUNCS, - 'rptr_ports' => 'rptrGroupPortCapacity', - 'rptr_port' => 'rptrPortIndex', - 'rptr_slot' => 'rptrPortGroupIndex', - 'rptr_up_admin' => 'rptrPortAdminStatus', - 'rptr_up' => 'rptrPortOperStatus', - 'rptr_last_src' => 'rptrAddrTrackNewLastSrcAddress', - ); +%FUNCS = ( + %SNMP::Info::FUNCS, + 'rptr_ports' => 'rptrGroupPortCapacity', + 'rptr_port' => 'rptrPortIndex', + 'rptr_slot' => 'rptrPortGroupIndex', + 'rptr_up_admin' => 'rptrPortAdminStatus', + 'rptr_up' => 'rptrPortOperStatus', + 'rptr_last_src' => 'rptrAddrTrackNewLastSrcAddress', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::MUNGE, - 'rptr_last_src'=> \&SNMP::Info::munge_mac, - ); + + # Inherit all the built in munging + %SNMP::Info::MUNGE, + 'rptr_last_src' => \&SNMP::Info::munge_mac, +); # Method OverRides @@ -76,23 +75,23 @@ $VERSION = '1.09'; sub ports { my $l1 = shift; - my $ports = $l1->ports_managed(); - my $rptr_ports = $l1->rptr_ports(); + my $ports = $l1->ports_managed(); + my $rptr_ports = $l1->rptr_ports(); - foreach my $group (keys %$rptr_ports){ - $ports += $rptr_ports->{$group}; + foreach my $group ( keys %$rptr_ports ) { + $ports += $rptr_ports->{$group}; } return $ports; } # $l1->model() - Looks at sysObjectID which gives the oid of the system -# name, contained in a propriatry MIB. +# name, contained in a propriatry MIB. sub model { - my $l1 = shift; - my $id = $l1->id(); + my $l1 = shift; + my $id = $l1->id(); my $model = &SNMP::translateObj($id); - + # HP $model =~ s/^hpswitch//i; @@ -103,58 +102,58 @@ sub model { } sub vendor { - my $l1 = shift; + my $l1 = shift; my $descr = $l1->description(); - return 'hp' if ($descr =~ /hp/i); - return 'cisco' if ($descr =~ /(catalyst|cisco|ios)/i); - return 'allied' if ($descr =~ /allied/i); - return 'asante' if ($descr =~ /asante/i); - + return 'hp' if ( $descr =~ /hp/i ); + return 'cisco' if ( $descr =~ /(catalyst|cisco|ios)/i ); + return 'allied' if ( $descr =~ /allied/i ); + return 'asante' if ( $descr =~ /asante/i ); + return 'unknown'; } # By Default we'll use the description field sub interfaces { - my $l1 = shift; + my $l1 = shift; my $partial = shift; - my $interfaces = $l1->i_index($partial) || {}; + my $interfaces = $l1->i_index($partial) || {}; my $rptr_port = $l1->rptr_port($partial) || {}; - foreach my $port (keys %$rptr_port){ + foreach my $port ( keys %$rptr_port ) { $interfaces->{$port} = $port; } return $interfaces; } sub i_up_admin { - my $l1 = shift; + my $l1 = shift; my $partial = shift; - my $i_up_admin = $l1->SUPER::i_up_admin($partial) || {}; - my $rptr_up_admin = $l1->rptr_up_admin($partial) || {}; + my $i_up_admin = $l1->SUPER::i_up_admin($partial) || {}; + my $rptr_up_admin = $l1->rptr_up_admin($partial) || {}; - foreach my $key (keys %$rptr_up_admin){ + foreach my $key ( keys %$rptr_up_admin ) { my $up = $rptr_up_admin->{$key}; - $i_up_admin->{$key} = 'up' if $up =~ /enabled/; - $i_up_admin->{$key} = 'down' if $up =~ /disabled/; + $i_up_admin->{$key} = 'up' if $up =~ /enabled/; + $i_up_admin->{$key} = 'down' if $up =~ /disabled/; } return $i_up_admin; } sub i_up { - my $l1 = shift; + my $l1 = shift; my $partial = shift; - my $i_up = $l1->SUPER::i_up($partial) || {}; - my $rptr_up = $l1->rptr_up($partial) || {}; + my $i_up = $l1->SUPER::i_up($partial) || {}; + my $rptr_up = $l1->rptr_up($partial) || {}; - foreach my $key (keys %$rptr_up){ + foreach my $key ( keys %$rptr_up ) { my $up = $rptr_up->{$key}; - $i_up->{$key} = 'up' if $up =~ /operational/; + $i_up->{$key} = 'up' if $up =~ /operational/; } return $i_up; diff --git a/Info/Layer1/Allied.pm b/Info/Layer1/Allied.pm index 982857fb..e9c87fc1 100644 --- a/Info/Layer1/Allied.pm +++ b/Info/Layer1/Allied.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,7 +36,7 @@ use strict; use Exporter; use SNMP::Info::Layer1; -@SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/; +@SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/; @SNMP::Info::Layer1::Allied::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -44,23 +44,17 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; # Set for No CDP -%GLOBALS = ( - %SNMP::Info::Layer1::GLOBALS, - 'root_ip' => 'actualIPAddr', - ); +%GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, 'root_ip' => 'actualIPAddr', ); -%FUNCS = (%SNMP::Info::Layer1::FUNCS, - 'ati_p_name' => 'portName', - 'ati_up' => 'linkTestLED', - ); +%FUNCS = ( + %SNMP::Info::Layer1::FUNCS, + 'ati_p_name' => 'portName', + 'ati_up' => 'linkTestLED', +); -%MIBS = ( - %SNMP::Info::Layer1::MIBS, - 'ATI-MIB' => 'atiPortGroupIndex' - ); +%MIBS = ( %SNMP::Info::Layer1::MIBS, 'ATI-MIB' => 'atiPortGroupIndex' ); -%MUNGE = (%SNMP::Info::Layer1::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer1::MUNGE, ); sub vendor { return 'allied'; @@ -72,9 +66,9 @@ sub os { sub os_ver { my $allied = shift; - my $descr = $allied->description(); - - if ($descr =~ m/version (\d+\.\d+)/){ + my $descr = $allied->description(); + + if ( $descr =~ m/version (\d+\.\d+)/ ) { return $1; } } @@ -84,40 +78,40 @@ sub model { my $desc = $allied->description(); - if ($desc =~ /(AT-\d{4}\S{1}?)/){ + if ( $desc =~ /(AT-\d{4}\S{1}?)/ ) { return $1; } return; } -sub i_name{ - my $allied = shift; +sub i_name { + my $allied = shift; my $partial = shift; - my $i_name = $allied->orig_i_name($partial) || {}; - my $ati_p_name = $allied->ati_p_name($partial) || {}; + my $i_name = $allied->orig_i_name($partial) || {}; + my $ati_p_name = $allied->ati_p_name($partial) || {}; - foreach my $port (keys %$ati_p_name){ + foreach my $port ( keys %$ati_p_name ) { my $name = $ati_p_name->{$port}; - $i_name->{$port} = $name if (defined $name and $name !~ /^\s*$/); + $i_name->{$port} = $name if ( defined $name and $name !~ /^\s*$/ ); } - + return $i_name; } sub i_up { - my $allied = shift; + my $allied = shift; my $partial = shift; - my $i_up = SNMP::Info::Layer1::i_up($allied, $partial); + my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial ); my $ati_up = $allied->ati_up($partial) || {}; - foreach my $port (keys %$ati_up){ + foreach my $port ( keys %$ati_up ) { my $up = $ati_up->{$port}; $i_up->{$port} = 'down' if $up eq 'linktesterror'; - $i_up->{$port} = 'up' if $up eq 'nolinktesterror'; + $i_up->{$port} = 'up' if $up eq 'nolinktesterror'; } - + return $i_up; } 1; diff --git a/Info/Layer1/Asante.pm b/Info/Layer1/Asante.pm index 30e812fb..7f496921 100644 --- a/Info/Layer1/Asante.pm +++ b/Info/Layer1/Asante.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,7 +36,7 @@ use strict; use Exporter; use SNMP::Info::Layer1; -@SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/; +@SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/; @SNMP::Info::Layer1::Asante::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -44,35 +44,29 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; # Set for No CDP -%GLOBALS = ( - %SNMP::Info::Layer1::GLOBALS, - ); +%GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, ); -%FUNCS = (%SNMP::Info::Layer1::FUNCS, - 'asante_port' => 'ePortIndex', - 'asante_group' => 'ePortGrpIndex', - 'i_type' => 'ePortStateType', - 'asante_up' => 'ePortStateLinkStatus', - ); +%FUNCS = ( + %SNMP::Info::Layer1::FUNCS, + 'asante_port' => 'ePortIndex', + 'asante_group' => 'ePortGrpIndex', + 'i_type' => 'ePortStateType', + 'asante_up' => 'ePortStateLinkStatus', +); -%MIBS = ( - %SNMP::Info::Layer1::MIBS, - 'ASANTE-HUB1012-MIB' => 'asante' - ); +%MIBS = ( %SNMP::Info::Layer1::MIBS, 'ASANTE-HUB1012-MIB' => 'asante' ); -%MUNGE = ( - %SNMP::Info::Layer1::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer1::MUNGE, ); sub interfaces { - my $asante = shift; + my $asante = shift; my $partial = shift; my $rptr_port = $asante->rptr_port($partial) || {}; my %interfaces; - foreach my $port (keys %$rptr_port){ + foreach my $port ( keys %$rptr_port ) { $interfaces{$port} = $port; } @@ -85,13 +79,13 @@ sub os { sub os_ver { my $asante = shift; - my $descr = $asante->description(); - - if ($descr =~ /software v(\d+\.\d+)/){ + my $descr = $asante->description(); + + if ( $descr =~ /software v(\d+\.\d+)/ ) { return $1; } } - + sub vendor { return 'asante'; } @@ -99,30 +93,30 @@ sub vendor { sub model { my $asante = shift; - my $id = $asante->id(); + my $id = $asante->id(); my $model = &SNMP::translateObj($id); return $model; } sub i_up { - my $asante = shift; + my $asante = shift; my $partial = shift; my $asante_up = $asante->asante_up($partial) || {}; my $i_up = {}; - foreach my $port (keys %$asante_up){ + foreach my $port ( keys %$asante_up ) { my $up = $asante_up->{$port}; $i_up->{$port} = 'down' if $up =~ /on/; - $i_up->{$port} = 'up' if $up =~ /off/; + $i_up->{$port} = 'up' if $up =~ /off/; } - + return $i_up; } sub i_speed { - my $asante = shift; + my $asante = shift; my $partial = shift; my $i_speed = $asante->orig_i_speed($partial) || {}; @@ -135,7 +129,7 @@ sub i_speed { } sub i_mac { - my $asante = shift; + my $asante = shift; my $partial = shift; my $i_mac = $asante->orig_i_mac($partial) || {}; @@ -152,7 +146,7 @@ sub i_description { } sub i_name { - my $asante = shift; + my $asante = shift; my $partial = shift; my $i_name = $asante->orig_i_descr($partial) || {}; diff --git a/Info/Layer1/Bayhub.pm b/Info/Layer1/Bayhub.pm index 32379389..16ff1856 100644 --- a/Info/Layer1/Bayhub.pm +++ b/Info/Layer1/Bayhub.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller, Max Baker # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,51 +36,53 @@ use SNMP::Info::SONMP; use SNMP::Info::NortelStack; use SNMP::Info::Layer2; -@SNMP::Info::Layer1::Bayhub::ISA = qw/SNMP::Info::SONMP SNMP::Info::NortelStack SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer1::Bayhub::ISA + = qw/SNMP::Info::SONMP SNMP::Info::NortelStack SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer1::Bayhub::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::NortelStack::MIBS, - %SNMP::Info::SONMP::MIBS, - 'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable', - 'S5-COMMON-STATS-MIB' => 's5CmStat', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + %SNMP::Info::NortelStack::MIBS, + %SNMP::Info::SONMP::MIBS, + 'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable', + 'S5-COMMON-STATS-MIB' => 's5CmStat', +); %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::NortelStack::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - ); + %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::NortelStack::GLOBALS, + %SNMP::Info::SONMP::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::NortelStack::FUNCS, - %SNMP::Info::SONMP::FUNCS, - # S5-ETHERNET-COMMON-MIB::s5EnPortTable - 'bayhub_pb_index' => 's5EnPortBrdIndx', - 'bayhub_pp_index' => 's5EnPortIndx', - 'bayhub_up_admin' => 's5EnPortPartStatus', - 'bayhub_up' => 's5EnPortLinkStatus', - # S5-ETHERNET-COMMON-MIB::s5EnPortExtTable - 'bayhub_p_speed' => 's5EnPortExtActiveSpeed', - 'bayhub_p_cap' => 's5EnPortExtHwCapability', - 'bayhub_p_adv' => 's5EnPortExtAutoNegAdv', - # S5-COMMON-STATS-MIB::s5CmSNodeTable - 'bayhub_nb_index' => 's5CmSNodeBrdIndx', - 'bayhub_np_index' => 's5CmSNodePortIndx', - 'fw_mac' => 's5CmSNodeMacAddr', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::NortelStack::FUNCS, + %SNMP::Info::SONMP::FUNCS, -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::NortelStack::MUNGE, - %SNMP::Info::SONMP::MUNGE, - ); + # S5-ETHERNET-COMMON-MIB::s5EnPortTable + 'bayhub_pb_index' => 's5EnPortBrdIndx', + 'bayhub_pp_index' => 's5EnPortIndx', + 'bayhub_up_admin' => 's5EnPortPartStatus', + 'bayhub_up' => 's5EnPortLinkStatus', + + # S5-ETHERNET-COMMON-MIB::s5EnPortExtTable + 'bayhub_p_speed' => 's5EnPortExtActiveSpeed', + 'bayhub_p_cap' => 's5EnPortExtHwCapability', + 'bayhub_p_adv' => 's5EnPortExtAutoNegAdv', + + # S5-COMMON-STATS-MIB::s5CmSNodeTable + 'bayhub_nb_index' => 's5CmSNodeBrdIndx', + 'bayhub_np_index' => 's5CmSNodePortIndx', + 'fw_mac' => 's5CmSNodeMacAddr', +); + +%MUNGE = ( + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::NortelStack::MUNGE, + %SNMP::Info::SONMP::MUNGE, +); sub layers { return '00000011'; @@ -96,15 +98,15 @@ sub vendor { sub model { my $bayhub = shift; - my $id = $bayhub->id(); + my $id = $bayhub->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; $model =~ s/^sreg-//i; - return 'Baystack Hub' if ($model =~ /BayStack/); - return '5000' if ($model =~ /5000/); - return '5005' if ($model =~ /5005/); + return 'Baystack Hub' if ( $model =~ /BayStack/ ); + return '5000' if ( $model =~ /5000/ ); + return '5005' if ( $model =~ /5005/ ); return $model; } @@ -112,33 +114,35 @@ sub model { # and port status sub i_index { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; my $b_index = $bayhub->bayhub_pb_index($partial) || {}; my $p_index = $bayhub->bayhub_pp_index($partial) || {}; - my $model = $bayhub->model() || 'Baystack Hub'; + my $model = $bayhub->model() || 'Baystack Hub'; my %i_index; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $board = $b_index->{$iid}; next unless defined $board; - my $port = $p_index->{$iid}||0; + my $port = $p_index->{$iid} || 0; - if ($model eq 'Baystack Hub') { + if ( $model eq 'Baystack Hub' ) { my $comidx = $board; - if (! ($comidx % 5)) { - $board = ($board / 5); - } elsif ($comidx =~ /[16]$/) { - $board = int($board/5); - $port = 25; - } elsif ($comidx =~ /[27]$/) { - $board = int($board/5); - $port = 26; - } - } + if ( !( $comidx % 5 ) ) { + $board = ( $board / 5 ); + } + elsif ( $comidx =~ /[16]$/ ) { + $board = int( $board / 5 ); + $port = 25; + } + elsif ( $comidx =~ /[27]$/ ) { + $board = int( $board / 5 ); + $port = 26; + } + } - my $index = ($board*256)+$port; + my $index = ( $board * 256 ) + $port; $i_index{$iid} = $index; } @@ -149,23 +153,23 @@ sub i_index { # for consistency sub interfaces { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; my $i_index = $bayhub->i_index() || {}; my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); # Index numbers are deterministic slot * 256 + port my $port = $index % 256; - my $slot = int($index / 256); + my $slot = int( $index / 256 ); my $slotport = "$slot.$port"; - + $if{$index} = $slotport; } @@ -173,113 +177,114 @@ sub interfaces { } sub i_duplex { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; - my $port_index = $bayhub->i_index() || {}; + my $port_index = $bayhub->i_index() || {}; my %i_duplex; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); - + next if ( defined $partial and $index !~ /^$partial$/ ); + my $duplex = 'half'; - $i_duplex{$index}=$duplex; + $i_duplex{$index} = $duplex; } return \%i_duplex; } sub i_duplex_admin { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; - my $port_index = $bayhub->i_index() || {}; + my $port_index = $bayhub->i_index() || {}; my %i_duplex_admin; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); - + next if ( defined $partial and $index !~ /^$partial$/ ); + my $duplex = 'half'; - $i_duplex_admin{$index}=$duplex; + $i_duplex_admin{$index} = $duplex; } return \%i_duplex_admin; } sub i_speed { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; - my $port_index = $bayhub->i_index() || {}; - my $port_speed = $bayhub->bayhub_p_speed() || {}; + my $port_index = $bayhub->i_index() || {}; + my $port_speed = $bayhub->bayhub_p_speed() || {}; my %i_speed; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $speed = $port_speed->{$iid} || '10 Mbps'; - $speed = '10 Mbps' if $speed =~ /bps10M/i; + $speed = '10 Mbps' if $speed =~ /bps10M/i; $speed = '100 Mbps' if $speed =~ /bps100M/i; - $i_speed{$index}=$speed; + $i_speed{$index} = $speed; } return \%i_speed; } sub i_up { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; - my $port_index = $bayhub->i_index() || {}; - my $link_stat = $bayhub->bayhub_up() || {}; - + my $port_index = $bayhub->i_index() || {}; + my $link_stat = $bayhub->bayhub_up() || {}; + my %i_up; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $link_stat = $link_stat->{$iid}; next unless defined $link_stat; - - $link_stat = 'up' if $link_stat =~ /on/i; + + $link_stat = 'up' if $link_stat =~ /on/i; $link_stat = 'down' if $link_stat =~ /off/i; - - $i_up{$index}=$link_stat; + + $i_up{$index} = $link_stat; } return \%i_up; } sub i_up_admin { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; - my $i_index = $bayhub->i_index() || {}; + my $i_index = $bayhub->i_index() || {}; my $link_stat = $bayhub->bayhub_up_admin() || {}; - + my %i_up_admin; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $link_stat = $link_stat->{$iid}; next unless defined $link_stat; - - $i_up_admin{$index}=$link_stat; + + $i_up_admin{$index} = $link_stat; } return \%i_up_admin; } sub set_i_up_admin { + # map setting to those the hub will understand my %setting = qw/up 2 down 3/; my $bayhub = shift; - my ($setting, $iid) = @_; + my ( $setting, $iid ) = @_; - my $i_index = $bayhub->i_index(); + my $i_index = $bayhub->i_index(); my %reverse_i_index = reverse %$i_index; $setting = lc($setting); @@ -288,39 +293,41 @@ sub set_i_up_admin { $iid = $reverse_i_index{$iid}; - return $bayhub->set_bayhub_up_admin($setting{$setting}, $iid); + return $bayhub->set_bayhub_up_admin( $setting{$setting}, $iid ); } # Hubs do not support the standard Bridge MIB sub bp_index { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; my $b_index = $bayhub->bayhub_nb_index() || {}; my $p_index = $bayhub->bayhub_np_index() || {}; - my $model = $bayhub->model() || 'Baystack Hub'; + my $model = $bayhub->model() || 'Baystack Hub'; my %bp_index; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $board = $b_index->{$iid}; next unless defined $board; - my $port = $p_index->{$iid}||0; - - if ($model eq 'Baystack Hub') { - my $comidx = $board; - if (! ($comidx % 5)) { - $board = ($board / 5); - } elsif ($comidx =~ /[16]$/) { - $board = int($board/5); - $port = 25; - } elsif ($comidx =~ /[27]$/) { - $board = int($board/5); - $port = 26; - } - } + my $port = $p_index->{$iid} || 0; - my $index = ($board*256)+$port; - next if (defined $partial and $index !~ /^$partial$/); + if ( $model eq 'Baystack Hub' ) { + my $comidx = $board; + if ( !( $comidx % 5 ) ) { + $board = ( $board / 5 ); + } + elsif ( $comidx =~ /[16]$/ ) { + $board = int( $board / 5 ); + $port = 25; + } + elsif ( $comidx =~ /[27]$/ ) { + $board = int( $board / 5 ); + $port = 26; + } + } + + my $index = ( $board * 256 ) + $port; + next if ( defined $partial and $index !~ /^$partial$/ ); $bp_index{$index} = $index; } @@ -328,35 +335,37 @@ sub bp_index { } sub fw_port { - my $bayhub = shift; + my $bayhub = shift; my $partial = shift; my $b_index = $bayhub->bayhub_nb_index($partial) || {}; my $p_index = $bayhub->bayhub_np_index($partial) || {}; - my $model = $bayhub->model() || 'Baystack Hub'; + my $model = $bayhub->model() || 'Baystack Hub'; my %fw_port; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $board = $b_index->{$iid}; next unless defined $board; - my $port = $p_index->{$iid}||0; + my $port = $p_index->{$iid} || 0; - if ($model eq 'Baystack Hub') { - my $comidx = $board; - if (! ($comidx % 5)) { - $board = ($board / 5); - } elsif ($comidx =~ /[16]$/) { - $board = int($board/5); - $port = 25; - } elsif ($comidx =~ /[27]$/) { - $board = int($board/5); - $port = 26; - } - } - - my $index = ($board*256)+$port; + if ( $model eq 'Baystack Hub' ) { + my $comidx = $board; + if ( !( $comidx % 5 ) ) { + $board = ( $board / 5 ); + } + elsif ( $comidx =~ /[16]$/ ) { + $board = int( $board / 5 ); + $port = 25; + } + elsif ( $comidx =~ /[27]$/ ) { + $board = int( $board / 5 ); + $port = 26; + } + } - $fw_port{$iid} = $index; + my $index = ( $board * 256 ) + $port; + + $fw_port{$iid} = $index; } return \%fw_port; } @@ -369,7 +378,6 @@ sub slot_offset { return 0; } - # Devices do not support ENTITY-MIB use proprietary methods. sub e_index { diff --git a/Info/Layer1/Cyclades.pm b/Info/Layer1/Cyclades.pm index fcb3f939..9a0bbba8 100644 --- a/Info/Layer1/Cyclades.pm +++ b/Info/Layer1/Cyclades.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,45 +34,46 @@ use strict; use Exporter; use SNMP::Info::Layer1; -@SNMP::Info::Layer1::Cyclades::ISA = qw/SNMP::Info::Layer1 Exporter/; +@SNMP::Info::Layer1::Cyclades::ISA = qw/SNMP::Info::Layer1 Exporter/; @SNMP::Info::Layer1::Cyclades::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer1::MIBS, - 'CYCLADES-ACS-SYS-MIB' => 'cyACSversion', - 'CYCLADES-ACS-CONF-MIB' => 'cyEthIPaddr', - 'CYCLADES-ACS-INFO-MIB' => 'cyISPortTty', - ); +%MIBS = ( + %SNMP::Info::Layer1::MIBS, + 'CYCLADES-ACS-SYS-MIB' => 'cyACSversion', + 'CYCLADES-ACS-CONF-MIB' => 'cyEthIPaddr', + 'CYCLADES-ACS-INFO-MIB' => 'cyISPortTty', +); %GLOBALS = ( - # CYCLADES-ACS-SYS-MIB - %SNMP::Info::Layer1::GLOBALS, - 'os_ver' => 'cyACSversion', - 'cy_model' => 'cyACSpname', - 'serial' => 'cyACSDevId', - 'root_ip' => 'cyEthIPaddr', - 'ps1_status' => 'cyACSPw1', - 'ps2_status' => 'cyACSPw2', - ); -%FUNCS = ( - %SNMP::Info::Layer1::FUNCS, - # CYCLADES-ACS-INFO-MIB::cyInfoSerialTable - 'cy_port_tty' => 'cyISPortTty', - 'cy_port_name' => 'cyISPortName', - 'cy_port_speed' => 'cyISPortSpeed', - 'cy_port_cd' => 'cyISPortSigCD', - # CYCLADES-ACS-CONF-MIB::cySerialPortTable - 'cy_port_socket' => 'cySPortSocketPort', - ); + # 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', +); -%MUNGE = ( - %SNMP::Info::Layer1::MUNGE, - ); +%FUNCS = ( + %SNMP::Info::Layer1::FUNCS, + + # CYCLADES-ACS-INFO-MIB::cyInfoSerialTable + 'cy_port_tty' => 'cyISPortTty', + 'cy_port_name' => 'cyISPortName', + 'cy_port_speed' => 'cyISPortSpeed', + 'cy_port_cd' => 'cyISPortSigCD', + + # CYCLADES-ACS-CONF-MIB::cySerialPortTable + 'cy_port_socket' => 'cySPortSocketPort', +); + +%MUNGE = ( %SNMP::Info::Layer1::MUNGE, ); # These devices don't have a FDB and we probably don't want to poll for ARP # cache so turn off reported L2/L3. @@ -108,10 +109,10 @@ 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->cy_port_socket() || {}; my %i_index; - foreach my $iid (keys %$orig_index){ + foreach my $iid ( keys %$orig_index ) { my $index = $orig_index->{$iid}; next unless defined $index; @@ -120,14 +121,14 @@ sub i_index { # Use alternative labeling system for the serial port, listening socket # to avoid conflicts with ifIndex. - foreach my $iid (keys %$cy_index){ + foreach my $iid ( keys %$cy_index ) { my $index = $cy_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); $i_index{$index} = $index; } - + return \%i_index; } @@ -135,25 +136,25 @@ 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->cy_port_socket() || {}; + my $cy_p_tty = $cyclades->cy_port_tty() || {}; my %if; - foreach my $iid (keys %$i_descr){ + foreach my $iid ( keys %$i_descr ) { my $descr = $i_descr->{$iid}; next unless defined $descr; - + $if{$iid} = $descr; } - foreach my $iid (keys %$cy_p_tty){ + foreach my $iid ( keys %$cy_p_tty ) { my $index = $cy_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $name = $cy_p_tty->{$iid}; next unless defined $name; - + $if{$index} = $name; } @@ -164,25 +165,25 @@ sub i_speed { my $cyclades = shift; my $partial = shift; - my $i_speed = $cyclades->orig_i_speed($partial) || {}; - my $cy_index = $cyclades->cy_port_socket() || {}; - my $cy_p_speed = $cyclades->cy_port_speed() || {}; + my $i_speed = $cyclades->orig_i_speed($partial) || {}; + my $cy_index = $cyclades->cy_port_socket() || {}; + my $cy_p_speed = $cyclades->cy_port_speed() || {}; my %i_speed; - foreach my $iid (keys %$i_speed){ + foreach my $iid ( keys %$i_speed ) { my $speed = $i_speed->{$iid}; next unless defined $speed; - + $i_speed{$iid} = $speed; } - foreach my $iid (keys %$cy_p_speed){ + foreach my $iid ( keys %$cy_p_speed ) { my $index = $cy_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $speed = $cy_p_speed->{$iid}; next unless defined $speed; - + $i_speed{$index} = $speed; } @@ -194,24 +195,24 @@ 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->cy_port_socket() || {}; + my $cy_p_up = $cyclades->cy_port_cd() || {}; my %i_up; - foreach my $iid (keys %$i_up){ + foreach my $iid ( keys %$i_up ) { my $up = $i_up->{$iid}; next unless defined $up; - + $i_up{$iid} = $up; } - foreach my $iid (keys %$cy_p_up){ + foreach my $iid ( keys %$cy_p_up ) { my $index = $cy_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $up = $cy_p_up->{$iid}; next unless defined $up; - + $i_up{$index} = $up; } @@ -223,24 +224,24 @@ 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->cy_port_socket() || {}; + my $cy_p_desc = $cyclades->cy_port_name() || {}; my %descr; - foreach my $iid (keys %$i_desc){ + foreach my $iid ( keys %$i_desc ) { my $desc = $i_desc->{$iid}; next unless defined $desc; - + $descr{$iid} = $desc; } - foreach my $iid (keys %$cy_p_desc){ + foreach my $iid ( keys %$cy_p_desc ) { my $index = $cy_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $desc = $cy_p_desc->{$iid}; next unless defined $desc; - + $descr{$index} = $desc; } @@ -252,24 +253,24 @@ 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->cy_port_socket() || {}; + my $cy_p_desc = $cyclades->cy_port_name() || {}; my %i_name; - foreach my $iid (keys %$i_name){ + foreach my $iid ( keys %$i_name ) { my $name = $i_name->{$iid}; next unless defined $name; - + $i_name{$iid} = $name; } - foreach my $iid (keys %$cy_p_desc){ + foreach my $iid ( keys %$cy_p_desc ) { my $index = $cy_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $name = $cy_p_desc->{$iid}; next unless defined $name; - + $i_name{$index} = $name; } @@ -373,8 +374,8 @@ These are methods that return scalar value from SNMP =item $cyclades->layers() -Returns 01000001. These devices don't have a FDB and we probably don't want to -poll for an ARP cache so turn off reported Layer 2 and Layer 3. +Returns 01000001. These devices don't have a FDB and we probably don't want +to poll for an ARP cache so turn off reported Layer 2 and Layer 3. =item $cyclades->vendor() diff --git a/Info/Layer1/S3000.pm b/Info/Layer1/S3000.pm index 478c462b..daf0db0d 100644 --- a/Info/Layer1/S3000.pm +++ b/Info/Layer1/S3000.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,48 +34,51 @@ use strict; use Exporter; use SNMP::Info::Layer2; -@SNMP::Info::Layer1::S3000::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer1::S3000::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer1::S3000::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - 'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable', - 'SYNOPTICS-COMMON-MIB' => 's3AgentType', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + 'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable', + 'SYNOPTICS-COMMON-MIB' => 's3AgentType', +); %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - # From SYNOPTICS-COMMON-MIB - 'os_bin' => 's3AgentFwVer', - 's3000_major_ver' => 's3AgentSwMajorVer', - 's3000_minor_ver' => 's3AgentSwMinorVer', - 's3000_maint_ver' => 's3AgentSwMaintVer', - ); + %SNMP::Info::Layer2::GLOBALS, -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - # SYNOPTICS-ETHERNET-MIB::s3EnetPortTable - 's3000_pb_index' => 's3EnetPortBoardIndex', - 's3000_pp_index' => 's3EnetPortIndex', - 's3000_up_admin' => 's3EnetPortPartStatus', - 's3000_up' => 's3EnetPortLinkStatus', - # SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable - 's3000_nb_index' => 's3EnetShowNodesSlotIndex', - 's3000_np_index' => 's3EnetShowNodesPortIndex', - 'fw_mac' => 's3EnetShowNodesMacAddress', - # SYNOPTICS-ETHERNET-MIB::s3EnetTopNmmTable - 's3000_topo_port' => 's3EnetTopNmmPort', - 's3000_topo_mac' => 's3EnetTopNmmMacAddr', - ); + # From SYNOPTICS-COMMON-MIB + 'os_bin' => 's3AgentFwVer', + 's3000_major_ver' => 's3AgentSwMajorVer', + 's3000_minor_ver' => 's3AgentSwMinorVer', + 's3000_maint_ver' => 's3AgentSwMaintVer', +); -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - 's3000_topo_mac' => \&SNMP::Info::munge_mac - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + + # SYNOPTICS-ETHERNET-MIB::s3EnetPortTable + 's3000_pb_index' => 's3EnetPortBoardIndex', + 's3000_pp_index' => 's3EnetPortIndex', + 's3000_up_admin' => 's3EnetPortPartStatus', + 's3000_up' => 's3EnetPortLinkStatus', + + # SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable + 's3000_nb_index' => 's3EnetShowNodesSlotIndex', + 's3000_np_index' => 's3EnetShowNodesPortIndex', + 'fw_mac' => 's3EnetShowNodesMacAddress', + + # SYNOPTICS-ETHERNET-MIB::s3EnetTopNmmTable + 's3000_topo_port' => 's3EnetTopNmmPort', + 's3000_topo_mac' => 's3EnetTopNmmMacAddr', +); + +%MUNGE = ( + %SNMP::Info::Layer2::MUNGE, 's3000_topo_mac' => \&SNMP::Info::munge_mac +); sub layers { return '00000011'; @@ -91,37 +94,38 @@ sub vendor { sub model { my $s3000 = shift; - my $id = $s3000->id(); + my $id = $s3000->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; $model =~ s/^s3reg-//i; - return $1 if ($model =~ /((\d+){3}[\dX])/); + return $1 if ( $model =~ /((\d+){3}[\dX])/ ); return $model; } sub os_ver { - my $s3000 = shift; + my $s3000 = shift; my $major_ver = $s3000->s3000_major_ver() || 0; my $minor_ver = $s3000->s3000_minor_ver() || 0; my $maint_ver = $s3000->s3000_maint_ver() || 0; - my $ver = "$major_ver.$minor_ver.$maint_ver"; - return $ver; + my $ver = "$major_ver.$minor_ver.$maint_ver"; + return $ver; } sub mac { - my $s3000 = shift; + my $s3000 = shift; my $topo_port = $s3000->s3000_topo_port(); - my $topo_mac = $s3000->s3000_topo_mac(); - - foreach my $entry (keys %$topo_port){ + my $topo_mac = $s3000->s3000_topo_mac(); + + foreach my $entry ( keys %$topo_port ) { my $port = $topo_port->{$entry}; next unless $port == 0; my $mac = $topo_mac->{$entry}; return $mac; } + # Topology turned off, not supported. return; } @@ -130,20 +134,20 @@ sub mac { # and port status sub i_index { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; my $b_index = $s3000->s3000_pb_index($partial) || {}; my $p_index = $s3000->s3000_pp_index($partial) || {}; my %i_index; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $board = $b_index->{$iid}; next unless defined $board; - my $port = $p_index->{$iid}||0; + my $port = $p_index->{$iid} || 0; # We need to make up an index for multiple board instances. - my $index = ($board*256)+$port; + my $index = ( $board * 256 ) + $port; $i_index{$iid} = $index; } @@ -154,23 +158,23 @@ sub i_index { # for consistency sub interfaces { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; my $i_index = $s3000->i_index() || {}; my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); # Index numbers are deterministic slot * 256 + port - see i_index() my $port = $index % 256; - my $slot = int($index / 256); + my $slot = int( $index / 256 ); my $slotport = "$slot.$port"; - + $if{$index} = $slotport; } @@ -178,113 +182,114 @@ sub interfaces { } sub i_duplex { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; - my $port_index = $s3000->i_index() || {}; + my $port_index = $s3000->i_index() || {}; my %i_duplex; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); # Hubs only function half duplex my $duplex = 'half'; - $i_duplex{$index}=$duplex; + $i_duplex{$index} = $duplex; } return \%i_duplex; } sub i_duplex_admin { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; - my $port_index = $s3000->i_index() || {}; + my $port_index = $s3000->i_index() || {}; my %i_duplex_admin; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); - # Hubs only function half duplex + # Hubs only function half duplex my $duplex = 'half'; - $i_duplex_admin{$index}=$duplex; + $i_duplex_admin{$index} = $duplex; } return \%i_duplex_admin; } sub i_speed { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; - my $port_index = $s3000->i_index() || {}; + my $port_index = $s3000->i_index() || {}; my %i_speed; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); - # These hubs only support 10 Mbs + # These hubs only support 10 Mbs my $speed = '10000000'; - $i_speed{$index}=$speed; + $i_speed{$index} = $speed; } return \%i_speed; } sub i_up { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; - my $port_index = $s3000->i_index() || {}; - my $link_stat = $s3000->s3000_up() || {}; - + my $port_index = $s3000->i_index() || {}; + my $link_stat = $s3000->s3000_up() || {}; + my %i_up; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $link_stat = $link_stat->{$iid}; next unless defined $link_stat; - - $link_stat = 'up' if $link_stat =~ /on/i; + + $link_stat = 'up' if $link_stat =~ /on/i; $link_stat = 'down' if $link_stat =~ /off/i; - - $i_up{$index}=$link_stat; + + $i_up{$index} = $link_stat; } return \%i_up; } sub i_up_admin { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; - my $i_index = $s3000->i_index() || {}; + my $i_index = $s3000->i_index() || {}; my $link_stat = $s3000->s3000_up_admin() || {}; - + my %i_up_admin; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - next if (defined $partial and $index !~ /^$partial$/); + next if ( defined $partial and $index !~ /^$partial$/ ); my $link_stat = $link_stat->{$iid}; next unless defined $link_stat; - - $i_up_admin{$index}=$link_stat; + + $i_up_admin{$index} = $link_stat; } return \%i_up_admin; } sub set_i_up_admin { + # map setting to those the hub will understand my %setting = qw/up 2 down 3/; my $s3000 = shift; - my ($setting, $iid) = @_; + my ( $setting, $iid ) = @_; - my $i_index = $s3000->i_index() || {}; + my $i_index = $s3000->i_index() || {}; my %reverse_i_index = reverse %$i_index; $setting = lc($setting); @@ -293,26 +298,26 @@ sub set_i_up_admin { $iid = $reverse_i_index{$iid}; - return $s3000->set_s3000_up_admin($setting{$setting}, $iid); + return $s3000->set_s3000_up_admin( $setting{$setting}, $iid ); } # Hubs do not support the standard Bridge MIB sub bp_index { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; my $b_index = $s3000->s3000_nb_index() || {}; my $p_index = $s3000->s3000_np_index() || {}; - my $model = $s3000->model(); + my $model = $s3000->model(); my %bp_index; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $board = $b_index->{$iid}; next unless defined $board; - my $port = $p_index->{$iid}||0; - - my $index = ($board*256)+$port; - next if (defined $partial and $index !~ /^$partial$/); + my $port = $p_index->{$iid} || 0; + + my $index = ( $board * 256 ) + $port; + next if ( defined $partial and $index !~ /^$partial$/ ); $bp_index{$index} = $index; } @@ -320,22 +325,22 @@ sub bp_index { } sub fw_port { - my $s3000 = shift; + my $s3000 = shift; my $partial = shift; my $b_index = $s3000->s3000_nb_index($partial) || {}; my $p_index = $s3000->s3000_np_index($partial) || {}; - my $model = $s3000->model(); + my $model = $s3000->model(); my %fw_port; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $board = $b_index->{$iid}; next unless defined $board; - my $port = $p_index->{$iid}||0; + my $port = $p_index->{$iid} || 0; - my $index = ($board*256)+$port; + my $index = ( $board * 256 ) + $port; - $fw_port{$iid} = $index; + $fw_port{$iid} = $index; } return \%fw_port; } @@ -489,7 +494,8 @@ Returns 10000000. The hubs only support 10 Mbs Ethernet. =item $s3000->i_up() -Returns (C) for each port. Translates on/off to up/down. +Returns (C) for each port. Translates on/off to +up/down. =item $s3000->i_up_admin() @@ -522,7 +528,8 @@ C to the Interface index. =item $s3000->s3000_topo_port() -Returns reference to hash. Key: Table entry, Value:Port Number (interface iid) +Returns reference to hash. Key: Table entry, Value:Port Number +(interface iid) (C) diff --git a/Info/Layer2.pm b/Info/Layer2.pm index bfb31d82..c0f577bb 100644 --- a/Info/Layer2.pm +++ b/Info/Layer2.pm @@ -1,25 +1,25 @@ -# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices +# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices # $Id$ # # Copyright (c) 2008 Max Baker -- All changes from Version 0.7 on # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -39,51 +39,51 @@ use SNMP::Info::Bridge; use SNMP::Info::Entity; use SNMP::Info::PowerEthernet; -@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity SNMP::Info::PowerEthernet Exporter/; +@SNMP::Info::Layer2::ISA + = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity SNMP::Info::PowerEthernet Exporter/; @SNMP::Info::Layer2::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::MIBS, - %SNMP::Info::Bridge::MIBS, - %SNMP::Info::Entity::MIBS, - %SNMP::Info::PowerEthernet::MIBS, - ); +%MIBS = ( + %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS, + %SNMP::Info::Entity::MIBS, %SNMP::Info::PowerEthernet::MIBS, +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - %SNMP::Info::Bridge::GLOBALS, - %SNMP::Info::Entity::GLOBALS, - %SNMP::Info::PowerEthernet::GLOBALS, - 'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0 - ); + %SNMP::Info::GLOBALS, + %SNMP::Info::Bridge::GLOBALS, + %SNMP::Info::Entity::GLOBALS, + %SNMP::Info::PowerEthernet::GLOBALS, + 'serial1' => + '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0 +); -%FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Bridge::FUNCS, - %SNMP::Info::Entity::FUNCS, - %SNMP::Info::PowerEthernet::FUNCS, - ); +%FUNCS = ( + %SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS, + %SNMP::Info::Entity::FUNCS, %SNMP::Info::PowerEthernet::FUNCS, +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::MUNGE, - %SNMP::Info::Bridge::MUNGE, - %SNMP::Info::Entity::MUNGE, - %SNMP::Info::PowerEthernet::MUNGE, - ); + + # Inherit all the built in munging + %SNMP::Info::MUNGE, + %SNMP::Info::Bridge::MUNGE, + %SNMP::Info::Entity::MUNGE, + %SNMP::Info::PowerEthernet::MUNGE, +); # Method OverRides # $l2->model() - Looks at sysObjectID which gives the oid of the system -# name, contained in a propriatry MIB. +# name, contained in a propriatry MIB. sub model { - my $l2 = shift; - my $id = $l2->id(); + my $l2 = shift; + my $id = $l2->id(); my $model = &SNMP::translateObj($id) || $id || ''; - + # HP $model =~ s/^hpswitch//i; @@ -96,15 +96,15 @@ sub model { } sub vendor { - my $l2 = shift; + my $l2 = shift; my $model = $l2->model(); my $descr = $l2->description(); - if ($model =~ /hp/i or $descr =~ /\bhp\b/i) { + if ( $model =~ /hp/i or $descr =~ /\bhp\b/i ) { return 'hp'; } - if ($model =~ /catalyst/i or $descr =~ /(catalyst|cisco)/i) { + if ( $model =~ /catalyst/i or $descr =~ /(catalyst|cisco)/i ) { return 'cisco'; } @@ -112,49 +112,50 @@ sub vendor { sub serial { my $l2 = shift; - - my $serial1 = $l2->serial1(); - my $e_descr = $l2->e_descr() || {}; - my $e_serial = $l2->e_serial() || {}; - - my $serial2 = $e_serial->{1} || undef; - my $chassis = $e_descr->{1} || undef; + + my $serial1 = $l2->serial1(); + my $e_descr = $l2->e_descr() || {}; + my $e_serial = $l2->e_serial() || {}; + + my $serial2 = $e_serial->{1} || undef; + my $chassis = $e_descr->{1} || undef; # precedence # serial2,chassis parse,serial1 - return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/); - return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i); - return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/); + return $serial2 if ( defined $serial2 and $serial2 !~ /^\s*$/ ); + return $1 + if ( defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i ); + return $serial1 if ( defined $serial1 and $serial1 !~ /^\s*$/ ); return; } sub i_ignore { - my $l2 = shift; + my $l2 = shift; my $partial = shift; my $i_type = $l2->i_type($partial) || {}; my %i_ignore = (); - foreach my $if (keys %$i_type){ + foreach my $if ( keys %$i_type ) { my $type = $i_type->{$if}; - $i_ignore{$if}++ + $i_ignore{$if}++ if $type =~ /(loopback|other|cpu)/i; } return \%i_ignore; -} +} sub interfaces { - my $l2 = shift; + my $l2 = shift; my $partial = shift; - my $interfaces = $l2->i_index($partial) || {}; + my $interfaces = $l2->i_index($partial) || {}; my $i_descr = $l2->i_description($partial) || {}; # Replace the Index with the ifDescr field. - foreach my $iid (keys %$i_descr){ + foreach my $iid ( keys %$i_descr ) { my $port = $i_descr->{$iid}; next unless defined $port; $interfaces->{$iid} = $port; @@ -287,7 +288,8 @@ to a hash. =item $l2->interfaces() -Creates a map between the interface identifier (iid) and the physical port name. +Creates a map between the interface identifier (iid) and the physical port +name. Defaults to C but checks and overrides with C diff --git a/Info/Layer2/Airespace.pm b/Info/Layer2/Airespace.pm index 42ee60c8..f05e42ca 100644 --- a/Info/Layer2/Airespace.pm +++ b/Info/Layer2/Airespace.pm @@ -3,20 +3,20 @@ # # Copyright (c) 2008 Eric Miller # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -35,40 +35,33 @@ use SNMP::Info::Bridge; use SNMP::Info::CDP; use SNMP::Info::Airespace; -@SNMP::Info::Layer2::Airespace::ISA = qw/SNMP::Info::Airespace SNMP::Info::CDP SNMP::Info::Bridge Exporter/; +@SNMP::Info::Layer2::Airespace::ISA + = qw/SNMP::Info::Airespace SNMP::Info::CDP SNMP::Info::Bridge Exporter/; @SNMP::Info::Layer2::Airespace::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::MIBS, - %SNMP::Info::Bridge::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::Airespace::MIBS, - ); +%MIBS = ( + %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS, + %SNMP::Info::CDP::MIBS, %SNMP::Info::Airespace::MIBS, +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - %SNMP::Info::Bridge::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::Airespace::GLOBALS, - ); + %SNMP::Info::GLOBALS, %SNMP::Info::Bridge::GLOBALS, + %SNMP::Info::CDP::GLOBALS, %SNMP::Info::Airespace::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Bridge::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::Airespace::FUNCS, - ); +%FUNCS = ( + %SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS, + %SNMP::Info::CDP::FUNCS, %SNMP::Info::Airespace::FUNCS, +); -%MUNGE = ( - %SNMP::Info::MUNGE, - %SNMP::Info::Bridge::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::Airespace::MUNGE, - ); +%MUNGE = ( + %SNMP::Info::MUNGE, %SNMP::Info::Bridge::MUNGE, + %SNMP::Info::CDP::MUNGE, %SNMP::Info::Airespace::MUNGE, +); sub os { return 'cisco'; @@ -80,7 +73,7 @@ sub vendor { sub model { my $airespace = shift; - my $model = $airespace->airespace_model(); + my $model = $airespace->airespace_model(); return unless defined $model; return $model; diff --git a/Info/Layer2/Aironet.pm b/Info/Layer2/Aironet.pm index d7a3fb8b..5809df80 100644 --- a/Info/Layer2/Aironet.pm +++ b/Info/Layer2/Aironet.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * 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 +# +# 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 @@ -41,8 +41,9 @@ use SNMP::Info::CiscoStats; use SNMP::Info::CDP; use SNMP::Info::IEEE802dot11; -@SNMP::Info::Layer2::Aironet::ISA = qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike - SNMP::Info::CiscoStats SNMP::Info::CDP Exporter/; +@SNMP::Info::Layer2::Aironet::ISA + = qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike + SNMP::Info::CiscoStats SNMP::Info::CDP Exporter/; @SNMP::Info::Layer2::Aironet::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -50,68 +51,69 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; %GLOBALS = ( - %SNMP::Info::IEEE802dot11::GLOBALS, - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::Entity::GLOBALS, - %SNMP::Info::EtherLike::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - 'serial' => 'entPhysicalSerialNum.1', - 'descr' => 'sysDescr' - ); + %SNMP::Info::IEEE802dot11::GLOBALS, + %SNMP::Info::Layer2::GLOBALS, + %SNMP::Info::Entity::GLOBALS, + %SNMP::Info::EtherLike::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + 'serial' => 'entPhysicalSerialNum.1', + 'descr' => 'sysDescr' +); -%FUNCS = ( - %SNMP::Info::IEEE802dot11::FUNCS, - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::Entity::FUNCS, - %SNMP::Info::EtherLike::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - 'i_ssidlist' => 'cd11IfAuxSsid', - 'i_ssidbcast' => 'cd11IfAuxSsidBroadcastSsid', - 'i_80211channel' => 'cd11IfPhyDsssCurrentChannel', - 'c_dot11subif' => 'cDot11ClientSubIfIndex', - 'cd11_txrate' => 'cDot11ClientCurrentTxRateSet', - 'cd11_uptime' => 'cDot11ClientUpTime', - 'cd11_sigstrength' => 'cDot11ClientSignalStrength', - 'cd11_sigqual' => 'cDot11ClientSigQuality', - 'cd11_rxpkt' => 'cDot11ClientPacketsReceived', - 'cd11_txpkt' => 'cDot11ClientPacketsSent', - 'cd11_rxbyte' => 'cDot11ClientBytesReceived', - 'cd11_txbyte' => 'cDot11ClientBytesSent', - 'mbss_mac_addr' => 'cdot11MbssidIfMacAddress', - ); +%FUNCS = ( + %SNMP::Info::IEEE802dot11::FUNCS, + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::Entity::FUNCS, + %SNMP::Info::EtherLike::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, + 'i_ssidlist' => 'cd11IfAuxSsid', + 'i_ssidbcast' => 'cd11IfAuxSsidBroadcastSsid', + 'i_80211channel' => 'cd11IfPhyDsssCurrentChannel', + 'c_dot11subif' => 'cDot11ClientSubIfIndex', + 'cd11_txrate' => 'cDot11ClientCurrentTxRateSet', + 'cd11_uptime' => 'cDot11ClientUpTime', + 'cd11_sigstrength' => 'cDot11ClientSignalStrength', + 'cd11_sigqual' => 'cDot11ClientSigQuality', + 'cd11_rxpkt' => 'cDot11ClientPacketsReceived', + 'cd11_txpkt' => 'cDot11ClientPacketsSent', + 'cd11_rxbyte' => 'cDot11ClientBytesReceived', + 'cd11_txbyte' => 'cDot11ClientBytesSent', + 'mbss_mac_addr' => 'cdot11MbssidIfMacAddress', +); -%MIBS = ( - %SNMP::Info::IEEE802dot11::MIBS, - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::Entity::MIBS, - %SNMP::Info::EtherLike::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - %SNMP::Info::CDP::MIBS, - 'CISCO-DOT11-IF-MIB' => 'cd11IfAuxSsid', - 'CISCO-DOT11-ASSOCIATION-MIB' => 'cDot11ClientSubIfIndex', - 'CISCO-DOT11-SSID-SECURITY-MIB' => 'cdot11SecVlanNameId', - 'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex', - ); +%MIBS = ( + %SNMP::Info::IEEE802dot11::MIBS, + %SNMP::Info::Layer2::MIBS, + %SNMP::Info::Entity::MIBS, + %SNMP::Info::EtherLike::MIBS, + %SNMP::Info::CiscoStats::MIBS, + %SNMP::Info::CiscoVTP::MIBS, + %SNMP::Info::CDP::MIBS, + 'CISCO-DOT11-IF-MIB' => 'cd11IfAuxSsid', + 'CISCO-DOT11-ASSOCIATION-MIB' => 'cDot11ClientSubIfIndex', + 'CISCO-DOT11-SSID-SECURITY-MIB' => 'cdot11SecVlanNameId', + 'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex', +); -%MUNGE = ( - %SNMP::Info::IEEE802dot11::MUNGE, - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::Entity::MUNGE, - %SNMP::Info::EtherLike::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - 'cd11_txrate' => \&munge_cd11_txrate, - 'mbss_mac_addr' => \&SNMP::Info::munge_mac, - ); +%MUNGE = ( + %SNMP::Info::IEEE802dot11::MUNGE, + %SNMP::Info::Layer2::MUNGE, + %SNMP::Info::Entity::MUNGE, + %SNMP::Info::EtherLike::MUNGE, + %SNMP::Info::CiscoStats::MUNGE, + %SNMP::Info::CDP::MUNGE, + 'cd11_txrate' => \&munge_cd11_txrate, + 'mbss_mac_addr' => \&SNMP::Info::munge_mac, +); # Use 802.11 power level without putting IEEE802dot11 in @ISA -*SNMP::Info::Layer2::Aironet::dot11_cur_tx_pwr_mw = - \&SNMP::Info::IEEE802dot11::dot11_cur_tx_pwr_mw; +*SNMP::Info::Layer2::Aironet::dot11_cur_tx_pwr_mw + = \&SNMP::Info::IEEE802dot11::dot11_cur_tx_pwr_mw; sub vendor { + # Sorry, but it's true. return 'cisco'; } @@ -128,7 +130,7 @@ sub interfaces { # Tag on e_descr.1 sub description { my $aironet = shift; - my $descr = $aironet->descr(); + my $descr = $aironet->descr(); my $e_descr = $aironet->e_descr(); $descr = "$e_descr->{1} $descr" if defined $e_descr->{1}; @@ -144,7 +146,7 @@ sub i_duplex { my $el_duplex = $aironet->el_duplex($partial); my %i_duplex; - foreach my $d (keys %$el_duplex){ + foreach my $d ( keys %$el_duplex ) { my $val = $el_duplex->{$d}; next unless defined $val; $i_duplex{$d} = 'full' if $val =~ /full/i; @@ -162,9 +164,12 @@ sub i_duplex { # Q-BRIDGE-MIB dot1qTpFdbTable but that was removed in 12.3. sub _aironet_special { my $aironet = shift; - my $os_ver = $aironet->os_ver(); - if (defined($os_ver) && $os_ver =~ /^(\d+)\.(\d+)(\D|$)/ && (($1 == 12 && $2 >= 3) || $1 > 12)) { - return 1; + my $os_ver = $aironet->os_ver(); + if ( defined($os_ver) + && $os_ver =~ /^(\d+)\.(\d+)(\D|$)/ + && ( ( $1 == 12 && $2 >= 3 ) || $1 > 12 ) ) + { + return 1; } } @@ -173,12 +178,12 @@ sub _aironet_special { sub _aironet_breakout_dot11idx { my $oid = shift; - my @parts = split(/\./, $oid); + my @parts = split( /\./, $oid ); my $ifindex = shift(@parts); my $ssidlen = shift(@parts); - my $ssid = pack("C*", splice(@parts, 0, $ssidlen)); - my $mac = join(":", map {sprintf "%02x", $_} @parts); - return ($ifindex, $ssid, $mac); + my $ssid = pack( "C*", splice( @parts, 0, $ssidlen ) ); + my $mac = join( ":", map { sprintf "%02x", $_ } @parts ); + return ( $ifindex, $ssid, $mac ); } sub fw_mac { @@ -186,11 +191,11 @@ sub fw_mac { return qb_fw_mac($aironet) unless _aironet_special($aironet); my $c_dot11subif = $aironet->c_dot11subif(); - my $fw_mac = {}; + my $fw_mac = {}; - foreach my $i (keys %$c_dot11subif) { - my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($i); - $fw_mac->{$i} = $mac; + foreach my $i ( keys %$c_dot11subif ) { + my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i); + $fw_mac->{$i} = $mac; } return $fw_mac; } @@ -200,11 +205,11 @@ sub fw_port { return $aironet->qb_fw_port() unless _aironet_special($aironet); my $c_dot11subif = $aironet->c_dot11subif(); - my $fw_port = {}; + my $fw_port = {}; - foreach my $i (keys %$c_dot11subif) { - my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($i); - $fw_port->{$i} = $c_dot11subif->{$i} || $ifindex; + foreach my $i ( keys %$c_dot11subif ) { + my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i); + $fw_port->{$i} = $c_dot11subif->{$i} || $ifindex; } return $fw_port; } @@ -214,12 +219,12 @@ sub bp_index { return $aironet->orig_bp_index() unless _aironet_special($aironet); my $c_dot11subif = $aironet->c_dot11subif(); - my $bp_index = {}; + my $bp_index = {}; - foreach my $i (keys %$c_dot11subif) { - my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($i); - my ($i) = $c_dot11subif->{$i} || $ifindex; - $bp_index->{$i} = $i; + foreach my $i ( keys %$c_dot11subif ) { + my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i); + my ($i) = $c_dot11subif->{$i} || $ifindex; + $bp_index->{$i} = $i; } return $bp_index; } @@ -231,14 +236,14 @@ sub bp_index { sub v_name { my $aironet = shift; - my $v_name = {}; + my $v_name = {}; my $vlan_nameid = $aironet->cdot11SecVlanNameId(); - foreach my $i (keys %$vlan_nameid) { - my @parts = split(/\./, $i); - my $namelen = shift(@parts); + foreach my $i ( keys %$vlan_nameid ) { + my @parts = split( /\./, $i ); + my $namelen = shift(@parts); - my $name = pack("C*", @parts); - $v_name->{$i} = $name; + my $name = pack( "C*", @parts ); + $v_name->{$i} = $name; } return $v_name; } @@ -254,9 +259,9 @@ sub i_vlan { my $i_vlan = {}; my $idxmap = $aironet->cviRoutedVlanIfIndex(); - foreach my $i (keys %$idxmap) { - my @parts = split(/\./, $i); - $i_vlan->{$idxmap->{$i}} = $parts[0]; + foreach my $i ( keys %$idxmap ) { + my @parts = split( /\./, $i ); + $i_vlan->{ $idxmap->{$i} } = $parts[0]; } return $i_vlan; } @@ -265,46 +270,46 @@ sub i_vlan { # 5.5Mbps is reported as 11. sub munge_cd11_txrate { my $txrates = shift; - my @units = unpack("C*", $txrates); - my @rates = map { - my $unit = $_; - $unit *= 0.5; - } @units; + my @units = unpack( "C*", $txrates ); + my @rates = map { + my $unit = $_; + $unit *= 0.5; + } @units; return \@rates; } # cd11 INDEX sub cd11_port { - my $aironet = shift; + my $aironet = shift; my $cd11_sigstrength = $aironet->cd11_sigstrength(); - my $interfaces = $aironet->interfaces(); + my $interfaces = $aironet->interfaces(); my %ret; - foreach (keys %$cd11_sigstrength) { - my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($_); - $ret{$_} = $interfaces->{$ifindex}; + foreach ( keys %$cd11_sigstrength ) { + my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_); + $ret{$_} = $interfaces->{$ifindex}; } return \%ret; } sub cd11_ssid { - my $aironet = shift; + my $aironet = shift; my $cd11_sigstrength = $aironet->cd11_sigstrength(); my %ret; - foreach (keys %$cd11_sigstrength) { - my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($_); - $ret{$_} = $ssid; + foreach ( keys %$cd11_sigstrength ) { + my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_); + $ret{$_} = $ssid; } return \%ret; } sub cd11_mac { - my $aironet = shift; + my $aironet = shift; my $cd11_sigstrength = $aironet->cd11_sigstrength(); my %ret; - foreach (keys %$cd11_sigstrength) { - my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($_); - $ret{$_} = $mac; + foreach ( keys %$cd11_sigstrength ) { + my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_); + $ret{$_} = $mac; } return \%ret; } @@ -316,6 +321,7 @@ sub cd11_mac { # to get the right overrides. sub i_mac { my $aironet = shift; + # no partial is possible due to the levels # of indirection. @@ -323,41 +329,40 @@ sub i_mac { my $mbss_mac = $aironet->orig_i_mac(); my $mbss_mac_addr = $aironet->mbss_mac_addr(); - my $ssid_vlan = $aironet->cdot11SecAuxSsidVlan(); - my $vlan_map = $aironet->cviRoutedVlanIfIndex(); - my $ifstack = $aironet->ifStackStatus(); + my $ssid_vlan = $aironet->cdot11SecAuxSsidVlan(); + my $vlan_map = $aironet->cviRoutedVlanIfIndex(); + my $ifstack = $aironet->ifStackStatus(); my $vlan_list = {}; - foreach my $idx (keys %$vlan_map) { - my ($vlan, $num) = split(/\./, $idx); - push(@{$vlan_list->{$vlan}}, $vlan_map->{$idx}); + foreach my $idx ( keys %$vlan_map ) { + my ( $vlan, $num ) = split( /\./, $idx ); + push( @{ $vlan_list->{$vlan} }, $vlan_map->{$idx} ); } my $stack = {}; - foreach my $idx (keys %$ifstack) { - my ($upper, $lower) = split(/\./, $idx); - $stack->{$upper}->{$lower} = $ifstack->{$idx}; + foreach my $idx ( keys %$ifstack ) { + my ( $upper, $lower ) = split( /\./, $idx ); + $stack->{$upper}->{$lower} = $ifstack->{$idx}; } # mbss_mac_addr index is (radio, ssid). # ssid_vlan maps ssid->vlan. # vlan_map maps vlan->[list of interfaces] # ifstack allows us to pick the right interface - foreach my $idx (keys %$mbss_mac_addr) { - my ($interface, @ssid) = split(/\./, $idx); - my $vlan = $ssid_vlan->{join(".", scalar(@ssid), @ssid)}; - next unless defined($vlan); - foreach my $vlanif (@{$vlan_list->{$vlan}}) { - if (defined($stack->{$vlanif}->{$interface})) { - $mbss_mac->{$vlanif} = $mbss_mac_addr->{$idx}; - } - } + foreach my $idx ( keys %$mbss_mac_addr ) { + my ( $interface, @ssid ) = split( /\./, $idx ); + my $vlan = $ssid_vlan->{ join( ".", scalar(@ssid), @ssid ) }; + next unless defined($vlan); + foreach my $vlanif ( @{ $vlan_list->{$vlan} } ) { + if ( defined( $stack->{$vlanif}->{$interface} ) ) { + $mbss_mac->{$vlanif} = $mbss_mac_addr->{$idx}; + } + } } return $mbss_mac; } - 1; __END__ diff --git a/Info/Layer2/Allied.pm b/Info/Layer2/Allied.pm index 1985e8d1..12bc0f6b 100644 --- a/Info/Layer2/Allied.pm +++ b/Info/Layer2/Allied.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Max Baker # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -35,32 +35,28 @@ use Exporter; use SNMP::Info::Layer2; use SNMP::Info::Layer1; -@SNMP::Info::Layer2::Allied::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Allied::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Allied::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS - ); +%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS ); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - 'ip_adresses'=> 'atNetAddress', - 'ip_mac' => 'atPhysAddress', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + 'ip_adresses' => 'atNetAddress', + 'ip_mac' => 'atPhysAddress', +); -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - 'AtiSwitch-MIB' => 'atiswitchProductType', - 'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + 'AtiSwitch-MIB' => 'atiswitchProductType', + 'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking', +); -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, ); sub vendor { return 'allied'; @@ -72,9 +68,9 @@ sub os { sub os_ver { my $allied = shift; - my $descr = $allied->description(); - - if ($descr =~ m/version (\d+\.\d+)/){ + my $descr = $allied->description(); + + if ( $descr =~ m/version (\d+\.\d+)/ ) { return $1; } } @@ -84,48 +80,48 @@ sub model { my $desc = $allied->description(); - if ($desc =~ /(AT-80\d{2}\S*)/){ + if ( $desc =~ /(AT-80\d{2}\S*)/ ) { return $1; } return; } sub root_ip { - my $allied = shift; + my $allied = shift; my $ip_hash = $allied->ip_addresses(); my $found_ip; - - foreach my $ip (values %{$ip_hash}) { - $found_ip = SNMP::Info::munge_ip($ip) if (defined $ip); - last; # this is only one IP address + + foreach my $ip ( values %{$ip_hash} ) { + $found_ip = SNMP::Info::munge_ip($ip) if ( defined $ip ); + last; # this is only one IP address } return $found_ip; } -sub mac{ - my $allied = shift; +sub mac { + my $allied = shift; my $mac_hash = $allied->ip_mac(); my $found_mac; - - foreach my $mac (values %{$mac_hash}) { + + foreach my $mac ( values %{$mac_hash} ) { $found_mac = SNMP::Info::munge_mac($mac); - last; # this is only one MAC address + last; # this is only one MAC address } return $found_mac; } sub i_up { - my $allied = shift; + my $allied = shift; my $partial = shift; - my $i_up = SNMP::Info::Layer1::i_up($allied, $partial); + my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial ); - foreach my $port (keys %$i_up){ + foreach my $port ( keys %$i_up ) { my $up = $i_up->{$port}; $i_up->{$port} = 'down' if $up eq 'linktesterror'; - $i_up->{$port} = 'up' if $up eq 'nolinktesterror'; + $i_up->{$port} = 'up' if $up eq 'nolinktesterror'; } - + return $i_up; } 1; diff --git a/Info/Layer2/Aruba.pm b/Info/Layer2/Aruba.pm index e8433291..213618b5 100644 --- a/Info/Layer2/Aruba.pm +++ b/Info/Layer2/Aruba.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,48 +34,47 @@ use strict; use Exporter; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Aruba::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - 'WLSX-SWITCH-MIB' => 'wlsxHostname', - 'WLSR-AP-MIB' => 'wlsrHideSSID', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + 'WLSX-SWITCH-MIB' => 'wlsxHostname', + 'WLSR-AP-MIB' => 'wlsrHideSSID', +); -%GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - ); +%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, ); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - # WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable - # Table index leafs do not return information - # therefore unable to use apBSSID. We extract - # the information from the IID instead. - 'aruba_ap_name' => 'apLocation', - 'aruba_ap_ip' => 'apIpAddress', - 'aruba_ap_essid' => 'apESSID', - 'aruba_ap_ssidbcast' => 'wlsrHideSSID', - # WLSR-AP-MIB::wlsrConfigTable - 'aruba_ap_channel' => 'apCurrentChannel', - # WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable - # Table index leafs do not return information - # therefore unable to use staAccessPointBSSID - # or staPhyAddress. We extract the information from - # the IID instead. - #'fw_port' => 'staAccessPointBSSID', - #'fw_mac' => 'staPhyAddress', - 'fw_user' => 'staUserName', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - ); + # WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable + # Table index leafs do not return information + # therefore unable to use apBSSID. We extract + # the information from the IID instead. + 'aruba_ap_name' => 'apLocation', + 'aruba_ap_ip' => 'apIpAddress', + 'aruba_ap_essid' => 'apESSID', + 'aruba_ap_ssidbcast' => 'wlsrHideSSID', + + # WLSR-AP-MIB::wlsrConfigTable + 'aruba_ap_channel' => 'apCurrentChannel', + + # WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable + # Table index leafs do not return information + # therefore unable to use staAccessPointBSSID + # or staPhyAddress. We extract the information from + # the IID instead. + #'fw_port' => 'staAccessPointBSSID', + #'fw_mac' => 'staPhyAddress', + 'fw_user' => 'staUserName', +); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, ); sub layers { return '00000011'; @@ -94,7 +93,7 @@ sub os_ver { my $descr = $aruba->description(); return unless defined $descr; - if ($descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/){ + if ( $descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/ ) { return $1; } @@ -103,7 +102,7 @@ sub os_ver { sub model { my $aruba = shift; - my $id = $aruba->id(); + my $id = $aruba->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -114,14 +113,14 @@ sub model { # Thin APs do not support ifMIB requirement sub i_index { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->orig_i_index($partial) || {}; - my $ap_index = $aruba->aruba_ap_name($partial) || {}; - + my $i_index = $aruba->orig_i_index($partial) || {}; + my $ap_index = $aruba->aruba_ap_name($partial) || {}; + my %if_index; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; @@ -129,9 +128,11 @@ sub i_index { } # Get Attached APs as Interfaces - foreach my $ap_id (keys %$ap_index){ + foreach my $ap_id ( keys %$ap_index ) { + # Convert the 0.254.123.456 index entry to a MAC address. - my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$ap_id)); + my $mac = join( ':', + map { sprintf( "%02x", $_ ) } split( /\./, $ap_id ) ); $if_index{$ap_id} = $mac; } @@ -139,27 +140,28 @@ sub i_index { } sub interfaces { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->i_index($partial) || {}; - my $i_descr = $aruba->i_description($partial) || {}; + my $i_index = $aruba->i_index($partial) || {}; + my $i_descr = $aruba->i_description($partial) || {}; my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { - # Replace the Index with the ifDescr field. - my $port = $i_descr->{$iid}; - next unless defined $port; - $if{$iid} = $port; + if ( $index =~ /^\d+$/ ) { + + # Replace the Index with the ifDescr field. + my $port = $i_descr->{$iid}; + next unless defined $port; + $if{$iid} = $port; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { - $if{$index} = $index; - } + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { + $if{$index} = $index; + } else { next; @@ -169,120 +171,119 @@ sub interfaces { } sub i_name { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->i_index($partial) || {}; - my $i_name2 = $aruba->orig_i_name($partial) || {}; - my $ap_name = $aruba->aruba_ap_name($partial) || {}; - + my $i_index = $aruba->i_index($partial) || {}; + my $i_name2 = $aruba->orig_i_name($partial) || {}; + my $ap_name = $aruba->aruba_ap_name($partial) || {}; + my %i_name; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /^\d+$/ ) { - my $name = $i_name2->{$iid}; - next unless defined $name; - $i_name{$index} = $name; + if ( $index =~ /^\d+$/ ) { + my $name = $i_name2->{$iid}; + next unless defined $name; + $i_name{$index} = $name; } - elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { - my $name = $ap_name->{$iid}; - next unless defined $name; - $i_name{$index} = $name; - } + elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { + my $name = $ap_name->{$iid}; + next unless defined $name; + $i_name{$index} = $name; + } else { next; } } - return \%i_name; + return \%i_name; } sub i_ssidlist { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->i_index($partial) || {}; - my $ap_ssid = $aruba->aruba_ap_essid($partial) || {}; - + my $i_index = $aruba->i_index($partial) || {}; + my $ap_ssid = $aruba->aruba_ap_essid($partial) || {}; + my %i_ssid; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { - my $ssid = $ap_ssid->{$iid}; - next unless defined $ssid; - $i_ssid{$index} = $ssid; - } + if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { + my $ssid = $ap_ssid->{$iid}; + next unless defined $ssid; + $i_ssid{$index} = $ssid; + } else { next; } } - return \%i_ssid; + return \%i_ssid; } sub i_80211channel { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->i_index($partial) || {}; - my $ap_ch = $aruba->aruba_ap_channel($partial) || {}; - + my $i_index = $aruba->i_index($partial) || {}; + my $ap_ch = $aruba->aruba_ap_channel($partial) || {}; + my %i_ch; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { - my $ch = $ap_ch->{$iid}; - next unless defined $ch; - $i_ch{$index} = $ch; - } + if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { + my $ch = $ap_ch->{$iid}; + next unless defined $ch; + $i_ch{$index} = $ch; + } else { next; } } - return \%i_ch; + return \%i_ch; } sub i_ssidbcast { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->i_index($partial) || {}; - my $ap_bc = $aruba->aruba_ap_ssidbcast($partial) || {}; - + my $i_index = $aruba->i_index($partial) || {}; + my $ap_bc = $aruba->aruba_ap_ssidbcast($partial) || {}; + my %i_bc; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { - my $bc = $ap_bc->{$iid}; - next unless defined $bc; - $bc = ($bc ? 0 : 1); - $i_bc{$index} = $bc; - } + if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) { + my $bc = $ap_bc->{$iid}; + next unless defined $bc; + $bc = ( $bc ? 0 : 1 ); + $i_bc{$index} = $bc; + } else { next; } } - return \%i_bc; + return \%i_bc; } - # Wireless switches do not support the standard Bridge MIB sub bp_index { - my $aruba = shift; + my $aruba = shift; my $partial = shift; - my $i_index = $aruba->orig_i_index($partial) || {}; - my $ap_index = $aruba->aruba_ap_name($partial) || {}; - + my $i_index = $aruba->orig_i_index($partial) || {}; + my $ap_index = $aruba->aruba_ap_name($partial) || {}; + my %bp_index; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; @@ -290,9 +291,11 @@ sub bp_index { } # Get Attached APs as Interfaces - foreach my $ap_id (keys %$ap_index){ + foreach my $ap_id ( keys %$ap_index ) { + # Convert the 0.254.123.456 index entry to a MAC address. - my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$ap_id)); + my $mac = join( ':', + map { sprintf( "%02x", $_ ) } split( /\./, $ap_id ) ); $bp_index{$mac} = $mac; } @@ -300,39 +303,47 @@ sub bp_index { } sub fw_port { - my $aruba = shift; + my $aruba = shift; my $partial = shift; my $fw_idx = $aruba->fw_user($partial) || {}; my %fw_port; - foreach my $iid (keys %$fw_idx){ - if ($iid =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/) { - my $port = join(':',map {sprintf("%02x",$_)} split(/\./,$2)); - $fw_port{$iid} = $port; - } - else { - next; - } + foreach my $iid ( keys %$fw_idx ) { + if ( $iid + =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/ + ) + { + my $port = join( ':', + map { sprintf( "%02x", $_ ) } split( /\./, $2 ) ); + $fw_port{$iid} = $port; + } + else { + next; + } } return \%fw_port; } sub fw_mac { - my $aruba = shift; + my $aruba = shift; my $partial = shift; my $fw_idx = $aruba->fw_user($partial) || {}; my %fw_mac; - foreach my $iid (keys %$fw_idx){ - if ($iid =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/) { - my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$1)); - $fw_mac{$iid} = $mac; - } - else { - next; - } + foreach my $iid ( keys %$fw_idx ) { + if ( $iid + =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/ + ) + { + my $mac = join( ':', + map { sprintf( "%02x", $_ ) } split( /\./, $1 ) ); + $fw_mac{$iid} = $mac; + } + else { + next; + } } return \%fw_mac; } @@ -366,10 +377,10 @@ Eric Miller =head1 DESCRIPTION -SNMP::Info::Layer2::Aruba is a subclass of SNMP::Info that provides an interface -to Aruba wireless switches. The Aruba platform utilizes intelligent wireless -switches which control thin access points. The thin access points themselves -are unable to be polled for end station information. +SNMP::Info::Layer2::Aruba is a subclass of SNMP::Info that provides an +interface to Aruba wireless switches. The Aruba platform utilizes +intelligent wireless switches which control thin access points. The thin +access points themselves are unable to be polled for end station information. This class emulates bridge functionality for the wireless switch. This enables end station MAC addresses collection and correlation to the thin access point @@ -464,8 +475,8 @@ interfaces. The thin AP MAC address is used as the port identifier. =item $aruba->i_name() -Interface name. Returns (C) for Ethernet interfaces and (C) -for thin AP interfaces. +Interface name. Returns (C) for Ethernet interfaces and +(C) for thin AP interfaces. =item $aruba->bp_index() diff --git a/Info/Layer2/Bay.pm b/Info/Layer2/Bay.pm index 841af94f..bfb67f26 100644 --- a/Info/Layer2/Bay.pm +++ b/Info/Layer2/Bay.pm @@ -6,21 +6,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,7 +37,7 @@ use strict; use Exporter; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Bay::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -45,90 +45,93 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; # Set for No CDP -%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, - 'cdp_id' => 's5EnMsTopIpAddr', - 'cdp_run' => 's5EnMsTopStatus', - ); +%GLOBALS = ( + %SNMP::Info::Layer2::GLOBALS, + 'cdp_id' => 's5EnMsTopIpAddr', + 'cdp_run' => 's5EnMsTopStatus', +); -%FUNCS = (%SNMP::Info::Layer2::FUNCS, - 'imac2' => 'ifPhysAddress', - # S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable - 'bay_topo_slot' => 's5EnMsTopNmmSlot', - 'bay_topo_port' => 's5EnMsTopNmmPort', - 'bay_topo_ip' => 's5EnMsTopNmmIpAddr', - 'bay_topo_seg' => 's5EnMsTopNmmSegId', - 'bay_topo_mac' => 's5EnMsTopNmmMacAddr', - 'bay_topo_platform' => 's5EnMsTopNmmChassisType', - 'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + 'imac2' => 'ifPhysAddress', -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - 'SYNOPTICS-ROOT-MIB' => 'synoptics', - 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop' - ); + # S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable + 'bay_topo_slot' => 's5EnMsTopNmmSlot', + 'bay_topo_port' => 's5EnMsTopNmmPort', + 'bay_topo_ip' => 's5EnMsTopNmmIpAddr', + 'bay_topo_seg' => 's5EnMsTopNmmSegId', + 'bay_topo_mac' => 's5EnMsTopNmmMacAddr', + 'bay_topo_platform' => 's5EnMsTopNmmChassisType', + 'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg', +); + +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + 'SYNOPTICS-ROOT-MIB' => 'synoptics', + 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop' +); delete $MIBS{'CISCO-CDP-MIB'}; + # 450's report full duplex as speed = 20mbps?! -$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps'; +$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps'; $SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps'; -%MUNGE = (%SNMP::Info::Layer2::MUNGE, - 'i_mac2' => \&SNMP::Info::munge_mac , - ); +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, 'i_mac2' => \&SNMP::Info::munge_mac, ); sub os { return 'bay'; } sub os_ver { - my $bay = shift; + my $bay = shift; my $descr = $bay->description(); return unless defined $descr; # 303 / 304 - if ($descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/){ + if ( $descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/ ) { return $1; } # 450 - if ($descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/){ + if ( $descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/ ) { return $1; } return; } sub os_bin { - my $bay = shift; + my $bay = shift; my $descr = $bay->description(); return unless defined $descr; # 303 / 304 - if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){ + if ( $descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/ ) { return $1; } # 450 - if ($descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/){ + if ( $descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/ ) { return $1; } return; } sub vendor { + # or nortel, or synopsis? return 'bay'; } sub i_ignore { - my $bay = shift; + my $bay = shift; my $descr = $bay->description(); my $i_type = $bay->i_type(); my %i_ignore; - foreach my $if (keys %$i_type){ - my $type = $i_type->{$if}; + foreach my $if ( keys %$i_type ) { + my $type = $i_type->{$if}; $i_ignore{$if}++ if $type =~ /(loopback|propvirtual|cpu)/i; } @@ -136,28 +139,27 @@ sub i_ignore { } sub interfaces { - my $bay = shift; + my $bay = shift; my $i_index = $bay->i_index(); return $i_index; } -sub i_mac { - my $bay = shift; +sub i_mac { + my $bay = shift; my $i_mac = $bay->i_mac2(); # Bay 303's with a hw rev < 2.11.4.5 report the mac as all zeros - foreach my $iid (keys %$i_mac){ + foreach my $iid ( keys %$i_mac ) { my $mac = $i_mac->{$iid}; delete $i_mac->{$iid} if $mac eq '00:00:00:00:00:00'; } return $i_mac; } - sub model { my $bay = shift; - my $id = $bay->id(); + my $id = $bay->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -165,20 +167,20 @@ sub model { my $descr = $bay->description(); - return '303' if ($descr =~ /\D303\D/); - return '304' if ($descr =~ /\D304\D/); - return '450' if ($model =~ /BayStack450/); + return '303' if ( $descr =~ /\D303\D/ ); + return '304' if ( $descr =~ /\D304\D/ ); + return '450' if ( $model =~ /BayStack450/ ); return $model; } # Hack in some CDP type stuff sub c_if { - my $bay = shift; + my $bay = shift; my $bay_topo_port = $bay->bay_topo_port(); my %c_if; - foreach my $entry (keys %$bay_topo_port){ + foreach my $entry ( keys %$bay_topo_port ) { my $port = $bay_topo_port->{$entry}; next unless defined $port; next if $port == 0; @@ -188,29 +190,30 @@ sub c_if { } sub c_ip { - my $bay = shift; + my $bay = shift; my $bay_topo_ip = $bay->bay_topo_ip(); my $bay_topo_port = $bay->bay_topo_port(); - my $ip = $bay->cdp_ip(); - + my $ip = $bay->cdp_ip(); + # Count the number of devices seen on each port. # more than one device seen means connected to a non-bay # device, but other bay devices are squawking further away. my %ip_port; - foreach my $entry (keys %$bay_topo_ip){ + foreach my $entry ( keys %$bay_topo_ip ) { my $port = $bay_topo_port->{$entry}; next unless defined $port; - next if ($port =~ /^[\d\.]+$/ and $port == 0); - my $ip = $bay_topo_ip->{$entry}; - push(@{$ip_port{$port}},$ip); + next if ( $port =~ /^[\d\.]+$/ and $port == 0 ); + my $ip = $bay_topo_ip->{$entry}; + push( @{ $ip_port{$port} }, $ip ); } my %c_ip; - foreach my $port (keys %ip_port){ + foreach my $port ( keys %ip_port ) { my $ips = $ip_port{$port}; - if (scalar @$ips == 1) { + if ( scalar @$ips == 1 ) { $c_ip{"$port.1"} = $ips->[0]; - } else { + } + else { $c_ip{"$port.1"} = $ips; } } @@ -219,12 +222,12 @@ sub c_ip { } sub c_port { - my $bay = shift; + my $bay = shift; my $bay_topo_port = $bay->bay_topo_port(); - my $bay_topo_seg = $bay->bay_topo_seg(); + my $bay_topo_seg = $bay->bay_topo_seg(); my %c_port; - foreach my $entry (keys %$bay_topo_seg){ + foreach my $entry ( keys %$bay_topo_seg ) { my $port = $bay_topo_port->{$entry}; next unless defined $port; next if $port == 0; @@ -232,11 +235,11 @@ sub c_port { # For fake remotes (multiple IPs for a c_ip), use first found next if defined $c_port{"$port.1"}; - my $seg = $bay_topo_seg->{$entry}; + my $seg = $bay_topo_seg->{$entry}; # Segment id is (256 * remote slot_num) + (remote_port) my $remote_port = $seg % 256; - + $c_port{"$port.1"} = $remote_port; } @@ -244,20 +247,19 @@ sub c_port { } sub c_platform { - my $bay = shift; + my $bay = shift; my $bay_topo_port = $bay->bay_topo_port(); my $bay_topo_platform = $bay->bay_topo_platform(); - my %c_platform; - foreach my $entry (keys %$bay_topo_platform){ + foreach my $entry ( keys %$bay_topo_platform ) { my $port = $bay_topo_port->{$entry} || 0; next if $port == 0; # For fake remotes (multiple IPs for a c_ip), use first found next if defined $c_platform{"$port.1"}; - my $platform = $bay_topo_platform->{$entry}; + my $platform = $bay_topo_platform->{$entry}; $c_platform{"$port.1"} = $platform; } @@ -446,7 +448,8 @@ Returns reference to hash. Key: Table entry, Value:slot number =item $bay->bay_topo_port() -Returns reference to hash. Key: Table entry, Value:Port Number (interface iid) +Returns reference to hash. Key: Table entry, Value:Port Number +(interface iid) (C) diff --git a/Info/Layer2/Baystack.pm b/Info/Layer2/Baystack.pm index 9e403a86..78ee49fb 100644 --- a/Info/Layer2/Baystack.pm +++ b/Info/Layer2/Baystack.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond. # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * 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 +# +# 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 @@ -38,82 +38,82 @@ use SNMP::Info::RapidCity; use SNMP::Info::LLDP; use SNMP::Info::Layer3; -@SNMP::Info::Layer2::Baystack::ISA = qw/SNMP::Info::SONMP SNMP::Info::NortelStack - SNMP::Info::RapidCity SNMP::Info::LLDP - SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer2::Baystack::ISA + = qw/SNMP::Info::SONMP SNMP::Info::NortelStack + SNMP::Info::RapidCity SNMP::Info::LLDP + SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer2::Baystack::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::LLDP::MIBS, - %SNMP::Info::RapidCity::MIBS, - %SNMP::Info::NortelStack::MIBS, - %SNMP::Info::SONMP::MIBS, - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, %SNMP::Info::LLDP::MIBS, + %SNMP::Info::RapidCity::MIBS, %SNMP::Info::NortelStack::MIBS, + %SNMP::Info::SONMP::MIBS, +); -%GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::LLDP::GLOBALS, - %SNMP::Info::RapidCity::GLOBALS, - %SNMP::Info::NortelStack::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - ); +%GLOBALS = ( + %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::LLDP::GLOBALS, + %SNMP::Info::RapidCity::GLOBALS, %SNMP::Info::NortelStack::GLOBALS, + %SNMP::Info::SONMP::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::LLDP::FUNCS, - %SNMP::Info::RapidCity::FUNCS, - %SNMP::Info::NortelStack::FUNCS, - %SNMP::Info::SONMP::FUNCS, - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, %SNMP::Info::LLDP::FUNCS, + %SNMP::Info::RapidCity::FUNCS, %SNMP::Info::NortelStack::FUNCS, + %SNMP::Info::SONMP::FUNCS, +); # 450's report full duplex as speed = 20mbps?! -$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps'; -$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps'; +$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps'; +$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps'; $SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps'; -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::LLDP::MUNGE, - %SNMP::Info::RapidCity::MUNGE, - %SNMP::Info::NortelStack::MUNGE, - %SNMP::Info::SONMP::MUNGE, - ); +%MUNGE = ( + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE, + %SNMP::Info::RapidCity::MUNGE, %SNMP::Info::NortelStack::MUNGE, + %SNMP::Info::SONMP::MUNGE, +); sub os { my $baystack = shift; - my $descr = $baystack->description(); - my $model = $baystack->model(); + my $descr = $baystack->description(); + my $model = $baystack->model(); - if ((defined $model and $model =~ /(325|420|425|470|460|BPS|2500|3510|4524|4526|4548|4550|5510|5520|5530)/) and (defined $descr and $descr =~ m/SW:v[3-5]/i)) { - return 'boss'; + if (( defined $model + and $model + =~ /(325|420|425|470|460|BPS|2500|3510|4524|4526|4548|4550|5510|5520|5530)/ + ) + and ( defined $descr and $descr =~ m/SW:v[3-5]/i ) + ) + { + return 'boss'; } - if ((defined $descr and $descr =~ /Business Ethernet Switch.*SW:v/i)) { - return 'bes'; + if ( ( defined $descr and $descr =~ /Business Ethernet Switch.*SW:v/i ) ) + { + return 'bes'; } return 'baystack'; } sub os_bin { my $baystack = shift; - my $descr = $baystack->description(); + my $descr = $baystack->description(); return unless defined $descr; # 303 / 304 - if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){ + if ( $descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/ ) { return $1; } # 450 - if ($descr =~ m/FW:V(\d+\.\d+)/){ + if ( $descr =~ m/FW:V(\d+\.\d+)/ ) { return $1; } - if ($descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i){ + if ( $descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i ) { return $1; } return; @@ -125,38 +125,41 @@ sub vendor { sub model { my $baystack = shift; - my $id = $baystack->id(); + my $id = $baystack->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; my $descr = $baystack->description(); - return '303' if (defined $descr and $descr =~ /\D303\D/); - return '304' if (defined $descr and $descr =~ /\D304\D/); - return 'BPS' if ($model =~ /BPS2000/i); - return $2 if ($model =~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)-?(\d+)/); - + return '303' if ( defined $descr and $descr =~ /\D303\D/ ); + return '304' if ( defined $descr and $descr =~ /\D304\D/ ); + return 'BPS' if ( $model =~ /BPS2000/i ); + return $2 + if ( $model + =~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)-?(\d+)/ ); + return $model; } sub interfaces { my $baystack = shift; - my $partial = shift; + my $partial = shift; - my $i_index = $baystack->i_index($partial) || {}; + my $i_index = $baystack->i_index($partial) || {}; my $index_factor = $baystack->index_factor(); - my $slot_offset = $baystack->slot_offset(); - + my $slot_offset = $baystack->slot_offset(); + my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; + # Ignore cascade ports next if $index > 513; - my $port = ($index % $index_factor); - my $slot = (int($index / $index_factor)) + $slot_offset; + my $port = ( $index % $index_factor ); + my $slot = ( int( $index / $index_factor ) ) + $slot_offset; my $slotport = "$slot.$port"; $if{$iid} = $slotport; @@ -164,54 +167,58 @@ sub interfaces { return \%if; } -sub i_mac { +sub i_mac { my $baystack = shift; - my $partial = shift; + my $partial = shift; my $i_mac = $baystack->orig_i_mac($partial) || {}; my %i_mac; + # Baystack 303's with a hw rev < 2.11.4.5 report the mac as all zeros - foreach my $iid (keys %$i_mac){ + foreach my $iid ( keys %$i_mac ) { my $mac = $i_mac->{$iid}; next unless defined $mac; next if $mac eq '00:00:00:00:00:00'; - $i_mac{$iid}=$mac; + $i_mac{$iid} = $mac; } return \%i_mac; } sub i_name { my $baystack = shift; - my $partial = shift; + my $partial = shift; - my $i_index = $baystack->i_index($partial) || {}; - my $i_alias = $baystack->i_alias($partial) || {}; - my $i_name2 = $baystack->orig_i_name($partial) || {}; + my $i_index = $baystack->i_index($partial) || {}; + my $i_alias = $baystack->i_alias($partial) || {}; + my $i_name2 = $baystack->orig_i_name($partial) || {}; my %i_name; - foreach my $iid (keys %$i_name2){ - my $name = $i_name2->{$iid}; + foreach my $iid ( keys %$i_name2 ) { + my $name = $i_name2->{$iid}; my $alias = $i_alias->{$iid}; - $i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ? - $alias : - $name; + $i_name{$iid} + = ( defined $alias and $alias !~ /^\s*$/ ) + ? $alias + : $name; } return \%i_name; } sub index_factor { - my $baystack = shift; - my $model = $baystack->model(); - my $os = $baystack->os(); - my $op_mode = $baystack->ns_op_mode(); - + my $baystack = shift; + my $model = $baystack->model(); + my $os = $baystack->os(); + my $op_mode = $baystack->ns_op_mode(); + $op_mode = 'pure' unless defined $op_mode; my $index_factor = 32; - $index_factor = 64 if ((defined $model and $model =~ /(470)/) or ($os =~ m/(boss|bes)/) and ($op_mode eq 'pure')); - + $index_factor = 64 + if ( ( defined $model and $model =~ /(470)/ ) + or ( $os =~ m/(boss|bes)/ ) and ( $op_mode eq 'pure' ) ); + return $index_factor; } @@ -225,20 +232,20 @@ sub hasCDP { sub c_ip { my $baystack = shift; - my $partial = shift; + my $partial = shift; my $cdp = $baystack->SUPER::c_ip($partial) || {}; - my $lldp = $baystack->lldp_ip($partial) || {}; + my $lldp = $baystack->lldp_ip($partial) || {}; my %c_ip; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $ip = $cdp->{$iid}; next unless defined $ip; $c_ip{$iid} = $ip; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $ip = $lldp->{$iid}; next unless defined $ip; @@ -249,20 +256,20 @@ sub c_ip { sub c_if { my $baystack = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $baystack->lldp_if($partial) || {};; + my $lldp = $baystack->lldp_if($partial) || {}; my $cdp = $baystack->SUPER::c_if($partial) || {}; - + my %c_if; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $if = $cdp->{$iid}; next unless defined $if; $c_if{$iid} = $if; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $if = $lldp->{$iid}; next unless defined $if; @@ -273,20 +280,20 @@ sub c_if { sub c_port { my $baystack = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $baystack->lldp_port($partial) || {}; + my $lldp = $baystack->lldp_port($partial) || {}; my $cdp = $baystack->SUPER::c_port($partial) || {}; - + my %c_port; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $port = $cdp->{$iid}; next unless defined $port; $c_port{$iid} = $port; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $port = $lldp->{$iid}; next unless defined $port; @@ -297,20 +304,20 @@ sub c_port { sub c_id { my $baystack = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $baystack->lldp_id($partial) || {}; + my $lldp = $baystack->lldp_id($partial) || {}; my $cdp = $baystack->SUPER::c_id($partial) || {}; my %c_id; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $id = $cdp->{$iid}; next unless defined $id; $c_id{$iid} = $id; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $id = $lldp->{$iid}; next unless defined $id; @@ -321,20 +328,20 @@ sub c_id { sub c_platform { my $baystack = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $baystack->lldp_rem_sysdesc($partial) || {}; + my $lldp = $baystack->lldp_rem_sysdesc($partial) || {}; my $cdp = $baystack->SUPER::c_platform($partial) || {}; my %c_platform; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $platform = $cdp->{$iid}; next unless defined $platform; $c_platform{$iid} = $platform; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $platform = $lldp->{$iid}; next unless defined $platform; @@ -582,7 +589,8 @@ to a hash. Returns reference to the map between IID and physical Port. - Slot and port numbers on the Baystack switches are determined by the formula: + Slot and port numbers on the Baystack switches are determined by the + formula: port = (Interface index % Index factor) slot = (int(Interface index / Index factor)) + Slot offset @@ -602,7 +610,8 @@ revisions of Baystack firmware report all zeros for each port mac. =item $baystack->i_name() -Crosses C with C and returns the human set port name if exists. +Crosses C with C and returns the human set port name if +exists. =back @@ -701,8 +710,8 @@ Returns reference to hash. Key: iid Value: remote IPv4 address If multiple entries exist with the same local port, c_if(), with the same IPv4 address, c_ip(), it may be a duplicate entry. -If multiple entries exist with the same local port, c_if(), with different IPv4 -addresses, c_ip(), there is either a non-SONMP/LLDP device in between two or +If multiple entries exist with the same local port, c_if(), with different +IPv4 addresses, c_ip(), there is either a non-SONMP/LLDP device in between two or more devices or multiple devices which are not directly connected. Use the data from the Layer2 Topology Table below to dig deeper. diff --git a/Info/Layer2/C1900.pm b/Info/Layer2/C1900.pm index 6fe3997e..c5cb945c 100644 --- a/Info/Layer2/C1900.pm +++ b/Info/Layer2/C1900.pm @@ -6,20 +6,20 @@ # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -40,8 +40,8 @@ use SNMP::Info::CiscoConfig; use SNMP::Info::Layer2; @SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::CDP SNMP::Info::CiscoStats - SNMP::Info::CiscoConfig SNMP::Info::Layer2 - Exporter/; + SNMP::Info::CiscoConfig SNMP::Info::Layer2 + Exporter/; @SNMP::Info::Layer2::C1900::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -49,44 +49,44 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::CiscoConfig::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - 'c1900_flash_status' => 'upgradeFlashBankStatus', - ); + %SNMP::Info::Layer2::GLOBALS, + %SNMP::Info::CiscoConfig::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + 'c1900_flash_status' => 'upgradeFlashBankStatus', +); %FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::CiscoConfig::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - # ESSWITCH-MIB - 'c1900_p_index' => 'swPortIndex', - 'c1900_p_ifindex' => 'swPortIfIndex', - 'c1900_p_duplex' => 'swPortDuplexStatus', - 'c1900_p_duplex_admin' => 'swPortFullDuplex', - 'c1900_p_name' => 'swPortName', - 'c1900_p_up_admin' => 'swPortAdminStatus', - 'c1900_p_type' => 'swPortMediaCapability', - 'c1900_p_media' => 'swPortConnectorType', - ); + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::CiscoConfig::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, + + # ESSWITCH-MIB + 'c1900_p_index' => 'swPortIndex', + 'c1900_p_ifindex' => 'swPortIfIndex', + 'c1900_p_duplex' => 'swPortDuplexStatus', + 'c1900_p_duplex_admin' => 'swPortFullDuplex', + 'c1900_p_name' => 'swPortName', + 'c1900_p_up_admin' => 'swPortAdminStatus', + 'c1900_p_type' => 'swPortMediaCapability', + 'c1900_p_media' => 'swPortConnectorType', +); %MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::CiscoConfig::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - # Also known as the ESSWITCH-MIB - 'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000' - ); + %SNMP::Info::Layer2::MIBS, + %SNMP::Info::CiscoConfig::MIBS, + %SNMP::Info::CiscoStats::MIBS, + %SNMP::Info::CDP::MIBS, + + # Also known as the ESSWITCH-MIB + 'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000' +); %MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::CiscoConfig::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - ); + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE, + %SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE, +); sub bulkwalk_no { return 1; } sub cisco_comm_indexing { return 1; } @@ -199,53 +199,54 @@ sub set_i_duplex_admin { } sub i_vlan { - my $c1900 = shift; - my $partial = shift; + my $c1900 = shift; + my $partial = shift; - # Overlap allows more than one VLAN per port. Unable to determine default - my $overlap = $c1900->bridgeGroupAllowMembershipOverlap() || - $c1900->vlanAllowMembershipOverlap() || 'disabled'; - - if ($overlap eq 'enabled') { + # Overlap allows more than one VLAN per port. Unable to determine default + my $overlap = $c1900->bridgeGroupAllowMembershipOverlap() + || $c1900->vlanAllowMembershipOverlap() + || 'disabled'; + + if ( $overlap eq 'enabled' ) { return; } - my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup() || - $c1900->vlanMemberPortOfVlan(); + my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup() + || $c1900->vlanMemberPortOfVlan(); my $i_pvid = {}; - foreach my $idx (keys %$member_of) { - my @values = split(/\./, $idx); - my ($vlan, $port) = @values; + foreach my $idx ( keys %$member_of ) { + my @values = split( /\./, $idx ); + my ( $vlan, $port ) = @values; next unless $vlan; next unless $port; - next if (defined $partial and $port !~ /^$partial$/); + next if ( defined $partial and $port !~ /^$partial$/ ); my $value = $member_of->{$idx}; - next if ($value eq 'false'); - + next if ( $value eq 'false' ); + $i_pvid->{$port} = $vlan; } return $i_pvid; } sub i_vlan_membership { - my $c1900 = shift; + my $c1900 = shift; my $partial = shift; - my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup() || - $c1900->vlanMemberPortOfVlan(); + my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup() + || $c1900->vlanMemberPortOfVlan(); my $i_vlan_membership = {}; - foreach my $idx (keys %$member_of) { - my @values = split(/\./, $idx); - my ($vlan, $port) = @values; + foreach my $idx ( keys %$member_of ) { + my @values = split( /\./, $idx ); + my ( $vlan, $port ) = @values; next unless $vlan; next unless $port; - next if (defined $partial and $port !~ /^$partial$/); + next if ( defined $partial and $port !~ /^$partial$/ ); my $value = $member_of->{$idx}; - next if ($value eq 'false'); + next if ( $value eq 'false' ); - push(@{$i_vlan_membership->{$port}}, $vlan); + push( @{ $i_vlan_membership->{$port} }, $vlan ); } return $i_vlan_membership; } @@ -499,9 +500,10 @@ See L for details. =head1 SET METHODS -These are methods that provide SNMP set functionality for overridden methods or -provide a simpler interface to complex set operations. See -L for general information on set operations. +These are methods that provide SNMP set functionality for overridden methods +or provide a simpler interface to complex set operations. See +L for general information on set +operations. =over diff --git a/Info/Layer2/C2900.pm b/Info/Layer2/C2900.pm index d9d18ffe..8bb2cffc 100644 --- a/Info/Layer2/C2900.pm +++ b/Info/Layer2/C2900.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -41,8 +41,8 @@ use SNMP::Info::CiscoConfig; use SNMP::Info::Layer2; @SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP - SNMP::Info::CiscoStats SNMP::Info::CiscoConfig - SNMP::Info::Layer2 Exporter/; + SNMP::Info::CiscoStats SNMP::Info::CiscoConfig + SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::C2900::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -50,43 +50,37 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::CiscoConfig::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - ); + %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::CiscoVTP::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::CiscoConfig::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - 'i_name' => 'ifAlias', - # C2900PortEntry - 'c2900_p_index' => 'c2900PortIfIndex', - 'c2900_p_duplex' => 'c2900PortDuplexStatus', - 'c2900_p_duplex_admin' => 'c2900PortDuplexState', - 'c2900_p_speed_admin' => 'c2900PortAdminSpeed', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::CiscoConfig::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, + %SNMP::Info::CiscoVTP::FUNCS, + 'i_name' => 'ifAlias', -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::CiscoConfig::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - 'CISCO-C2900-MIB' => 'ciscoC2900MIB', - ); + # C2900PortEntry + 'c2900_p_index' => 'c2900PortIfIndex', + 'c2900_p_duplex' => 'c2900PortDuplexStatus', + 'c2900_p_duplex_admin' => 'c2900PortDuplexState', + 'c2900_p_speed_admin' => 'c2900PortAdminSpeed', +); -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::CiscoConfig::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoConfig::MIBS, + %SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS, + %SNMP::Info::CiscoVTP::MIBS, 'CISCO-C2900-MIB' => 'ciscoC2900MIB', +); + +%MUNGE = ( + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE, + %SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE, + %SNMP::Info::CiscoVTP::MUNGE, +); sub vendor { return 'cisco'; @@ -97,9 +91,9 @@ sub cisco_comm_indexing { } sub i_duplex { - my $c2900 = shift; + my $c2900 = shift; my $partial = shift; - + my $interfaces = $c2900->interfaces($partial); my $c2900_p_index = $c2900->c2900_p_index(); my $c2900_p_duplex = $c2900->c2900_p_duplex(); @@ -107,53 +101,53 @@ sub i_duplex { my %reverse_2900 = reverse %$c2900_p_index; my %i_duplex; - foreach my $if (keys %$interfaces){ + foreach my $if ( keys %$interfaces ) { my $port_2900 = $reverse_2900{$if}; next unless defined $port_2900; my $duplex = $c2900_p_duplex->{$port_2900}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; - $i_duplex{$if}=$duplex; + $i_duplex{$if} = $duplex; } return \%i_duplex; } sub i_duplex_admin { - my $c2900 = shift; + my $c2900 = shift; my $partial = shift; - - my $interfaces = $c2900->interfaces($partial); - my $c2900_p_index = $c2900->c2900_p_index(); + + my $interfaces = $c2900->interfaces($partial); + my $c2900_p_index = $c2900->c2900_p_index(); my $c2900_p_admin = $c2900->c2900_p_duplex_admin(); my %reverse_2900 = reverse %$c2900_p_index; my %i_duplex_admin; - foreach my $if (keys %$interfaces){ + foreach my $if ( keys %$interfaces ) { my $port_2900 = $reverse_2900{$if}; next unless defined $port_2900; my $duplex = $c2900_p_admin->{$port_2900}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; $duplex = 'auto' if $duplex =~ /auto/i; - $i_duplex_admin{$if}=$duplex; + $i_duplex_admin{$if} = $duplex; } return \%i_duplex_admin; } sub set_i_speed_admin { my $c2900 = shift; - my ($speed, $iid) = @_; - + my ( $speed, $iid ) = @_; + # map speeds to those the switch will understand my %speeds = qw/auto 1 10 10000000 100 100000000/; - my $c2900_p_index = $c2900->c2900_p_index(); - my %reverse_2900 = reverse %$c2900_p_index; + my $c2900_p_index = $c2900->c2900_p_index(); + my %reverse_2900 = reverse %$c2900_p_index; $speed = lc($speed); @@ -162,18 +156,18 @@ sub set_i_speed_admin { # account for weirdness of c2900 mib $iid = $reverse_2900{$iid}; - return $c2900->set_c2900_p_speed_admin($speeds{$speed}, $iid); + return $c2900->set_c2900_p_speed_admin( $speeds{$speed}, $iid ); } sub set_i_duplex_admin { my $c2900 = shift; - my ($duplex, $iid) = @_; + my ( $duplex, $iid ) = @_; # map a textual duplex to an integer one the switch understands my %duplexes = qw/full 1 half 2 auto 3/; - my $c2900_p_index = $c2900->c2900_p_index(); - my %reverse_2900 = reverse %$c2900_p_index; + my $c2900_p_index = $c2900->c2900_p_index(); + my %reverse_2900 = reverse %$c2900_p_index; $duplex = lc($duplex); @@ -182,29 +176,29 @@ sub set_i_duplex_admin { # account for weirdness of c2900 mib $iid = $reverse_2900{$iid}; - return $c2900->set_c2900_p_duplex_admin($duplexes{$duplex}, $iid); + return $c2900->set_c2900_p_duplex_admin( $duplexes{$duplex}, $iid ); } # Use i_descritption for port key, cuz i_name can be manually entered. sub interfaces { - my $c2900 = shift; + my $c2900 = shift; my $partial = shift; - my $interfaces = $c2900->i_index($partial) || {}; - my $i_descr = $c2900->i_description($partial) || {}; + my $interfaces = $c2900->i_index($partial) || {}; + my $i_descr = $c2900->i_description($partial) || {}; my %if; - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $port = $i_descr->{$iid}; next unless defined $port; - $port =~ s/\./\//g if( $port =~ /\d+\.\d+$/); + $port =~ s/\./\//g if ( $port =~ /\d+\.\d+$/ ); $port =~ s/[^\d\/,()\w]+//gi; - + $if{$iid} = $port; } - return \%if + return \%if; } 1; @@ -409,9 +403,10 @@ See L for details. =head1 SET METHODS -These are methods that provide SNMP set functionality for overridden methods or -provide a simpler interface to complex set operations. See -L for general information on set operations. +These are methods that provide SNMP set functionality for overridden methods +or provide a simpler interface to complex set operations. See +L for general information on set +operations. =over diff --git a/Info/Layer2/Catalyst.pm b/Info/Layer2/Catalyst.pm index 481c6fad..c0ab6924 100644 --- a/Info/Layer2/Catalyst.pm +++ b/Info/Layer2/Catalyst.pm @@ -4,21 +4,21 @@ # Copyright (c) 2002,2003 Regents of the University of California # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * 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 +# +# 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 @@ -40,51 +40,43 @@ use SNMP::Info::CiscoStats; use SNMP::Info::CiscoPortSecurity; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::CiscoStack SNMP::Info::CiscoVTP - SNMP::Info::CDP SNMP::Info::CiscoStats - SNMP::Info::CiscoPortSecurity - SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Catalyst::ISA + = qw/SNMP::Info::CiscoStack SNMP::Info::CiscoVTP + SNMP::Info::CDP SNMP::Info::CiscoStats + SNMP::Info::CiscoPortSecurity + SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::CiscoPortSecurity::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - %SNMP::Info::CiscoStack::MIBS, - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS, + %SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS, + %SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoStack::MIBS, +); %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::CiscoPortSecurity::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - %SNMP::Info::CiscoStack::GLOBALS, - ); + %SNMP::Info::Layer2::GLOBALS, + %SNMP::Info::CiscoPortSecurity::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::CiscoVTP::GLOBALS, + %SNMP::Info::CiscoStack::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::CiscoPortSecurity::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - %SNMP::Info::CiscoStack::FUNCS, - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CDP::FUNCS, + %SNMP::Info::CiscoVTP::FUNCS, %SNMP::Info::CiscoStack::FUNCS, +); -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::CiscoPortSecurity::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - %SNMP::Info::CiscoStack::MUNGE, - ); +%MUNGE = ( + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE, + %SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE, + %SNMP::Info::CiscoVTP::MUNGE, %SNMP::Info::CiscoStack::MUNGE, +); # Overidden Methods @@ -95,9 +87,9 @@ sub i_physical { my $p_port = $cat->p_port(); my %i_physical; - foreach my $port (keys %$p_port) { + foreach my $port ( keys %$p_port ) { my $iid = $p_port->{$port}; - $i_physical{$iid} = 1; + $i_physical{$iid} = 1; } return \%i_physical; } @@ -111,7 +103,7 @@ sub os { } sub os_ver { - my $cat = shift; + my $cat = shift; my $os_ver = $cat->SUPER::os_ver(); return $os_ver if defined $os_ver; @@ -125,15 +117,15 @@ sub os_ver { # Workaround for incomplete bp_index sub bp_index { - my $cat = shift; + my $cat = shift; my $p_index = $cat->p_port(); my $b_index = $cat->p_oidx(); my %bp_index; - foreach my $iid (keys %$p_index){ + foreach my $iid ( keys %$p_index ) { my $ifidx = $p_index->{$iid}; next unless defined $ifidx; - my $bpidx = $b_index->{$iid}||0; + my $bpidx = $b_index->{$iid} || 0; $bp_index{$bpidx} = $ifidx; } @@ -145,15 +137,15 @@ sub cisco_comm_indexing { } sub interfaces { - my $cat = shift; + my $cat = shift; my $partial = shift; - my $i_index = $cat->i_index($partial); - my $portnames = $cat->p_port() || {}; - my %portmap = reverse %$portnames; + my $i_index = $cat->i_index($partial); + my $portnames = $cat->p_port() || {}; + my %portmap = reverse %$portnames; my %interfaces = (); - foreach my $iid (keys %$i_index) { + foreach my $iid ( keys %$i_index ) { next unless defined $iid; my $if = $i_index->{$iid}; my $port = $portmap{$iid}; @@ -163,20 +155,20 @@ sub interfaces { } sub i_name { - my $cat = shift; + my $cat = shift; my $partial = shift; my $p_port = $cat->p_port() || {}; my $p_name = $cat->p_name() || {}; my %i_name; - foreach my $port (keys %$p_name) { + foreach my $port ( keys %$p_name ) { my $iid = $p_port->{$port}; next unless defined $iid; - next if (defined $partial and $iid !~ /^$partial$/); + next if ( defined $partial and $iid !~ /^$partial$/ ); $i_name{$iid} = $p_name->{$port}; } - return \%i_name; + return \%i_name; } 1; @@ -211,7 +203,8 @@ Max Baker SNMP::Info subclass to provide information for Cisco Catalyst series switches running CatOS. -This class includes the Catalyst 2920, 4000, 5000, 6000 (hybrid mode) families. +This class includes the Catalyst 2920, 4000, 5000, 6000 (hybrid mode) +families. This subclass is not for all devices that have the name Catalyst. Note that some Catalyst switches run IOS, like the 2900 and 3550 families. Cisco @@ -330,7 +323,8 @@ to a hash. =item $cat->interfaces() -Returns the map between SNMP Interface Identifier (iid) and physical port name. +Returns the map between SNMP Interface Identifier (iid) and physical port +name. =item $cat->i_name() @@ -347,8 +341,8 @@ Returns a map to IID for ports that are physical ports, not vlans, etc. Returns reference to hash of bridge port table entries map back to interface identifier (iid) -Crosses (C) to (C) since some devices seem to have -problems with F +Crosses (C) to (C) since some devices seem to +have problems with F =back diff --git a/Info/Layer2/Centillion.pm b/Info/Layer2/Centillion.pm index 87e8a6db..1e308eeb 100644 --- a/Info/Layer2/Centillion.pm +++ b/Info/Layer2/Centillion.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,61 +37,66 @@ use SNMP::Info::Bridge; use SNMP::Info::NortelStack; use SNMP::Info::SONMP; -@SNMP::Info::Layer2::Centillion::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/; +@SNMP::Info::Layer2::Centillion::ISA + = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/; @SNMP::Info::Layer2::Centillion::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::MIBS, - %SNMP::Info::Bridge::MIBS, - %SNMP::Info::NortelStack::MIBS, - %SNMP::Info::SONMP::MIBS, - 'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable', - 'S5-COMMON-STATS-MIB' => 's5CmStat', - 'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt', - 'CENTILLION-CONFIG-MIB' => 'sysTFTPStart', - ); +%MIBS = ( + %SNMP::Info::MIBS, + %SNMP::Info::Bridge::MIBS, + %SNMP::Info::NortelStack::MIBS, + %SNMP::Info::SONMP::MIBS, + 'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable', + 'S5-COMMON-STATS-MIB' => 's5CmStat', + 'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt', + 'CENTILLION-CONFIG-MIB' => 'sysTFTPStart', +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - %SNMP::Info::Bridge::GLOBALS, - %SNMP::Info::NortelStack::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - 'tftp_action' => 'sysTFTPStart', - 'tftp_host' => 'sysTFTPIpAddress', - 'tftp_file' => 'sysTFTPFileName', - 'tftp_type' => 'sysTFTPFileType', - 'tftp_result' => 'sysTFTPResult', - ); + %SNMP::Info::GLOBALS, + %SNMP::Info::Bridge::GLOBALS, + %SNMP::Info::NortelStack::GLOBALS, + %SNMP::Info::SONMP::GLOBALS, + 'tftp_action' => 'sysTFTPStart', + 'tftp_host' => 'sysTFTPIpAddress', + 'tftp_file' => 'sysTFTPFileName', + 'tftp_type' => 'sysTFTPFileType', + 'tftp_result' => 'sysTFTPResult', +); -%FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Bridge::FUNCS, - %SNMP::Info::NortelStack::FUNCS, - %SNMP::Info::SONMP::FUNCS, - # CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable - 'centillion_p_index' => 'cnDot3ExtnIfIndex', - 'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType', - 'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType', - # S5-COMMON-STATS-MIB::s5CmSNodeTable - 'fw_mac' => 's5CmSNodeMacAddr', - 'fw_port' => 's5CmSNodeIfIndx', - # CENTILLION-VLAN-MIB::cnVlanPortMemberTable - 'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex', - 'centillion_i_vlan' => 'cnVlanPortMemberVID', - 'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType', - ); +%FUNCS = ( + %SNMP::Info::FUNCS, + %SNMP::Info::Bridge::FUNCS, + %SNMP::Info::NortelStack::FUNCS, + %SNMP::Info::SONMP::FUNCS, -%MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::MUNGE, - %SNMP::Info::Bridge::MUNGE, - %SNMP::Info::NortelStack::MUNGE, - %SNMP::Info::SONMP::MUNGE, - ); + # CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable + 'centillion_p_index' => 'cnDot3ExtnIfIndex', + 'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType', + 'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType', + + # S5-COMMON-STATS-MIB::s5CmSNodeTable + 'fw_mac' => 's5CmSNodeMacAddr', + 'fw_port' => 's5CmSNodeIfIndx', + + # CENTILLION-VLAN-MIB::cnVlanPortMemberTable + 'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex', + 'centillion_i_vlan' => 'cnVlanPortMemberVID', + 'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType', +); + +%MUNGE = ( + + # Inherit all the built in munging + %SNMP::Info::MUNGE, + %SNMP::Info::Bridge::MUNGE, + %SNMP::Info::NortelStack::MUNGE, + %SNMP::Info::SONMP::MUNGE, +); sub os { return 'centillion'; @@ -103,12 +108,13 @@ sub vendor { sub i_ignore { my $centillion = shift; - my $descr = $centillion->i_description(); + my $descr = $centillion->i_description(); my %i_ignore; - foreach my $if (keys %$descr){ + foreach my $if ( keys %$descr ) { my $type = $descr->{$if}; - # Skip virtual interfaces + + # Skip virtual interfaces $i_ignore{$if}++ if $type =~ /(VE|VID|vc|lp)/i; } return \%i_ignore; @@ -116,24 +122,25 @@ sub i_ignore { sub interfaces { my $centillion = shift; - my $i_index = $centillion->i_index(); - my $i_descr = $centillion->i_description(); + my $i_index = $centillion->i_index(); + my $i_descr = $centillion->i_description(); my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - my $descr = $i_descr->{$iid}; - # Skip ATM and virtual interfaces - next if $descr =~ /(VE|VID|vc|lp)/i; + my $descr = $i_descr->{$iid}; - # Index numbers are deterministic slot * 256 + port - my $port = $index % 256; - my $slot = int($index / 256); + # Skip ATM and virtual interfaces + next if $descr =~ /(VE|VID|vc|lp)/i; + + # Index numbers are deterministic slot * 256 + port + my $port = $index % 256; + my $slot = int( $index / 256 ); my $slotport = "$slot.$port"; - $slotport = "$descr" if $descr =~ /(mcp)/i; - + $slotport = "$descr" if $descr =~ /(mcp)/i; + $if{$index} = $slotport; } @@ -142,89 +149,89 @@ sub interfaces { sub i_duplex { my $centillion = shift; - + my $port_index = $centillion->centillion_p_index(); my $port_duplex = $centillion->centillion_p_duplex(); my %i_duplex; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; my $duplex = $port_duplex->{$iid}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; - $i_duplex{$index}=$duplex; + $i_duplex{$index} = $duplex; } return \%i_duplex; } sub i_duplex_admin { my $centillion = shift; - + my $port_index = $centillion->centillion_p_index(); my $port_admin = $centillion->centillion_p_duplex_admin(); my %i_duplex_admin; - foreach my $iid (keys %$port_index){ + foreach my $iid ( keys %$port_index ) { my $index = $port_index->{$iid}; next unless defined $index; my $duplex = $port_admin->{$iid}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; $duplex = 'auto' if $duplex =~ /auto/i; - $i_duplex_admin{$index}=$duplex; + $i_duplex_admin{$index} = $duplex; } return \%i_duplex_admin; } sub i_vlan { my $centillion = shift; - + my $cn_vlan_index = $centillion->centillion_i_vlan_index(); - my $cn_vlan = $centillion->centillion_i_vlan(); + my $cn_vlan = $centillion->centillion_i_vlan(); my %i_vlan; - foreach my $iid (keys %$cn_vlan_index){ + foreach my $iid ( keys %$cn_vlan_index ) { my $index = $cn_vlan_index->{$iid}; next unless defined $index; my $vlan = $cn_vlan->{$iid}; - next unless defined $vlan; - - $i_vlan{$index}=$vlan; + next unless defined $vlan; + + $i_vlan{$index} = $vlan; } return \%i_vlan; } sub model { my $centillion = shift; - my $id = $centillion->id(); + my $id = $centillion->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; $model =~ s/^sreg-//i; - return '5000BH' if ($model =~ /5000BH/); - return '5005BH' if ($model =~ /5005BH/); - return 'C100' if ($model =~ /Centillion100/); - return 'C50N' if ($model =~ /Centillion50N/); - return 'C50T' if ($model =~ /Centillion50T/); + return '5000BH' if ( $model =~ /5000BH/ ); + return '5005BH' if ( $model =~ /5005BH/ ); + return 'C100' if ( $model =~ /Centillion100/ ); + return 'C50N' if ( $model =~ /Centillion50N/ ); + return 'C50T' if ( $model =~ /Centillion50T/ ); return $model; } sub bp_index { my $centillion = shift; - my $index = $centillion->fw_port(); + my $index = $centillion->fw_port(); my %bp_index; - foreach my $iid (keys %$index){ + foreach my $iid ( keys %$index ) { my $b_index = $index->{$iid}; next unless defined $b_index; - #Index value is the same as ifIndex + #Index value is the same as ifIndex $bp_index{$b_index} = $b_index; } @@ -239,7 +246,6 @@ sub slot_offset { return 0; } - 1; __END__ @@ -411,7 +417,8 @@ to a hash. Returns reference to the map between IID and physical Port. - Slot and port numbers on the Passport switches are determined by the formula: + Slot and port numbers on the Passport switches are determined by the + formula: port = index % 256 slot = int(index / 256) diff --git a/Info/Layer2/Cisco.pm b/Info/Layer2/Cisco.pm index bb8b95ab..bab97462 100644 --- a/Info/Layer2/Cisco.pm +++ b/Info/Layer2/Cisco.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Max Baker # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -41,60 +41,44 @@ use SNMP::Info::CiscoQOS; use SNMP::Info::CiscoConfig; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP - SNMP::Info::CiscoStats SNMP::Info::CiscoImage - SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS - SNMP::Info::CiscoConfig SNMP::Info::Layer2 - Exporter/; +@SNMP::Info::Layer2::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP + SNMP::Info::CiscoStats SNMP::Info::CiscoImage + SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS + SNMP::Info::CiscoConfig SNMP::Info::Layer2 + Exporter/; @SNMP::Info::Layer2::Cisco::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::CiscoConfig::MIBS, - %SNMP::Info::CiscoQOS::MIBS, - %SNMP::Info::CiscoRTT::MIBS, - %SNMP::Info::CiscoImage::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - ); + %SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoConfig::MIBS, + %SNMP::Info::CiscoQOS::MIBS, %SNMP::Info::CiscoRTT::MIBS, + %SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS, + %SNMP::Info::CDP::MIBS, %SNMP::Info::CiscoVTP::MIBS, +); %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::CiscoConfig::GLOBALS, - %SNMP::Info::CiscoQOS::GLOBALS, - %SNMP::Info::CiscoRTT::GLOBALS, - %SNMP::Info::CiscoImage::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - ); + %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS, + %SNMP::Info::CiscoQOS::GLOBALS, %SNMP::Info::CiscoRTT::GLOBALS, + %SNMP::Info::CiscoImage::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS, +); %FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::CiscoConfig::FUNCS, - %SNMP::Info::CiscoQOS::FUNCS, - %SNMP::Info::CiscoRTT::FUNCS, - %SNMP::Info::CiscoImage::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - ); + %SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoConfig::FUNCS, + %SNMP::Info::CiscoQOS::FUNCS, %SNMP::Info::CiscoRTT::FUNCS, + %SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, %SNMP::Info::CiscoVTP::FUNCS, +); %MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::CiscoConfig::MUNGE, - %SNMP::Info::CiscoQOS::MUNGE, - %SNMP::Info::CiscoRTT::MUNGE, - %SNMP::Info::CiscoImage::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - ); + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE, + %SNMP::Info::CiscoQOS::MUNGE, %SNMP::Info::CiscoRTT::MUNGE, + %SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE, + %SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE, +); 1; __END__ diff --git a/Info/Layer2/Foundry.pm b/Info/Layer2/Foundry.pm index ff21047b..bfd9b8f2 100644 --- a/Info/Layer2/Foundry.pm +++ b/Info/Layer2/Foundry.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Max Baker # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,51 +37,45 @@ use SNMP::Info::FDP; use SNMP::Info::EtherLike; use SNMP::Info::MAU; -@SNMP::Info::Layer2::Foundry::ISA = qw/SNMP::Info::Layer2 SNMP::Info::FDP SNMP::Info::EtherLike - SNMP::Info::MAU Exporter/; +@SNMP::Info::Layer2::Foundry::ISA + = qw/SNMP::Info::Layer2 SNMP::Info::FDP SNMP::Info::EtherLike + SNMP::Info::MAU Exporter/; @SNMP::Info::Layer2::Foundry::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer2::MIBS, - %SNMP::Info::FDP::MIBS, - %SNMP::Info::EtherLike::MIBS, - %SNMP::Info::MAU::MIBS, - 'FOUNDRY-SN-ROOT-MIB' => 'foundry', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, %SNMP::Info::FDP::MIBS, + %SNMP::Info::EtherLike::MIBS, %SNMP::Info::MAU::MIBS, + 'FOUNDRY-SN-ROOT-MIB' => 'foundry', +); %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::FDP::GLOBALS, - %SNMP::Info::EtherLike::GLOBALS, - %SNMP::Info::MAU::GLOBALS, - ); + %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::FDP::GLOBALS, + %SNMP::Info::EtherLike::GLOBALS, %SNMP::Info::MAU::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::FDP::FUNCS, - %SNMP::Info::EtherLike::FUNCS, - %SNMP::Info::MAU::FUNCS, - 'test' => 'dot1dStpPortState', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, %SNMP::Info::FDP::FUNCS, + %SNMP::Info::EtherLike::FUNCS, %SNMP::Info::MAU::FUNCS, + 'test' => 'dot1dStpPortState', +); %MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::FDP::MUNGE, - %SNMP::Info::EtherLike::MUNGE, - %SNMP::Info::MAU::MUNGE, - ); - + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::FDP::MUNGE, + %SNMP::Info::EtherLike::MUNGE, %SNMP::Info::MAU::MUNGE, +); # Method OverRides #sub bulkwalk_no { 1;} -*SNMP::Info::Layer2::Foundry::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; -*SNMP::Info::Layer2::Foundry::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin; -*SNMP::Info::Layer2::Foundry::i_vlan = \&SNMP::Info::Bridge::qb_i_vlan_t; +*SNMP::Info::Layer2::Foundry::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; +*SNMP::Info::Layer2::Foundry::i_duplex_admin + = \&SNMP::Info::MAU::mau_i_duplex_admin; +*SNMP::Info::Layer2::Foundry::i_vlan = \&SNMP::Info::Bridge::qb_i_vlan_t; # todo doc these @@ -92,19 +86,19 @@ sub os_ver { # find entity table entry for "stackmanaget.1" my $unit_iid = undef; - foreach my $e (keys %$e_name){ + foreach my $e ( keys %$e_name ) { my $name = $e_name->{$e} || ''; $unit_iid = $e if $name eq 'stackmanaget.1'; } - + # Default to OID method if no dice. - unless (defined $unit_iid){ + unless ( defined $unit_iid ) { return $foundry->SUPER::model(); } # Find Model Name my $e_fwver = $foundry->e_fwver(); - if (defined $e_fwver->{$unit_iid}){ + if ( defined $e_fwver->{$unit_iid} ) { return $e_fwver->{$unit_iid}; } @@ -119,25 +113,25 @@ sub model { # find entity table entry for "unit.1" my $unit_iid = undef; - foreach my $e (keys %$e_name){ + foreach my $e ( keys %$e_name ) { my $name = $e_name->{$e} || ''; $unit_iid = $e if $name eq 'unit.1'; } - + # Default to OID method if no dice. - unless (defined $unit_iid){ + unless ( defined $unit_iid ) { return $foundry->SUPER::model(); } # Find Model Name my $e_model = $foundry->e_model(); - if (defined $e_model->{$unit_iid}){ + if ( defined $e_model->{$unit_iid} ) { return $e_model->{$unit_iid}; } # Not found in ENTITY-MIB, go up a level. return $foundry->SUPER::model(); - + } sub serial { @@ -147,7 +141,7 @@ sub serial { # find entity table entry for "unit.1" my $unit_iid = undef; - foreach my $e (keys %$e_name){ + foreach my $e ( keys %$e_name ) { my $name = $e_name->{$e} || ''; $unit_iid = $e if $name eq 'unit.1'; } @@ -165,13 +159,13 @@ sub interfaces { my $i_descr = $foundry->i_description; my $i_name = $foundry->i_name; - # use ifName only if it is in portn + # use ifName only if it is in portn # format. For EdgeIrons # else use ifDescr - foreach my $iid (keys %$i_name){ + foreach my $iid ( keys %$i_name ) { my $name = $i_name->{$iid}; next unless defined $name; - $i_descr->{$iid} = $name + $i_descr->{$iid} = $name if $name =~ /^port\d+/i; } @@ -180,21 +174,21 @@ sub interfaces { sub i_ignore { my $foundry = shift; - my $i_type = $foundry->i_type(); + my $i_type = $foundry->i_type(); my %i_ignore = (); - foreach my $iid (keys %$i_type){ + foreach my $iid ( keys %$i_type ) { my $type = $i_type->{$iid} || ''; - $i_ignore{$iid}++ + $i_ignore{$iid}++ + # 33 is the console port if $type =~ /(loopback|propvirtual|other|cpu|33)/i; } return \%i_ignore; } - -sub os { +sub os { return 'foundry'; } @@ -211,7 +205,8 @@ __END__ =head1 NAME -SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry FastIron Network Devices +SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry FastIron Network +Devices =head1 AUTHOR diff --git a/Info/Layer2/HP.pm b/Info/Layer2/HP.pm index 906812cf..a13a72c1 100644 --- a/Info/Layer2/HP.pm +++ b/Info/Layer2/HP.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -39,140 +39,147 @@ use SNMP::Info::MAU; use SNMP::Info::LLDP; use SNMP::Info::CDP; -@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer3 SNMP::Info::MAU SNMP::Info::LLDP - SNMP::Info::CDP Exporter/; +@SNMP::Info::Layer2::HP::ISA + = qw/SNMP::Info::Layer3 SNMP::Info::MAU SNMP::Info::LLDP + SNMP::Info::CDP Exporter/; @SNMP::Info::Layer2::HP::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, - %SNMP::Info::MAU::MIBS, - %SNMP::Info::LLDP::MIBS, - %SNMP::Info::CDP::MIBS, - 'RFC1271-MIB' => 'logDescription', - 'HP-ICF-OID' => 'hpSwitch4000', - 'HP-VLAN' => 'hpVlanMemberIndex', - 'STATISTICS-MIB' => 'hpSwitchCpuStat', - 'NETSWITCH-MIB' => 'hpMsgBufFree', - 'CONFIG-MIB' => 'hpSwitchConfig', - 'SEMI-MIB' => 'hpHttpMgSerialNumber', - 'HP-ICF-CHASSIS' => 'hpicfSensorObjectId', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::MAU::MIBS, + %SNMP::Info::LLDP::MIBS, + %SNMP::Info::CDP::MIBS, + 'RFC1271-MIB' => 'logDescription', + 'HP-ICF-OID' => 'hpSwitch4000', + 'HP-VLAN' => 'hpVlanMemberIndex', + 'STATISTICS-MIB' => 'hpSwitchCpuStat', + 'NETSWITCH-MIB' => 'hpMsgBufFree', + 'CONFIG-MIB' => 'hpSwitchConfig', + 'SEMI-MIB' => 'hpHttpMgSerialNumber', + 'HP-ICF-CHASSIS' => 'hpicfSensorObjectId', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::MAU::GLOBALS, - %SNMP::Info::LLDP::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - 'serial1' => 'entPhysicalSerialNum.1', - 'serial2' => 'hpHttpMgSerialNumber.0', - 'hp_cpu' => 'hpSwitchCpuStat.0', - 'hp_mem_total' => 'hpGlobalMemTotalBytes.1', - 'mem_free' => 'hpGlobalMemFreeBytes.1', - 'mem_used' => 'hpGlobalMemAllocBytes.1', - 'os_version' => 'hpSwitchOsVersion.0', - 'os_bin' => 'hpSwitchRomVersion.0', - 'mac' => 'hpSwitchBaseMACAddress.0', - 'hp_vlans' => 'hpVlanNumber', - ); + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::MAU::GLOBALS, + %SNMP::Info::LLDP::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + 'serial1' => 'entPhysicalSerialNum.1', + 'serial2' => 'hpHttpMgSerialNumber.0', + 'hp_cpu' => 'hpSwitchCpuStat.0', + 'hp_mem_total' => 'hpGlobalMemTotalBytes.1', + 'mem_free' => 'hpGlobalMemFreeBytes.1', + 'mem_used' => 'hpGlobalMemAllocBytes.1', + 'os_version' => 'hpSwitchOsVersion.0', + 'os_bin' => 'hpSwitchRomVersion.0', + 'mac' => 'hpSwitchBaseMACAddress.0', + 'hp_vlans' => 'hpVlanNumber', +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::MAU::FUNCS, - %SNMP::Info::LLDP::FUNCS, - %SNMP::Info::CDP::FUNCS, - 'bp_index2' => 'dot1dBasePortIfIndex', - 'i_type2' => 'ifType', - # RFC1271 - 'l_descr' => 'logDescription', - # HP-VLAN-MIB - 'hp_v_index' => 'hpVlanDot1QID', - 'hp_v_name' => 'hpVlanIdentName', - 'hp_v_state' => 'hpVlanIdentState', - 'hp_v_type' => 'hpVlanIdentType', - 'hp_v_status' => 'hpVlanIdentStatus', - 'hp_v_mac' => 'hpVlanAddrPhysAddress', - 'hp_v_if_index'=> 'hpVlanMemberIndex', - 'hp_v_if_tag' => 'hpVlanMemberTagged2', - # CONFIG-MIB::hpSwitchPortTable - 'hp_duplex' => 'hpSwitchPortEtherMode', - 'hp_duplex_admin' => 'hpSwitchPortFastEtherMode', - # HP-ICF-CHASSIS - 'hp_s_oid' => 'hpicfSensorObjectId', - 'hp_s_name' => 'hpicfSensorDescr', - 'hp_s_status' => 'hpicfSensorStatus', - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::MAU::FUNCS, + %SNMP::Info::LLDP::FUNCS, + %SNMP::Info::CDP::FUNCS, + 'bp_index2' => 'dot1dBasePortIfIndex', + 'i_type2' => 'ifType', + + # RFC1271 + 'l_descr' => 'logDescription', + + # HP-VLAN-MIB + 'hp_v_index' => 'hpVlanDot1QID', + 'hp_v_name' => 'hpVlanIdentName', + 'hp_v_state' => 'hpVlanIdentState', + 'hp_v_type' => 'hpVlanIdentType', + 'hp_v_status' => 'hpVlanIdentStatus', + 'hp_v_mac' => 'hpVlanAddrPhysAddress', + 'hp_v_if_index' => 'hpVlanMemberIndex', + 'hp_v_if_tag' => 'hpVlanMemberTagged2', + + # CONFIG-MIB::hpSwitchPortTable + 'hp_duplex' => 'hpSwitchPortEtherMode', + 'hp_duplex_admin' => 'hpSwitchPortFastEtherMode', + + # HP-ICF-CHASSIS + 'hp_s_oid' => 'hpicfSensorObjectId', + 'hp_s_name' => 'hpicfSensorDescr', + 'hp_s_status' => 'hpicfSensorStatus', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::MAU::MUNGE, - %SNMP::Info::LLDP::MUNGE, - %SNMP::Info::CDP::MUNGE - ); -%MODEL_MAP = ( - 'J4093A' => '2424M', - 'J4110A' => '8000M', - 'J4120A' => '1600M', - 'J4121A' => '4000M', - 'J4122A' => '2400M', - 'J4122B' => '2424M', - 'J4138A' => '9308M', - 'J4139A' => '9304M', - 'J4812A' => '2512', - 'J4813A' => '2524', - 'J4815A' => '3324XL', - 'J4819A' => '5308XL', - 'J4840A' => '6308M-SX', - 'J4841A' => '6208M-SX', - 'J4850A' => '5304XL', - 'J4851A' => '3124', - 'J4865A' => '4108GL', - 'J4874A' => '9315M', - 'J4887A' => '4104GL', - 'J4899A' => '2650', - 'J4899B' => '2650-CR', - 'J4900A' => '2626', - 'J4900B' => '2626-CR', - 'J4902A' => '6108', - 'J4903A' => '2824', - 'J4904A' => '2848', - 'J4905A' => '3400cl-24G', - 'J4906A' => '3400cl-48G', - 'J8130A' => 'WAP-420-NA', - 'J8131A' => 'WAP-420-WW', - 'J8133A' => 'AP520WL', - 'J8164A' => '2626-PWR', - 'J8165A' => '2650-PWR', - 'J8433A' => 'CX4-6400cl-6XG', - 'J8474A' => 'MF-6400cl-6XG', - 'J8680A' => '9608sl', - 'J8692A' => '3500yl-24G-PWR', - 'J8693A' => '3500yl-48G-PWR', - 'J8697A' => '5406zl', - 'J8698A' => '5412zl', - 'J8718A' => '5404yl', - 'J8719A' => '5408yl', - 'J8770A' => '4204vl', - 'J8771A' => '4202vl-48G', - 'J8772A' => '4202vl-72', - 'J8773A' => '4208vl', - 'J8762A' => '2600-8-PWR', - 'J8992A' => '6200yl-24G', - 'J9019A' => '2510-24A', - 'J9020A' => '2510-48A', - 'J9021A' => '2810-24G', - 'J9022A' => '2810-48G', - 'J9028A' => '1800-24G', - 'J9029A' => '1800-8G', - 'J9050A' => '2900-48G', - 'J9049A' => '2900-24G', - 'J9032A' => '4202vl-68G', - 'J9091A' => '8212zl', - ); + # Inherit all the built in munging + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::MAU::MUNGE, + %SNMP::Info::LLDP::MUNGE, + %SNMP::Info::CDP::MUNGE +); + +%MODEL_MAP = ( + 'J4093A' => '2424M', + 'J4110A' => '8000M', + 'J4120A' => '1600M', + 'J4121A' => '4000M', + 'J4122A' => '2400M', + 'J4122B' => '2424M', + 'J4138A' => '9308M', + 'J4139A' => '9304M', + 'J4812A' => '2512', + 'J4813A' => '2524', + 'J4815A' => '3324XL', + 'J4819A' => '5308XL', + 'J4840A' => '6308M-SX', + 'J4841A' => '6208M-SX', + 'J4850A' => '5304XL', + 'J4851A' => '3124', + 'J4865A' => '4108GL', + 'J4874A' => '9315M', + 'J4887A' => '4104GL', + 'J4899A' => '2650', + 'J4899B' => '2650-CR', + 'J4900A' => '2626', + 'J4900B' => '2626-CR', + 'J4902A' => '6108', + 'J4903A' => '2824', + 'J4904A' => '2848', + 'J4905A' => '3400cl-24G', + 'J4906A' => '3400cl-48G', + 'J8130A' => 'WAP-420-NA', + 'J8131A' => 'WAP-420-WW', + 'J8133A' => 'AP520WL', + 'J8164A' => '2626-PWR', + 'J8165A' => '2650-PWR', + 'J8433A' => 'CX4-6400cl-6XG', + 'J8474A' => 'MF-6400cl-6XG', + 'J8680A' => '9608sl', + 'J8692A' => '3500yl-24G-PWR', + 'J8693A' => '3500yl-48G-PWR', + 'J8697A' => '5406zl', + 'J8698A' => '5412zl', + 'J8718A' => '5404yl', + 'J8719A' => '5408yl', + 'J8770A' => '4204vl', + 'J8771A' => '4202vl-48G', + 'J8772A' => '4202vl-72', + 'J8773A' => '4208vl', + 'J8762A' => '2600-8-PWR', + 'J8992A' => '6200yl-24G', + 'J9019A' => '2510-24A', + 'J9020A' => '2510-48A', + 'J9021A' => '2810-24G', + 'J9022A' => '2810-48G', + 'J9028A' => '1800-24G', + 'J9029A' => '1800-8G', + 'J9050A' => '2900-48G', + 'J9049A' => '2900-24G', + 'J9032A' => '4202vl-68G', + 'J9091A' => '8212zl', +); # Method Overrides @@ -189,13 +196,15 @@ sub mem_total { sub os { return 'hp'; } + sub os_ver { - my $hp = shift; + my $hp = shift; my $os_version = $hp->os_version(); return $os_version if defined $os_version; + # Some older ones don't have this value,so we cull it from the description my $descr = $hp->description(); - if ($descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/) { + if ( $descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/ ) { return $1; } return; @@ -208,7 +217,7 @@ sub model { return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; - + $model =~ s/^hpswitch//i; return defined $MODEL_MAP{$model} ? $MODEL_MAP{$model} : $model; @@ -220,19 +229,19 @@ sub serial { my $serial = $hp->serial1() || $hp->serial2() || undef; - return $serial; + return $serial; } sub interfaces { - my $hp = shift; + my $hp = shift; my $interfaces = $hp->i_index(); - my $i_descr = $hp->i_description(); + my $i_descr = $hp->i_description(); my %if; - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $descr = $i_descr->{$iid}; next unless defined $descr; - $if{$iid} = $descr if (defined $descr and length $descr); + $if{$iid} = $descr if ( defined $descr and length $descr ); } return \%if @@ -240,14 +249,14 @@ sub interfaces { } sub i_name { - my $hp = shift; - my $i_alias = $hp->i_alias(); - my $e_name = $hp->e_name(); - my $e_port = $hp->e_port(); + my $hp = shift; + my $i_alias = $hp->i_alias(); + my $e_name = $hp->e_name(); + my $e_port = $hp->e_port(); my %i_name; - foreach my $port (keys %$e_name){ + foreach my $port ( keys %$e_name ) { my $iid = $e_port->{$port}; next unless defined $iid; my $alias = $i_alias->{$iid}; @@ -255,9 +264,9 @@ sub i_name { $i_name{$iid} = $e_name->{$port}; # Check for alias - $i_name{$iid} = $alias if (defined $alias and length($alias)); + $i_name{$iid} = $alias if ( defined $alias and length($alias) ); } - + return \%i_name; } @@ -268,22 +277,22 @@ sub i_duplex { } sub i_duplex_admin { - my $hp = shift; + my $hp = shift; my $partial = shift; # Try HP MIB first my $hp_duplex = $hp->hp_duplex_admin($partial); - if (defined $hp_duplex and scalar(keys %$hp_duplex)){ + if ( defined $hp_duplex and scalar( keys %$hp_duplex ) ) { my %i_duplex; - foreach my $if (keys %$hp_duplex){ + foreach my $if ( keys %$hp_duplex ) { my $duplex = $hp_duplex->{$if}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; $duplex = 'auto' if $duplex =~ /auto/i; - $i_duplex{$if}=$duplex; + $i_duplex{$if} = $duplex; } return \%i_duplex; } @@ -297,29 +306,29 @@ sub vendor { } sub log { - my $hp=shift; + my $hp = shift; my $log = $hp->l_descr(); my $logstring = undef; - foreach my $val (values %$log){ + foreach my $val ( values %$log ) { next if $val =~ /^Link\s+(Up|Down)/; - $logstring .= "$val\n"; + $logstring .= "$val\n"; } - return $logstring; + return $logstring; } sub slots { - my $hp=shift; - + my $hp = shift; + my $e_name = $hp->e_name(); return unless defined $e_name; my $slots; - foreach my $slot (keys %$e_name) { + foreach my $slot ( keys %$e_name ) { $slots++ if $e_name->{$slot} =~ /slot/i; } @@ -328,31 +337,33 @@ sub slots { sub fan { my $hp = shift; - return &_sensor($hp, 'fan'); + return &_sensor( $hp, 'fan' ); } sub ps1_status { my $hp = shift; - return &_sensor($hp, 'power', '^power supply 1') || &_sensor($hp, 'power', '^power supply sensor'); + return &_sensor( $hp, 'power', '^power supply 1' ) + || &_sensor( $hp, 'power', '^power supply sensor' ); } sub ps2_status { my $hp = shift; - return &_sensor($hp, 'power', '^power supply 2') || &_sensor($hp, 'power', '^redundant'); + return &_sensor( $hp, 'power', '^power supply 2' ) + || &_sensor( $hp, 'power', '^redundant' ); } sub _sensor { - my $hp = shift; + my $hp = shift; my $search_type = shift || 'fan'; my $search_name = shift || ''; - my $hp_s_oid = $hp->hp_s_oid(); + my $hp_s_oid = $hp->hp_s_oid(); my $result; - foreach my $sensor (keys %$hp_s_oid) { - my $sensortype = &SNMP::translateObj($hp_s_oid->{$sensor}); - if ($sensortype =~ /$search_type/i) { - my $sensorname = $hp->hp_s_name()->{$sensor}; + foreach my $sensor ( keys %$hp_s_oid ) { + my $sensortype = &SNMP::translateObj( $hp_s_oid->{$sensor} ); + if ( $sensortype =~ /$search_type/i ) { + my $sensorname = $hp->hp_s_name()->{$sensor}; my $sensorstatus = $hp->hp_s_status()->{$sensor}; - if ($sensorname =~ /$search_name/i) { + if ( $sensorname =~ /$search_name/i ) { $result = $sensorstatus; } } @@ -362,19 +373,19 @@ sub _sensor { # Bridge MIB does not map Bridge Port to ifIndex correctly on all models sub bp_index { - my $hp = shift; + my $hp = shift; my $partial = shift; my $if_index = $hp->i_index($partial); - my $model = $hp->model(); + my $model = $hp->model(); my $bp_index = $hp->bp_index2($partial); - - unless (defined $model and $model =~ /(1600|2424|4000|8000)/) { + + unless ( defined $model and $model =~ /(1600|2424|4000|8000)/ ) { return $bp_index; } my %mod_bp_index; - foreach my $iid (keys %$if_index){ + foreach my $iid ( keys %$if_index ) { $mod_bp_index{$iid} = $iid; } return \%mod_bp_index; @@ -384,12 +395,12 @@ sub bp_index { # Q-BRIDGE if available. sub v_index { - my $hp = shift; + my $hp = shift; my $partial = shift; # Newer devices my $q_index = $hp->SUPER::v_index($partial); - if (defined $q_index and scalar(keys %$q_index)){ + if ( defined $q_index and scalar( keys %$q_index ) ) { return $q_index; } @@ -398,12 +409,12 @@ sub v_index { } sub v_name { - my $hp = shift; + my $hp = shift; my $partial = shift; # Newer devices my $q_name = $hp->SUPER::v_name($partial); - if (defined $q_name and scalar(keys %$q_name)){ + if ( defined $q_name and scalar( keys %$q_name ) ) { return $q_name; } @@ -416,23 +427,23 @@ sub i_vlan { # Newer devices use Q-BRIDGE-MIB my $qb_i_vlan = $hp->SUPER::i_vlan(); - if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ + if ( defined $qb_i_vlan and scalar( keys %$qb_i_vlan ) ) { return $qb_i_vlan; } # HP4000 ... get it from HP-VLAN - # the hpvlanmembertagged2 table has an entry in the form of + # the hpvlanmembertagged2 table has an entry in the form of # vlan.interface = /untagged/no/tagged/auto my $i_vlan = {}; my $hp_v_index = $hp->hp_v_index(); my $hp_v_if_tag = $hp->hp_v_if_tag(); - foreach my $row (keys %$hp_v_if_tag){ - my ($index,$if) = split(/\./,$row); + foreach my $row ( keys %$hp_v_if_tag ) { + my ( $index, $if ) = split( /\./, $row ); - my $tag = $hp_v_if_tag->{$row}; + my $tag = $hp_v_if_tag->{$row}; my $vlan = $hp_v_index->{$index}; - - next unless (defined $tag and $tag =~ /untagged/); + + next unless ( defined $tag and $tag =~ /untagged/ ); $i_vlan->{$if} = $vlan if defined $vlan; } @@ -445,24 +456,24 @@ sub i_vlan_membership { # Newer devices use Q-BRIDGE-MIB my $qb_i_vlan = $hp->SUPER::i_vlan_membership(); - if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ + if ( defined $qb_i_vlan and scalar( keys %$qb_i_vlan ) ) { return $qb_i_vlan; } # Older get it from HP-VLAN my $i_vlan_membership = {}; - my $hp_v_index = $hp->hp_v_index(); - my $hp_v_if_tag = $hp->hp_v_if_tag(); - foreach my $row (keys %$hp_v_if_tag){ - my ($index,$if) = split(/\./,$row); + my $hp_v_index = $hp->hp_v_index(); + my $hp_v_if_tag = $hp->hp_v_if_tag(); + foreach my $row ( keys %$hp_v_if_tag ) { + my ( $index, $if ) = split( /\./, $row ); - my $tag = $hp_v_if_tag->{$row}; + my $tag = $hp_v_if_tag->{$row}; my $vlan = $hp_v_index->{$index}; - - next unless (defined $tag); - next if ($tag eq 'no'); - push(@{$i_vlan_membership->{$if}}, $vlan); + next unless ( defined $tag ); + next if ( $tag eq 'no' ); + + push( @{ $i_vlan_membership->{$if} }, $vlan ); } return $i_vlan_membership; @@ -477,21 +488,21 @@ sub hasCDP { } sub c_ip { - my $hp = shift; + my $hp = shift; my $partial = shift; my $cdp = $hp->SUPER::c_ip($partial) || {}; - my $lldp = $hp->lldp_ip($partial) || {}; + my $lldp = $hp->lldp_ip($partial) || {}; my %c_ip; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $ip = $cdp->{$iid}; next unless defined $ip; $c_ip{$iid} = $ip; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $ip = $lldp->{$iid}; next unless defined $ip; @@ -501,21 +512,21 @@ sub c_ip { } sub c_if { - my $hp = shift; + my $hp = shift; my $partial = shift; - my $lldp = $hp->lldp_if($partial) || {};; + my $lldp = $hp->lldp_if($partial) || {}; my $cdp = $hp->SUPER::c_if($partial) || {}; - + my %c_if; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $if = $cdp->{$iid}; next unless defined $if; $c_if{$iid} = $if; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $if = $lldp->{$iid}; next unless defined $if; @@ -525,21 +536,21 @@ sub c_if { } sub c_port { - my $hp = shift; + my $hp = shift; my $partial = shift; - my $lldp = $hp->lldp_port($partial) || {}; + my $lldp = $hp->lldp_port($partial) || {}; my $cdp = $hp->SUPER::c_port($partial) || {}; - + my %c_port; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $port = $cdp->{$iid}; next unless defined $port; $c_port{$iid} = $port; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $port = $lldp->{$iid}; next unless defined $port; @@ -549,21 +560,21 @@ sub c_port { } sub c_id { - my $hp = shift; + my $hp = shift; my $partial = shift; - my $lldp = $hp->lldp_id($partial) || {}; + my $lldp = $hp->lldp_id($partial) || {}; my $cdp = $hp->SUPER::c_id($partial) || {}; my %c_id; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $id = $cdp->{$iid}; next unless defined $id; $c_id{$iid} = $id; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $id = $lldp->{$iid}; next unless defined $id; @@ -573,21 +584,21 @@ sub c_id { } sub c_platform { - my $hp = shift; + my $hp = shift; my $partial = shift; - my $lldp = $hp->lldp_rem_sysdesc($partial) || {}; + my $lldp = $hp->lldp_rem_sysdesc($partial) || {}; my $cdp = $hp->SUPER::c_platform($partial) || {}; my %c_platform; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $platform = $cdp->{$iid}; next unless defined $platform; $c_platform{$iid} = $platform; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $platform = $lldp->{$iid}; next unless defined $platform; @@ -923,9 +934,9 @@ Returns reference to hash. Key: iid Value: remote IPv4 address If multiple entries exist with the same local port, c_if(), with the same IPv4 address, c_ip(), it may be a duplicate entry. -If multiple entries exist with the same local port, c_if(), with different IPv4 -addresses, c_ip(), there is either a non-CDP/LLDP device in between two or -more devices or multiple devices which are not directly connected. +If multiple entries exist with the same local port, c_if(), with different +IPv4 addresses, c_ip(), there is either a non-CDP/LLDP device in between two +or more devices or multiple devices which are not directly connected. Use the data from the Layer2 Topology Table below to dig deeper. diff --git a/Info/Layer2/N2270.pm b/Info/Layer2/N2270.pm index 5af6be23..a6ffc418 100644 --- a/Info/Layer2/N2270.pm +++ b/Info/Layer2/N2270.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,40 +37,33 @@ use SNMP::Info::Bridge; use SNMP::Info::SONMP; use SNMP::Info::Airespace; -@SNMP::Info::Layer2::N2270::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::Airespace Exporter/; +@SNMP::Info::Layer2::N2270::ISA + = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::Airespace Exporter/; @SNMP::Info::Layer2::N2270::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::MIBS, - %SNMP::Info::Bridge::MIBS, - %SNMP::Info::SONMP::MIBS, - %SNMP::Info::Airespace::MIBS, - ); +%MIBS = ( + %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS, + %SNMP::Info::SONMP::MIBS, %SNMP::Info::Airespace::MIBS, +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - %SNMP::Info::Bridge::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - %SNMP::Info::Airespace::GLOBALS, - ); + %SNMP::Info::GLOBALS, %SNMP::Info::Bridge::GLOBALS, + %SNMP::Info::SONMP::GLOBALS, %SNMP::Info::Airespace::GLOBALS, +); -%FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Bridge::FUNCS, - %SNMP::Info::SONMP::FUNCS, - %SNMP::Info::Airespace::FUNCS, - ); +%FUNCS = ( + %SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS, + %SNMP::Info::SONMP::FUNCS, %SNMP::Info::Airespace::FUNCS, +); -%MUNGE = ( - %SNMP::Info::MUNGE, - %SNMP::Info::Bridge::MUNGE, - %SNMP::Info::SONMP::MUNGE, - %SNMP::Info::Airespace::MUNGE, - ); +%MUNGE = ( + %SNMP::Info::MUNGE, %SNMP::Info::Bridge::MUNGE, + %SNMP::Info::SONMP::MUNGE, %SNMP::Info::Airespace::MUNGE, +); sub os { return 'nortel'; @@ -82,7 +75,7 @@ sub vendor { sub model { my $n2270 = shift; - my $id = $n2270->id(); + my $id = $n2270->id(); return unless defined $id; my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -104,7 +97,8 @@ __END__ =head1 NAME -SNMP::Info::Layer2::N2270 - SNMP Interface to Nortel 2270 Series Wireless Switch +SNMP::Info::Layer2::N2270 - SNMP Interface to Nortel 2270 Series Wireless +Switch =head1 AUTHOR diff --git a/Info/Layer2/NAP222x.pm b/Info/Layer2/NAP222x.pm index 0d2ca907..6059b645 100644 --- a/Info/Layer2/NAP222x.pm +++ b/Info/Layer2/NAP222x.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,59 +36,60 @@ use SNMP::Info::SONMP; use SNMP::Info::IEEE802dot11; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::NAP222x::ISA = qw/SNMP::Info::SONMP SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::NAP222x::ISA + = qw/SNMP::Info::SONMP SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::NAP222x::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::IEEE802dot11::MIBS, - %SNMP::Info::SONMP::MIBS, - 'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, %SNMP::Info::IEEE802dot11::MIBS, + %SNMP::Info::SONMP::MIBS, 'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer', +); %GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::IEEE802dot11::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - 'nt_hw_ver' => 'ntWlanSwHardwareVer', - 'nt_fw_ver' => 'ntWlanSwBootRomVer', - 'nt_sw_ver' => 'ntWlanSwOpCodeVer', - 'nt_cc' => 'ntWlanSwCountryCode', - 'tftp_action' => 'ntWlanTransferStart', - 'tftp_host' => 'ntWlanFileServer', - 'tftp_file' => 'ntWlanDestFile', - 'tftp_type' => 'ntWlanFileType', - 'tftp_result' => 'ntWlanFileTransferStatus', - 'tftp_xtype' => 'ntWlanTransferType', - 'tftp_src_file' => 'ntWlanSrcFile', - 'ftp_user' => 'ntWlanUserName', - 'ftp_pass' => 'ntWlanPassword', - ); + %SNMP::Info::Layer2::GLOBALS, + %SNMP::Info::IEEE802dot11::GLOBALS, + %SNMP::Info::SONMP::GLOBALS, + 'nt_hw_ver' => 'ntWlanSwHardwareVer', + 'nt_fw_ver' => 'ntWlanSwBootRomVer', + 'nt_sw_ver' => 'ntWlanSwOpCodeVer', + 'nt_cc' => 'ntWlanSwCountryCode', + 'tftp_action' => 'ntWlanTransferStart', + 'tftp_host' => 'ntWlanFileServer', + 'tftp_file' => 'ntWlanDestFile', + 'tftp_type' => 'ntWlanFileType', + 'tftp_result' => 'ntWlanFileTransferStatus', + 'tftp_xtype' => 'ntWlanTransferType', + 'tftp_src_file' => 'ntWlanSrcFile', + 'ftp_user' => 'ntWlanUserName', + 'ftp_pass' => 'ntWlanPassword', +); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::IEEE802dot11::FUNCS, - %SNMP::Info::SONMP::FUNCS, - # From ntWlanPortTable - 'nt_prt_name' => 'ntWlanPortName', - 'nt_dpx_admin' => 'ntWlanPortCapabilities', - 'nt_auto' => 'ntWlanPortAutonegotiation', - 'nt_dpx' => 'ntWlanPortSpeedDpxStatus', - # From ntWlanDot11PhyOperationTable - 'nt_i_broadcast' => 'ntWlanDot11ClosedSystem', - # From ntWlanApVlanTable - 'nt_i_vlan' => 'ntWlanApVlanDefaultVid', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::IEEE802dot11::FUNCS, + %SNMP::Info::SONMP::FUNCS, -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::IEEE802dot11::MUNGE, - %SNMP::Info::SONMP::MUNGE, - ); + # From ntWlanPortTable + 'nt_prt_name' => 'ntWlanPortName', + 'nt_dpx_admin' => 'ntWlanPortCapabilities', + 'nt_auto' => 'ntWlanPortAutonegotiation', + 'nt_dpx' => 'ntWlanPortSpeedDpxStatus', + + # From ntWlanDot11PhyOperationTable + 'nt_i_broadcast' => 'ntWlanDot11ClosedSystem', + + # From ntWlanApVlanTable + 'nt_i_vlan' => 'ntWlanApVlanDefaultVid', +); + +%MUNGE = ( + %SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE, + %SNMP::Info::SONMP::MUNGE, +); sub os { return 'nortel'; @@ -96,31 +97,31 @@ sub os { sub os_bin { my $nap222x = shift; - my $bin = $nap222x->nt_fw_ver(); + my $bin = $nap222x->nt_fw_ver(); return unless defined $bin; - if ($bin =~ m/(\d+\.\d+\.\d+)/){ + if ( $bin =~ m/(\d+\.\d+\.\d+)/ ) { return $1; - } + } return; } sub model { my $nap222x = shift; - my $descr = $nap222x->description(); + my $descr = $nap222x->description(); return unless defined $descr; - return 'AP-2220' if ($descr =~ /2220/); - return 'AP-2221' if ($descr =~ /2221/); + return 'AP-2220' if ( $descr =~ /2220/ ); + return 'AP-2221' if ( $descr =~ /2221/ ); return; } sub mac { my $nap222x = shift; - my $i_mac = $nap222x->i_mac(); + my $i_mac = $nap222x->i_mac(); -# Return Interface MAC - foreach my $entry (keys %$i_mac){ + # Return Interface MAC + foreach my $entry ( keys %$i_mac ) { my $sn = $i_mac->{$entry}; next unless $sn; return $sn; @@ -130,10 +131,10 @@ sub mac { sub serial { my $nap222x = shift; - my $i_mac = $nap222x->i_mac(); + my $i_mac = $nap222x->i_mac(); -# Return Interface MAC - foreach my $entry (keys %$i_mac){ + # Return Interface MAC + foreach my $entry ( keys %$i_mac ) { my $sn = $i_mac->{$entry}; next unless $sn; return $sn; @@ -145,11 +146,11 @@ sub interfaces { my $nap222x = shift; my $partial = shift; - my $interfaces = $nap222x->i_index($partial) || {}; + my $interfaces = $nap222x->i_index($partial) || {}; my $description = $nap222x->i_description($partial) || {}; my %interfaces = (); - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $desc = $description->{$iid}; next unless defined $desc; next if $desc =~ /lo/i; @@ -162,25 +163,25 @@ sub interfaces { sub i_duplex { my $nap222x = shift; my $partial = shift; - - my $mode = $nap222x->nt_dpx($partial) || {}; - my $port_name = $nap222x->nt_prt_name($partial) || {}; - my $interfaces = $nap222x->interfaces($partial) || {}; - + + my $mode = $nap222x->nt_dpx($partial) || {}; + my $port_name = $nap222x->nt_prt_name($partial) || {}; + my $interfaces = $nap222x->interfaces($partial) || {}; + my %i_duplex; - foreach my $if (keys %$interfaces){ + foreach my $if ( keys %$interfaces ) { my $port = $interfaces->{$if}; next unless $port =~ /dp/i; - foreach my $idx (keys %$mode) { - my $name = $port_name->{$idx}||'unknown'; + foreach my $idx ( keys %$mode ) { + my $name = $port_name->{$idx} || 'unknown'; next unless $name eq $port; my $duplex = $mode->{$idx}; - + $duplex = 'other' unless defined $duplex; $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; - - $i_duplex{$if}=$duplex; + + $i_duplex{$if} = $duplex; } } return \%i_duplex; @@ -190,27 +191,29 @@ sub i_duplex_admin { my $nap222x = shift; my $partial = shift; - my $dpx_admin = $nap222x->nt_dpx_admin($partial) || {}; - my $nt_auto = $nap222x->nt_auto($partial) || {}; - my $interfaces = $nap222x->interfaces($partial) || {}; - my $port_name = $nap222x->nt_prt_name($partial) || {}; - + my $dpx_admin = $nap222x->nt_dpx_admin($partial) || {}; + my $nt_auto = $nap222x->nt_auto($partial) || {}; + my $interfaces = $nap222x->interfaces($partial) || {}; + my $port_name = $nap222x->nt_prt_name($partial) || {}; + my %i_duplex_admin; - foreach my $if (keys %$interfaces){ + foreach my $if ( keys %$interfaces ) { my $port = $interfaces->{$if}; next unless $port =~ /dp/i; - foreach my $idx (keys %$dpx_admin) { - my $name = $port_name->{$idx}||'unknown'; + foreach my $idx ( keys %$dpx_admin ) { + my $name = $port_name->{$idx} || 'unknown'; next unless $name eq $port; my $duplex = $dpx_admin->{$idx}; - my $auto = $nt_auto->{$idx}; - + my $auto = $nt_auto->{$idx}; + $duplex = 'other' unless defined $duplex; - $duplex = 'half' if ($duplex =~ /half/i and $auto =~ /disabled/i); - $duplex = 'full' if ($duplex =~ /full/i and $auto =~ /disabled/i); + $duplex = 'half' + if ( $duplex =~ /half/i and $auto =~ /disabled/i ); + $duplex = 'full' + if ( $duplex =~ /full/i and $auto =~ /disabled/i ); $duplex = 'auto' if $auto =~ /enabled/i; - - $i_duplex_admin{$if}=$duplex; + + $i_duplex_admin{$if} = $duplex; } } return \%i_duplex_admin; @@ -223,15 +226,15 @@ sub i_name { my $interfaces = $nap222x->interfaces($partial) || {}; my %i_name; - foreach my $if (keys %$interfaces){ + foreach my $if ( keys %$interfaces ) { my $desc = $interfaces->{$if}; next unless defined $desc; - + my $name = 'unknown'; - $name = 'Ethernet Interface' if $desc =~ /dp/i; + $name = 'Ethernet Interface' if $desc =~ /dp/i; $name = 'Wireless Interface B' if $desc =~ /ndc/i; $name = 'Wireless Interface A' if $desc =~ /ar/i; - + $i_name{$if} = $name; } return \%i_name; @@ -245,15 +248,15 @@ sub bp_index { my $interfaces = $nap222x->interfaces($partial) || {}; my %bp_index; - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $desc = $interfaces->{$iid}; next unless defined $desc; next unless $desc =~ /(ndc|ar)/i; - + my $port = 1; $port = 2 if $desc =~ /ndc/i; - $bp_index{$port} = $iid; + $bp_index{$port} = $iid; } return \%bp_index; } @@ -265,20 +268,20 @@ sub i_ssidlist { my $partial = shift; # modify partial to match index - if (defined $partial) { + if ( defined $partial ) { $partial = $partial - 2; } my $ssids = $nap222x->orig_i_ssidlist($partial) || {}; my %i_ssidlist; - foreach my $iid (keys %$ssids){ + foreach my $iid ( keys %$ssids ) { my $port = $iid + 2; my $ssid = $ssids->{$iid}; next unless defined $ssid; - + $i_ssidlist{$port} = $ssid; } - return \%i_ssidlist; + return \%i_ssidlist; } sub i_ssidbcast { @@ -286,20 +289,20 @@ sub i_ssidbcast { my $partial = shift; # modify partial to match index - if (defined $partial) { + if ( defined $partial ) { $partial = $partial - 2; } my $bcast = $nap222x->nt_i_broadcast($partial) || {}; my %i_ssidbcast; - foreach my $iid (keys %$bcast){ + foreach my $iid ( keys %$bcast ) { my $port = $iid + 2; my $bc = $bcast->{$iid}; next unless defined $bc; - + $i_ssidbcast{$port} = $bc; } - return \%i_ssidbcast; + return \%i_ssidbcast; } sub i_80211channel { @@ -307,24 +310,24 @@ sub i_80211channel { my $partial = shift; # modify partial to match index - if (defined $partial) { + if ( defined $partial ) { $partial = $partial - 2; } my $phy_type = $nap222x->dot11_phy_type($partial) || {}; - my $cur_freq = $nap222x->dot11_cur_freq() || {}; - my $cur_ch = $nap222x->dot11_cur_ch() || {}; + my $cur_freq = $nap222x->dot11_cur_freq() || {}; + my $cur_ch = $nap222x->dot11_cur_ch() || {}; my %i_80211channel; - foreach my $iid (keys %$phy_type){ + foreach my $iid ( keys %$phy_type ) { my $port = $iid + 2; my $type = $phy_type->{$iid}; next unless defined $type; - if ($type =~ /dsss/) { + if ( $type =~ /dsss/ ) { my $ch = $cur_ch->{1}; next unless defined $ch; $i_80211channel{$port} = $ch; } - elsif ($type =~ /ofdm/) { + elsif ( $type =~ /ofdm/ ) { my $ch = $cur_freq->{0}; next unless defined $ch; $i_80211channel{$port} = $ch; @@ -342,20 +345,20 @@ sub i_vlan { my $partial = shift; # modify partial to match index - if (defined $partial) { + if ( defined $partial ) { $partial = $partial - 2; } my $vlans = $nap222x->nt_i_vlan($partial) || {}; my %i_vlan; - foreach my $iid (keys %$vlans){ + foreach my $iid ( keys %$vlans ) { my $port = $iid + 2; my $vlan = $vlans->{$iid}; next unless defined $vlan; - + $i_vlan{$port} = $vlan; } - return \%i_vlan; + return \%i_vlan; } 1; @@ -363,7 +366,8 @@ __END__ =head1 NAME -SNMP::Info::Layer2::NAP222x - SNMP Interface to Nortel 2220 Series Access Points +SNMP::Info::Layer2::NAP222x - SNMP Interface to Nortel 2220 Series Access +Points =head1 AUTHOR diff --git a/Info/Layer2/Netgear.pm b/Info/Layer2/Netgear.pm index 7c16f5f5..dd980d10 100644 --- a/Info/Layer2/Netgear.pm +++ b/Info/Layer2/Netgear.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Bill Fenner # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,28 +34,20 @@ use strict; use Exporter; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::Netgear::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Netgear::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Netgear::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - ); +%MIBS = ( %SNMP::Info::Layer2::MIBS, ); -%GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - ); +%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, ); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - ); +%FUNCS = ( %SNMP::Info::Layer2::FUNCS, ); -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, ); sub vendor { return 'netgear'; @@ -82,20 +74,20 @@ sub model { # return anything. sub fw_mac { my $netgear = shift; - my $ret = $netgear->qb_fw_mac(); - $ret = $netgear->orig_fw_mac() if (!defined($ret)); + my $ret = $netgear->qb_fw_mac(); + $ret = $netgear->orig_fw_mac() if ( !defined($ret) ); return $ret; } sub fw_port { my $netgear = shift; - my $ret = $netgear->qb_fw_port(); - $ret = $netgear->orig_fw_port() if (!defined($ret)); + my $ret = $netgear->qb_fw_port(); + $ret = $netgear->orig_fw_port() if ( !defined($ret) ); return $ret; } 1; - + __END__ =head1 NAME @@ -141,7 +133,8 @@ inherited methods. =item Inherited Classes' MIBs -MIBs listed in L and its inherited classes. +MIBs listed in L and its inherited +classes. =back diff --git a/Info/Layer2/Orinoco.pm b/Info/Layer2/Orinoco.pm index c8de0464..16ae1462 100644 --- a/Info/Layer2/Orinoco.pm +++ b/Info/Layer2/Orinoco.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -35,38 +35,36 @@ use Exporter; use SNMP::Info::IEEE802dot11; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::Orinoco::ISA = qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::Orinoco::ISA + = qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - %SNMP::Info::IEEE802dot11::MIBS, - #'ORiNOCO-MIB' => 'orinoco', - ); +%MIBS = ( + %SNMP::Info::Layer2::MIBS, + %SNMP::Info::IEEE802dot11::MIBS, -%GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS, - %SNMP::Info::IEEE802dot11::GLOBALS, - ); + #'ORiNOCO-MIB' => 'orinoco', +); -%FUNCS = ( - %SNMP::Info::Layer2::FUNCS, - %SNMP::Info::IEEE802dot11::FUNCS, - # ORiNOCO-MIB:oriWirelessIfPropertiesTable - #'ori_ssid' => 'oriWirelessIfNetworkName', - #'ori_channel' => 'oriWirelessIfChannel', - #'ori_closed_sys' => 'oriWirelessIfClosedSystem', - # ORiNOCO-MIB:oriSystemInvMgmtComponentTable - ); +%GLOBALS + = ( %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS, ); -%MUNGE = ( - %SNMP::Info::Layer2::MUNGE, - %SNMP::Info::IEEE802dot11::MUNGE, - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + %SNMP::Info::IEEE802dot11::FUNCS, + + # ORiNOCO-MIB:oriWirelessIfPropertiesTable + #'ori_ssid' => 'oriWirelessIfNetworkName', + #'ori_channel' => 'oriWirelessIfChannel', + #'ori_closed_sys' => 'oriWirelessIfClosedSystem', + # ORiNOCO-MIB:oriSystemInvMgmtComponentTable +); + +%MUNGE = ( %SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE, ); sub os { return 'orinoco'; @@ -78,10 +76,10 @@ sub os_ver { my $descr = $orinoco->description(); return unless defined $descr; - if ($descr =~ m/V(\d+\.\d+)/){ + if ( $descr =~ m/V(\d+\.\d+)/ ) { return $1; } - if ($descr =~ m/v(\d+\.\d+\.\d+)/){ + if ( $descr =~ m/v(\d+\.\d+\.\d+)/ ) { return $1; } @@ -94,10 +92,10 @@ sub os_bin { my $descr = $orinoco->description(); return unless defined $descr; - if ($descr =~ m/V(\d+\.\d+)$/){ + if ( $descr =~ m/V(\d+\.\d+)$/ ) { return $1; } - if ($descr =~ m/v(\d+\.\d+\.\d+)$/){ + if ( $descr =~ m/v(\d+\.\d+\.\d+)$/ ) { return $1; } @@ -114,8 +112,8 @@ sub model { my $descr = $orinoco->description(); return unless defined $descr; - return $1 if ($descr =~ /(AP-\d+)/); - return 'WavePOINT-II' if ($descr =~ /WavePOINT-II/); + return $1 if ( $descr =~ /(AP-\d+)/ ); + return 'WavePOINT-II' if ( $descr =~ /WavePOINT-II/ ); return; } @@ -125,7 +123,7 @@ sub serial { my $descr = $orinoco->description(); return unless defined $descr; - $descr = $1 if $descr =~ /SN-(\S+)/; + $descr = $1 if $descr =~ /SN-(\S+)/; return $descr; } @@ -136,9 +134,10 @@ sub i_ignore { my $descr = $orinoco->i_description($partial) || {}; my %i_ignore; - foreach my $if (keys %$descr){ + foreach my $if ( keys %$descr ) { my $type = $descr->{$if}; - # Skip virtual interfaces + + # Skip virtual interfaces $i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i; } return \%i_ignore; @@ -148,16 +147,16 @@ sub interfaces { my $orinoco = shift; my $partial = shift; - my $interfaces = $orinoco->i_index($partial) || {}; + my $interfaces = $orinoco->i_index($partial) || {}; my $descriptions = $orinoco->i_description($partial) || {}; my %interfaces = (); - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $desc = $descriptions->{$iid}; next unless defined $desc; next if $desc =~ /(lo|empty|PCMCIA)/i; - $desc = 'AMD' if $desc =~ /AMD/; + $desc = 'AMD' if $desc =~ /AMD/; $interfaces{$iid} = $desc; } @@ -177,7 +176,7 @@ sub interfaces { # # $i_ssidbcast{$iid} = $bc; # } -# return \%i_ssidbcast; +# return \%i_ssidbcast; #} 1; @@ -208,9 +207,9 @@ Eric Miller =head1 DESCRIPTION -Provides abstraction to the configuration information obtainable from a Orinoco -Access Point through SNMP. Orinoco devices have been manufactured by Proxim, -Agere, and Lucent. +Provides abstraction to the configuration information obtainable from +Orinoco Access Point through SNMP. Orinoco devices have been manufactured +by Proxim, Agere, and Lucent. For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above. diff --git a/Info/Layer2/ZyXEL_DSLAM.pm b/Info/Layer2/ZyXEL_DSLAM.pm index b3f257ce..35bd10d1 100644 --- a/Info/Layer2/ZyXEL_DSLAM.pm +++ b/Info/Layer2/ZyXEL_DSLAM.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Max Baker # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,7 +34,7 @@ use strict; use Exporter; use SNMP::Info::Layer2; -@SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/; +@SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::ZyXEL_DSLAM::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; @@ -42,27 +42,22 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; # Set for No CDP -%GLOBALS = ( - %SNMP::Info::Layer2::GLOBALS - ); +%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS ); -%FUNCS = (%SNMP::Info::Layer2::FUNCS, - 'ip_adresses' => 'ipAdEntAddr', - 'i_name' => 'ifDescr', - 'i_description' => 'adslLineConfProfile', - ); +%FUNCS = ( + %SNMP::Info::Layer2::FUNCS, + 'ip_adresses' => 'ipAdEntAddr', + 'i_name' => 'ifDescr', + 'i_description' => 'adslLineConfProfile', +); -%MIBS = ( - %SNMP::Info::Layer2::MIBS, - 'ADSL-LINE-MIB' => 'adslLineConfProfile' - ); - -%MUNGE = (%SNMP::Info::Layer2::MUNGE - ); +%MIBS + = ( %SNMP::Info::Layer2::MIBS, 'ADSL-LINE-MIB' => 'adslLineConfProfile' ); +%MUNGE = ( %SNMP::Info::Layer2::MUNGE ); sub layers { - my $zyxel = shift; + my $zyxel = shift; my $layers = $zyxel->layers(); return $layers if defined $layers; @@ -81,8 +76,8 @@ sub os { sub os_ver { my $zyxel = shift; my $descr = $zyxel->description(); - - if ($descr =~ m/version (\S+) /){ + + if ( $descr =~ m/version (\S+) / ) { return $1; } return; @@ -93,21 +88,24 @@ sub model { my $desc = $zyxel->description(); - if ($desc =~ /8-port ADSL Module\(Annex A\)/){ + if ( $desc =~ /8-port ADSL Module\(Annex A\)/ ) { return "AAM1008-61"; - } elsif ($desc =~ /8-port ADSL Module\(Annex B\)/){ + } + elsif ( $desc =~ /8-port ADSL Module\(Annex B\)/ ) { return "AAM1008-63"; } return; } -sub ip{ - my $zyxel = shift; +sub ip { + my $zyxel = shift; my $ip_hash = $zyxel->ip_addresses(); my $found_ip; - - foreach my $ip (keys %{$ip_hash}) { - $found_ip = $ip if (defined $ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/); + + foreach my $ip ( keys %{$ip_hash} ) { + $found_ip = $ip + if ( defined $ip + and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ ); } return $found_ip; } diff --git a/Info/Layer3.pm b/Info/Layer3.pm index 11f49148..ecc188f9 100644 --- a/Info/Layer3.pm +++ b/Info/Layer3.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -41,102 +41,110 @@ use SNMP::Info::Entity; use SNMP::Info::PowerEthernet; @SNMP::Info::Layer3::ISA = qw/SNMP::Info::PowerEthernet - SNMP::Info::Entity SNMP::Info::EtherLike - SNMP::Info::Bridge SNMP::Info Exporter/; + SNMP::Info::Entity SNMP::Info::EtherLike + SNMP::Info::Bridge SNMP::Info Exporter/; @SNMP::Info::Layer3::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::MIBS, - %SNMP::Info::Bridge::MIBS, - %SNMP::Info::EtherLike::MIBS, - %SNMP::Info::Entity::MIBS, - %SNMP::Info::PowerEthernet::MIBS, - 'IP-MIB' => 'ipNetToMediaIfIndex', - 'OSPF-MIB' => 'ospfRouterId', - 'BGP4-MIB' => 'bgpIdentifier', - ); +%MIBS = ( + %SNMP::Info::MIBS, + %SNMP::Info::Bridge::MIBS, + %SNMP::Info::EtherLike::MIBS, + %SNMP::Info::Entity::MIBS, + %SNMP::Info::PowerEthernet::MIBS, + 'IP-MIB' => 'ipNetToMediaIfIndex', + 'OSPF-MIB' => 'ospfRouterId', + 'BGP4-MIB' => 'bgpIdentifier', +); %GLOBALS = ( - # Inherit the super class ones - %SNMP::Info::GLOBALS, - %SNMP::Info::Bridge::GLOBALS, - %SNMP::Info::EtherLike::GLOBALS, - %SNMP::Info::Entity::GLOBALS, - %SNMP::Info::PowerEthernet::GLOBALS, - 'mac' => 'ifPhysAddress.1', - 'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0 - 'router_ip' => 'ospfRouterId.0', - 'bgp_id' => 'bgpIdentifier.0', - 'bgp_local_as' => 'bgpLocalAs.0', - ); -%FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Bridge::FUNCS, - %SNMP::Info::EtherLike::FUNCS, - %SNMP::Info::Entity::FUNCS, - %SNMP::Info::PowerEthernet::FUNCS, - # Obsolete Address Translation Table (ARP Cache) - 'old_at_index' => 'atIfIndex', - 'old_at_paddr' => 'atPhysAddress', - 'old_at_netaddr' => 'atNetAddress', - # IP-MIB IP Net to Media Table (ARP Cache) - 'at_index' => 'ipNetToMediaIfIndex', - 'at_paddr' => 'ipNetToMediaPhysAddress', - 'at_netaddr' => 'ipNetToMediaNetAddress', - # OSPF-MIB::ospfIfTable - 'ospf_if_ip' => 'ospfIfIpAddress', - 'ospf_if_area' => 'ospfIfAreaId', - 'ospf_if_type' => 'ospfIfType', - 'ospf_if_hello' => 'ospfIfHelloInterval', - 'ospf_if_dead' => 'ospfIfRtrDeadInterval', - 'ospf_if_admin' => 'ospfIfAdminStat', - 'ospf_if_state' => 'ospfIfState', - # OSPF-MIB::ospfNbrTable - 'ospf_ip' => 'ospfHostIpAddress', - 'ospf_peers' => 'ospfNbrIpAddr', - 'ospf_peer_id' => 'ospfNbrRtrId', - 'ospf_peer_state' => 'ospfNbrState', - # BGP4-MIB::bgpPeerTable - 'bgp_peers' => 'bgpPeerLocalAddr', - 'bgp_peer_id' => 'bgpPeerIdentifier', - 'bgp_peer_state' => 'bgpPeerState', - 'bgp_peer_as' => 'bgpPeerRemoteAs', - 'bgp_peer_addr' => 'bgpPeerRemoteAddr', - 'bgp_peer_fsm_est_trans' => 'bgpPeerFsmEstablishedTransitions', - 'bgp_peer_in_tot_msgs' => 'bgpPeerInTotalMessages', - 'bgp_peer_in_upd_el_time' => 'bgpPeerInUpdateElapsedTime', - 'bgp_peer_in_upd' => 'bgpPeerInUpdates', - 'bgp_peer_out_tot_msgs' => 'bgpPeerOutTotalMessages', - 'bgp_peer_out_upd' => 'bgpPeerOutUpdates', - ); + # Inherit the super class ones + %SNMP::Info::GLOBALS, + %SNMP::Info::Bridge::GLOBALS, + %SNMP::Info::EtherLike::GLOBALS, + %SNMP::Info::Entity::GLOBALS, + %SNMP::Info::PowerEthernet::GLOBALS, + 'mac' => 'ifPhysAddress.1', + 'serial1' => + '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0 + 'router_ip' => 'ospfRouterId.0', + 'bgp_id' => 'bgpIdentifier.0', + 'bgp_local_as' => 'bgpLocalAs.0', +); + +%FUNCS = ( + %SNMP::Info::FUNCS, + %SNMP::Info::Bridge::FUNCS, + %SNMP::Info::EtherLike::FUNCS, + %SNMP::Info::Entity::FUNCS, + %SNMP::Info::PowerEthernet::FUNCS, + + # Obsolete Address Translation Table (ARP Cache) + 'old_at_index' => 'atIfIndex', + 'old_at_paddr' => 'atPhysAddress', + 'old_at_netaddr' => 'atNetAddress', + + # IP-MIB IP Net to Media Table (ARP Cache) + 'at_index' => 'ipNetToMediaIfIndex', + 'at_paddr' => 'ipNetToMediaPhysAddress', + 'at_netaddr' => 'ipNetToMediaNetAddress', + + # OSPF-MIB::ospfIfTable + 'ospf_if_ip' => 'ospfIfIpAddress', + 'ospf_if_area' => 'ospfIfAreaId', + 'ospf_if_type' => 'ospfIfType', + 'ospf_if_hello' => 'ospfIfHelloInterval', + 'ospf_if_dead' => 'ospfIfRtrDeadInterval', + 'ospf_if_admin' => 'ospfIfAdminStat', + 'ospf_if_state' => 'ospfIfState', + + # OSPF-MIB::ospfNbrTable + 'ospf_ip' => 'ospfHostIpAddress', + 'ospf_peers' => 'ospfNbrIpAddr', + 'ospf_peer_id' => 'ospfNbrRtrId', + 'ospf_peer_state' => 'ospfNbrState', + + # BGP4-MIB::bgpPeerTable + 'bgp_peers' => 'bgpPeerLocalAddr', + 'bgp_peer_id' => 'bgpPeerIdentifier', + 'bgp_peer_state' => 'bgpPeerState', + 'bgp_peer_as' => 'bgpPeerRemoteAs', + 'bgp_peer_addr' => 'bgpPeerRemoteAddr', + 'bgp_peer_fsm_est_trans' => 'bgpPeerFsmEstablishedTransitions', + 'bgp_peer_in_tot_msgs' => 'bgpPeerInTotalMessages', + 'bgp_peer_in_upd_el_time' => 'bgpPeerInUpdateElapsedTime', + 'bgp_peer_in_upd' => 'bgpPeerInUpdates', + 'bgp_peer_out_tot_msgs' => 'bgpPeerOutTotalMessages', + 'bgp_peer_out_upd' => 'bgpPeerOutUpdates', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::MUNGE, - %SNMP::Info::Bridge::MUNGE, - %SNMP::Info::EtherLike::MUNGE, - %SNMP::Info::Entity::MUNGE, - %SNMP::Info::PowerEthernet::MUNGE, - 'old_at_paddr' => \&SNMP::Info::munge_mac, - 'at_paddr' => \&SNMP::Info::munge_mac, - ); + # Inherit all the built in munging + %SNMP::Info::MUNGE, + %SNMP::Info::Bridge::MUNGE, + %SNMP::Info::EtherLike::MUNGE, + %SNMP::Info::Entity::MUNGE, + %SNMP::Info::PowerEthernet::MUNGE, + 'old_at_paddr' => \&SNMP::Info::munge_mac, + 'at_paddr' => \&SNMP::Info::munge_mac, +); # Method OverRides sub root_ip { my $l3 = shift; - my $router_ip = $l3->router_ip(); - my $ospf_ip = $l3->ospf_ip(); + my $router_ip = $l3->router_ip(); + my $ospf_ip = $l3->ospf_ip(); # return the first one found here (should be only one) - if (defined $ospf_ip and scalar(keys %$ospf_ip)){ - foreach my $key (keys %$ospf_ip){ + if ( defined $ospf_ip and scalar( keys %$ospf_ip ) ) { + foreach my $key ( keys %$ospf_ip ) { my $ip = $ospf_ip->{$key}; next if $ip eq '0.0.0.0'; next unless $l3->snmp_connect_ip($ip); @@ -145,20 +153,24 @@ sub root_ip { } } - return $router_ip if ( (defined $router_ip) and ($router_ip ne '0.0.0.0') and ($l3->snmp_connect_ip($router_ip)) ); + return $router_ip + if (( defined $router_ip ) + and ( $router_ip ne '0.0.0.0' ) + and ( $l3->snmp_connect_ip($router_ip) ) ); return; } sub i_ignore { - my $l3 = shift; + my $l3 = shift; my $partial = shift; - + my $interfaces = $l3->interfaces($partial) || {}; my %i_ignore; - foreach my $if (keys %$interfaces) { + foreach my $if ( keys %$interfaces ) { + # lo -> cisco aironet 350 loopback - if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|null)/i){ + if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|null)/i ) { $i_ignore{$if}++; } } @@ -167,34 +179,37 @@ sub i_ignore { sub serial { my $l3 = shift; - - my $serial1 = $l3->serial1(); - my $e_descr = $l3->e_descr() || {}; - my $e_serial = $l3->e_serial() || {}; - - my $serial2 = $e_serial->{1} || undef; - my $chassis = $e_descr->{1} || undef; - + + my $serial1 = $l3->serial1(); + my $e_descr = $l3->e_descr() || {}; + my $e_serial = $l3->e_serial() || {}; + + my $serial2 = $e_serial->{1} || undef; + my $chassis = $e_descr->{1} || undef; + # precedence # serial2,chassis parse,serial1 - return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/); - return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i); - return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/); + return $serial2 if ( defined $serial2 and $serial2 !~ /^\s*$/ ); + return $1 + if ( defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i ); + return $serial1 if ( defined $serial1 and $serial1 !~ /^\s*$/ ); return; } -# $l3->model() - the sysObjectID returns an IID to an entry in +# $l3->model() - the sysObjectID returns an IID to an entry in # the CISCO-PRODUCT-MIB. Look it up and return it. sub model { my $l3 = shift; my $id = $l3->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::model() - Device does not support sysObjectID\n" if $l3->debug(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::model() - Device does not support sysObjectID\n" + if $l3->debug(); return; } - + my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -206,34 +221,35 @@ sub model { } sub i_name { - my $l3 = shift; + my $l3 = shift; my $partial = shift; - + my $i_index = $l3->i_index($partial); my $i_alias = $l3->i_alias($partial); - my $i_name2 = $l3->orig_i_name($partial); + my $i_name2 = $l3->orig_i_name($partial); my %i_name; - foreach my $iid (keys %$i_name2){ - my $name = $i_name2->{$iid}; + foreach my $iid ( keys %$i_name2 ) { + my $name = $i_name2->{$iid}; my $alias = $i_alias->{$iid}; - $i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ? - $alias : - $name; + $i_name{$iid} + = ( defined $alias and $alias !~ /^\s*$/ ) + ? $alias + : $name; } return \%i_name; } sub i_duplex { - my $l3 = shift; + my $l3 = shift; my $partial = shift; - - my $el_index = $l3->el_index($partial); + + my $el_index = $l3->el_index($partial); my $el_duplex = $l3->el_duplex($partial); - + my %i_index; - foreach my $el_port (keys %$el_duplex){ + foreach my $el_port ( keys %$el_duplex ) { my $iid = $el_index->{$el_port}; next unless defined $iid; my $duplex = $el_duplex->{$el_port}; @@ -249,20 +265,20 @@ sub i_duplex { # $l3->interfaces() - Map the Interfaces to their physical names sub interfaces { - my $l3 = shift; + my $l3 = shift; my $partial = shift; - my $interfaces = $l3->i_index($partial); + my $interfaces = $l3->i_index($partial); my $descriptions = $l3->i_description($partial); my %interfaces = (); - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $desc = $descriptions->{$iid}; next unless defined $desc; $interfaces{$iid} = $desc; } - + return \%interfaces; } @@ -271,29 +287,29 @@ sub vendor { my $descr = $l3->description(); - return 'cisco' if ($descr =~ /(cisco|\bios\b)/i); - return 'foundry' if ($descr =~ /foundry/i); - + return 'cisco' if ( $descr =~ /(cisco|\bios\b)/i ); + return 'foundry' if ( $descr =~ /foundry/i ); + return 'unknown'; } sub at_index { - my $l3 = shift; + my $l3 = shift; my $partial = shift; return $l3->orig_at_index($partial) || $l3->old_at_index($partial); } sub at_paddr { - my $l3 = shift; + my $l3 = shift; my $partial = shift; return $l3->orig_at_paddr($partial) || $l3->old_at_paddr($partial); } sub at_netaddr { - my $l3 = shift; + my $l3 = shift; my $partial = shift; return $l3->orig_at_netaddr($partial) || $l3->old_at_netaddr($partial); @@ -472,7 +488,8 @@ to a hash. =item $l3->interfaces() -Returns the map between SNMP Interface Identifier (iid) and physical port name. +Returns the map between SNMP Interface Identifier (iid) and physical port +name. Only returns those iids that have a description listed in $l3->i_description() @@ -623,8 +640,8 @@ received on this connection =item $l3->bgp_peer_out_tot_msgs() -Returns reference to hash of BGP peer to the total number of messages transmitted -to the remote peer on this connection +Returns reference to hash of BGP peer to the total number of messages +transmitted to the remote peer on this connection (C) diff --git a/Info/Layer3/Aironet.pm b/Info/Layer3/Aironet.pm index 68cf3714..fb45ac85 100644 --- a/Info/Layer3/Aironet.pm +++ b/Info/Layer3/Aironet.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,50 +36,54 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Aironet::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - 'AWCVX-MIB' => 'awcIfTable', - 'IEEE802dot11-MIB' => 'dot11StationID', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + 'AWCVX-MIB' => 'awcIfTable', + 'IEEE802dot11-MIB' => 'dot11StationID', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'mac' => 'dot11StationID.2', - # AWC Ethernet Table - 'awc_duplex' => 'awcEtherDuplex.0', - ); + %SNMP::Info::Layer3::GLOBALS, + 'mac' => 'dot11StationID.2', -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - 'i_mac2' => 'ifPhysAddress', - 'i_mtu2' => 'ifMtu', - 'i_ssid' => 'dot11DesiredSSID', - # Bridge-mib overrides - 'fw_mac2' => 'dot1dTpFdbAddress', - 'fw_port2' => 'dot1dTpFdbPort', - 'bp_index2' => 'dot1dBasePortIfIndex', - # AWC Interface Table (awcIfTable) - 'awc_default_mac' => 'awcIfDefaultPhyAddress', - 'awc_mac' => 'awcIfPhyAddress', - 'awc_ip' => 'awcIfIpAddress', - 'awc_netmask' => 'awcIfIpNetMask', - 'awc_msdu' => 'awcIfMSDUMaxLength', - ); + # AWC Ethernet Table + 'awc_duplex' => 'awcEtherDuplex.0', +); + +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + 'i_mac2' => 'ifPhysAddress', + 'i_mtu2' => 'ifMtu', + 'i_ssid' => 'dot11DesiredSSID', + + # Bridge-mib overrides + 'fw_mac2' => 'dot1dTpFdbAddress', + 'fw_port2' => 'dot1dTpFdbPort', + 'bp_index2' => 'dot1dBasePortIfIndex', + + # AWC Interface Table (awcIfTable) + 'awc_default_mac' => 'awcIfDefaultPhyAddress', + 'awc_mac' => 'awcIfPhyAddress', + 'awc_ip' => 'awcIfIpAddress', + 'awc_netmask' => 'awcIfIpNetMask', + 'awc_msdu' => 'awcIfMSDUMaxLength', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::Layer3::MUNGE, - 'i_mac2' => \&SNMP::Info::munge_mac, - 'awc_mac' => \&SNMP::Info::munge_mac, - 'fw_mac2' => \&SNMP::Info::munge_mac, - ); + + # Inherit all the built in munging + %SNMP::Info::Layer3::MUNGE, + 'i_mac2' => \&SNMP::Info::munge_mac, + 'awc_mac' => \&SNMP::Info::munge_mac, + 'fw_mac2' => \&SNMP::Info::munge_mac, +); sub os { return 'aironet'; @@ -90,11 +94,11 @@ sub os_ver { my $descr = $aironet->description() || ''; # CAP340 11.21, AP4800-E 11.21 - if ($descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/){ + if ( $descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/ ) { return $2; } - - if ($descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/){ + + if ( $descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/ ) { return $1; } @@ -103,19 +107,19 @@ sub os_ver { # Override wireless port with static info sub bp_index { - my $aironet = shift; + my $aironet = shift; my $interfaces = $aironet->interfaces(); - my $bp_index = $aironet->bp_index2(); - - foreach my $iid (keys %$interfaces){ + my $bp_index = $aironet->bp_index2(); + + foreach my $iid ( keys %$interfaces ) { my $port = $interfaces->{$iid}; # Hardwire the wireless port to the transparent bridge port - if ($port =~ /awc/){ - $bp_index->{0}=$iid; + if ( $port =~ /awc/ ) { + $bp_index->{0} = $iid; } } - + return $bp_index; } @@ -124,16 +128,16 @@ sub fw_mac { my $aironet = shift; my $fw_mac = $aironet->fw_mac2(); my $fw_port = $aironet->fw_port2(); - my $bs_mac = $aironet->bs_mac(); - + my $bs_mac = $aironet->bs_mac(); + # remove port 0 forwarding table entries, only port 0 static entries - foreach my $fw (keys %$fw_mac){ + foreach my $fw ( keys %$fw_mac ) { my $port = $fw_port->{$fw}; next unless defined $port; delete $fw_mac->{$fw} if $port == 0; } - foreach my $bs (keys %$bs_mac){ + foreach my $bs ( keys %$bs_mac ) { my $entry = $bs; $entry =~ s/\.0$//; $fw_mac->{$entry} = $bs_mac->{$bs}; @@ -146,10 +150,9 @@ sub fw_mac { sub fw_port { my $aironet = shift; my $fw_port = $aironet->fw_port2(); - my $bs_port = $aironet->bs_port(); + my $bs_port = $aironet->bs_port(); - - foreach my $bs (keys %$bs_port){ + foreach my $bs ( keys %$bs_port ) { my $entry = $bs; $entry =~ s/\.0$//; $fw_port->{$entry} = $bs_port->{$bs}; @@ -158,18 +161,17 @@ sub fw_port { return $fw_port; } - sub i_duplex { - my $aironet = shift; + my $aironet = shift; my $interfaces = $aironet->interfaces(); my $awc_duplex = $aironet->awc_duplex(); - + my %i_duplex; - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $name = $interfaces->{$iid}; - if ($name =~ /fec/){ + if ( $name =~ /fec/ ) { $i_duplex{$iid} = $awc_duplex; } } @@ -183,7 +185,7 @@ sub i_mac { my $i_mac = $aironet->i_mac2(); my $awc_mac = $aironet->awc_mac(); - foreach my $iid (keys %$awc_mac){ + foreach my $iid ( keys %$awc_mac ) { next unless defined $i_mac->{$iid}; $i_mac->{$iid} = $awc_mac->{$iid}; } @@ -192,14 +194,14 @@ sub i_mac { } sub i_ignore { - my $aironet = shift; + my $aironet = shift; my $interfaces = $aironet->interfaces(); my %i_ignore; - foreach my $if (keys %$interfaces){ - $i_ignore{$if}++ if ($interfaces->{$if} =~ /(rptr|lo)/); + foreach my $if ( keys %$interfaces ) { + $i_ignore{$if}++ if ( $interfaces->{$if} =~ /(rptr|lo)/ ); } - + return \%i_ignore; } @@ -213,8 +215,8 @@ __END__ =head1 NAME -SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices -running Aironet software, not IOS +SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless +Devices running Aironet software, not IOS =head1 AUTHOR diff --git a/Info/Layer3/AlteonAD.pm b/Info/Layer3/AlteonAD.pm index dbf1e379..12415074 100644 --- a/Info/Layer3/AlteonAD.pm +++ b/Info/Layer3/AlteonAD.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All Rights Reserved # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,7 +34,7 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; @@ -42,82 +42,92 @@ use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer3::MIBS, - 'ALTEON-ROOT-MIB' => 'aceswitch184', - 'ALTEON-TIGON-SWITCH-MIB' => 'hwPowerSupplyStatus', - 'ALTEON-CHEETAH-SWITCH-MIB' => 'hwFanStatus', - 'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt', - 'ALTEON-CS-PHYSICAL-MIB' => 'vlanCurCfgLearn', - 'ALTEON-TS-NETWORK-MIB' => 'ripCurCfgSupply', - 'ALTEON-CHEETAH-NETWORK-MIB' => 'ripCurCfgIntfSupply', - ); + %SNMP::Info::Layer3::MIBS, + 'ALTEON-ROOT-MIB' => 'aceswitch184', + 'ALTEON-TIGON-SWITCH-MIB' => 'hwPowerSupplyStatus', + 'ALTEON-CHEETAH-SWITCH-MIB' => 'hwFanStatus', + 'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt', + 'ALTEON-CS-PHYSICAL-MIB' => 'vlanCurCfgLearn', + 'ALTEON-TS-NETWORK-MIB' => 'ripCurCfgSupply', + 'ALTEON-CHEETAH-NETWORK-MIB' => 'ripCurCfgIntfSupply', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'old_sw_ver' => 'ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion', - 'new_sw_ver' => 'ALTEON_CHEETAH_SWITCH_MIB__agSoftwareVersion', - 'old_tftp_action' => 'ALTEON_TIGON_SWITCH_MIB__agTftpAction', - 'new_tftp_action' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpAction', - 'old_tftp_host' => 'ALTEON_TIGON_SWITCH_MIB__agTftpServer', - 'new_tftp_host' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpServer', - 'old_tftp_file' => 'ALTEON_TIGON_SWITCH_MIB__agTftpCfgFileName', - 'new_tftp_file' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpCfgFileName', - 'old_tftp_result' => 'ALTEON_TIGON_SWITCH_MIB__agTftpLastActionStatus', - 'new_tftp_result' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpLastActionStatus', - 'old_ip_max' => 'ALTEON_TS_NETWORK_MIB__ipInterfaceTableMax', - 'new_ip_max' => 'ALTEON_CHEETAH_NETWORK_MIB__ipInterfaceTableMax', - ); + %SNMP::Info::Layer3::GLOBALS, + 'old_sw_ver' => 'ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion', + 'new_sw_ver' => 'ALTEON_CHEETAH_SWITCH_MIB__agSoftwareVersion', + 'old_tftp_action' => 'ALTEON_TIGON_SWITCH_MIB__agTftpAction', + 'new_tftp_action' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpAction', + 'old_tftp_host' => 'ALTEON_TIGON_SWITCH_MIB__agTftpServer', + 'new_tftp_host' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpServer', + 'old_tftp_file' => 'ALTEON_TIGON_SWITCH_MIB__agTftpCfgFileName', + 'new_tftp_file' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpCfgFileName', + 'old_tftp_result' => 'ALTEON_TIGON_SWITCH_MIB__agTftpLastActionStatus', + 'new_tftp_result' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpLastActionStatus', + 'old_ip_max' => 'ALTEON_TS_NETWORK_MIB__ipInterfaceTableMax', + 'new_ip_max' => 'ALTEON_CHEETAH_NETWORK_MIB__ipInterfaceTableMax', +); %FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - # From agPortCurCfgTable - 'old_ag_p_cfg_idx' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgIndx', - 'new_ag_p_cfg_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgIndx', - 'old_ag_p_cfg_pref' => 'agPortCurCfgPrefLink', - 'new_ag_p_cfg_pref' => 'agPortCurCfgPreferred', - 'old_ag_p_cfg_pvid' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPVID', - 'new_ag_p_cfg_pvid' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPVID', - 'old_ag_p_cfg_fe_auto' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthAutoNeg', - 'new_ag_p_cfg_fe_auto' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthAutoNeg', - 'old_ag_p_cfg_fe_mode' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthMode', - 'new_ag_p_cfg_fe_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthMode', - 'old_ag_p_cfg_ge_auto' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgGigEthAutoNeg', - 'new_ag_p_cfg_ge_auto' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgGigEthAutoNeg', - 'old_ag_p_cfg_name' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName', - 'new_ag_p_cfg_name' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPortName', - # From portInfoTable - 'old_p_info_idx' => 'ALTEON_TS_PHYSICAL_MIB__portInfoIndx', - 'new_p_info_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoIndx', - 'old_p_info_mode' => 'ALTEON_TS_PHYSICAL_MIB__portInfoMode', - 'new_p_info_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoMode', - # From ipCurCfgIntfTable - 'old_ip_cfg_vlan' => 'ALTEON_TS_NETWORK_MIB__ipCurCfgIntfVlan', - 'new_ip_cfg_vlan' => 'ALTEON_CHEETAH_NETWORK_MIB__ipCurCfgIntfVlan', - # From vlanCurCfgTable - 'old_vlan_id' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanId', - 'new_vlan_id' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanId', - 'old_vlan_state' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgState', - 'new_vlan_state' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgState', - 'old_vlan_name' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanName', - 'new_vlan_name' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanName', - 'old_vlan_ports' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgPorts', - 'new_vlan_ports' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgPorts', - ); - -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - ); + %SNMP::Info::Layer3::FUNCS, + + # From agPortCurCfgTable + 'old_ag_p_cfg_idx' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgIndx', + 'new_ag_p_cfg_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgIndx', + 'old_ag_p_cfg_pref' => 'agPortCurCfgPrefLink', + 'new_ag_p_cfg_pref' => 'agPortCurCfgPreferred', + 'old_ag_p_cfg_pvid' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPVID', + 'new_ag_p_cfg_pvid' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPVID', + 'old_ag_p_cfg_fe_auto' => + 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthAutoNeg', + 'new_ag_p_cfg_fe_auto' => + 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthAutoNeg', + 'old_ag_p_cfg_fe_mode' => + 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthMode', + 'new_ag_p_cfg_fe_mode' => + 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthMode', + 'old_ag_p_cfg_ge_auto' => + 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgGigEthAutoNeg', + 'new_ag_p_cfg_ge_auto' => + 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgGigEthAutoNeg', + 'old_ag_p_cfg_name' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName', + 'new_ag_p_cfg_name' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPortName', + + # From portInfoTable + 'old_p_info_idx' => 'ALTEON_TS_PHYSICAL_MIB__portInfoIndx', + 'new_p_info_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoIndx', + 'old_p_info_mode' => 'ALTEON_TS_PHYSICAL_MIB__portInfoMode', + 'new_p_info_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoMode', + + # From ipCurCfgIntfTable + 'old_ip_cfg_vlan' => 'ALTEON_TS_NETWORK_MIB__ipCurCfgIntfVlan', + 'new_ip_cfg_vlan' => 'ALTEON_CHEETAH_NETWORK_MIB__ipCurCfgIntfVlan', + + # From vlanCurCfgTable + 'old_vlan_id' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanId', + 'new_vlan_id' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanId', + 'old_vlan_state' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgState', + 'new_vlan_state' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgState', + 'old_vlan_name' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanName', + 'new_vlan_name' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanName', + 'old_vlan_ports' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgPorts', + 'new_vlan_ports' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgPorts', +); + +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub model { my $alteon = shift; my $id = $alteon->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::AlteonAD::model() - Device does not support sysObjectID\n" if $alteon->debug(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::AlteonAD::model() - Device does not support sysObjectID\n" + if $alteon->debug(); return; } - + my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -146,23 +156,24 @@ sub os_ver { } sub interfaces { - my $alteon = shift; + my $alteon = shift; my $interfaces = $alteon->i_index(); my $descriptions = $alteon->i_description(); my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my %interfaces = (); - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $desc = $descriptions->{$iid}; next unless defined $desc; - if ($desc =~ /(^net\d+)/) { - $desc = $1; + if ( $desc =~ /(^net\d+)/ ) { + $desc = $1; } + # IP interfaces are first followed by physical, number possible # varies by switch model - elsif (defined $ip_max and $iid > $ip_max ) { - $desc = ($iid % $ip_max); + elsif ( defined $ip_max and $iid > $ip_max ) { + $desc = ( $iid % $ip_max ); } $interfaces{$iid} = $desc; } @@ -172,21 +183,23 @@ sub interfaces { sub i_duplex { my $alteon = shift; - my $p_mode = $alteon->new_p_info_mode() || $alteon->old_p_info_mode() || {}; + my $p_mode = $alteon->new_p_info_mode() + || $alteon->old_p_info_mode() + || {}; my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my %i_duplex; - foreach my $if (keys %$p_mode){ + foreach my $if ( keys %$p_mode ) { my $duplex = $p_mode->{$if}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; - + my $idx; - $idx = $if + $ip_max if (defined $ip_max); - - $i_duplex{$idx}=$duplex; + $idx = $if + $ip_max if ( defined $ip_max ); + + $i_duplex{$idx} = $duplex; } return \%i_duplex; } @@ -194,35 +207,45 @@ sub i_duplex { sub i_duplex_admin { my $alteon = shift; - my $ag_pref = $alteon->new_ag_p_cfg_pref() || $alteon->old_ag_p_cfg_pref() || {}; - my $ag_fe_auto = $alteon->new_ag_p_cfg_fe_auto() || $alteon->old_ag_p_cfg_fe_auto() || {}; - my $ag_fe_mode = $alteon->new_ag_p_cfg_fe_mode() || $alteon->old_ag_p_cfg_fe_mode() || {}; - my $ag_ge_auto = $alteon->new_ag_p_cfg_ge_auto() || $alteon->old_ag_p_cfg_ge_auto() || {}; + my $ag_pref = $alteon->new_ag_p_cfg_pref() + || $alteon->old_ag_p_cfg_pref() + || {}; + my $ag_fe_auto = $alteon->new_ag_p_cfg_fe_auto() + || $alteon->old_ag_p_cfg_fe_auto() + || {}; + my $ag_fe_mode = $alteon->new_ag_p_cfg_fe_mode() + || $alteon->old_ag_p_cfg_fe_mode() + || {}; + my $ag_ge_auto = $alteon->new_ag_p_cfg_ge_auto() + || $alteon->old_ag_p_cfg_ge_auto() + || {}; my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); - + my %i_duplex_admin; - foreach my $if (keys %$ag_pref){ + foreach my $if ( keys %$ag_pref ) { my $pref = $ag_pref->{$if}; next unless defined $pref; - - my $string = 'other'; - if ($pref =~ /gigabit/i) { + + my $string = 'other'; + if ( $pref =~ /gigabit/i ) { my $ge_auto = $ag_ge_auto->{$if}; - $string = 'full' if ($ge_auto =~ /off/i); - $string = 'auto' if ($ge_auto =~ /on/i); + $string = 'full' if ( $ge_auto =~ /off/i ); + $string = 'auto' if ( $ge_auto =~ /on/i ); } - elsif ($pref =~ /fast/i) { + elsif ( $pref =~ /fast/i ) { my $fe_auto = $ag_fe_auto->{$if}; my $fe_mode = $ag_fe_mode->{$if}; - $string = 'half' if ($fe_mode =~ /half/i and $fe_auto =~ /off/i); - $string = 'full' if ($fe_mode =~ /full/i and $fe_auto =~ /off/i); + $string = 'half' + if ( $fe_mode =~ /half/i and $fe_auto =~ /off/i ); + $string = 'full' + if ( $fe_mode =~ /full/i and $fe_auto =~ /off/i ); $string = 'auto' if $fe_auto =~ /on/i; } my $idx; - $idx = $if + $ip_max if (defined $ip_max); - - $i_duplex_admin{$idx}=$string; + $idx = $if + $ip_max if ( defined $ip_max ); + + $i_duplex_admin{$idx} = $string; } return \%i_duplex_admin; } @@ -230,55 +253,62 @@ sub i_duplex_admin { sub i_name { my $alteon = shift; - my $p_name = $alteon->new_ag_p_cfg_name() || $alteon->old_ag_p_cfg_name() || {}; + my $p_name = $alteon->new_ag_p_cfg_name() + || $alteon->old_ag_p_cfg_name() + || {}; my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my %i_name; - foreach my $iid (keys %$p_name){ + foreach my $iid ( keys %$p_name ) { my $name = $p_name->{$iid}; next unless defined $name; my $idx; - $idx = $iid + $ip_max if (defined $ip_max); + $idx = $iid + $ip_max if ( defined $ip_max ); $i_name{$idx} = $name; } return \%i_name; } sub v_index { - my $alteon = shift; + my $alteon = shift; my $partial = shift; return $alteon->new_vlan_id($partial) || $alteon->old_vlan_id($partial); } sub v_name { - my $alteon = shift; + my $alteon = shift; my $partial = shift; - return $alteon->new_vlan_name($partial) || $alteon->old_vlan_name($partial); + return $alteon->new_vlan_name($partial) + || $alteon->old_vlan_name($partial); } sub i_vlan { my $alteon = shift; - my $ag_vlans = $alteon->new_ag_p_cfg_pvid() || $alteon->old_ag_p_cfg_pvid() || {}; - my $ip_vlans = $alteon->new_ip_cfg_vlan() || $alteon->old_ip_cfg_vlan() || {}; - my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); + my $ag_vlans = $alteon->new_ag_p_cfg_pvid() + || $alteon->old_ag_p_cfg_pvid() + || {}; + my $ip_vlans = $alteon->new_ip_cfg_vlan() + || $alteon->old_ip_cfg_vlan() + || {}; + my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my %i_vlan; - foreach my $if (keys %$ip_vlans){ + foreach my $if ( keys %$ip_vlans ) { my $ip_vlanid = $ip_vlans->{$if}; next unless defined $ip_vlanid; - - $i_vlan{$if}=$ip_vlanid; + + $i_vlan{$if} = $ip_vlanid; } - foreach my $if (keys %$ag_vlans){ + foreach my $if ( keys %$ag_vlans ) { my $ag_vlanid = $ag_vlans->{$if}; next unless defined $ag_vlanid; - + my $idx; - $idx = $if + $ip_max if (defined $ip_max); - $i_vlan{$idx}=$ag_vlanid; + $idx = $if + $ip_max if ( defined $ip_max ); + $i_vlan{$idx} = $ag_vlanid; } return \%i_vlan; } @@ -286,24 +316,26 @@ sub i_vlan { sub i_vlan_membership { my $alteon = shift; - my $v_ports = $alteon->old_vlan_ports() || $alteon->new_vlan_ports() || {}; - my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); + my $v_ports = $alteon->old_vlan_ports() + || $alteon->new_vlan_ports() + || {}; + my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my $i_vlan_membership = {}; - foreach my $vlan (keys %$v_ports) { - my $portlist = [split(//, unpack("B*", $v_ports->{$vlan}))]; + foreach my $vlan ( keys %$v_ports ) { + my $portlist = [ split( //, unpack( "B*", $v_ports->{$vlan} ) ) ]; my $ret = []; # Convert portlist bit array to ifIndex array - for (my $i = 0; $i <= scalar(@$portlist); $i++) { + for ( my $i = 0; $i <= scalar(@$portlist); $i++ ) { my $idx; - $idx = $i + $ip_max if (defined $ip_max); - push(@{$ret}, $idx) if (@$portlist[$i]); + $idx = $i + $ip_max if ( defined $ip_max ); + push( @{$ret}, $idx ) if ( @$portlist[$i] ); } #Create HoA ifIndex -> VLAN array - foreach my $port (@{$ret}) { - push(@{$i_vlan_membership->{$port}}, $vlan); + foreach my $port ( @{$ret} ) { + push( @{ $i_vlan_membership->{$port} }, $vlan ); } } return $i_vlan_membership; @@ -315,13 +347,13 @@ sub bp_index { my $alteon = shift; my $b_index = $alteon->orig_bp_index(); - my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); + my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my %bp_index; - foreach my $iid (keys %$b_index){ + foreach my $iid ( keys %$b_index ) { my $port = $b_index->{$iid}; next unless defined $port; - $port = $port + $ip_max if (defined $ip_max and $iid == $ip_max); + $port = $port + $ip_max if ( defined $ip_max and $iid == $ip_max ); $bp_index{$iid} = $port; } @@ -357,8 +389,8 @@ Eric Miller =head1 DESCRIPTION -Abstraction subclass for Nortel Alteon Series Layer 2-7 load balancing switches -and Nortel BladeCenter Layer2-3 GbE Switch Modules. +Abstraction subclass for Nortel Alteon Series Layer 2-7 load balancing +switches and Nortel BladeCenter Layer2-3 GbE Switch Modules. For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above. diff --git a/Info/Layer3/BayRS.pm b/Info/Layer3/BayRS.pm index 63b35f05..14bbf9fa 100644 --- a/Info/Layer3/BayRS.pm +++ b/Info/Layer3/BayRS.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,498 +37,505 @@ use SNMP::Info::Layer3; use SNMP::Info::Bridge; @SNMP::Info::Layer3::BayRS::ISA = qw/SNMP::Info SNMP::Info::Layer3 - SNMP::Info::Bridge Exporter/; + SNMP::Info::Bridge Exporter/; @SNMP::Info::Layer3::BayRS::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE %MODEL_MAP - %MODID_MAP %PROCID_MAP/; + %MODID_MAP %PROCID_MAP/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::MIBS, - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::Bridge::MIBS, - 'Wellfleet-HARDWARE-MIB' => 'wfHwBpIdOpt', - 'Wellfleet-OSPF-MIB' => 'wfOspfRouterId', - 'Wellfleet-DOT1QTAG-CONFIG-MIB' => 'wfDot1qTagCfgVlanName', - 'Wellfleet-CSMACD-MIB' => 'wfCSMACDCct', - 'Wellfleet-MODULE-MIB' => 'wfHwModuleSlot', - ); + %SNMP::Info::MIBS, + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::Bridge::MIBS, + 'Wellfleet-HARDWARE-MIB' => 'wfHwBpIdOpt', + 'Wellfleet-OSPF-MIB' => 'wfOspfRouterId', + 'Wellfleet-DOT1QTAG-CONFIG-MIB' => 'wfDot1qTagCfgVlanName', + 'Wellfleet-CSMACD-MIB' => 'wfCSMACDCct', + 'Wellfleet-MODULE-MIB' => 'wfHwModuleSlot', +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::Bridge::GLOBALS, - 'bp_id' => 'wfHwBpIdOpt', - 'bp_serial' => 'wfHwBpSerialNumber', - 'ospf_rtr_id' => 'wfOspfRouterId', - ); + %SNMP::Info::GLOBALS, + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::Bridge::GLOBALS, + 'bp_id' => 'wfHwBpIdOpt', + 'bp_serial' => 'wfHwBpSerialNumber', + 'ospf_rtr_id' => 'wfOspfRouterId', +); %FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::Bridge::FUNCS, - # From Wellfleet-CSMACD-MIB::wfCSMACDTable - 'wf_csmacd_cct' => 'wfCSMACDCct', - 'wf_csmacd_slot' => 'wfCSMACDSlot', - 'wf_csmacd_conn' => 'wfCSMACDConnector', - 'wf_csmacd_mtu' => 'wfCSMACDMtu', - 'wf_duplex' => 'wfCSMACDLineCapability', - 'wf_csmacd_line' => 'wfCSMACDLineNumber', - # From Wellfleet-CSMACD-MIB::wfCSMACDAutoNegTable - 'wf_auto' => 'wfCSMACDAutoNegSpeedSelect', - # From Wellfleet-DOT1QTAG-CONFIG-MIB::wfDot1qTagConfigTable - 'wf_vlan_name' => 'wfDot1qTagCfgVlanName', - 'wf_local_vlan_id' => 'wfDot1qTagCfgLocalVlanId', - 'wf_global_vlan_id' => 'wfDot1qTagCfgGlobalVlanId', - 'wf_vlan_port' => 'wfDot1qTagCfgPhysicalPortId', - # From Wellfleet-HARDWARE-MIB::wfHwTable - 'wf_hw_slot' => 'wfHwSlot', - 'wf_hw_mod_id' => 'wfHwModIdOpt', - 'wf_hw_mod_rev' => 'wfHwModRev', - 'wf_hw_mod_ser' => 'wfHwModSerialNumber', - 'wf_hw_mobo_id' => 'wfHwMotherBdIdOpt', - 'wf_hw_mobo_rev' => 'wfHwMotherBdRev', - 'wf_hw_mobo_ser' => 'wfHwMotherBdSerialNumber', - 'wf_hw_diag' => 'wfHwDiagPromRev', - 'wf_hw_boot' => 'wfHwBootPromRev', - 'wf_hw_mobo_mem' => 'wfHwMotherBdMemorySize', - 'wf_hw_cfg_time' => 'wfHwConfigDateAndTime', - 'wf_hw_db_ser' => 'wfHwDaughterBdSerialNumber', - 'wf_hw_bb_ser' => 'wfHwBabyBdSerialNumber', - 'wf_hw_mm_ser' => 'wfHwModuleModSerialNumber', - 'wf_hw_md1_ser' => 'wfHwModDaughterBd1SerialNumber', - 'wf_hw_md2_ser' => 'wfHwModDaughterBd2SerialNumber', - ); - -%MUNGE = ( - %SNMP::Info::MUNGE, - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::Bridge::MUNGE, - 'wf_hw_boot' => \&munge_hw_rev, - 'wf_hw_diag' => \&munge_hw_rev, - 'wf_hw_mobo_ser' => \&munge_wf_serial, - 'wf_hw_mod_ser' => \&munge_wf_serial, - 'wf_hw_db_ser' => \&munge_wf_serial, - 'wf_hw_bb_ser' => \&munge_wf_serial, - 'wf_hw_mm_ser' => \&munge_wf_serial, - 'wf_hw_md1_ser' => \&munge_wf_serial, - 'wf_hw_md2_ser' => \&munge_wf_serial, - ); + %SNMP::Info::FUNCS, + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::Bridge::FUNCS, -%MODEL_MAP = ( - 'acefn' => 'FN', - 'aceln' => 'LN', - 'acecn' => 'CN', - 'afn' => 'AFN', - 'in' => 'IN', - 'an' => 'AN', - 'arn' => 'ARN', - 'sys5000' => '5000', - 'freln' => 'BLN', - 'frecn' => 'BCN', - 'frerbln' => 'BLN-2', - 'asn' => 'ASN', - 'asnzcable' => 'ASN-Z', - 'asnbcable' => 'ASN-B', - ); + # From Wellfleet-CSMACD-MIB::wfCSMACDTable + 'wf_csmacd_cct' => 'wfCSMACDCct', + 'wf_csmacd_slot' => 'wfCSMACDSlot', + 'wf_csmacd_conn' => 'wfCSMACDConnector', + 'wf_csmacd_mtu' => 'wfCSMACDMtu', + 'wf_duplex' => 'wfCSMACDLineCapability', + 'wf_csmacd_line' => 'wfCSMACDLineNumber', + + # From Wellfleet-CSMACD-MIB::wfCSMACDAutoNegTable + 'wf_auto' => 'wfCSMACDAutoNegSpeedSelect', + + # From Wellfleet-DOT1QTAG-CONFIG-MIB::wfDot1qTagConfigTable + 'wf_vlan_name' => 'wfDot1qTagCfgVlanName', + 'wf_local_vlan_id' => 'wfDot1qTagCfgLocalVlanId', + 'wf_global_vlan_id' => 'wfDot1qTagCfgGlobalVlanId', + 'wf_vlan_port' => 'wfDot1qTagCfgPhysicalPortId', + + # From Wellfleet-HARDWARE-MIB::wfHwTable + 'wf_hw_slot' => 'wfHwSlot', + 'wf_hw_mod_id' => 'wfHwModIdOpt', + 'wf_hw_mod_rev' => 'wfHwModRev', + 'wf_hw_mod_ser' => 'wfHwModSerialNumber', + 'wf_hw_mobo_id' => 'wfHwMotherBdIdOpt', + 'wf_hw_mobo_rev' => 'wfHwMotherBdRev', + 'wf_hw_mobo_ser' => 'wfHwMotherBdSerialNumber', + 'wf_hw_diag' => 'wfHwDiagPromRev', + 'wf_hw_boot' => 'wfHwBootPromRev', + 'wf_hw_mobo_mem' => 'wfHwMotherBdMemorySize', + 'wf_hw_cfg_time' => 'wfHwConfigDateAndTime', + 'wf_hw_db_ser' => 'wfHwDaughterBdSerialNumber', + 'wf_hw_bb_ser' => 'wfHwBabyBdSerialNumber', + 'wf_hw_mm_ser' => 'wfHwModuleModSerialNumber', + 'wf_hw_md1_ser' => 'wfHwModDaughterBd1SerialNumber', + 'wf_hw_md2_ser' => 'wfHwModDaughterBd2SerialNumber', +); + +%MUNGE = ( + %SNMP::Info::MUNGE, + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::Bridge::MUNGE, + 'wf_hw_boot' => \&munge_hw_rev, + 'wf_hw_diag' => \&munge_hw_rev, + 'wf_hw_mobo_ser' => \&munge_wf_serial, + 'wf_hw_mod_ser' => \&munge_wf_serial, + 'wf_hw_db_ser' => \&munge_wf_serial, + 'wf_hw_bb_ser' => \&munge_wf_serial, + 'wf_hw_mm_ser' => \&munge_wf_serial, + 'wf_hw_md1_ser' => \&munge_wf_serial, + 'wf_hw_md2_ser' => \&munge_wf_serial, +); + +%MODEL_MAP = ( + 'acefn' => 'FN', + 'aceln' => 'LN', + 'acecn' => 'CN', + 'afn' => 'AFN', + 'in' => 'IN', + 'an' => 'AN', + 'arn' => 'ARN', + 'sys5000' => '5000', + 'freln' => 'BLN', + 'frecn' => 'BCN', + 'frerbln' => 'BLN-2', + 'asn' => 'ASN', + 'asnzcable' => 'ASN-Z', + 'asnbcable' => 'ASN-B', +); %MODID_MAP = ( - 1 => 'DUAL ENET', - 8 => 'DUAL ENET', - 16 => 'QSYNC', - 24 => 'DUAL T1', - 32 => 'SSE,DSE', - 40 => 'TS 4/16 - 1x2', - 44 => 'TS 4/16 - 1x1', - 45 => 'TS 4/16 - 1x0', - 48 => 'SYSTEM I/O', - 49 => 'SYSTEM I/O', - 56 => 'DUAL T1', - 57 => 'DUAL T1 - 56K', - 58 => 'T1 - SINGLE PORT', - 60 => 'T1 56K - SINGLE PORT', - 61 => 'E1 - 75 OHM', - 80 => 'QSYNC', - 112 => 'DSDE 4', - 116 => 'DSE', - 118 => 'SSE', - 132 => 'ESA 2x0', - 156 => 'ESA 2x2', - 162 => 'QUAD ENET with CAM DAUGHTERCARD', - 164 => 'QUAD ENET with CAM DAUGHTERCARD,QUAD ENET CAM DAUGHTER CARD', - 168 => 'MCT1 - 2', - 169 => 'MCT1 - 1', - 176 => 'DUAL TOKEN', - 184 => 'MCE1 - DUAL PORT', - 185 => 'MCE1 - SINGLE PORT', - 192 => 'MULTIMODE FDDI', - 193 => 'SINGLEMODE FDDI PHY-B', - 194 => 'SINGLEMODE FDDI PHY-A/B', - 195 => 'SINGLEMODE FDDI PHY-A', - 196 => 'MULTIMODE FDDI,FDDI CAM DAUGHTER CARD', - 197 => 'SINGLEMODE FDDI PHY-B,FDDI CAM DAUGHTER CARD', - 198 => 'SINGLEMODE FDDI PHY-A/B,FDDI CAM DAUGHTER CARD', - 199 => 'SINGLEMODE FDDI PHY-A,FDDI CAM DAUGHTER CARD', - 208 => - { - 0 => 'AFNes - V.35,AFNes - X.21,AFNes - CCITT V.35,AFNes - RS449/RS422,AFNes - V.35 w/FLASH,AFNes - X.21 w/FLASH,AFNes-CCITT V.35 w/FL,AFNes - RS422 w/FLASH AFNes 16M - V.35,AFNes 16M - X.21,AFNes 16M - CCITT V.35,AFNes 16M - RS449/RS422,AFNes 16M V.35 w/Flash,AFNes 16M X.21 w/Flash,AFNes 16M CCITT V.35 w/Flash,AFNes 16M RS449/RS422 w/Flash', - 4096 => 'AFNes - V.35,AFNes - X.21,AFNes - CCITT V.35,AFNes - RS449/RS422,AFNes - V.35 w/FLASH,AFNes - X.21 w/FLASH,AFNes-CCITT V.35 w/FL,AFNes - RS422 w/FLASH', - 16384 => 'AFNes 16M - V.35,AFNes 16M - X.21,AFNes 16M - CCITT V.35,AFNes 16M - RS449/RS422,AFNes 16M V.35 w/Flash,AFNes 16M X.21 w/Flash,AFNes 16M CCITT V.35 w/Flash,AFNes 16M RS449/RS422 w/Flash', - }, - 216 => - { - 0 => 'AFNts 2x2,AFNts 2x2 - w/FLASH,AFNTS 2X2 16MB,AFNTS 2X2 16MB FLASH', - 4096 => 'AFNts 2x2,AFNts 2x2 - w/FLASH', + 1 => 'DUAL ENET', + 8 => 'DUAL ENET', + 16 => 'QSYNC', + 24 => 'DUAL T1', + 32 => 'SSE,DSE', + 40 => 'TS 4/16 - 1x2', + 44 => 'TS 4/16 - 1x1', + 45 => 'TS 4/16 - 1x0', + 48 => 'SYSTEM I/O', + 49 => 'SYSTEM I/O', + 56 => 'DUAL T1', + 57 => 'DUAL T1 - 56K', + 58 => 'T1 - SINGLE PORT', + 60 => 'T1 56K - SINGLE PORT', + 61 => 'E1 - 75 OHM', + 80 => 'QSYNC', + 112 => 'DSDE 4', + 116 => 'DSE', + 118 => 'SSE', + 132 => 'ESA 2x0', + 156 => 'ESA 2x2', + 162 => 'QUAD ENET with CAM DAUGHTERCARD', + 164 => 'QUAD ENET with CAM DAUGHTERCARD,QUAD ENET CAM DAUGHTER CARD', + 168 => 'MCT1 - 2', + 169 => 'MCT1 - 1', + 176 => 'DUAL TOKEN', + 184 => 'MCE1 - DUAL PORT', + 185 => 'MCE1 - SINGLE PORT', + 192 => 'MULTIMODE FDDI', + 193 => 'SINGLEMODE FDDI PHY-B', + 194 => 'SINGLEMODE FDDI PHY-A/B', + 195 => 'SINGLEMODE FDDI PHY-A', + 196 => 'MULTIMODE FDDI,FDDI CAM DAUGHTER CARD', + 197 => 'SINGLEMODE FDDI PHY-B,FDDI CAM DAUGHTER CARD', + 198 => 'SINGLEMODE FDDI PHY-A/B,FDDI CAM DAUGHTER CARD', + 199 => 'SINGLEMODE FDDI PHY-A,FDDI CAM DAUGHTER CARD', + 208 => { + 0 => + 'AFNes - V.35,AFNes - X.21,AFNes - CCITT V.35,AFNes - RS449/RS422,AFNes - V.35 w/FLASH,AFNes - X.21 w/FLASH,AFNes-CCITT V.35 w/FL,AFNes - RS422 w/FLASH AFNes 16M - V.35,AFNes 16M - X.21,AFNes 16M - CCITT V.35,AFNes 16M - RS449/RS422,AFNes 16M V.35 w/Flash,AFNes 16M X.21 w/Flash,AFNes 16M CCITT V.35 w/Flash,AFNes 16M RS449/RS422 w/Flash', + 4096 => + 'AFNes - V.35,AFNes - X.21,AFNes - CCITT V.35,AFNes - RS449/RS422,AFNes - V.35 w/FLASH,AFNes - X.21 w/FLASH,AFNes-CCITT V.35 w/FL,AFNes - RS422 w/FLASH', + 16384 => + 'AFNes 16M - V.35,AFNes 16M - X.21,AFNes 16M - CCITT V.35,AFNes 16M - RS449/RS422,AFNes 16M V.35 w/Flash,AFNes 16M X.21 w/Flash,AFNes 16M CCITT V.35 w/Flash,AFNes 16M RS449/RS422 w/Flash', + }, + 216 => { + 0 => + 'AFNts 2x2,AFNts 2x2 - w/FLASH,AFNTS 2X2 16MB,AFNTS 2X2 16MB FLASH', + 4096 => 'AFNts 2x2,AFNts 2x2 - w/FLASH', 16384 => 'AFNTS 2X2 16MB,AFNTS 2X2 16MB FLASH', - }, - 217 => - { - 0 => 'AFNts 1x2,AFNts 1x2 - w/FLASH,AFNTS 1X2 16MB,AFNTS 1X2 16MB FLASH', - 4096 => 'AFNts 1x2,AFNts 1x2 - w/FLASH', + }, + 217 => { + 0 => + 'AFNts 1x2,AFNts 1x2 - w/FLASH,AFNTS 1X2 16MB,AFNTS 1X2 16MB FLASH', + 4096 => 'AFNts 1x2,AFNts 1x2 - w/FLASH', 16384 => 'AFNTS 1X2 16MB,AFNTS 1X2 16MB FLASH', - }, - 225 => 'HSSI - SINGLE PORT', - 232 => 'EASF 0 DEFA & 0 CAMS', - 236 => 'ESAF w/DEFA & 2 CAMS,ESAF w/DEFA & 6 CAMS', - 256 => 'QUAD TOKEN', - 512 => 'SPX NET MODULE', - 769 => 'HOT SWAP SPEX NET MOD', - 1024 => - { - 4096 => 'AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', - 8192 => 'AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', + }, + 225 => 'HSSI - SINGLE PORT', + 232 => 'EASF 0 DEFA & 0 CAMS', + 236 => 'ESAF w/DEFA & 2 CAMS,ESAF w/DEFA & 6 CAMS', + 256 => 'QUAD TOKEN', + 512 => 'SPX NET MODULE', + 769 => 'HOT SWAP SPEX NET MOD', + 1024 => { + 4096 => 'AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', + 8192 => 'AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', 16384 => 'AN-ENET 1X2 SPARE 4F/16D,BAYSTACK AN-ES 16MB', - }, - 1025 => - { - 4096 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', - 8192 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', + }, + 1025 => { + 4096 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', + 8192 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', 16384 => 'AN-ENET/TOK 1X1X2 SPARE 4F/16D,BAYSTACK AN-ETS 16MB', - }, - 1026 => - { - 4096 => 'AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', - 8192 => 'AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', + }, + 1026 => { + 4096 => 'AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', + 8192 => 'AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', 16384 => 'AN - HUB SPARE 4F/16D,BAYSTACK ANH-12 16MB', - }, - 1027 => - { - 4096 => 'AN-ENET 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', - 8192 => 'AN-ENET 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + }, + 1027 => { + 4096 => 'AN-ENET 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + 8192 => 'AN-ENET 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', 16384 => 'AN-ENET 1X2 SPARE 4F/16D,AN ISDN BRI DAUGHTER CARD', - }, - 1028 => - { - 4096 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', - 8192 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + }, + 1028 => { + 4096 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + 8192 => 'AN-ENET/TOK 1X1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', 16384 => 'AN-ENET/TOK 1X1X2 SPARE 4F/16D,AN ISDN BRI DAUGHTER CARD', - }, - 1029 => - { - 4096 => 'AN-HUB SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', - 8192 => 'AN-HUB SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + }, + 1029 => { + 4096 => 'AN-HUB SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + 8192 => 'AN-HUB SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', 16384 => 'AN - HUB SPARE 4F/16D,AN ISDN BRI DAUGHTER CARD', - }, - 1030 => - { - 4096 => 'AN 3RD SYNC DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', - 8192 => 'AN 3RD SYNC DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', - 16384 => 'AN 3RD SYNC DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/16D,BAYSTACK AN-ES 16MB', - }, - 1031 => - { - 4096 => 'AN 3RD SYNC DAUGHTER CARD,AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', - 8192 => 'AN 3RD SYNC DAUGHTER CARD,AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', - 16384 => 'AN 3RD SYNC DAUGHTER CARD,AN-ENET/TOK 1X1X2 SPARE 4F/16D,BAYSTACK AN-ETS 16MB', - }, - 1032 => - { - 4096 => 'AN 3RD SYNC DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', - 8192 => 'AN 3RD SYNC DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', - 16384 => 'AN 3RD SYNC DAUGHTER CARD,AN - HUB SPARE 4F/16D,BAYSTACK ANH-12 16MB', - }, - 1033 => - { - 4096 => 'AN 2ND ENET DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', - 8192 => 'AN 2ND ENET DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', - 16384 => 'AN 2ND ENET DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/16D,BAYSTACK AN-ES 16MB', - }, - 1035 => - { - 4096 => 'AN 2ND ENET DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', - 8192 => 'AN 2ND ENET DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', - 16384 => 'AN 2ND ENET DAUGHTER CARD,AN - HUB SPARE 4F/16D,BAYSTACK ANH-12 16MB', - }, - 1037 => - { - 4096 => 'AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', - 8192 => 'AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', + }, + 1030 => { + 4096 => + 'AN 3RD SYNC DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', + 8192 => + 'AN 3RD SYNC DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', + 16384 => + 'AN 3RD SYNC DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/16D,BAYSTACK AN-ES 16MB', + }, + 1031 => { + 4096 => + 'AN 3RD SYNC DAUGHTER CARD,AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', + 8192 => + 'AN 3RD SYNC DAUGHTER CARD,AN-ENET/TOK 1X1X2 SPARE 4F/8D,BAYSTACK AN-ETS 8MB', + 16384 => + 'AN 3RD SYNC DAUGHTER CARD,AN-ENET/TOK 1X1X2 SPARE 4F/16D,BAYSTACK AN-ETS 16MB', + }, + 1032 => { + 4096 => + 'AN 3RD SYNC DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', + 8192 => + 'AN 3RD SYNC DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', + 16384 => + 'AN 3RD SYNC DAUGHTER CARD,AN - HUB SPARE 4F/16D,BAYSTACK ANH-12 16MB', + }, + 1033 => { + 4096 => + 'AN 2ND ENET DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', + 8192 => + 'AN 2ND ENET DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/8D,BAYSTACK AN-ES 8MB', + 16384 => + 'AN 2ND ENET DAUGHTER CARD,AN-ENET 1X2 SPARE 4F/16D,BAYSTACK AN-ES 16MB', + }, + 1035 => { + 4096 => + 'AN 2ND ENET DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', + 8192 => + 'AN 2ND ENET DAUGHTER CARD,AN-HUB SPARE 4F/8D,BAYSTACK ANH-12 8MB', + 16384 => + 'AN 2ND ENET DAUGHTER CARD,AN - HUB SPARE 4F/16D,BAYSTACK ANH-12 16MB', + }, + 1037 => { + 4096 => 'AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', + 8192 => 'AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', 16384 => 'AN-TOK 1X2 SPARE 4F/16D,BAYSTACK AN-TS 16MB', - }, - 1038 => - { - 4096 => 'AN-TOK 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', - 8192 => 'AN-TOK 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + }, + 1038 => { + 4096 => 'AN-TOK 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', + 8192 => 'AN-TOK 1X2 SPARE 4F/8D,AN ISDN BRI DAUGHTER CARD', 16384 => 'AN-TOK 1X2 SPARE 4F/16D,AN ISDN BRI DAUGHTER CARD', - }, - 1039 => - { - 4096 => 'AN 3RD SYNC DAUGHTER CARD,AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', - 8192 => 'AN 3RD SYNC DAUGHTER CARD,AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', - 16384 => 'AN 3RD SYNC DAUGHTER CARD,AN-TOK 1X2 SPARE 4F/16D,BAYSTACK AN-TS 16MB', - }, - 1042 => - { - 4096 => 'BAYSTACK AN-ETS 8MB,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ETS 8MB,BAYSTACK AN N11 DCM', + }, + 1039 => { + 4096 => + 'AN 3RD SYNC DAUGHTER CARD,AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', + 8192 => + 'AN 3RD SYNC DAUGHTER CARD,AN-TOK 1X2 SPARE 4F/8D,BAYSTACK AN-TS 8MB', + 16384 => + 'AN 3RD SYNC DAUGHTER CARD,AN-TOK 1X2 SPARE 4F/16D,BAYSTACK AN-TS 16MB', + }, + 1042 => { + 4096 => 'BAYSTACK AN-ETS 8MB,BAYSTACK AN N11 DCM', + 8192 => 'BAYSTACK AN-ETS 8MB,BAYSTACK AN N11 DCM', 16384 => 'BAYSTACK AN-ETS 16MB,BAYSTACK AN N11 DCM', - }, - 1043 => - { - 4096 => 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD', - 8192 => 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD', + }, + 1043 => { + 4096 => 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD', + 8192 => 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD', 16384 => 'BAYSTACK AN-ES 16MB,AN ISDN BRI DAUGHTER CARD', - }, - 1044 => - { - 4096 => 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD', - 8192 => 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD', + }, + 1044 => { + 4096 => 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD', + 8192 => 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD', 16384 => 'BAYSTACK AN-ETS 16MB,AN ISDN BRI DAUGHTER CARD', - }, - 1045 => - { - 4096 => 'BAYSTACK ANH-12 8MB,AN ISDN BRI DAUGHTER CARD', - 8192 => 'BAYSTACK ANH-12 8MB,AN ISDN BRI DAUGHTER CARD', + }, + 1045 => { + 4096 => 'BAYSTACK ANH-12 8MB,AN ISDN BRI DAUGHTER CARD', + 8192 => 'BAYSTACK ANH-12 8MB,AN ISDN BRI DAUGHTER CARD', 16384 => 'BAYSTACK ANH-12 16MB,AN ISDN BRI DAUGHTER CARD', - }, - 1046 => - { - 4096 => 'BAYSTACK AN-TS 8MB,AN ISDN BRI DAUGHTER CARD', - 8192 => 'BAYSTACK AN-TS 8MB,AN ISDN BRI DAUGHTER CARD', + }, + 1046 => { + 4096 => 'BAYSTACK AN-TS 8MB,AN ISDN BRI DAUGHTER CARD', + 8192 => 'BAYSTACK AN-TS 8MB,AN ISDN BRI DAUGHTER CARD', 16384 => 'BAYSTACK AN-TS 16MB,AN ISDN BRI DAUGHTER CARD', - }, - 1047 => - { - 4096 => 'BAYSTACK ANH-8 8MB', - 8192 => 'BAYSTACK ANH-8 8MB', + }, + 1047 => { + 4096 => 'BAYSTACK ANH-8 8MB', + 8192 => 'BAYSTACK ANH-8 8MB', 16384 => 'BAYSTACK ANH-8 16MB', - }, - 1048 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 N11 DCM', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 N11 DCM', + }, + 1048 => { + 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 N11 DCM', + 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 N11 DCM', 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 N11 DCM', - }, - 1049 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD', + }, + 1049 => { + 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD', + 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD', 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD', - }, - 1050 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD', + }, + 1050 => { + 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD', + 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD', 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD', - }, - 1051 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD', + }, + 1051 => { + 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD', + 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD', 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD', - }, - 1052 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - }, - 1053 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - }, - 1054 => - { - 4096 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - 8192 => 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - 16384 => 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', - }, - 1055 => - { - 4096 => 'BAYSTACK AN-ES 8MB,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ES 8MB,BAYSTACK AN N11 DCM', + }, + 1052 => { + 4096 => + 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + 8192 => + 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + 16384 => + 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 3RD SYNC DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + }, + 1053 => { + 4096 => + 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + 8192 => + 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + 16384 => + 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 2ND ENET DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + }, + 1054 => { + 4096 => + 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + 8192 => + 'BAYSTACK ANH-8 8MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + 16384 => + 'BAYSTACK ANH-8 16MB,BAYSTACK ANH-8 ISDN BRI DAUGHTER CARD,BAYSTACK ANH-8 N11 DCM', + }, + 1055 => { + 4096 => 'BAYSTACK AN-ES 8MB,BAYSTACK AN N11 DCM', + 8192 => 'BAYSTACK AN-ES 8MB,BAYSTACK AN N11 DCM', 16384 => 'BAYSTACK AN-ES 16MB,BAYSTACK AN N11 DCM', - }, - 1056 => - { - 4096 => 'BAYSTACK AN-ES 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ES 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', - 16384 => 'BAYSTACK AN-ES 16MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', - }, - 1057 => - { - 4096 => 'BAYSTACK AN-ES 8MB,AN 2ND ENET DAUGHTER CARD,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ES 8MB,AN 2ND ENET DAUGHTER CARD,BAYSTACK AN N11 DCM', - 16384 => 'BAYSTACK AN-ES 16MB,AN 2ND ENET DAUGHTER CARD,BAYSTACK AN N11 DCM', - }, - 1059 => - { - 4096 => 'BAYSTACK AN-ETS 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ETS 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', - 16384 => 'BAYSTACK AN-ETS 16MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', - }, - 1062 => - { - 4096 => 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', - 16384 => 'BAYSTACK AN-ES 16MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', - }, - 1063 => - { - 4096 => 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', - 8192 => 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', - 16384 => 'BAYSTACK AN-ETS 16MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', - }, - 1280 => 'DUAL ENET NET MODULE', - 1536 => 'DUAL SYNC NET MODULE', - 1537 => 'DUAL SYNC NET MODULE', - 1538 => 'DUAL SYNC NET MODULE', - 1540 => 'DUAL SYNC NET MODULE', - 1541 => 'DUAL SYNC NET MODULE', - 1542 => 'DUAL SYNC NET MODULE', - 1544 => 'DUAL SYNC NET MODULE', - 1545 => 'DUAL SYNC NET MODULE', - 1546 => 'DUAL SYNC NET MODULE', - 1584 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1585 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1586 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1588 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1589 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1590 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1592 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1593 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1594 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', - 1793 => 'MUTLIMODE FDDI NET MODULE', - 1801 => 'SINGLEMODE FDDI NET MODULE', - 1825 => 'S.M. PHY A FDDI NET MODULE', - 1833 => 'S.M. PHY B FDDI NET MODULE', - 2048 => 'DUAL TOKEN NET MODULE', - 2304 => '100 BASE-TX NET MODULE', - 2560 => 'QUAD ISDN BRI NET MOD', - 2816 => 'MCE1 NET MODULE', - 3584 => 'SINGLE HSSI NET MODULE', - 4098 => 'ATM LINK - OC3 MULTIMODE', - 4099 => 'ATM LINK - OC3 SINGLEMODE', - 4352 => 'OCTAL SYNC LINK MODULE', - 4353 => 'OCTAL SYNC LINK MODULE,32 CONTEXTS HARDWARE COMPRESSION DGHTR. CARD', - 4354 => 'OCTAL SYNC LINK MODULE,128 CONTEXTS HARDWARE COMPRESSION DGHTR. CARD', - 4608 => 'SONET/SDH MMF LINK', - 4609 => 'SONET/SDH SMF LINK', - 4864 => '100 BASE-Tx ETHERNET', - 5376 => 'QUAD PORT MULTICHANNEL T1 (QMCT1) RJ48', - 5377 => 'QUAD PORT MULTICHANNEL T1 (QMCT1) DB15', - 5378 => 'QUAD PORT MULTICHANNEL T1 DS0A (QMCT1 w/DS0A) DB15', - 6144 => '4-PORT 10/100BASE-TX', - 6145 => '4-PORT 100BASE-FX', - 6400 => '1000BASE-SX', - 6401 => '1000BASE-LX', - 8448 => 'SRM-L', - 8704 => 'ARN Motherboard Single Token Ring', - 8720 => 'ARN Motherboard Single Ethernet', - 8728 => 'ARN Motherboard Single 10/100BASE-TX', - 8729 => 'ARN Motherboard Single 10/100BASE-FX', - 8736 => 'ARN Serial Adapter Module', - 8752 => 'ARN V.34 Modem Adapter Module', - 8768 => 'ARN 56/64 DSU/CSU Adapter Module', - 8784 => 'ARN ISDN BRI S/T Adapter Module', - 8800 => 'ARN ISDN BRI U Adapter Module', - 8816 => 'ARN Token Ring Expansion Module', - 8832 => 'ARN Ethernet Expansion Module', - 8848 => 'ARN Tri Serial Expansion Module', - 8864 => 'ARN Ethernet and Tri-Serial Expansion Module', - 8880 => 'ARN Token Ring and Tri-Serial Expansion Module', - 8896 => 'arnmbenx10', - 8912 => 'arnmbtrx10', - 8928 => 'arnpbenx10', - 8944 => 'arnpbtrx10', - 8960 => 'arnpbtenx10', - 8976 => 'arnpbttrx10', - ); + }, + 1056 => { + 4096 => + 'BAYSTACK AN-ES 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', + 8192 => + 'BAYSTACK AN-ES 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', + 16384 => + 'BAYSTACK AN-ES 16MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', + }, + 1057 => { + 4096 => + 'BAYSTACK AN-ES 8MB,AN 2ND ENET DAUGHTER CARD,BAYSTACK AN N11 DCM', + 8192 => + 'BAYSTACK AN-ES 8MB,AN 2ND ENET DAUGHTER CARD,BAYSTACK AN N11 DCM', + 16384 => + 'BAYSTACK AN-ES 16MB,AN 2ND ENET DAUGHTER CARD,BAYSTACK AN N11 DCM', + }, + 1059 => { + 4096 => + 'BAYSTACK AN-ETS 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', + 8192 => + 'BAYSTACK AN-ETS 8MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', + 16384 => + 'BAYSTACK AN-ETS 16MB,AN 3RD SYNC DAUGHTER CARD,BAYSTACK AN N11 DCM', + }, + 1062 => { + 4096 => + 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', + 8192 => + 'BAYSTACK AN-ES 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', + 16384 => + 'BAYSTACK AN-ES 16MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', + }, + 1063 => { + 4096 => + 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', + 8192 => + 'BAYSTACK AN-ETS 8MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', + 16384 => + 'BAYSTACK AN-ETS 16MB,AN ISDN BRI DAUGHTER CARD,BAYSTACK AN N11 DCM', + }, + 1280 => 'DUAL ENET NET MODULE', + 1536 => 'DUAL SYNC NET MODULE', + 1537 => 'DUAL SYNC NET MODULE', + 1538 => 'DUAL SYNC NET MODULE', + 1540 => 'DUAL SYNC NET MODULE', + 1541 => 'DUAL SYNC NET MODULE', + 1542 => 'DUAL SYNC NET MODULE', + 1544 => 'DUAL SYNC NET MODULE', + 1545 => 'DUAL SYNC NET MODULE', + 1546 => 'DUAL SYNC NET MODULE', + 1584 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1585 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1586 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1588 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1589 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1590 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1592 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1593 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1594 => 'DUAL SYNC NET MODULE,ASN ISDN DAUGHTER CARD', + 1793 => 'MUTLIMODE FDDI NET MODULE', + 1801 => 'SINGLEMODE FDDI NET MODULE', + 1825 => 'S.M. PHY A FDDI NET MODULE', + 1833 => 'S.M. PHY B FDDI NET MODULE', + 2048 => 'DUAL TOKEN NET MODULE', + 2304 => '100 BASE-TX NET MODULE', + 2560 => 'QUAD ISDN BRI NET MOD', + 2816 => 'MCE1 NET MODULE', + 3584 => 'SINGLE HSSI NET MODULE', + 4098 => 'ATM LINK - OC3 MULTIMODE', + 4099 => 'ATM LINK - OC3 SINGLEMODE', + 4352 => 'OCTAL SYNC LINK MODULE', + 4353 => + 'OCTAL SYNC LINK MODULE,32 CONTEXTS HARDWARE COMPRESSION DGHTR. CARD', + 4354 => + 'OCTAL SYNC LINK MODULE,128 CONTEXTS HARDWARE COMPRESSION DGHTR. CARD', + 4608 => 'SONET/SDH MMF LINK', + 4609 => 'SONET/SDH SMF LINK', + 4864 => '100 BASE-Tx ETHERNET', + 5376 => 'QUAD PORT MULTICHANNEL T1 (QMCT1) RJ48', + 5377 => 'QUAD PORT MULTICHANNEL T1 (QMCT1) DB15', + 5378 => 'QUAD PORT MULTICHANNEL T1 DS0A (QMCT1 w/DS0A) DB15', + 6144 => '4-PORT 10/100BASE-TX', + 6145 => '4-PORT 100BASE-FX', + 6400 => '1000BASE-SX', + 6401 => '1000BASE-LX', + 8448 => 'SRM-L', + 8704 => 'ARN Motherboard Single Token Ring', + 8720 => 'ARN Motherboard Single Ethernet', + 8728 => 'ARN Motherboard Single 10/100BASE-TX', + 8729 => 'ARN Motherboard Single 10/100BASE-FX', + 8736 => 'ARN Serial Adapter Module', + 8752 => 'ARN V.34 Modem Adapter Module', + 8768 => 'ARN 56/64 DSU/CSU Adapter Module', + 8784 => 'ARN ISDN BRI S/T Adapter Module', + 8800 => 'ARN ISDN BRI U Adapter Module', + 8816 => 'ARN Token Ring Expansion Module', + 8832 => 'ARN Ethernet Expansion Module', + 8848 => 'ARN Tri Serial Expansion Module', + 8864 => 'ARN Ethernet and Tri-Serial Expansion Module', + 8880 => 'ARN Token Ring and Tri-Serial Expansion Module', + 8896 => 'arnmbenx10', + 8912 => 'arnmbtrx10', + 8928 => 'arnpbenx10', + 8944 => 'arnpbtrx10', + 8960 => 'arnpbtenx10', + 8976 => 'arnpbttrx10', +); %PROCID_MAP = ( - 1 => 'SYSTEM CONTROLLER', - 2 => '5MEG ACE25', - 3 => - { + 1 => 'SYSTEM CONTROLLER', + 2 => '5MEG ACE25', + 3 => { 5120 => '5MEG ACE25', 8192 => '8MEG ACE25', - }, - 4 => - { - 4096 => 'ACE32', - 8192 => '8MEG ACE32', + }, + 4 => { + 4096 => 'ACE32', + 8192 => '8MEG ACE32', 16384 => '16MEG ACE32', - }, - 5 => 'AFN', - 6 => 'LN', - 7 => 'FLASH SYSTEM CTRL.', - 16384 => 'AN', - 32 => - { - 4096 => 'ARN Ethernet - 4 MEG', - 8192 => 'ARN Ethernet - 8 MEG', + }, + 5 => 'AFN', + 6 => 'LN', + 7 => 'FLASH SYSTEM CTRL.', + 16384 => 'AN', + 32 => { + 4096 => 'ARN Ethernet - 4 MEG', + 8192 => 'ARN Ethernet - 8 MEG', 16384 => 'ARN Ethernet - 16 MEG', 32768 => 'ARN Ethernet - 32 MEG', - }, - 256 => 'FAST ROUTING ENGINE', - 768 => - { + }, + 256 => 'FAST ROUTING ENGINE', + 768 => { 8192 => 'FRE2 - 8MEG', 16384 => 'FRE2 - 16MEG', 24576 => 'FRE2 - 24MEG', 32768 => 'FRE2 - 32MEG', - }, - 769 => - { - 8192 => 'FRE2 060 - 8MEG', + }, + 769 => { + 8192 => 'FRE2 060 - 8MEG', 16384 => 'FRE2 060 - 16MEG', 32768 => 'FRE2 060 - 32MEG', 65536 => 'FRE2 060 - 64MEG', - }, - 1024 => - { - 8192 => 'ASN MOTHER BOARD - 8MB,ASN TRAY / POWER SUPPLY ASSEMBLY', + }, + 1024 => { + 8192 => 'ASN MOTHER BOARD - 8MB,ASN TRAY / POWER SUPPLY ASSEMBLY', 16384 => 'ASN MOTHER BOARD - 16MB,ASN TRAY / POWER SUPPLY ASSEMBLY', 32768 => 'ASN MOTHER BOARD - 32MB,ASN TRAY / POWER SUPPLY ASSEMBLY', - }, - 1025 => - { - 8192 => 'ASN2 MOTHER BOARD - 8MB,ASN TRAY / POWER SUPPLY ASSEMBLY', + }, + 1025 => { + 8192 => 'ASN2 MOTHER BOARD - 8MB,ASN TRAY / POWER SUPPLY ASSEMBLY', 16384 => 'ASN2 MOTHER BOARD - 16MB,ASN TRAY / POWER SUPPLY ASSEMBLY', 32768 => 'ASN2 MOTHER BOARD - 32MB,ASN TRAY / POWER SUPPLY ASSEMBLY', - }, - 1280 => - { + }, + 1280 => { 9216 => 'ARE - 8MB DRAM & 1MB VBM', 19456 => 'ARE - 16MB DRAM & 3MB VBM', 38912 => 'ARE -32MB DRAM & 6MB VBM', 71680 => 'ARE -64MB DRAM & 6MB VBM', - }, - 8704 => 'SRM-F', - 1536 => 'ARE5000', - 1792 => 'ASN500', - 6656 => - { + }, + 8704 => 'SRM-F', + 1536 => 'ARE5000', + 1792 => 'ASN500', + 6656 => { 49152 => 'FRE4-PPC - 32MEG', 81920 => 'FRE4-PPC - 64MEG', 147456 => 'FRE4-PPC - 128MEG', - }, - ); - + }, +); sub model { my $bayrs = shift; @@ -550,64 +557,68 @@ sub os_ver { my $descr = $bayrs->description(); return unless defined $descr; - if ($descr =~ m/^\s*Image:\s+re[lv]\/((\d+\.){1,3}\d+)/){ + if ( $descr =~ m/^\s*Image:\s+re[lv]\/((\d+\.){1,3}\d+)/ ) { return $1; } return; } sub serial { - my $bayrs = shift; - my $serialnum = $bayrs->bp_serial(); - $serialnum = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$serialnum))); - - return $serialnum if defined $serialnum ; + my $bayrs = shift; + my $serialnum = $bayrs->bp_serial(); + $serialnum = hex( + join( '', + '0x', map { sprintf "%02X", $_ } unpack( "C*", $serialnum ) ) + ); + + return $serialnum if defined $serialnum; return; } sub interfaces { - my $bayrs = shift; + my $bayrs = shift; my $description = $bayrs->i_description(); - my $vlan_ids = $bayrs->wf_global_vlan_id(); - my $vlan_idx = $bayrs->wf_local_vlan_id(); - + my $vlan_ids = $bayrs->wf_global_vlan_id(); + my $vlan_idx = $bayrs->wf_local_vlan_id(); + my %interfaces = (); - foreach my $iid (keys %$description){ + foreach my $iid ( keys %$description ) { my $desc = $description->{$iid}; next unless defined $desc; - $desc = $1 if $desc =~ /(^[A-Z]\d+)/; + $desc = $1 if $desc =~ /(^[A-Z]\d+)/; $interfaces{$iid} = $desc; } - foreach my $iid (keys %$vlan_ids){ + foreach my $iid ( keys %$vlan_ids ) { my $vlan = $vlan_ids->{$iid}; next unless defined $vlan; my $vlan_if = $vlan_idx->{$iid}; next unless defined $vlan_if; - + my $desc = 'Vlan' . $vlan; $interfaces{$vlan_if} = $desc; - } + } return \%interfaces; } sub i_name { - my $bayrs = shift; - my $i_index = $bayrs->i_index(); + my $bayrs = shift; + my $i_index = $bayrs->i_index(); my $description = $bayrs->i_description(); - my $v_name = $bayrs->wf_vlan_name(); - my $vlan_idx = $bayrs->wf_local_vlan_id(); + my $v_name = $bayrs->wf_vlan_name(); + my $vlan_idx = $bayrs->wf_local_vlan_id(); my %i_name; - foreach my $iid (keys %$description){ + foreach my $iid ( keys %$description ) { my $name = $description->{$iid}; next unless defined $name; $i_name{$iid} = $name; } + # Get VLAN Virtual Router Interfaces - foreach my $vid (keys %$v_name){ + foreach my $vid ( keys %$v_name ) { my $v_name = $v_name->{$vid}; next unless defined $v_name; my $vlan_if = $vlan_idx->{$vid}; @@ -620,45 +631,45 @@ sub i_name { sub i_duplex { my $bayrs = shift; - - my $wf_cct = $bayrs->wf_csmacd_cct(); + + my $wf_cct = $bayrs->wf_csmacd_cct(); my $wf_duplex = $bayrs->wf_duplex(); - + my %i_duplex; - foreach my $if (keys %$wf_cct){ + foreach my $if ( keys %$wf_cct ) { my $idx = $wf_cct->{$if}; - next unless defined $idx; + next unless defined $idx; my $duplex = $wf_duplex->{$if}; - next unless defined $duplex; - + next unless defined $duplex; + my $string = 'half'; $string = 'full' if $duplex =~ /duplex/i; - - $i_duplex{$idx}=$string; + + $i_duplex{$idx} = $string; } return \%i_duplex; } sub i_duplex_admin { my $bayrs = shift; - + my $wf_cct = $bayrs->wf_csmacd_cct(); my $wf_duplex = $bayrs->wf_duplex(); my $wf_auto = $bayrs->wf_auto(); my $wf_slot = $bayrs->wf_csmacd_slot(); my $wf_conn = $bayrs->wf_csmacd_conn(); - + my %i_duplex_admin; - foreach my $if (keys %$wf_cct){ + foreach my $if ( keys %$wf_cct ) { my $idx = $wf_cct->{$if}; next unless defined $idx; my $duplex = $wf_duplex->{$if}; - next unless defined $duplex; - my $slot = $wf_slot->{$if}; - my $conn = $wf_conn->{$if}; + next unless defined $duplex; + my $slot = $wf_slot->{$if}; + my $conn = $wf_conn->{$if}; my $auto_idx = "$slot.$conn"; - my $auto = $wf_auto->{$auto_idx}; - + my $auto = $wf_auto->{$auto_idx}; + my $string = 'other'; if ($auto) { $string = 'half'; @@ -666,11 +677,11 @@ sub i_duplex_admin { $string = 'auto' if $auto =~ /nway/i; } elsif ($duplex) { - $string = 'half'; - $string = 'full' if $duplex =~ /duplex/i; + $string = 'half'; + $string = 'full' if $duplex =~ /duplex/i; } - - $i_duplex_admin{$idx}=$string; + + $i_duplex_admin{$idx} = $string; } return \%i_duplex_admin; } @@ -678,42 +689,45 @@ sub i_duplex_admin { sub i_vlan { my $bayrs = shift; - my $wf_cct = $bayrs->wf_csmacd_cct(); - my $wf_mtu = $bayrs->wf_csmacd_mtu(); - my $wf_line = $bayrs->wf_csmacd_line(); - my $wf_local_vid = $bayrs->wf_local_vlan_id(); - my $wf_global_vid = $bayrs->wf_global_vlan_id(); - my $wf_vport = $bayrs->wf_vlan_port(); + my $wf_cct = $bayrs->wf_csmacd_cct(); + my $wf_mtu = $bayrs->wf_csmacd_mtu(); + my $wf_line = $bayrs->wf_csmacd_line(); + my $wf_local_vid = $bayrs->wf_local_vlan_id(); + my $wf_global_vid = $bayrs->wf_global_vlan_id(); + my $wf_vport = $bayrs->wf_vlan_port(); my %i_vlan; + # Look for VLANs on Ethernet Interfaces - foreach my $if (keys %$wf_cct){ + foreach my $if ( keys %$wf_cct ) { my $idx = $wf_cct->{$if}; next unless defined $idx; + # Check MTU size, if unable to carry VLAN tag skip. my $mtu = $wf_mtu->{$if}; - next if (($mtu =~ /default/i) or ($mtu < 1522)); - my $line = $wf_line->{$if}; + next if ( ( $mtu =~ /default/i ) or ( $mtu < 1522 ) ); + my $line = $wf_line->{$if}; my @vlans = (); - foreach my $v_idx (keys %$wf_vport){ + foreach my $v_idx ( keys %$wf_vport ) { my $port = $wf_vport->{$v_idx}; next unless defined $port; - next if ($port != $line); - + next if ( $port != $line ); + my $vlan = $wf_global_vid->{$v_idx}; - push(@vlans, $vlan); + push( @vlans, $vlan ); } - my $vlans = join (',', @vlans); - $i_vlan{$idx}=$vlans; + my $vlans = join( ',', @vlans ); + $i_vlan{$idx} = $vlans; } + # Add VLAN on VLAN Interfaces - foreach my $idx (keys %$wf_global_vid){ + foreach my $idx ( keys %$wf_global_vid ) { my $v_if = $wf_local_vid->{$idx}; next unless defined $v_if; my $vlan = $wf_global_vid->{$idx}; next unless defined $vlan; - - $i_vlan{$v_if}=$vlan; + + $i_vlan{$v_if} = $vlan; } return \%i_vlan; } @@ -721,22 +735,31 @@ sub i_vlan { sub root_ip { my $bayrs = shift; - my $ip_index = $bayrs->ip_index(); - my $ip_table = $bayrs->ip_table(); - + my $ip_index = $bayrs->ip_index(); + my $ip_table = $bayrs->ip_table(); + # Check for CLIP - foreach my $entry (keys %$ip_index){ + foreach my $entry ( keys %$ip_index ) { my $idx = $ip_index->{$entry}; next unless $idx == 0; my $clip = $ip_table->{$entry}; - next unless ( (defined $clip) and ($clip ne '0.0.0.0') and ($bayrs->snmp_connect_ip($clip)) ); - print " SNMP::Layer3::BayRS::root_ip() using $clip\n" if $bayrs->debug(); + next + unless ( ( defined $clip ) + and ( $clip ne '0.0.0.0' ) + and ( $bayrs->snmp_connect_ip($clip) ) ); + print " SNMP::Layer3::BayRS::root_ip() using $clip\n" + if $bayrs->debug(); return $clip; } + # Check for OSPF Router ID - my $ospf_ip = $bayrs->ospf_rtr_id(); - if ((defined $ospf_ip) and ($ospf_ip ne '0.0.0.0') and ($bayrs->snmp_connect_ip($ospf_ip)) ) { - print " SNMP::Layer3::BayRS::root_ip() using $ospf_ip\n" if $bayrs->debug(); + my $ospf_ip = $bayrs->ospf_rtr_id(); + if ( ( defined $ospf_ip ) + and ( $ospf_ip ne '0.0.0.0' ) + and ( $bayrs->snmp_connect_ip($ospf_ip) ) ) + { + print " SNMP::Layer3::BayRS::root_ip() using $ospf_ip\n" + if $bayrs->debug(); return $ospf_ip; } @@ -746,7 +769,7 @@ sub root_ip { # Pseudo ENTITY-MIB methods sub e_index { - my $bayrs = shift; + my $bayrs = shift; my $bp_id = $bayrs->bp_id(); @@ -757,54 +780,58 @@ sub e_index { # Using mib leafs so we don't have to define everything in FUNCS # Processor - All models should support these - my $wf_mb = $bayrs->wfHwMotherBdIdOpt() || {}; + my $wf_mb = $bayrs->wfHwMotherBdIdOpt() || {}; my $wf_db = $bayrs->wfHwDaughterBdIdOpt() || {}; - my $wf_bb = $bayrs->wfHwBabyBdIdOpt() || {}; - - my ($wf_mod, $wf_mod1, $wf_mod2, $wf_mm, $wf_dm) = {}; + my $wf_bb = $bayrs->wfHwBabyBdIdOpt() || {}; + + my ( $wf_mod, $wf_mod1, $wf_mod2, $wf_mm, $wf_dm ) = {}; # Only query objects we need - # Link Module - if ($bp_id !~ /arn|asn/) { - $wf_mod = $bayrs->wfHwModIdOpt() || {}; + # Link Module + if ( $bp_id !~ /arn|asn/ ) { + $wf_mod = $bayrs->wfHwModIdOpt() || {}; $wf_mod1 = $bayrs->wfHwModDaughterBd1IdOpt() || {}; $wf_mod2 = $bayrs->wfHwModDaughterBd2IdOpt() || {}; } + # Hardware Module - if ($bp_id =~ /arn|asn/) { - $wf_mm = $bayrs->wfHwModuleModIdOpt() || {}; + if ( $bp_id =~ /arn|asn/ ) { + $wf_mm = $bayrs->wfHwModuleModIdOpt() || {}; $wf_dm = $bayrs->wfHwModuleDaughterBdIdOpt() || {}; } - - my @slots = ($wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2); - my @mods = ($wf_mm, $wf_dm); - + + my @slots = ( $wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2 ); + my @mods = ( $wf_mm, $wf_dm ); + # We're going to hack an index: Slot/Module/Postion my %wf_e_index; + # Chassis on BN types - if ($bp_id !~ /an|arn|asn/) { + if ( $bp_id !~ /an|arn|asn/ ) { $wf_e_index{1} = 1; } - # Handle Processor / Link Modules first - foreach my $idx (keys %$wf_mb){ - my $index = "$idx"."0000"; - unless ($bp_id =~ /an|arn|asn/) { + + # Handle Processor / Link Modules first + foreach my $idx ( keys %$wf_mb ) { + my $index = "$idx" . "0000"; + unless ( $bp_id =~ /an|arn|asn/ ) { $wf_e_index{$index} = $index; } foreach my $slot (@slots) { - $index ++; + $index++; $wf_e_index{$index} = $index if $slot->{$idx}; } } + # Handle Hardware Modules - foreach my $iid (keys %$wf_mm){ + foreach my $iid ( keys %$wf_mm ) { my $main_mod = $wf_mm->{$iid}; next unless $main_mod; - my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); - $index = "$index"."00"; + my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); + $index = "$index" . "00"; $wf_e_index{$index} = $index; foreach my $mod (@mods) { - $index ++; + $index++; $wf_e_index{$index} = $index if $mod->{$iid}; } } @@ -816,17 +843,17 @@ sub e_class { my $bp_id = $bayrs->bp_id(); - my $wf_e_idx = $bayrs->e_index() || {}; + my $wf_e_idx = $bayrs->e_index() || {}; my %wf_e_class; - foreach my $iid (keys %$wf_e_idx){ - if ($iid == 1) { + foreach my $iid ( keys %$wf_e_idx ) { + if ( $iid == 1 ) { $wf_e_class{$iid} = 'chassis'; } - elsif ($bp_id =~ /an|arn|asn/ and $iid == '10001') { + elsif ( $bp_id =~ /an|arn|asn/ and $iid == '10001' ) { $wf_e_class{$iid} = 'chassis'; } - elsif ($iid =~/(00){1,2}$/) { + elsif ( $iid =~ /(00){1,2}$/ ) { $wf_e_class{$iid} = 'container'; } else { @@ -837,81 +864,82 @@ sub e_class { } sub e_name { - my $bayrs = shift; + my $bayrs = shift; my $bp_id = $bayrs->bp_id(); - my $wf_e_idx = $bayrs->e_index() || {}; + my $wf_e_idx = $bayrs->e_index() || {}; my %wf_e_name; + # Chassis - foreach my $iid (keys %$wf_e_idx){ - if ($iid == 1) { + foreach my $iid ( keys %$wf_e_idx ) { + if ( $iid == 1 ) { $wf_e_name{$iid} = 'Router'; next; } - my $pos = substr($iid, -1); - my $sub = substr($iid, -4, 2); + my $pos = substr( $iid, -1 ); + my $sub = substr( $iid, -4, 2 ); $sub =~ s/^0//; - my $slot = substr($iid, -6, 2); + my $slot = substr( $iid, -6, 2 ); $slot =~ s/^0//; - if ($bp_id =~ /an|arn|asn/ and $iid == '10001') { + if ( $bp_id =~ /an|arn|asn/ and $iid == '10001' ) { $wf_e_name{$iid} = 'Router'; } - elsif ($iid =~/(00){2}$/) { + elsif ( $iid =~ /(00){2}$/ ) { $wf_e_name{$iid} = "Slot $slot"; } - elsif ($iid =~/(00){1}$/ and $bp_id =~ /asn/) { + elsif ( $iid =~ /(00){1}$/ and $bp_id =~ /asn/ ) { $wf_e_name{$iid} = "Module Container $slot $sub"; } - elsif ($iid =~/(00){1}$/ and $bp_id =~ /an|arn/) { + elsif ( $iid =~ /(00){1}$/ and $bp_id =~ /an|arn/ ) { $sub--; - if ($sub == 0) { + if ( $sub == 0 ) { $wf_e_name{$iid} = "Motherboard Container"; } else { $wf_e_name{$iid} = "Module Container $sub"; } } - elsif ($bp_id !~ /an|arn|asn/ and $iid =~/1$/) { + elsif ( $bp_id !~ /an|arn|asn/ and $iid =~ /1$/ ) { $wf_e_name{$iid} = "Processor Slot $slot"; } - elsif ($bp_id =~ /asn/ and $iid =~/1$/) { + elsif ( $bp_id =~ /asn/ and $iid =~ /1$/ ) { $wf_e_name{$iid} = "Module $slot $sub"; } - elsif ($bp_id =~ /an|arn/ and $iid =~/1$/) { + elsif ( $bp_id =~ /an|arn/ and $iid =~ /1$/ ) { $sub--; - if ($sub == 0) { + if ( $sub == 0 ) { $wf_e_name{$iid} = "Motherboard"; } else { $wf_e_name{$iid} = "Module $sub"; } } - elsif ($bp_id !~ /asn/ and $iid =~/2$/) { + elsif ( $bp_id !~ /asn/ and $iid =~ /2$/ ) { $wf_e_name{$iid} = "Processor Daughter Board Slot $slot"; } - elsif ($bp_id !~ /an|arn/ and $iid =~/2$/) { + elsif ( $bp_id !~ /an|arn/ and $iid =~ /2$/ ) { $wf_e_name{$iid} = "Processor Daughter Board"; } - elsif ($bp_id =~ /asn/ and $iid =~/2$/) { + elsif ( $bp_id =~ /asn/ and $iid =~ /2$/ ) { $wf_e_name{$iid} = "Module Daughter Board $slot $sub"; } - elsif ($bp_id =~ /an|arn/ and $iid =~/2$/) { + elsif ( $bp_id =~ /an|arn/ and $iid =~ /2$/ ) { $sub--; $wf_e_name{$iid} = "Module Daughter Board $sub"; } - elsif ($iid =~/3$/) { + elsif ( $iid =~ /3$/ ) { $wf_e_name{$iid} = "Processor Baby Board Slot $slot"; } - elsif ($iid =~/4$/) { + elsif ( $iid =~ /4$/ ) { $wf_e_name{$iid} = "Link Module Slot $slot"; } - elsif ($iid =~/5$/) { + elsif ( $iid =~ /5$/ ) { $wf_e_name{$iid} = "Link Module Daughter Board 1 Slot $slot"; } - elsif ($iid =~/6$/) { + elsif ( $iid =~ /6$/ ) { $wf_e_name{$iid} = "Link Module Daughter Board 2 Slot $slot"; } else { @@ -922,142 +950,163 @@ sub e_name { } sub e_descr { - my $bayrs = shift; + my $bayrs = shift; my $bp_id = $bayrs->bp_id(); # Using mib leafs so we don't have to define everything in FUNCS # We only have descriptions for the processors and modules # Processor - my $wf_mb = $bayrs->wfHwMotherBdIdOpt() || {}; + my $wf_mb = $bayrs->wfHwMotherBdIdOpt() || {}; my $wf_mb_mem = $bayrs->wfHwMotherBdMemorySize() || {}; - my ($wf_mod, $wf_mm) = {}; + my ( $wf_mod, $wf_mm ) = {}; + # Link Module - if ($bp_id !~ /arn|asn/) { + if ( $bp_id !~ /arn|asn/ ) { $wf_mod = $bayrs->wfHwModIdOpt() || {}; } + # Hardware Module - if ($bp_id =~ /arn|asn/) { + if ( $bp_id =~ /arn|asn/ ) { $wf_mm = $bayrs->wfHwModuleModIdOpt() || {}; } my %wf_e_descr; + # Chassis - if ($bp_id !~ /an|arn|asn/) { + if ( $bp_id !~ /an|arn|asn/ ) { $wf_e_descr{1} = $bayrs->model(); } - # Handle Processor / Link Modules first - foreach my $idx (keys %$wf_mb){ - unless ($bp_id =~ /an|arn|asn/) { - $wf_e_descr{"$idx"."0000"} = 'Slot '.$idx; + + # Handle Processor / Link Modules first + foreach my $idx ( keys %$wf_mb ) { + unless ( $bp_id =~ /an|arn|asn/ ) { + $wf_e_descr{ "$idx" . "0000" } = 'Slot ' . $idx; } my $mb_id; - $mb_id = &SNMP::mapEnum('wfHwMotherBdIdOpt',$wf_mb->{$idx}) if $wf_mb->{$idx}; + $mb_id = &SNMP::mapEnum( 'wfHwMotherBdIdOpt', $wf_mb->{$idx} ) + if $wf_mb->{$idx}; my $mb_mem = $wf_mb_mem->{$idx}; my $mod_id; - $mod_id = &SNMP::mapEnum('wfHwModIdOpt',$wf_mod->{$idx})if $wf_mod->{$idx}; + $mod_id = &SNMP::mapEnum( 'wfHwModIdOpt', $wf_mod->{$idx} ) + if $wf_mod->{$idx}; + # Processor if ($mb_id) { - if (ref($PROCID_MAP{$mb_id}) =~ /HASH/) { - $wf_e_descr{"$idx"."0001"} = defined $PROCID_MAP{$mb_id}{$mb_mem} ? - $PROCID_MAP{$mb_id}{$mb_mem} : $mb_id; + if ( ref( $PROCID_MAP{$mb_id} ) =~ /HASH/ ) { + $wf_e_descr{ "$idx" . "0001" } + = defined $PROCID_MAP{$mb_id}{$mb_mem} + ? $PROCID_MAP{$mb_id}{$mb_mem} + : $mb_id; } else { - $wf_e_descr{"$idx"."0001"} = defined $PROCID_MAP{$mb_id} ? - $PROCID_MAP{$mb_id} : $mb_id; + $wf_e_descr{ "$idx" . "0001" } + = defined $PROCID_MAP{$mb_id} + ? $PROCID_MAP{$mb_id} + : $mb_id; } } + # Link Module if ($mod_id) { - if (ref($MODID_MAP{$mod_id}) =~ /HASH/) { - $wf_e_descr{"$idx"."0004"} = defined $MODID_MAP{$mod_id}{$mb_mem} ? - $MODID_MAP{$mod_id}{$mb_mem} : $mod_id; + if ( ref( $MODID_MAP{$mod_id} ) =~ /HASH/ ) { + $wf_e_descr{ "$idx" . "0004" } + = defined $MODID_MAP{$mod_id}{$mb_mem} + ? $MODID_MAP{$mod_id}{$mb_mem} + : $mod_id; } else { - $wf_e_descr{"$idx"."0004"} = defined $MODID_MAP{$mod_id} ? - $MODID_MAP{$mod_id} : $mod_id; + $wf_e_descr{ "$idx" . "0004" } + = defined $MODID_MAP{$mod_id} + ? $MODID_MAP{$mod_id} + : $mod_id; } } } + # Handle Hardware Modules - foreach my $iid (keys %$wf_mm){ - next unless ($wf_mm->{$iid}); - my $idx = join('',map { sprintf "%02d",$_ } split /\./, $iid); - my ($slot, $mod) = split /\./, $iid; - if ($bp_id =~ /an|arn/) { + foreach my $iid ( keys %$wf_mm ) { + next unless ( $wf_mm->{$iid} ); + my $idx = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); + my ( $slot, $mod ) = split /\./, $iid; + if ( $bp_id =~ /an|arn/ ) { $mod--; - if ($mod == 0) { - $wf_e_descr{"$idx"."00"} = "Motherboard Container"; + if ( $mod == 0 ) { + $wf_e_descr{ "$idx" . "00" } = "Motherboard Container"; } else { - $wf_e_descr{"$idx"."00"} = "Module Container $mod"; + $wf_e_descr{ "$idx" . "00" } = "Module Container $mod"; } } else { - $wf_e_descr{"$idx"."00"} = "Module Container $slot $mod"; + $wf_e_descr{ "$idx" . "00" } = "Module Container $slot $mod"; } - my $mm_id = &SNMP::mapEnum('wfHwModuleModIdOpt',$wf_mm->{$iid}); - my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); - $wf_e_descr{"$index"."01"} = - defined $MODID_MAP{$mm_id} ? $MODID_MAP{$mm_id} : $mm_id; + my $mm_id = &SNMP::mapEnum( 'wfHwModuleModIdOpt', $wf_mm->{$iid} ); + my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); + $wf_e_descr{ "$index" . "01" } + = defined $MODID_MAP{$mm_id} ? $MODID_MAP{$mm_id} : $mm_id; } return \%wf_e_descr; } sub e_type { - my $bayrs = shift; + my $bayrs = shift; my $bp_id = $bayrs->bp_id(); # Using mib leafs so we don't have to define everything in FUNCS # Processor - my $wf_mb = $bayrs->wfHwMotherBdIdOpt() || {}; + my $wf_mb = $bayrs->wfHwMotherBdIdOpt() || {}; my $wf_db = $bayrs->wfHwDaughterBdIdOpt() || {}; - my $wf_bb = $bayrs->wfHwBabyBdIdOpt() || {}; + my $wf_bb = $bayrs->wfHwBabyBdIdOpt() || {}; - my ($wf_mod, $wf_mod1, $wf_mod2, $wf_mm, $wf_dm) = {}; + my ( $wf_mod, $wf_mod1, $wf_mod2, $wf_mm, $wf_dm ) = {}; # Link Module - if ($bp_id !~ /arn|asn/) { - $wf_mod = $bayrs->wfHwModIdOpt() || {}; + if ( $bp_id !~ /arn|asn/ ) { + $wf_mod = $bayrs->wfHwModIdOpt() || {}; $wf_mod1 = $bayrs->wfHwModDaughterBd1IdOpt() || {}; $wf_mod2 = $bayrs->wfHwModDaughterBd2IdOpt() || {}; } + # Hardware Module - if ($bp_id =~ /arn|asn/) { - $wf_mm = $bayrs->wfHwModuleModIdOpt() || {}; + if ( $bp_id =~ /arn|asn/ ) { + $wf_mm = $bayrs->wfHwModuleModIdOpt() || {}; $wf_dm = $bayrs->wfHwModuleDaughterBdIdOpt() || {}; } - - my @slots = ($wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2); - my @mods = ($wf_mm, $wf_dm); + + my @slots = ( $wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2 ); + my @mods = ( $wf_mm, $wf_dm ); my %wf_e_type; + # Chassis - if ($bp_id !~ /an|arn|asn/) { + if ( $bp_id !~ /an|arn|asn/ ) { $wf_e_type{1} = $bayrs->bp_id(); } - # Handle Processor / Link Modules first - foreach my $idx (keys %$wf_mb){ - my $index = "$idx"."0000"; - unless ($bp_id =~ /an|arn|asn/) { + + # Handle Processor / Link Modules first + foreach my $idx ( keys %$wf_mb ) { + my $index = "$idx" . "0000"; + unless ( $bp_id =~ /an|arn|asn/ ) { $wf_e_type{$index} = "zeroDotZero"; } foreach my $slot (@slots) { - $index ++; + $index++; $wf_e_type{$index} = $slot->{$idx} if $slot->{$idx}; } } + # Handle Hardware Modules - foreach my $iid (keys %$wf_mm){ + foreach my $iid ( keys %$wf_mm ) { my $main_mod = $wf_mm->{$iid}; next unless $main_mod; - my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); - $index = "$index"."00"; + my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); + $index = "$index" . "00"; $wf_e_type{$index} = "zeroDotZero"; foreach my $mod (@mods) { - $index ++; + $index++; $wf_e_type{$index} = $mod->{$iid} if $mod->{$iid}; } } @@ -1065,57 +1114,71 @@ sub e_type { } sub e_hwver { - my $bayrs = shift; + my $bayrs = shift; my $bp_id = $bayrs->bp_id(); # Using mib leafs so we don't have to define everything in FUNCS # Processor - my $wf_mb = $bayrs->wfHwMotherBdRev() || {}; + my $wf_mb = $bayrs->wfHwMotherBdRev() || {}; my $wf_db = $bayrs->wfHwDaughterBdRev() || {}; - my $wf_bb = $bayrs->wfHwBabyBdRev() || {}; + my $wf_bb = $bayrs->wfHwBabyBdRev() || {}; - my ($wf_mod, $wf_mod1, $wf_mod2, $wf_mm) = {}; + my ( $wf_mod, $wf_mod1, $wf_mod2, $wf_mm ) = {}; # Link Module - if ($bp_id !~ /arn|asn/) { - $wf_mod = $bayrs->wfHwModRev() || {}; + if ( $bp_id !~ /arn|asn/ ) { + $wf_mod = $bayrs->wfHwModRev() || {}; $wf_mod1 = $bayrs->wfHwModDaughterBd1Rev() || {}; $wf_mod2 = $bayrs->wfHwModDaughterBd2Rev() || {}; } + # Hardware Module - if ($bp_id =~ /arn|asn/) { + if ( $bp_id =~ /arn|asn/ ) { $wf_mm = $bayrs->wfHwModuleModRev() || {}; } - - my @slots = ($wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2); + + my @slots = ( $wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2 ); my %wf_e_hwver; + # Chassis - if ($bp_id !~ /an|arn|asn/) { - my $bp_rev = $bayrs->wfHwBpRev(); - $bp_rev = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$bp_rev))); + if ( $bp_id !~ /an|arn|asn/ ) { + my $bp_rev = $bayrs->wfHwBpRev(); + $bp_rev = hex( + join( '', + '0x', map { sprintf "%02X", $_ } unpack( "C*", $bp_rev ) ) + ); $wf_e_hwver{1} = $bp_rev; } - # Handle Processor / Link Modules first - foreach my $idx (keys %$wf_mb){ - my $index = "$idx"."0000"; + + # Handle Processor / Link Modules first + foreach my $idx ( keys %$wf_mb ) { + my $index = "$idx" . "0000"; foreach my $slot (@slots) { - $index ++; - next unless ($slot->{$idx}); + $index++; + next unless ( $slot->{$idx} ); my $mod; - $mod = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$slot->{$idx}))) if $slot->{$idx}; + $mod = hex( + join( '', + '0x', + map { sprintf "%02X", $_ } unpack( "C*", $slot->{$idx} ) ) + ) if $slot->{$idx}; $wf_e_hwver{$index} = $mod if $mod; } } - foreach my $iid (keys %$wf_mm){ - my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); + foreach my $iid ( keys %$wf_mm ) { + my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); my $mod; - $mod = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$wf_mm->{$iid}))) if $wf_mm->{$iid}; - $index = "$index"."00"; - $index ++; - next unless ($wf_mm->{$iid}); + $mod = hex( + join( '', + '0x', + map { sprintf "%02X", $_ } unpack( "C*", $wf_mm->{$iid} ) ) + ) if $wf_mm->{$iid}; + $index = "$index" . "00"; + $index++; + next unless ( $wf_mm->{$iid} ); $wf_e_hwver{$index} = $mod if $mod; } return \%wf_e_hwver; @@ -1124,61 +1187,65 @@ sub e_hwver { sub e_vendor { my $bayrs = shift; - my $wf_e_idx = $bayrs->e_index() || {}; + my $wf_e_idx = $bayrs->e_index() || {}; my %wf_e_vendor; - foreach my $iid (keys %$wf_e_idx){ + foreach my $iid ( keys %$wf_e_idx ) { $wf_e_vendor{$iid} = 'nortel'; } return \%wf_e_vendor; } sub e_serial { - my $bayrs = shift; + my $bayrs = shift; my $bp_id = $bayrs->bp_id(); # Processor my $wf_mb = $bayrs->wf_hw_mobo_ser() || {}; - my $wf_db = $bayrs->wf_hw_db_ser() || {}; - my $wf_bb = $bayrs->wf_hw_bb_ser() || {}; + my $wf_db = $bayrs->wf_hw_db_ser() || {}; + my $wf_bb = $bayrs->wf_hw_bb_ser() || {}; - my ($wf_mod, $wf_mod1, $wf_mod2, $wf_mm) = {}; + my ( $wf_mod, $wf_mod1, $wf_mod2, $wf_mm ) = {}; # Link Module - if ($bp_id !~ /arn|asn/) { - $wf_mod = $bayrs->wf_hw_mod_ser() || {}; + if ( $bp_id !~ /arn|asn/ ) { + $wf_mod = $bayrs->wf_hw_mod_ser() || {}; $wf_mod1 = $bayrs->wf_hw_md1_ser() || {}; $wf_mod2 = $bayrs->wf_hw_md2_ser() || {}; } + # Hardware Module - if ($bp_id =~ /arn|asn/) { + if ( $bp_id =~ /arn|asn/ ) { $wf_mm = $bayrs->wf_hw_mm_ser() || {}; } - - my @slots = ($wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2); + + my @slots = ( $wf_mb, $wf_db, $wf_bb, $wf_mod, $wf_mod1, $wf_mod2 ); my %wf_e_serial; + # Chassis - if ($bp_id !~ /an|arn|asn/) { + if ( $bp_id !~ /an|arn|asn/ ) { $wf_e_serial{1} = $bayrs->serial(); } - # Handle Processor / Link Modules first - foreach my $idx (keys %$wf_mb){ - my $index = "$idx"."0000"; + + # Handle Processor / Link Modules first + foreach my $idx ( keys %$wf_mb ) { + my $index = "$idx" . "0000"; foreach my $slot (@slots) { - $index ++; + $index++; my $mod = $slot->{$idx}; next unless ($mod); $wf_e_serial{$index} = $mod if $mod; } } + # Handle Hardware Modules - foreach my $iid (keys %$wf_mm){ - my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); + foreach my $iid ( keys %$wf_mm ) { + my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); my $mod = $wf_mm->{$iid}; - $index = "$index"."00"; - $index ++; + $index = "$index" . "00"; + $index++; next unless ($mod); $wf_e_serial{$index} = $mod if $mod; } @@ -1188,27 +1255,27 @@ sub e_serial { sub e_pos { my $bayrs = shift; - my $wf_e_idx = $bayrs->e_index() || {}; + my $wf_e_idx = $bayrs->e_index() || {}; my $bp_id = $bayrs->bp_id(); my %wf_e_pos; - foreach my $iid (keys %$wf_e_idx){ - if ($iid == 1) { + foreach my $iid ( keys %$wf_e_idx ) { + if ( $iid == 1 ) { $wf_e_pos{$iid} = -1; next; } - my $pos = substr($iid, -1); - my $sub = substr($iid, -4, 2); - my $slot = substr($iid, -6, 2); + my $pos = substr( $iid, -1 ); + my $sub = substr( $iid, -4, 2 ); + my $slot = substr( $iid, -6, 2 ); - if ($bp_id =~ /an|arn|asn/ and $iid == '10001') { + if ( $bp_id =~ /an|arn|asn/ and $iid == '10001' ) { $wf_e_pos{$iid} = -1; } - elsif ($iid =~/(00){2}$/) { + elsif ( $iid =~ /(00){2}$/ ) { $wf_e_pos{$iid} = $slot; } - elsif ($iid =~/(00){1}$/) { + elsif ( $iid =~ /(00){1}$/ ) { $wf_e_pos{$iid} = $sub; } else { @@ -1219,31 +1286,31 @@ sub e_pos { } sub e_fwver { - my $bayrs = shift; + my $bayrs = shift; # Only on Processor my $wf_mb = $bayrs->wf_hw_boot() || {}; my %wf_e_hwver; - foreach my $idx (keys %$wf_mb){ + foreach my $idx ( keys %$wf_mb ) { my $fw = $wf_mb->{$idx}; next unless $fw; - - $wf_e_hwver{"$idx"."0001"} = $fw; + + $wf_e_hwver{ "$idx" . "0001" } = $fw; } return \%wf_e_hwver; } sub e_swver { - my $bayrs = shift; + my $bayrs = shift; # Only on Processor my $wf_mb = $bayrs->wfHwActiveImageSource() || {}; my %wf_e_swver; - foreach my $idx (keys %$wf_mb){ + foreach my $idx ( keys %$wf_mb ) { my $sw = $wf_mb->{$idx}; next unless $sw; - - $wf_e_swver{"$idx"."0001"} = $sw; + + $wf_e_swver{ "$idx" . "0001" } = $sw; } return \%wf_e_swver; } @@ -1251,32 +1318,32 @@ sub e_swver { sub e_parent { my $bayrs = shift; - my $wf_e_idx = $bayrs->e_index() || {}; + my $wf_e_idx = $bayrs->e_index() || {}; my $bp_id = $bayrs->bp_id(); my %wf_e_parent; - foreach my $iid (keys %$wf_e_idx){ - if ($iid == 1) { + foreach my $iid ( keys %$wf_e_idx ) { + if ( $iid == 1 ) { $wf_e_parent{$iid} = 0; next; } - my $mod = substr($iid, -4, 2); - my $slot = substr($iid, -6, 2); + my $mod = substr( $iid, -4, 2 ); + my $slot = substr( $iid, -6, 2 ); - if ($bp_id =~ /an|arn|asn/ and $iid == '10001') { + if ( $bp_id =~ /an|arn|asn/ and $iid == '10001' ) { $wf_e_parent{$iid} = 0; } - elsif ($iid =~/(00){1,2}$/) { + elsif ( $iid =~ /(00){1,2}$/ ) { my $parent = 1; - $parent = '10001' if ($bp_id =~ /an|arn|asn/); + $parent = '10001' if ( $bp_id =~ /an|arn|asn/ ); $wf_e_parent{$iid} = $parent; } - elsif ($mod != 0) { - $wf_e_parent{$iid} = "$slot"."$mod"."00"; + elsif ( $mod != 0 ) { + $wf_e_parent{$iid} = "$slot" . "$mod" . "00"; } else { - $wf_e_parent{$iid} = "$slot"."0000"; + $wf_e_parent{$iid} = "$slot" . "0000"; } } return \%wf_e_parent; @@ -1284,11 +1351,11 @@ sub e_parent { sub munge_hw_rev { my $hw_boot = shift; - - my @bytes = map{sprintf "%02X", $_}unpack("C*",$hw_boot); - my $major = hex("$bytes[0]"."$bytes[1]"); - my $minor = hex("$bytes[2]"."$bytes[3]"); - + + my @bytes = map { sprintf "%02X", $_ } unpack( "C*", $hw_boot ); + my $major = hex( "$bytes[0]" . "$bytes[1]" ); + my $minor = hex( "$bytes[2]" . "$bytes[3]" ); + my $rev = "$major.$minor"; return $rev if defined($rev); return; @@ -1297,7 +1364,10 @@ sub munge_hw_rev { sub munge_wf_serial { my $wf_serial = shift; - my $serial = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$wf_serial))); + my $serial = hex( + join( '', + '0x', map { sprintf "%02X", $_ } unpack( "C*", $wf_serial ) ) + ); return $serial if defined($serial); return; @@ -1382,8 +1452,8 @@ These are methods that return scalar value from SNMP =item $bayrs->model() -Returns the model of the BayRS router. Will translate between the MIB model and -the common model with this map : +Returns the model of the BayRS router. Will translate between the MIB model +and the common model with this map : C<%MODEL_MAP = ( 'acefn' => 'FN', @@ -1466,8 +1536,8 @@ interfaces. =item $bayrs->i_duplex() -Returns reference to hash. Maps port operational duplexes to IIDs for Ethernet -interfaces. +Returns reference to hash. Maps port operational duplexes to IIDs for +Ethernet interfaces. =item $bayrs->i_duplex_admin() @@ -1532,13 +1602,13 @@ F for hardware modules. =item $bayrs->e_fwver() -Returns reference to hash. Key: IID, Value: Firmware revision. Only available -on processors. +Returns reference to hash. Key: IID, Value: Firmware revision. Only +available on processors. =item $bayrs->e_swver() -Returns reference to hash. Key: IID, Value: Software revision. Only available -on processors. +Returns reference to hash. Key: IID, Value: Software revision. Only +available on processors. =item $bayrs->e_parent() diff --git a/Info/Layer3/C3550.pm b/Info/Layer3/C3550.pm index 4b1a773c..fa8224af 100644 --- a/Info/Layer3/C3550.pm +++ b/Info/Layer3/C3550.pm @@ -4,21 +4,21 @@ # Copyright (c) 2008 Max Baker changes from version 0.8 and beyond. # Copyright (c) 2004 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -42,63 +42,57 @@ use SNMP::Info::CiscoPortSecurity; use SNMP::Info::CiscoPower; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::C3550::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack - SNMP::Info::CDP SNMP::Info::CiscoStats - SNMP::Info::CiscoPortSecurity - SNMP::Info::CiscoImage SNMP::Info::CiscoPower - SNMP::Info::Layer3 - Exporter/; +@SNMP::Info::Layer3::C3550::ISA + = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack + SNMP::Info::CDP SNMP::Info::CiscoStats + SNMP::Info::CiscoPortSecurity + SNMP::Info::CiscoImage SNMP::Info::CiscoPower + SNMP::Info::Layer3 + Exporter/; @SNMP::Info::Layer3::C3550::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::CiscoPower::MIBS, - %SNMP::Info::CiscoPortSecurity::MIBS, - %SNMP::Info::CiscoImage::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoStack::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoPower::MIBS, + %SNMP::Info::CiscoPortSecurity::MIBS, %SNMP::Info::CiscoImage::MIBS, + %SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS, + %SNMP::Info::CiscoStack::MIBS, %SNMP::Info::CiscoVTP::MIBS, +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::CiscoPower::GLOBALS, - %SNMP::Info::CiscoPortSecurity::GLOBALS, - %SNMP::Info::CiscoImage::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoStack::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - 'ports2' => 'ifNumber', - ); + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::CiscoPower::GLOBALS, + %SNMP::Info::CiscoPortSecurity::GLOBALS, + %SNMP::Info::CiscoImage::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::CiscoStack::GLOBALS, + %SNMP::Info::CiscoVTP::GLOBALS, + 'ports2' => 'ifNumber', +); %FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::CiscoPower::FUNCS, - %SNMP::Info::CiscoPortSecurity::FUNCS, - %SNMP::Info::CiscoImage::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoStack::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - ); + %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CiscoPower::FUNCS, + %SNMP::Info::CiscoPortSecurity::FUNCS, %SNMP::Info::CiscoImage::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CDP::FUNCS, + %SNMP::Info::CiscoStack::FUNCS, %SNMP::Info::CiscoVTP::FUNCS, +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::CiscoPower::MUNGE, - %SNMP::Info::CiscoPortSecurity::MUNGE, - %SNMP::Info::CiscoImage::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoStack::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - ); + + # Inherit all the built in munging + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::CiscoPower::MUNGE, + %SNMP::Info::CiscoPortSecurity::MUNGE, + %SNMP::Info::CiscoImage::MUNGE, + %SNMP::Info::CiscoStats::MUNGE, + %SNMP::Info::CDP::MUNGE, + %SNMP::Info::CiscoStack::MUNGE, + %SNMP::Info::CiscoVTP::MUNGE, +); sub vendor { return 'cisco'; @@ -106,12 +100,12 @@ sub vendor { sub model { my $c3550 = shift; - my $id = $c3550->id(); + my $id = $c3550->id(); my $model = &SNMP::translateObj($id) || $id; $model =~ s/^catalyst//; # turn 355048 into 3550-48 - if ($model =~ /^(35\d\d)(\d\d(T|G)?)$/) { + if ( $model =~ /^(35\d\d)(\d\d(T|G)?)$/ ) { $model = "$1-$2"; } return $model; @@ -121,11 +115,11 @@ sub model { sub ports { my $c3550 = shift; - my $ports2 = $c3550->ports2(); + my $ports2 = $c3550->ports2(); - my $id = $c3550->id(); + my $id = $c3550->id(); my $model = &SNMP::translateObj($id); - if ($model =~ /(12|24|48)(C|T|TS|G|TS-E|TS-S|T-E)?$/) { + if ( $model =~ /(12|24|48)(C|T|TS|G|TS-E|TS-S|T-E)?$/ ) { return $1; } return $ports2; @@ -136,15 +130,15 @@ sub ports { # See http://www.ciscosystems.com/en/US/products/hw/switches/ps646/prod_release_note09186a00802a08ee.html sub i_duplex { - my $c3550 = shift; + my $c3550 = shift; my $partial = shift; my $el_duplex = $c3550->el_duplex($partial); - # Newer software - if (defined $el_duplex and scalar(keys %$el_duplex)){ + # Newer software + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { my %i_duplex; - foreach my $el_port (keys %$el_duplex){ + foreach my $el_port ( keys %$el_duplex ) { my $duplex = $el_duplex->{$el_port}; next unless defined $duplex; @@ -153,6 +147,7 @@ sub i_duplex { } return \%i_duplex; } + # Fall back to CiscoStack method else { return $c3550->SUPER::i_duplex($partial); @@ -162,53 +157,55 @@ sub i_duplex { # Software >= 12.1(22)EA1a uses portDuplex as admin setting sub i_duplex_admin { - my $c3550 = shift; + my $c3550 = shift; my $partial = shift; my $el_duplex = $c3550->el_duplex($partial); - # Newer software - if (defined $el_duplex and scalar(keys %$el_duplex)){ + # Newer software + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { my $p_port = $c3550->p_port() || {}; my $p_duplex = $c3550->p_duplex() || {}; - + my $i_duplex_admin = {}; - foreach my $port (keys %$p_duplex) { + foreach my $port ( keys %$p_duplex ) { my $iid = $p_port->{$port}; next unless defined $iid; - next if (defined $partial and $iid !~ /^$partial$/); - + next if ( defined $partial and $iid !~ /^$partial$/ ); + $i_duplex_admin->{$iid} = $p_duplex->{$port}; } return $i_duplex_admin; } + # Fall back to CiscoStack method else { return $c3550->SUPER::i_duplex_admin($partial); - } + } } sub set_i_duplex_admin { + # map a textual duplex to an integer one the switch understands my %duplexes = qw/half 1 full 2 auto 4/; my $c3550 = shift; - my ($duplex, $iid) = @_; + my ( $duplex, $iid ) = @_; my $el_duplex = $c3550->el_duplex($iid); # Auto duplex only supported on newer software - if (defined $el_duplex and scalar(keys %$el_duplex)){ - my $p_port = $c3550->p_port() || {}; + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { + my $p_port = $c3550->p_port() || {}; my %reverse_p_port = reverse %$p_port; - $duplex = lc($duplex); + $duplex = lc($duplex); - return 0 unless defined $duplexes{$duplex}; + return 0 unless defined $duplexes{$duplex}; - $iid = $reverse_p_port{$iid}; + $iid = $reverse_p_port{$iid}; - return $c3550->set_p_duplex($duplexes{$duplex}, $iid); + return $c3550->set_p_duplex( $duplexes{$duplex}, $iid ); } else { return $c3550->SUPER::set_i_duplex_admin; @@ -315,7 +312,7 @@ These are methods that return scalar value from SNMP =item $c3550->vendor() - Returns 'cisco' +Returns 'cisco' =item $c3550->model() diff --git a/Info/Layer3/C4000.pm b/Info/Layer3/C4000.pm index 429e9c8c..cfd60035 100644 --- a/Info/Layer3/C4000.pm +++ b/Info/Layer3/C4000.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Bill Fenner # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -42,83 +42,81 @@ use SNMP::Info::MAU; use SNMP::Info::Layer3; @SNMP::Info::Layer3::C4000::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP - SNMP::Info::CiscoStats SNMP::Info::CiscoImage - SNMP::Info::CiscoPortSecurity - SNMP::Info::CiscoConfig SNMP::Info::MAU - SNMP::Info::Layer3 Exporter/; + SNMP::Info::CiscoStats SNMP::Info::CiscoImage + SNMP::Info::CiscoPortSecurity + SNMP::Info::CiscoConfig SNMP::Info::MAU + SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::C4000::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::MAU::MIBS, - %SNMP::Info::CiscoConfig::MIBS, - %SNMP::Info::CiscoPortSecurity::MIBS, - %SNMP::Info::CiscoImage::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - 'CISCO-ENVMON-MIB' => 'ciscoEnvMonMIB', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::MAU::MIBS, + %SNMP::Info::CiscoConfig::MIBS, + %SNMP::Info::CiscoPortSecurity::MIBS, + %SNMP::Info::CiscoImage::MIBS, + %SNMP::Info::CiscoStats::MIBS, + %SNMP::Info::CDP::MIBS, + %SNMP::Info::CiscoVTP::MIBS, + 'CISCO-ENVMON-MIB' => 'ciscoEnvMonMIB', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::MAU::GLOBALS, - %SNMP::Info::CiscoConfig::GLOBALS, - %SNMP::Info::CiscoPortSecurity::GLOBALS, - %SNMP::Info::CiscoImage::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - 'ps1_type' => 'ciscoEnvMonSupplyStatusDescr.1', - 'ps1_status' => 'ciscoEnvMonSupplyState.1', - 'ps2_type' => 'ciscoEnvMonSupplyStatusDescr.2', - 'ps2_status' => 'ciscoEnvMonSupplyState.2', - ); + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::MAU::GLOBALS, + %SNMP::Info::CiscoConfig::GLOBALS, + %SNMP::Info::CiscoPortSecurity::GLOBALS, + %SNMP::Info::CiscoImage::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::CiscoVTP::GLOBALS, + 'ps1_type' => 'ciscoEnvMonSupplyStatusDescr.1', + 'ps1_status' => 'ciscoEnvMonSupplyState.1', + 'ps2_type' => 'ciscoEnvMonSupplyStatusDescr.2', + 'ps2_status' => 'ciscoEnvMonSupplyState.2', +); %FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::MAU::FUNCS, - %SNMP::Info::CiscoConfig::FUNCS, - %SNMP::Info::CiscoPortSecurity::FUNCS, - %SNMP::Info::CiscoImage::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - 'fan_state' => 'ciscoEnvMonFanState', - 'fan_descr' => 'ciscoEnvMonFanStatusDescr', - ); + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::MAU::FUNCS, + %SNMP::Info::CiscoConfig::FUNCS, + %SNMP::Info::CiscoPortSecurity::FUNCS, + %SNMP::Info::CiscoImage::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, + %SNMP::Info::CiscoVTP::FUNCS, + 'fan_state' => 'ciscoEnvMonFanState', + 'fan_descr' => 'ciscoEnvMonFanStatusDescr', +); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::MAU::MUNGE, - %SNMP::Info::CiscoConfig::MUNGE, - %SNMP::Info::CiscoPortSecurity::MUNGE, - %SNMP::Info::CiscoImage::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - ); + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::MAU::MUNGE, + %SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE, + %SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE, + %SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE, +); # Override Inheritance for these specific methods # use MAU-MIB for admin. duplex and admin. speed -*SNMP::Info::Layer3::C4000::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin; -*SNMP::Info::Layer3::C4000::i_speed_admin = \&SNMP::Info::MAU::mau_i_speed_admin; +*SNMP::Info::Layer3::C4000::i_duplex_admin + = \&SNMP::Info::MAU::mau_i_duplex_admin; +*SNMP::Info::Layer3::C4000::i_speed_admin + = \&SNMP::Info::MAU::mau_i_speed_admin; sub fan { - my $c4000 = shift; + my $c4000 = shift; my $fan_state = $c4000->fan_state(); my $fan_descr = $c4000->fan_descr(); - my $ret = ""; - my $s = ""; - foreach my $i (sort {$a <=> $b} keys %$fan_state) { - $ret .= $s . $fan_descr->{$i} . ": " . $fan_state->{$i}; - $s = ", "; + my $ret = ""; + my $s = ""; + foreach my $i ( sort { $a <=> $b } keys %$fan_state ) { + $ret .= $s . $fan_descr->{$i} . ": " . $fan_state->{$i}; + $s = ", "; } - return if ($s eq ""); + return if ( $s eq "" ); return $ret; } diff --git a/Info/Layer3/C6500.pm b/Info/Layer3/C6500.pm index c0bc4720..3ab4da44 100644 --- a/Info/Layer3/C6500.pm +++ b/Info/Layer3/C6500.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Max Baker # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -42,67 +42,56 @@ use SNMP::Info::CiscoConfig; use SNMP::Info::CiscoPower; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::C6500::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack - SNMP::Info::CDP SNMP::Info::CiscoStats - SNMP::Info::CiscoImage - SNMP::Info::CiscoPortSecurity - SNMP::Info::CiscoConfig - SNMP::Info::CiscoPower - SNMP::Info::Layer3 - Exporter/; +@SNMP::Info::Layer3::C6500::ISA + = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack + SNMP::Info::CDP SNMP::Info::CiscoStats + SNMP::Info::CiscoImage + SNMP::Info::CiscoPortSecurity + SNMP::Info::CiscoConfig + SNMP::Info::CiscoPower + SNMP::Info::Layer3 + Exporter/; @SNMP::Info::Layer3::C6500::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::CiscoPower::MIBS, - %SNMP::Info::CiscoConfig::MIBS, - %SNMP::Info::CiscoPortSecurity::MIBS, - %SNMP::Info::CiscoImage::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoStack::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoPower::MIBS, + %SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS, + %SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS, + %SNMP::Info::CDP::MIBS, %SNMP::Info::CiscoStack::MIBS, + %SNMP::Info::CiscoVTP::MIBS, +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::CiscoPower::GLOBALS, - %SNMP::Info::CiscoConfig::GLOBALS, - %SNMP::Info::CiscoPortSecurity::GLOBALS, - %SNMP::Info::CiscoImage::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoStack::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - ); + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::CiscoPower::GLOBALS, + %SNMP::Info::CiscoConfig::GLOBALS, + %SNMP::Info::CiscoPortSecurity::GLOBALS, + %SNMP::Info::CiscoImage::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, + %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::CiscoStack::GLOBALS, + %SNMP::Info::CiscoVTP::GLOBALS, +); %FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::CiscoPower::FUNCS, - %SNMP::Info::CiscoConfig::FUNCS, - %SNMP::Info::CiscoPortSecurity::FUNCS, - %SNMP::Info::CiscoImage::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoStack::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - ); + %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CiscoPower::FUNCS, + %SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS, + %SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, %SNMP::Info::CiscoStack::FUNCS, + %SNMP::Info::CiscoVTP::FUNCS, +); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::CiscoPower::MUNGE, - %SNMP::Info::CiscoConfig::MUNGE, - %SNMP::Info::CiscoPortSecurity::MUNGE, - %SNMP::Info::CiscoImage::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoStack::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - ); + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::CiscoPower::MUNGE, + %SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE, + %SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE, + %SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoStack::MUNGE, + %SNMP::Info::CiscoVTP::MUNGE, +); sub vendor { return 'cisco'; @@ -113,15 +102,15 @@ sub cisco_comm_indexing { return 1; } # Newer versions use the ETHERLIKE-MIB to report operational duplex. sub i_duplex { - my $c6500 = shift; + my $c6500 = shift; my $partial = shift; my $el_duplex = $c6500->el_duplex($partial); - # Newer software - if (defined $el_duplex and scalar(keys %$el_duplex)){ + # Newer software + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { my %i_duplex; - foreach my $el_port (keys %$el_duplex){ + foreach my $el_port ( keys %$el_duplex ) { my $duplex = $el_duplex->{$el_port}; next unless defined $duplex; @@ -130,6 +119,7 @@ sub i_duplex { } return \%i_duplex; } + # Fall back to CiscoStack method else { return $c6500->SUPER::i_duplex($partial); @@ -139,53 +129,55 @@ sub i_duplex { # Newer software uses portDuplex as admin setting sub i_duplex_admin { - my $c6500 = shift; + my $c6500 = shift; my $partial = shift; my $el_duplex = $c6500->el_duplex($partial); - # Newer software - if (defined $el_duplex and scalar(keys %$el_duplex)){ + # Newer software + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { my $p_port = $c6500->p_port() || {}; my $p_duplex = $c6500->p_duplex() || {}; - + my $i_duplex_admin = {}; - foreach my $port (keys %$p_duplex) { + foreach my $port ( keys %$p_duplex ) { my $iid = $p_port->{$port}; next unless defined $iid; - next if (defined $partial and $iid !~ /^$partial$/); - + next if ( defined $partial and $iid !~ /^$partial$/ ); + $i_duplex_admin->{$iid} = $p_duplex->{$port}; } return $i_duplex_admin; } + # Fall back to CiscoStack method else { return $c6500->SUPER::i_duplex_admin($partial); - } + } } sub set_i_duplex_admin { + # map a textual duplex to an integer one the switch understands my %duplexes = qw/half 1 full 2 auto 4/; my $c6500 = shift; - my ($duplex, $iid) = @_; + my ( $duplex, $iid ) = @_; my $el_duplex = $c6500->el_duplex($iid); # Auto duplex only supported on newer software - if (defined $el_duplex and scalar(keys %$el_duplex)){ - my $p_port = $c6500->p_port() || {}; + if ( defined $el_duplex and scalar( keys %$el_duplex ) ) { + my $p_port = $c6500->p_port() || {}; my %reverse_p_port = reverse %$p_port; - $duplex = lc($duplex); + $duplex = lc($duplex); - return 0 unless defined $duplexes{$duplex}; + return 0 unless defined $duplexes{$duplex}; - $iid = $reverse_p_port{$iid}; + $iid = $reverse_p_port{$iid}; - return $c6500->set_p_duplex($duplexes{$duplex}, $iid); + return $c6500->set_p_duplex( $duplexes{$duplex}, $iid ); } else { return $c6500->SUPER::set_i_duplex_admin; @@ -224,9 +216,9 @@ Max Baker Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches. -These devices run IOS but have some of the same characteristics as the Catalyst -WS-C family (5xxx). For example, forwarding tables are held in VLANs, and -extended interface information is gleaned from F. +These devices run IOS but have some of the same characteristics as the +Catalyst WS-C family (5xxx). For example, forwarding tables are held in +VLANs, and extended interface information is gleaned from F. For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above. diff --git a/Info/Layer3/Cisco.pm b/Info/Layer3/Cisco.pm index de176ccf..3b21c52f 100644 --- a/Info/Layer3/Cisco.pm +++ b/Info/Layer3/Cisco.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Max Baker # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -43,11 +43,11 @@ use SNMP::Info::CiscoPower; use SNMP::Info::Layer3; @SNMP::Info::Layer3::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP - SNMP::Info::CiscoStats SNMP::Info::CiscoImage - SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS - SNMP::Info::CiscoConfig SNMP::Info::CiscoPower - SNMP::Info::Layer3 - Exporter/; + SNMP::Info::CiscoStats SNMP::Info::CiscoImage + SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS + SNMP::Info::CiscoConfig SNMP::Info::CiscoPower + SNMP::Info::Layer3 + Exporter/; @SNMP::Info::Layer3::Cisco::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; @@ -55,74 +55,70 @@ use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::CiscoPower::MIBS, - %SNMP::Info::CiscoConfig::MIBS, - %SNMP::Info::CiscoQOS::MIBS, - %SNMP::Info::CiscoRTT::MIBS, - %SNMP::Info::CiscoImage::MIBS, - %SNMP::Info::CiscoStats::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::CiscoVTP::MIBS, - 'CISCO-EIGRP-MIB' => 'cEigrpAsRouterId', - ); + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::CiscoPower::MIBS, + %SNMP::Info::CiscoConfig::MIBS, + %SNMP::Info::CiscoQOS::MIBS, + %SNMP::Info::CiscoRTT::MIBS, + %SNMP::Info::CiscoImage::MIBS, + %SNMP::Info::CiscoStats::MIBS, + %SNMP::Info::CDP::MIBS, + %SNMP::Info::CiscoVTP::MIBS, + 'CISCO-EIGRP-MIB' => 'cEigrpAsRouterId', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::CiscoPower::GLOBALS, - %SNMP::Info::CiscoConfig::GLOBALS, - %SNMP::Info::CiscoQOS::GLOBALS, - %SNMP::Info::CiscoRTT::GLOBALS, - %SNMP::Info::CiscoImage::GLOBALS, - %SNMP::Info::CiscoStats::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::CiscoVTP::GLOBALS, - 'eigrp_id' => 'cEigrpAsRouterId', - ); + %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CiscoPower::GLOBALS, + %SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoQOS::GLOBALS, + %SNMP::Info::CiscoRTT::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS, + %SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::CiscoVTP::GLOBALS, 'eigrp_id' => 'cEigrpAsRouterId', +); %FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::CiscoPower::FUNCS, - %SNMP::Info::CiscoConfig::FUNCS, - %SNMP::Info::CiscoQOS::FUNCS, - %SNMP::Info::CiscoRTT::FUNCS, - %SNMP::Info::CiscoImage::FUNCS, - %SNMP::Info::CiscoStats::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::CiscoVTP::FUNCS, - # EIGRP - 'eigrp_peers' => 'cEigrpPeerAddr', - ); + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::CiscoPower::FUNCS, + %SNMP::Info::CiscoConfig::FUNCS, + %SNMP::Info::CiscoQOS::FUNCS, + %SNMP::Info::CiscoRTT::FUNCS, + %SNMP::Info::CiscoImage::FUNCS, + %SNMP::Info::CiscoStats::FUNCS, + %SNMP::Info::CDP::FUNCS, + %SNMP::Info::CiscoVTP::FUNCS, + + # EIGRP + 'eigrp_peers' => 'cEigrpPeerAddr', +); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::CiscoPower::MUNGE, - %SNMP::Info::CiscoConfig::MUNGE, - %SNMP::Info::CiscoQOS::MUNGE, - %SNMP::Info::CiscoRTT::MUNGE, - %SNMP::Info::CiscoImage::MUNGE, - %SNMP::Info::CiscoStats::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::CiscoVTP::MUNGE, - 'eigrp_peers' => \&SNMP::Info::munge_ip, - ); + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::CiscoPower::MUNGE, + %SNMP::Info::CiscoConfig::MUNGE, + %SNMP::Info::CiscoQOS::MUNGE, + %SNMP::Info::CiscoRTT::MUNGE, + %SNMP::Info::CiscoImage::MUNGE, + %SNMP::Info::CiscoStats::MUNGE, + %SNMP::Info::CDP::MUNGE, + %SNMP::Info::CiscoVTP::MUNGE, + 'eigrp_peers' => \&SNMP::Info::munge_ip, +); sub i_vlan { - my ($cisco) = shift; - my ($partial) = shift; + my ($cisco) = shift; + my ($partial) = shift; - my ($i_type) = $cisco->i_type($partial); - my ($i_descr) = $cisco->i_description($partial); - my %i_vlan; + my ($i_type) = $cisco->i_type($partial); + my ($i_descr) = $cisco->i_description($partial); + my %i_vlan; - foreach my $idx (keys %$i_descr) { - if ($i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135) { - if ($i_descr->{$idx} =~ /\.(\d+)$/) { - $i_vlan{$idx} = $1; - } - } - } - return \%i_vlan; + foreach my $idx ( keys %$i_descr ) { + if ( $i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135 ) { + if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) { + $i_vlan{$idx} = $1; + } + } + } + return \%i_vlan; } 1; diff --git a/Info/Layer3/Contivity.pm b/Info/Layer3/Contivity.pm index 1f4a18c1..268a5810 100644 --- a/Info/Layer3/Contivity.pm +++ b/Info/Layer3/Contivity.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,7 +36,8 @@ use SNMP::Info; use SNMP::Info::Layer3; use SNMP::Info::Entity; -@SNMP::Info::Layer3::Contivity::ISA = qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Entity Exporter/; +@SNMP::Info::Layer3::Contivity::ISA + = qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Entity Exporter/; @SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; @@ -44,28 +45,23 @@ use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::MIBS, - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::Entity::MIBS, - ); + %SNMP::Info::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::Entity::MIBS, +); %GLOBALS = ( - %SNMP::Info::GLOBALS, - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::Entity::GLOBALS, - ); + %SNMP::Info::GLOBALS, %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::Entity::GLOBALS, +); %FUNCS = ( - %SNMP::Info::FUNCS, - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::Entity::FUNCS, - ); - + %SNMP::Info::FUNCS, %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::Entity::FUNCS, +); + %MUNGE = ( - %SNMP::Info::MUNGE, - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::Entity::MUNGE, - ); + %SNMP::Info::MUNGE, %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::Entity::MUNGE, +); sub layers { return '00000100'; @@ -80,8 +76,8 @@ sub model { my $e_model = $contivity->e_model() || {}; my $model = $e_model->{1} || undef; - - return $1 if (defined $model and $model =~ /(CES\d+)/i); + + return $1 if ( defined $model and $model =~ /(CES\d+)/i ); return; } @@ -91,10 +87,10 @@ sub os { sub os_ver { my $contivity = shift; - my $descr = $contivity->description(); + my $descr = $contivity->description(); return unless defined $descr; - if ($descr =~ m/V(\d+_\d+\.\d+)/i){ + if ( $descr =~ m/V(\d+_\d+\.\d+)/i ) { return $1; } return; @@ -102,10 +98,10 @@ sub os_ver { sub mac { my $contivity = shift; - my $i_mac = $contivity->i_mac(); + my $i_mac = $contivity->i_mac(); -# Return Interface MAC - foreach my $entry (keys %$i_mac){ + # Return Interface MAC + foreach my $entry ( keys %$i_mac ) { my $sn = $i_mac->{$entry}; next unless $sn; return $sn; @@ -118,23 +114,23 @@ sub serial { my $e_serial = $contivity->e_serial() || {}; my $serial = $e_serial->{1} || undef; - - return $1 if (defined $serial and $serial =~ /(\d+)/); + + return $1 if ( defined $serial and $serial =~ /(\d+)/ ); return; } - sub interfaces { my $contivity = shift; - my $partial = shift; + my $partial = shift; my $description = $contivity->i_description($partial) || {}; - + my %interfaces = (); - foreach my $iid (keys %$description){ + foreach my $iid ( keys %$description ) { my $desc = $description->{$iid}; + # Skip everything except Ethernet interfaces - next unless (defined $desc and $desc =~ /fe/i); + next unless ( defined $desc and $desc =~ /fe/i ); $interfaces{$iid} = $desc; } @@ -143,21 +139,22 @@ sub interfaces { sub i_name { my $contivity = shift; - my $partial = shift; + my $partial = shift; my $i_name2 = $contivity->orig_i_name($partial) || {}; - + my %i_name; - foreach my $iid (keys %$i_name2){ + foreach my $iid ( keys %$i_name2 ) { my $name = $i_name2->{$iid}; + #Skip everything except Ethernet interfaces - next unless (defined $name and $name =~ /fe/i); + next unless ( defined $name and $name =~ /fe/i ); $name = $1 if $name =~ /(fei\.\d+\.\d+)/; $i_name{$iid} = $name; - } - return \%i_name; + } + return \%i_name; } 1; @@ -165,8 +162,8 @@ __END__ =head1 NAME -SNMP::Info::Layer3::Contivity - SNMP Interface to Nortel VPN Routers (Contivity -Extranet Switches). +SNMP::Info::Layer3::Contivity - SNMP Interface to Nortel VPN Routers +(Contivity Extranet Switches). =head1 AUTHOR diff --git a/Info/Layer3/Dell.pm b/Info/Layer3/Dell.pm index e1056409..0ada9ac6 100644 --- a/Info/Layer3/Dell.pm +++ b/Info/Layer3/Dell.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,84 +34,88 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Dell::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, - 'RADLAN-Physicaldescription-MIB' => 'rlPhdStackReorder', - 'RADLAN-rlInterfaces' => 'rlIfNumOfLoopbackPorts', - 'RADLAN-HWENVIROMENT' => 'rlEnvPhysicalDescription', - 'Dell-Vendor-MIB' => 'productIdentificationVersion', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + 'RADLAN-Physicaldescription-MIB' => 'rlPhdStackReorder', + 'RADLAN-rlInterfaces' => 'rlIfNumOfLoopbackPorts', + 'RADLAN-HWENVIROMENT' => 'rlEnvPhysicalDescription', + 'Dell-Vendor-MIB' => 'productIdentificationVersion', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'os_ver' => 'productIdentificationVersion', - 'dell_id_name' => 'productIdentificationDisplayName', - ); + %SNMP::Info::Layer3::GLOBALS, + 'os_ver' => 'productIdentificationVersion', + 'dell_id_name' => 'productIdentificationDisplayName', +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - # RADLAN-rlInterfaces:swIfTable - 'dell_duplex_admin' => 'swIfDuplexAdminMode', - 'dell_duplex' => 'swIfDuplexOperMode', - 'dell_tag_mode' => 'swIfTaggedMode', - 'dell_i_type' => 'swIfType', - 'dell_fc_admin' => 'swIfFlowControlMode', - 'dell_speed_admin' => 'swIfSpeedAdminMode', - 'dell_auto' => 'swIfSpeedDuplexAutoNegotiation', - 'dell_fc' => 'swIfOperFlowControlMode', - # RADLAN-Physicaldescription-MIB:rlPhdUnitGenParamTable - 'dell_unit' => 'rlPhdUnitGenParamStackUnit', - 'dell_sw_ver' => 'rlPhdUnitGenParamSoftwareVersion', - 'dell_fw_ver' => 'rlPhdUnitGenParamFirmwareVersion', - 'dell_hw_ver' => 'rlPhdUnitGenParamHardwareVersion', - 'dell_serial_no' => 'rlPhdUnitGenParamSerialNum', - 'dell_asset_no' => 'rlPhdUnitGenParamAssetTag', - # RADLAN-COPY-MIB:rlCopyTable - 'dell_cp_idx' => 'rlCopyIndex', - 'dell_cp_sloc' => 'rlCopySourceLocation', - 'dell_cp_sip' => 'rlCopySourceIpAddress', - 'dell_cp_sunit' => 'rlCopySourceUnitNumber', - 'dell_cp_sfile' => 'rlCopySourceFileName', - 'dell_cp_stype' => 'rlCopySourceFileType', - 'dell_cp_dloc' => 'rlCopyDestinationLocation', - 'dell_cp_dip' => 'rlCopyDestinationIpAddress', - 'dell_cp_dunit' => 'rlCopyDestinationUnitNumber', - 'dell_cp_dfile' => 'rlCopyDestinationFileName', - 'dell_cp_dtype' => 'rlCopyDestinationFileType', - 'dell_cp_state' => 'rlCopyOperationState', - 'dell_cp_bkgnd' => 'rlCopyInBackground', - 'dell_cp_rstatus' => 'rlCopyRowStatus', - # RADLAN-HWENVIROMENT:rlEnvMonSupplyStatusTable - 'dell_pwr_src' => 'rlEnvMonSupplySource', - 'dell_pwr_state' => 'rlEnvMonSupplyState', - 'dell_pwr_desc' => 'rlEnvMonSupplyStatusDescr', - # RADLAN-HWENVIROMENT:rlEnvMonFanStatusTable - 'dell_fan_state' => 'rlEnvMonFanState', - 'dell_fan_desc' => 'rlEnvMonFanStatusDescr', - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + # RADLAN-rlInterfaces:swIfTable + 'dell_duplex_admin' => 'swIfDuplexAdminMode', + 'dell_duplex' => 'swIfDuplexOperMode', + 'dell_tag_mode' => 'swIfTaggedMode', + 'dell_i_type' => 'swIfType', + 'dell_fc_admin' => 'swIfFlowControlMode', + 'dell_speed_admin' => 'swIfSpeedAdminMode', + 'dell_auto' => 'swIfSpeedDuplexAutoNegotiation', + 'dell_fc' => 'swIfOperFlowControlMode', -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - ); + # RADLAN-Physicaldescription-MIB:rlPhdUnitGenParamTable + 'dell_unit' => 'rlPhdUnitGenParamStackUnit', + 'dell_sw_ver' => 'rlPhdUnitGenParamSoftwareVersion', + 'dell_fw_ver' => 'rlPhdUnitGenParamFirmwareVersion', + 'dell_hw_ver' => 'rlPhdUnitGenParamHardwareVersion', + 'dell_serial_no' => 'rlPhdUnitGenParamSerialNum', + 'dell_asset_no' => 'rlPhdUnitGenParamAssetTag', + + # RADLAN-COPY-MIB:rlCopyTable + 'dell_cp_idx' => 'rlCopyIndex', + 'dell_cp_sloc' => 'rlCopySourceLocation', + 'dell_cp_sip' => 'rlCopySourceIpAddress', + 'dell_cp_sunit' => 'rlCopySourceUnitNumber', + 'dell_cp_sfile' => 'rlCopySourceFileName', + 'dell_cp_stype' => 'rlCopySourceFileType', + 'dell_cp_dloc' => 'rlCopyDestinationLocation', + 'dell_cp_dip' => 'rlCopyDestinationIpAddress', + 'dell_cp_dunit' => 'rlCopyDestinationUnitNumber', + 'dell_cp_dfile' => 'rlCopyDestinationFileName', + 'dell_cp_dtype' => 'rlCopyDestinationFileType', + 'dell_cp_state' => 'rlCopyOperationState', + 'dell_cp_bkgnd' => 'rlCopyInBackground', + 'dell_cp_rstatus' => 'rlCopyRowStatus', + + # RADLAN-HWENVIROMENT:rlEnvMonSupplyStatusTable + 'dell_pwr_src' => 'rlEnvMonSupplySource', + 'dell_pwr_state' => 'rlEnvMonSupplyState', + 'dell_pwr_desc' => 'rlEnvMonSupplyStatusDescr', + + # RADLAN-HWENVIROMENT:rlEnvMonFanStatusTable + 'dell_fan_state' => 'rlEnvMonFanState', + 'dell_fan_desc' => 'rlEnvMonFanStatusDescr', +); + +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); # Method OverRides sub model { my $dell = shift; - my $name = $dell->dell_id_name(); + my $name = $dell->dell_id_name(); my $descr = $dell->description(); - if (defined $name and $name =~ m/(\d+)/){ + if ( defined $name and $name =~ m/(\d+)/ ) { return $1; } + # Don't have a vendor MIB for D-Link else { return $descr; @@ -120,24 +124,24 @@ sub model { sub vendor { my $dell = shift; - + return $dell->_vendor(); } sub os { my $dell = shift; - + return $dell->_vendor(); } sub serial { - my $dell = shift; + my $dell = shift; my $numbers = $dell->dell_serial_no(); - - foreach my $key (keys %$numbers){ - my $serial = $numbers->{$key}; - return $serial if (defined $serial and $serial !~ /^\s*$/); + + foreach my $key ( keys %$numbers ) { + my $serial = $numbers->{$key}; + return $serial if ( defined $serial and $serial !~ /^\s*$/ ); next; } @@ -146,41 +150,41 @@ sub serial { } sub interfaces { - my $dell = shift; + my $dell = shift; my $partial = shift; my $i_descr = $dell->i_description($partial) || {}; - my $i_name = $dell->i_name($partial) || {}; + my $i_name = $dell->i_name($partial) || {}; # Descriptions are all the same on some Dells, so use name instead if # available - foreach my $iid (keys %$i_name){ + foreach my $iid ( keys %$i_name ) { my $name = $i_name->{$iid}; next unless defined $name; $i_descr->{$iid} = $name; } - + return $i_descr; } sub i_duplex_admin { - my $dell = shift; + my $dell = shift; my $partial = shift; - - my $interfaces = $dell->interfaces($partial) || {}; + + my $interfaces = $dell->interfaces($partial) || {}; my $dell_duplex = $dell->dell_duplex_admin($partial) || {}; - my $dell_auto = $dell->dell_auto($partial) || {}; - + my $dell_auto = $dell->dell_auto($partial) || {}; + my %i_duplex_admin; - foreach my $if (keys %$interfaces){ + foreach my $if ( keys %$interfaces ) { my $duplex = $dell_duplex->{$if}; next unless defined $duplex; - my $auto = $dell_auto->{$if}||'false'; - - $duplex = 'half' if ($duplex =~ /half/i and $auto =~ /false/i); - $duplex = 'full' if ($duplex =~ /half/i and $auto =~ /false/i); + my $auto = $dell_auto->{$if} || 'false'; + + $duplex = 'half' if ( $duplex =~ /half/i and $auto =~ /false/i ); + $duplex = 'full' if ( $duplex =~ /half/i and $auto =~ /false/i ); $duplex = 'auto' if $auto =~ /true/i; - $i_duplex_admin{$if}=$duplex; + $i_duplex_admin{$if} = $duplex; } return \%i_duplex_admin; } @@ -192,31 +196,31 @@ sub i_duplex_admin { # return anything. sub fw_mac { my $dell = shift; - my $ret = $dell->qb_fw_mac(); - $ret = $dell->orig_fw_mac() if (!defined($ret)); + my $ret = $dell->qb_fw_mac(); + $ret = $dell->orig_fw_mac() if ( !defined($ret) ); return $ret; } sub fw_port { my $dell = shift; - my $ret = $dell->qb_fw_port(); - $ret = $dell->orig_fw_port() if (!defined($ret)); + my $ret = $dell->qb_fw_port(); + $ret = $dell->orig_fw_port() if ( !defined($ret) ); return $ret; } sub _vendor { my $dell = shift; - my $id = $dell->id() || 'undef'; + my $id = $dell->id() || 'undef'; my %oidmap = ( - 2 => 'ibm', - 171 => 'dlink', - 674 => 'dell', - 3955 => 'linksys', - ); - $id = $1 if (defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/); + 2 => 'ibm', + 171 => 'dlink', + 674 => 'dell', + 3955 => 'linksys', + ); + $id = $1 if ( defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/ ); - if (defined($id) and exists($oidmap{$id})) { + if ( defined($id) and exists( $oidmap{$id} ) ) { return $oidmap{$id}; } else { @@ -229,7 +233,8 @@ __END__ =head1 NAME -SNMP::Info::Layer3::Dell - SNMP Interface to Dell Power Connect Network Devices +SNMP::Info::Layer3::Dell - SNMP Interface to Dell Power Connect Network +Devices =head1 AUTHOR @@ -304,8 +309,9 @@ These are methods that return scalar value from SNMP =item $dell->model() -Returns model type. Returns numeric from (C) -if available, otherwise if returns description(). +Returns model type. Returns numeric from +(C) if available, otherwise if returns +description(). =item $dell->vendor() @@ -383,13 +389,14 @@ to a hash. =item $dell->interfaces() -Returns the map between SNMP Interface Identifier (iid) and physical port name. -Uses name if available instead of description since descriptions are +Returns the map between SNMP Interface Identifier (iid) and physical port +name. Uses name if available instead of description since descriptions are sometimes not unique. =item $dell->i_duplex_admin() -Returns reference to hash of iid to current link administrative duplex setting. +Returns reference to hash of iid to current link administrative duplex +setting. =item $dell->fw_mac() diff --git a/Info/Layer3/Enterasys.pm b/Info/Layer3/Enterasys.pm index c3034cb6..ce63b2e0 100644 --- a/Info/Layer3/Enterasys.pm +++ b/Info/Layer3/Enterasys.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -38,8 +38,8 @@ use SNMP::Info::CDP; use SNMP::Info::Layer3; @SNMP::Info::Layer3::Enterasys::ISA = qw/SNMP::Info::MAU SNMP::Info::LLDP - SNMP::Info::CDP SNMP::Info::Layer3 - Exporter/; + SNMP::Info::CDP SNMP::Info::Layer3 + Exporter/; @SNMP::Info::Layer3::Enterasys::EXPORT_OK = qw//; use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/; @@ -47,44 +47,38 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::CDP::MIBS, - %SNMP::Info::LLDP::MIBS, - %SNMP::Info::MAU::MIBS, - 'ENTERASYS-OIDS-MIB' => 'etsysOidDevice', - ); + %SNMP::Info::Layer3::MIBS, %SNMP::Info::CDP::MIBS, + %SNMP::Info::LLDP::MIBS, %SNMP::Info::MAU::MIBS, + 'ENTERASYS-OIDS-MIB' => 'etsysOidDevice', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::CDP::GLOBALS, - %SNMP::Info::LLDP::GLOBALS, - %SNMP::Info::MAU::GLOBALS, - 'mac' => 'dot1dBaseBridgeAddress', - ); + %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CDP::GLOBALS, + %SNMP::Info::LLDP::GLOBALS, %SNMP::Info::MAU::GLOBALS, + 'mac' => 'dot1dBaseBridgeAddress', +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::CDP::FUNCS, - %SNMP::Info::LLDP::FUNCS, - %SNMP::Info::MAU::FUNCS, - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CDP::FUNCS, + %SNMP::Info::LLDP::FUNCS, %SNMP::Info::MAU::FUNCS, +); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::CDP::MUNGE, - %SNMP::Info::LLDP::MUNGE, - %SNMP::Info::MAU::MUNGE, - ); + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::CDP::MUNGE, + %SNMP::Info::LLDP::MUNGE, %SNMP::Info::MAU::MUNGE, +); sub model { my $enterasys = shift; - my $id = $enterasys->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::Enterasys::model() - Device does not support sysObjectID\n" if $enterasys->debug(); + my $id = $enterasys->id(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::Enterasys::model() - Device does not support sysObjectID\n" + if $enterasys->debug(); return; } - + my $model = &SNMP::translateObj($id); $model =~ s/^etsysOidDev//i; @@ -104,10 +98,10 @@ sub os { sub os_ver { my $enterasys = shift; - my $descr = $enterasys->description(); + my $descr = $enterasys->description(); return unless defined $descr; - if ($descr =~ m/\bRev ([\d.]*)/){ + if ( $descr =~ m/\bRev ([\d.]*)/ ) { return $1; } @@ -117,23 +111,24 @@ sub os_ver { # Use ifName as it is used for CDP and LLDP. sub interfaces { my $enterasys = shift; - my $partial = shift; + my $partial = shift; # We need the original ifName, SUPER:: would give us a method definition # in a higher class, we could use orig_ but just call the MIB leaf since # that's what we really want anyway. - return $enterasys->ifName($partial) || $enterasys->i_description($partial); + return $enterasys->ifName($partial) + || $enterasys->i_description($partial); } sub i_ignore { my $enterasys = shift; - my $partial = shift; - + my $partial = shift; + my $interfaces = $enterasys->i_type($partial) || {}; my %i_ignore; - foreach my $if (keys %$interfaces) { - if ($interfaces->{$if} =~ /(rs232|tunnel|loopback|\blo\b|null)/i){ + foreach my $if ( keys %$interfaces ) { + if ( $interfaces->{$if} =~ /(rs232|tunnel|loopback|\blo\b|null)/i ) { $i_ignore{$if}++; } } @@ -142,15 +137,15 @@ sub i_ignore { sub i_duplex { my $enterasys = shift; - my $partial = shift; - + my $partial = shift; + return $enterasys->mau_i_duplex($partial); } sub i_duplex_admin { my $enterasys = shift; - my $partial = shift; - + my $partial = shift; + return $enterasys->mau_i_duplex_admin($partial); } @@ -158,24 +153,25 @@ sub i_duplex_admin { # non-increasing oids, Use Q-BRIDGE-MIB for macsuck sub fw_mac { my $enterasys = shift; - my $partial = shift; + my $partial = shift; return $enterasys->qb_fw_mac($partial); } sub fw_port { my $enterasys = shift; - my $partial = shift; + my $partial = shift; return $enterasys->qb_fw_port($partial); } # Use CDP and/or LLDP # -# LLDP table timefilter implementation continuously increments when walked and -# we may never reach the end of the table. This behavior can be modified with -# the "set snmp timefilter break disable" command, unfortunately it is not -# the default. Query with a partial value of zero which means no time filter. +# LLDP table timefilter implementation continuously increments when walked +# and we may never reach the end of the table. This behavior can be +# modified with the "set snmp timefilter break disable" command, +# unfortunately it is not the default. Query with a partial value of zero +# which means no time filter. sub hasCDP { my $enterasys = shift; @@ -185,20 +181,20 @@ sub hasCDP { sub c_ip { my $enterasys = shift; - my $partial = shift; + my $partial = shift; my $cdp = $enterasys->SUPER::c_ip($partial) || {}; - my $lldp = $enterasys->lldp_ip(0) || {}; + my $lldp = $enterasys->lldp_ip(0) || {}; my %c_ip; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $ip = $cdp->{$iid}; next unless defined $ip; $c_ip{$iid} = $ip; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $ip = $lldp->{$iid}; next unless defined $ip; @@ -209,20 +205,20 @@ sub c_ip { sub c_if { my $enterasys = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $enterasys->lldp_if(0) || {};; + my $lldp = $enterasys->lldp_if(0) || {}; my $cdp = $enterasys->SUPER::c_if($partial) || {}; - + my %c_if; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $if = $cdp->{$iid}; next unless defined $if; $c_if{$iid} = $if; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $if = $lldp->{$iid}; next unless defined $if; @@ -233,20 +229,20 @@ sub c_if { sub c_port { my $enterasys = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $enterasys->lldp_port(0) || {}; + my $lldp = $enterasys->lldp_port(0) || {}; my $cdp = $enterasys->SUPER::c_port($partial) || {}; - + my %c_port; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $port = $cdp->{$iid}; next unless defined $port; $c_port{$iid} = $port; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $port = $lldp->{$iid}; next unless defined $port; @@ -257,20 +253,20 @@ sub c_port { sub c_id { my $enterasys = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $enterasys->lldp_id(0) || {}; + my $lldp = $enterasys->lldp_id(0) || {}; my $cdp = $enterasys->SUPER::c_id($partial) || {}; my %c_id; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $id = $cdp->{$iid}; next unless defined $id; $c_id{$iid} = $id; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $id = $lldp->{$iid}; next unless defined $id; @@ -281,20 +277,20 @@ sub c_id { sub c_platform { my $enterasys = shift; - my $partial = shift; + my $partial = shift; - my $lldp = $enterasys->lldp_rem_sysdesc(0) || {}; + my $lldp = $enterasys->lldp_rem_sysdesc(0) || {}; my $cdp = $enterasys->SUPER::c_platform($partial) || {}; my %c_platform; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $platform = $cdp->{$iid}; next unless defined $platform; $c_platform{$iid} = $platform; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $platform = $lldp->{$iid}; next unless defined $platform; @@ -380,7 +376,8 @@ These are methods that return scalar value from SNMP =item $enterasys->model() -Returns model type. Checks $enterasys->id() against the F. +Returns model type. Checks $enterasys->id() against the +F. =item $enterasys->vendor() diff --git a/Info/Layer3/Extreme.pm b/Info/Layer3/Extreme.pm index 09d057ac..8c3965a3 100644 --- a/Info/Layer3/Extreme.pm +++ b/Info/Layer3/Extreme.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,74 +37,83 @@ use Exporter; use SNMP::Info::Layer3; use SNMP::Info::MAU; -@SNMP::Info::Layer3::Extreme::ISA = qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/; +@SNMP::Info::Layer3::Extreme::ISA + = qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/; @SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, - %SNMP::Info::MAU::MIBS, - 'EXTREME-BASE-MIB' => 'extremeAgent', - 'EXTREME-SYSTEM-MIB' => 'extremeSystem', - 'EXTREME-FDB-MIB' => 'extremeSystem', - 'EXTREME-VLAN-MIB' => 'extremeVlan', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::MAU::MIBS, + 'EXTREME-BASE-MIB' => 'extremeAgent', + 'EXTREME-SYSTEM-MIB' => 'extremeSystem', + 'EXTREME-FDB-MIB' => 'extremeSystem', + 'EXTREME-VLAN-MIB' => 'extremeVlan', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::MAU::GLOBALS, - 'serial1' => 'extremeSystemID.0', - 'temp' => 'extremeCurrentTemperature', - 'ps1_status_old' => 'extremePrimaryPowerOperational.0', - 'ps1_status_new' => 'extremePowerSupplyStatus.1', - 'ps2_status_old' => 'extremeRedundantPowerStatus.0', - 'ps2_status_new' => 'extremePowerSupplyStatus.2', - 'mac' => 'dot1dBaseBridgeAddress', - ); + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::MAU::GLOBALS, + 'serial1' => 'extremeSystemID.0', + 'temp' => 'extremeCurrentTemperature', + 'ps1_status_old' => 'extremePrimaryPowerOperational.0', + 'ps1_status_new' => 'extremePowerSupplyStatus.1', + 'ps2_status_old' => 'extremeRedundantPowerStatus.0', + 'ps2_status_new' => 'extremePowerSupplyStatus.2', + 'mac' => 'dot1dBaseBridgeAddress', +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::MAU::FUNCS, - 'fan_state' => 'extremeFanOperational', - # EXTREME-FDB-MIB:extremeFdbMacFdbTable - 'ex_fw_mac' => 'extremeFdbMacFdbMacAddress', - 'ex_fw_port' => 'extremeFdbMacFdbPortIfIndex', - 'ex_fw_status' => 'extremeFdbMacFdbStatus', - # EXTREME-VLAN-MIB:extremeVlanIfTable - 'ex_vlan_descr' => 'extremeVlanIfDescr', - 'ex_vlan_global_id' => 'extremeVlanIfGlobalIdentifier', - # EXTREME-VLAN-MIB:extremeVlanEncapsIfTable - 'ex_vlan_encap_tag' => 'extremeVlanEncapsIfTag', - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::MAU::FUNCS, + 'fan_state' => 'extremeFanOperational', + + # EXTREME-FDB-MIB:extremeFdbMacFdbTable + 'ex_fw_mac' => 'extremeFdbMacFdbMacAddress', + 'ex_fw_port' => 'extremeFdbMacFdbPortIfIndex', + 'ex_fw_status' => 'extremeFdbMacFdbStatus', + + # EXTREME-VLAN-MIB:extremeVlanIfTable + 'ex_vlan_descr' => 'extremeVlanIfDescr', + 'ex_vlan_global_id' => 'extremeVlanIfGlobalIdentifier', + + # EXTREME-VLAN-MIB:extremeVlanEncapsIfTable + 'ex_vlan_encap_tag' => 'extremeVlanEncapsIfTag', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::MAU::MUNGE, - 'ex_fw_mac' => \&SNMP::Info::munge_mac, - 'ps1_status_old' => \&munge_true_ok, - 'ps1_status_new' => \&munge_power_stat, - 'ps2_status_old' => \&munge_power_stat, - 'ps2_status_new' => \&munge_power_stat, - 'fan_state' => \&munge_true_ok, - ); + + # Inherit all the built in munging + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::MAU::MUNGE, + 'ex_fw_mac' => \&SNMP::Info::munge_mac, + 'ps1_status_old' => \&munge_true_ok, + 'ps1_status_new' => \&munge_power_stat, + 'ps2_status_old' => \&munge_power_stat, + 'ps2_status_new' => \&munge_power_stat, + 'fan_state' => \&munge_true_ok, +); # Method OverRides -*SNMP::Info::Layer3::Extreme::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; -*SNMP::Info::Layer3::Extreme::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin; +*SNMP::Info::Layer3::Extreme::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; +*SNMP::Info::Layer3::Extreme::i_duplex_admin + = \&SNMP::Info::MAU::mau_i_duplex_admin; sub model { my $extreme = shift; - my $id = $extreme->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n" if $extreme->debug(); + my $id = $extreme->id(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n" + if $extreme->debug(); return; } - + my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -122,10 +131,10 @@ sub os { sub os_ver { my $extreme = shift; - my $descr = $extreme->description(); + my $descr = $extreme->description(); return unless defined $descr; - if ($descr =~ m/Version ([\d.]*)/){ + if ( $descr =~ m/Version ([\d.]*)/ ) { return $1; } @@ -139,15 +148,16 @@ sub os_ver { # assigned for router interfaces, so we use ifDescr # for those. sub interfaces { - my $extreme = shift; - my $partial = shift; - my $i_name = $extreme->orig_i_name($partial); + my $extreme = shift; + my $partial = shift; + my $i_name = $extreme->orig_i_name($partial); my $i_description = $extreme->orig_i_description($partial); - my $interfaces = {}; - foreach my $idx (keys %$i_name) { - if ($i_name->{$idx} =~ /\([0-9.]+\)/) { + my $interfaces = {}; + foreach my $idx ( keys %$i_name ) { + if ( $i_name->{$idx} =~ /\([0-9.]+\)/ ) { $interfaces->{$idx} = $i_description->{$idx}; - } else { + } + else { $interfaces->{$idx} = $i_name->{$idx}; } } @@ -159,12 +169,14 @@ sub interfaces { sub i_ignore { my $extreme = shift; my $partial = shift; - + my $i_description = $extreme->i_description($partial) || {}; my %i_ignore; - foreach my $if (keys %$i_description) { - if ($i_description->{$if} =~ /^(802.1Q Encapsulation Tag \d+|VLAN \d+|lo\d+)/i){ + foreach my $if ( keys %$i_description ) { + if ( $i_description->{$if} + =~ /^(802.1Q Encapsulation Tag \d+|VLAN \d+|lo\d+)/i ) + { $i_ignore{$if}++; } } @@ -175,11 +187,11 @@ sub i_ignore { # Either way, Extreme uses a 1:1 mapping of bridge interface ID to # ifIndex. sub bp_index { - my $extreme = shift; + my $extreme = shift; my $if_index = $extreme->i_index(); my %bp_index; - foreach my $iid (keys %$if_index){ + foreach my $iid ( keys %$if_index ) { $bp_index{$iid} = $iid; } return \%bp_index; @@ -188,8 +200,8 @@ sub bp_index { sub munge_true_ok { my $val = shift; return unless defined($val); - return "OK" if ($val eq 'true'); - return "Not OK" if ($val eq 'false'); + return "OK" if ( $val eq 'true' ); + return "Not OK" if ( $val eq 'false' ); return $val; } @@ -202,27 +214,27 @@ sub munge_power_stat { } sub ps1_status { - my $extreme = shift; + my $extreme = shift; my $ps1_status = $extreme->ps1_status_new(); return $ps1_status || $extreme->ps1_status_old(); } sub ps2_status { - my $extreme = shift; + my $extreme = shift; my $ps2_status = $extreme->ps2_status_new(); return $ps2_status || $extreme->ps2_status_old(); } sub fan { - my $extreme = shift; + my $extreme = shift; my $fan_state = $extreme->fan_state(); - my $ret = ""; - my $s = ""; - foreach my $i (sort {$a <=> $b} keys %$fan_state) { + my $ret = ""; + my $s = ""; + foreach my $i ( sort { $a <=> $b } keys %$fan_state ) { $ret .= $s . $i . ": " . $fan_state->{$i}; $s = ", "; } - return if ($s eq ""); + return if ( $s eq "" ); return $ret; } @@ -231,7 +243,7 @@ sub fan { # these tables, so we use the BRIDGE-MIB tables. sub fw_mac { my $extreme = shift; - my $fw_mac = $extreme->ex_fw_mac; + my $fw_mac = $extreme->ex_fw_mac; return $fw_mac if defined($fw_mac); return $extreme->orig_fw_mac(); } @@ -244,7 +256,7 @@ sub fw_port { } sub fw_status { - my $extreme = shift; + my $extreme = shift; my $fw_status = $extreme->ex_fw_status; return $fw_status if defined($fw_status); return $extreme->orig_fw_status(); @@ -260,35 +272,38 @@ sub fw_status { # To represent this, we use a negative version of the # internal VLAN ID (the deprecated extremeVlanIfGlobalIdentifier) sub _if2tag { - my $extreme = shift; - my $partial = shift; - my $stack = shift || $extreme->ifStackStatus($partial); - my $encap_tag = $extreme->ex_vlan_encap_tag(); + my $extreme = shift; + my $partial = shift; + my $stack = shift || $extreme->ifStackStatus($partial); + my $encap_tag = $extreme->ex_vlan_encap_tag(); my $vlan_descr = $extreme->ex_vlan_descr(); my $stackmap = {}; - foreach my $idx (keys %$stack) { - my ($higher, $lower) = split(/\./, $idx); + foreach my $idx ( keys %$stack ) { + my ( $higher, $lower ) = split( /\./, $idx ); $stackmap->{$higher}->{$lower} = $stack->{$idx}; } my %if2tag = (); my $missed = 0; - foreach my $if (keys %$vlan_descr) { + foreach my $if ( keys %$vlan_descr ) { $if2tag{$if} = -1; - foreach my $tagif (keys %$encap_tag) { - if (defined($stackmap->{$if}->{$tagif}) && $stackmap->{$if}->{$tagif} eq 'active') { + foreach my $tagif ( keys %$encap_tag ) { + if ( defined( $stackmap->{$if}->{$tagif} ) + && $stackmap->{$if}->{$tagif} eq 'active' ) + { $if2tag{$if} = $encap_tag->{$tagif}; } } - if ($if2tag{$if} == -1) { + if ( $if2tag{$if} == -1 ) { $missed++; } } if ($missed) { my $global_id = $extreme->ex_vlan_global_id(); - foreach my $if (keys %if2tag) { - $if2tag{$if} = -$global_id->{$if} if ($if2tag{$if} == -1 && defined($global_id->{$if})); + foreach my $if ( keys %if2tag ) { + $if2tag{$if} = -$global_id->{$if} + if ( $if2tag{$if} == -1 && defined( $global_id->{$if} ) ); } } return \%if2tag; @@ -308,23 +323,24 @@ sub v_index { } sub i_vlan { - my $extreme = shift; - my $partial = shift; - my $stack = $extreme->ifStackStatus($partial); - my $encap_tag = $extreme->ex_vlan_encap_tag(); + my $extreme = shift; + my $partial = shift; + my $stack = $extreme->ifStackStatus($partial); + my $encap_tag = $extreme->ex_vlan_encap_tag(); my $vlan_descr = $extreme->ex_vlan_descr(); - my $stackmap = {}; - foreach my $idx (keys %$stack) { - my ($higher, $lower) = split(/\./, $idx); + my $stackmap = {}; + foreach my $idx ( keys %$stack ) { + my ( $higher, $lower ) = split( /\./, $idx ); $stackmap->{$higher}->{$lower} = $stack->{$idx}; } - my $if2tag = $extreme->_if2tag($partial, $stack); + my $if2tag = $extreme->_if2tag( $partial, $stack ); + # # Now that we've done all that mapping work, we can map the # ifStack indexes. my %i_vlan = (); - foreach my $if (keys %$if2tag) { - foreach my $lowif (keys %{$stackmap->{$if}}) { + foreach my $if ( keys %$if2tag ) { + foreach my $lowif ( keys %{ $stackmap->{$if} } ) { $i_vlan{$lowif} = $if2tag->{$if}; } } @@ -332,31 +348,33 @@ sub i_vlan { } sub i_vlan_membership { - my $extreme = shift; - my $partial = shift; - my $stack = $extreme->ifStackStatus($partial); - my $encap_tag = $extreme->ex_vlan_encap_tag(); + my $extreme = shift; + my $partial = shift; + my $stack = $extreme->ifStackStatus($partial); + my $encap_tag = $extreme->ex_vlan_encap_tag(); my $vlan_descr = $extreme->ex_vlan_descr(); - my $stackmap = {}; - foreach my $idx (keys %$stack) { - my ($higher, $lower) = split(/\./, $idx); + my $stackmap = {}; + foreach my $idx ( keys %$stack ) { + my ( $higher, $lower ) = split( /\./, $idx ); $stackmap->{$higher}->{$lower} = $stack->{$idx}; } - my $if2tag = $extreme->_if2tag($partial, $stack); + my $if2tag = $extreme->_if2tag( $partial, $stack ); + # # Now that we've done all that mapping work, we can map the # ifStack indexes. my %i_vlan_membership = (); - foreach my $if (keys %$if2tag) { - foreach my $lowif (keys %{$stackmap->{$if}}) { - push(@{$i_vlan_membership{$lowif}}, $if2tag->{$if}); + foreach my $if ( keys %$if2tag ) { + foreach my $lowif ( keys %{ $stackmap->{$if} } ) { + push( @{ $i_vlan_membership{$lowif} }, $if2tag->{$if} ); } } + # # Now add all the tagged ports. - foreach my $if (keys %$encap_tag) { - foreach my $lowif (keys %{$stackmap->{$if}}) { - push(@{$i_vlan_membership{$lowif}}, $encap_tag->{$if}); + foreach my $if ( keys %$encap_tag ) { + foreach my $lowif ( keys %{ $stackmap->{$if} } ) { + push( @{ $i_vlan_membership{$lowif} }, $encap_tag->{$if} ); } } return \%i_vlan_membership; @@ -368,12 +386,12 @@ sub i_vlan_membership { sub set_i_vlan { my $extreme = shift; - return $extreme->_extreme_set_i_vlan(0, @_); + return $extreme->_extreme_set_i_vlan( 0, @_ ); } sub set_i_pvid { my $extreme = shift; - return $extreme->_extreme_set_i_vlan(1, @_); + return $extreme->_extreme_set_i_vlan( 1, @_ ); } # set_i_vlan implicitly turns off any encapsulation @@ -384,98 +402,127 @@ sub set_i_pvid { # off any encapsulation. sub _extreme_set_i_vlan { my $extreme = shift; - my ($is_pvid, $vlan_id, $ifindex) = @_; + my ( $is_pvid, $vlan_id, $ifindex ) = @_; my $encap_tag = $extreme->ex_vlan_encap_tag(); + # The inverted stack MIB would make this easier, since # we need to find the vlan interface # that's stacked above $ifindex. my $cur_stack = $extreme->ifStackStatus(); + # # create inverted stack my $invstack; - foreach my $idx (keys %$cur_stack) { - my ($higher, $lower) = split(/\./, $idx); + foreach my $idx ( keys %$cur_stack ) { + my ( $higher, $lower ) = split( /\./, $idx ); $invstack->{$lower}->{$higher} = $cur_stack->{$idx}; } + # create vlan tag -> encap interface map my %encapif = reverse %$encap_tag; + # now find encap interface from tag my $encapidx = $encapif{$vlan_id}; - if (!defined($encapidx)) { - $extreme->error_throw("can't map $vlan_id to encapsulation interface"); + if ( !defined($encapidx) ) { + $extreme->error_throw( + "can't map $vlan_id to encapsulation interface"); return; } + # now find vlan interface stacked above encap - my @abovevlan = keys %{$invstack->{$encapidx}}; - if (@abovevlan != 1) { - $extreme->error_throw("can't map encap interface $encapidx for $vlan_id to encapsulation interface"); + my @abovevlan = keys %{ $invstack->{$encapidx} }; + if ( @abovevlan != 1 ) { + $extreme->error_throw( + "can't map encap interface $encapidx for $vlan_id to encapsulation interface" + ); return; } my $vlanidx = $abovevlan[0]; my $rv; + # Delete old VLAN mapping - foreach my $oldidx (keys %{$invstack->{$ifindex}}) { - if ($is_pvid && defined($encap_tag->{$oldidx})) { - next; # Don't delete tagged mappings + foreach my $oldidx ( keys %{ $invstack->{$ifindex} } ) { + if ( $is_pvid && defined( $encap_tag->{$oldidx} ) ) { + next; # Don't delete tagged mappings } - $rv = $extreme->set_ifStackStatus("destroy", $oldidx . "." . $ifindex); + $rv = $extreme->set_ifStackStatus( "destroy", + $oldidx . "." . $ifindex ); unless ($rv) { - $extreme->error_throw("Unable to remove $ifindex from old VLAN index $oldidx"); + $extreme->error_throw( + "Unable to remove $ifindex from old VLAN index $oldidx"); return; } } + # Add new VLAN mapping - $rv = $extreme->set_ifStackStatus("createAndGo", $vlanidx . "." . $ifindex); + $rv = $extreme->set_ifStackStatus( "createAndGo", + $vlanidx . "." . $ifindex ); unless ($rv) { - $extreme->error_throw("Unable to add new VLAN index $vlanidx to ifIndex $ifindex"); + $extreme->error_throw( + "Unable to add new VLAN index $vlanidx to ifIndex $ifindex"); return; } - # XXX invalidate cache of ifstack? - # XXX Info.pm library function for this? - # XXX set_ should do invalidation? - # $store = $extreme->store(); delete $store->{ifStackStatus}; $extreme->store($store); - # $extreme->{_ifStackStatus} = 0; + +# XXX invalidate cache of ifstack? +# XXX Info.pm library function for this? +# XXX set_ should do invalidation? +# $store = $extreme->store(); delete $store->{ifStackStatus}; $extreme->store($store); +# $extreme->{_ifStackStatus} = 0; return $rv; } sub set_remove_i_vlan_tagged { my $extreme = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; my $encap_tag = $extreme->ex_vlan_encap_tag(); + # create vlan tag -> encap interface map my %encapif = reverse %$encap_tag; + # now find encap interface from tag my $encapidx = $encapif{$vlan_id}; - if (!defined($encapidx)) { - $extreme->error_throw("can't map $vlan_id to encapsulation interface"); + if ( !defined($encapidx) ) { + $extreme->error_throw( + "can't map $vlan_id to encapsulation interface"); return; } - my $rv = $extreme->set_ifStackStatus("destroy", $encapidx . "." . $ifindex); + my $rv = $extreme->set_ifStackStatus( "destroy", + $encapidx . "." . $ifindex ); unless ($rv) { - $extreme->error_throw("Unable to delete VLAN encap ifIndex $encapidx for VLAN $vlan_id from ifIndex $ifindex"); + $extreme->error_throw( + "Unable to delete VLAN encap ifIndex $encapidx for VLAN $vlan_id from ifIndex $ifindex" + ); return; } + # invalidate cache of ifstack? return $rv; } sub set_add_i_vlan_tagged { my $extreme = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; my $encap_tag = $extreme->ex_vlan_encap_tag(); + # create vlan tag -> encap interface map my %encapif = reverse %$encap_tag; + # now find encap interface from tag my $encapidx = $encapif{$vlan_id}; - if (!defined($encapidx)) { - $extreme->error_throw("can't map $vlan_id to encapsulation interface"); + if ( !defined($encapidx) ) { + $extreme->error_throw( + "can't map $vlan_id to encapsulation interface"); return; } - my $rv = $extreme->set_ifStackStatus("createAndGo", $encapidx . "." . $ifindex); + my $rv = $extreme->set_ifStackStatus( "createAndGo", + $encapidx . "." . $ifindex ); unless ($rv) { - $extreme->error_throw("Unable to add VLAN encap ifIndex $encapidx for VLAN $vlan_id to ifIndex $ifindex"); + $extreme->error_throw( + "Unable to add VLAN encap ifIndex $encapidx for VLAN $vlan_id to ifIndex $ifindex" + ); return; } + # invalidate cache of ifstack? return $rv; } @@ -698,8 +745,8 @@ Returns VLAN names Returns reference to hash of bridge port table entries map back to interface identifier (iid) -Returns (C) for both key and value since we're using F -rather than F. +Returns (C) for both key and value since we're using +F rather than F. =back diff --git a/Info/Layer3/Foundry.pm b/Info/Layer3/Foundry.pm index f4594d2d..1fc5df1c 100644 --- a/Info/Layer3/Foundry.pm +++ b/Info/Layer3/Foundry.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -39,51 +39,52 @@ use SNMP::Info::FDP; use SNMP::Info::LLDP; @SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP - SNMP::Info::Layer3 Exporter/; + SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, - %SNMP::Info::LLDP::MIBS, - %SNMP::Info::FDP::MIBS, - 'FOUNDRY-SN-ROOT-MIB' => 'foundry', - 'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', - 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::LLDP::MIBS, + %SNMP::Info::FDP::MIBS, + 'FOUNDRY-SN-ROOT-MIB' => 'foundry', + 'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', + 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::LLDP::GLOBALS, - %SNMP::Info::FDP::GLOBALS, - 'mac' => 'ifPhysAddress.1', - 'chassis' => 'entPhysicalDescr.1', - 'temp' => 'snChasActualTemperature', - 'ps1_type' => 'snChasPwrSupplyDescription.1', - 'ps1_status' => 'snChasPwrSupplyOperStatus.1', - 'fan' => 'snChasFanOperStatus.1', + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::LLDP::GLOBALS, + %SNMP::Info::FDP::GLOBALS, + 'mac' => 'ifPhysAddress.1', + 'chassis' => 'entPhysicalDescr.1', + 'temp' => 'snChasActualTemperature', + 'ps1_type' => 'snChasPwrSupplyDescription.1', + 'ps1_status' => 'snChasPwrSupplyOperStatus.1', + 'fan' => 'snChasFanOperStatus.1', - ); +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::LLDP::FUNCS, - %SNMP::Info::FDP::FUNCS, - # FOUNDRY-SN-SWITCH-GROUP-MIB - # snSwPortInfoTable - Switch Port Information Group - 'sw_index' => 'snSwPortIfIndex', - 'sw_duplex' => 'snSwPortInfoChnMode', - 'sw_type' => 'snSwPortInfoMediaType', - 'sw_speed' => 'snSwPortInfoSpeed', - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::LLDP::FUNCS, + %SNMP::Info::FDP::FUNCS, + + # FOUNDRY-SN-SWITCH-GROUP-MIB + # snSwPortInfoTable - Switch Port Information Group + 'sw_index' => 'snSwPortIfIndex', + 'sw_duplex' => 'snSwPortInfoChnMode', + 'sw_type' => 'snSwPortInfoMediaType', + 'sw_speed' => 'snSwPortInfoSpeed', +); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::LLDP::MUNGE, - %SNMP::Info::FDP::MUNGE, - ); + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE, + %SNMP::Info::FDP::MUNGE, +); sub i_ignore { my $foundry = shift; @@ -92,8 +93,8 @@ sub i_ignore { my $interfaces = $foundry->interfaces($partial) || {}; my %i_ignore; - foreach my $if (keys %$interfaces) { - if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i){ + foreach my $if ( keys %$interfaces ) { + if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) { $i_ignore{$if}++; } } @@ -104,16 +105,16 @@ sub i_duplex { my $foundry = shift; my $partial = shift; - my $sw_index = $foundry->sw_index($partial); - my $sw_duplex= $foundry->sw_duplex($partial); + my $sw_index = $foundry->sw_index($partial); + my $sw_duplex = $foundry->sw_duplex($partial); - unless (defined $sw_index and defined $sw_duplex){ - return $foundry->SUPER::i_duplex(); + unless ( defined $sw_index and defined $sw_duplex ) { + return $foundry->SUPER::i_duplex(); } - + my %i_duplex; - foreach my $sw_port (keys %$sw_duplex){ - my $iid = $sw_index->{$sw_port}; + foreach my $sw_port ( keys %$sw_duplex ) { + my $iid = $sw_index->{$sw_port}; my $duplex = $sw_duplex->{$sw_port}; next if $duplex =~ /none/i; $i_duplex{$iid} = 'half' if $duplex =~ /half/i; @@ -124,36 +125,36 @@ sub i_duplex { sub model { my $foundry = shift; - my $id = $foundry->id(); - my $model = &SNMP::translateObj($id); + my $id = $foundry->id(); + my $model = &SNMP::translateObj($id); # EdgeIron - if ($id =~ /\.1991\.1\.[45]\./) { + if ( $id =~ /\.1991\.1\.[45]\./ ) { my $e_name = $foundry->e_name(); # Find entity table entry for "unit.1" my $unit_iid = undef; - foreach my $e (keys %$e_name){ + foreach my $e ( keys %$e_name ) { my $name = $e_name->{$e} || ''; $unit_iid = $e if $name eq 'unit.1'; } # Find Model Name my $e_model = $foundry->e_model(); - if (defined $e_model->{$unit_iid}){ + if ( defined $e_model->{$unit_iid} ) { return $e_model->{$unit_iid}; } } - + return $id unless defined $model; - + $model =~ s/^sn//; return $model; } -sub os { +sub os { return 'foundry'; } @@ -168,7 +169,7 @@ sub os_ver { # Some older ones don't have this value,so we cull it from the description my $descr = $foundry->description(); - if ($descr =~ m/Version (\d\S*)/) { + if ( $descr =~ m/Version (\d\S*)/ ) { return $1; } @@ -177,16 +178,16 @@ sub os_ver { # find entity table entry for "stackmanaget.1" my $unit_iid = undef; - foreach my $e (keys %$e_name){ + foreach my $e ( keys %$e_name ) { my $name = $e_name->{$e} || ''; $unit_iid = $e if $name eq 'stackmanaget.1'; } - if (defined $unit_iid){ + if ( defined $unit_iid ) { # Find Model Name my $e_fwver = $foundry->e_fwver(); - if (defined $e_fwver->{$unit_iid}){ + if ( defined $e_fwver->{$unit_iid} ) { return $e_fwver->{$unit_iid}; } } @@ -205,7 +206,7 @@ sub serial { # If no chassis serial use first module serial my $mod_serials = $foundry->snAgentConfigModuleSerialNumber(); - foreach my $mod (sort keys %$mod_serials){ + foreach my $mod ( sort keys %$mod_serials ) { my $serial = $mod_serials->{$mod} || ''; next unless defined $serial; return $serial; @@ -216,12 +217,13 @@ sub serial { # find entity table entry for "unit.1" my $unit_iid = undef; - foreach my $e (keys %$e_name){ + foreach my $e ( keys %$e_name ) { my $name = $e_name->{$e} || ''; $unit_iid = $e if $name eq 'unit.1'; } - if (defined $unit_iid) { + if ( defined $unit_iid ) { + # Look up serial of found entry. my $e_serial = $foundry->e_serial(); return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid}; @@ -236,26 +238,26 @@ sub interfaces { my $partial = shift; my $i_descr = $foundry->i_description($partial) || {}; - my $i_name = $foundry->i_name($partial) || {}; + my $i_name = $foundry->i_name($partial) || {}; # Use ifName for EdgeIrons else use ifDescr - foreach my $iid (keys %$i_name){ + foreach my $iid ( keys %$i_name ) { my $name = $i_name->{$iid}; next unless defined $name; - $i_descr->{$iid} = $name + $i_descr->{$iid} = $name if $name =~ /^port\d+/i; } - + return $i_descr; } # Reported hangs on a EdgeIron 24G sub stp_p_state { - my $foundry = shift; + my $foundry = shift; my $partial = shift; my $descr = $foundry->description(); - if ($descr =~ m/\bEdgeIron 24G\b/) { + if ( $descr =~ m/\bEdgeIron 24G\b/ ) { return; } @@ -276,17 +278,17 @@ sub c_ip { my $partial = shift; my $cdp = $foundry->SUPER::c_ip($partial) || {}; - my $lldp = $foundry->lldp_ip($partial) || {}; + my $lldp = $foundry->lldp_ip($partial) || {}; my %c_ip; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $ip = $cdp->{$iid}; next unless defined $ip; $c_ip{$iid} = $ip; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $ip = $lldp->{$iid}; next unless defined $ip; @@ -299,18 +301,18 @@ sub c_if { my $foundry = shift; my $partial = shift; - my $lldp = $foundry->lldp_if($partial) || {};; + my $lldp = $foundry->lldp_if($partial) || {}; my $cdp = $foundry->SUPER::c_if($partial) || {}; - + my %c_if; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $if = $cdp->{$iid}; next unless defined $if; $c_if{$iid} = $if; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $if = $lldp->{$iid}; next unless defined $if; @@ -323,18 +325,18 @@ sub c_port { my $foundry = shift; my $partial = shift; - my $lldp = $foundry->lldp_port($partial) || {}; + my $lldp = $foundry->lldp_port($partial) || {}; my $cdp = $foundry->SUPER::c_port($partial) || {}; - + my %c_port; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $port = $cdp->{$iid}; next unless defined $port; $c_port{$iid} = $port; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $port = $lldp->{$iid}; next unless defined $port; @@ -347,18 +349,18 @@ sub c_id { my $foundry = shift; my $partial = shift; - my $lldp = $foundry->lldp_id($partial) || {}; + my $lldp = $foundry->lldp_id($partial) || {}; my $cdp = $foundry->SUPER::c_id($partial) || {}; my %c_id; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $id = $cdp->{$iid}; next unless defined $id; $c_id{$iid} = $id; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $id = $lldp->{$iid}; next unless defined $id; @@ -371,18 +373,18 @@ sub c_platform { my $foundry = shift; my $partial = shift; - my $lldp = $foundry->lldp_rem_sysdesc($partial) || {}; + my $lldp = $foundry->lldp_rem_sysdesc($partial) || {}; my $cdp = $foundry->SUPER::c_platform($partial) || {}; my %c_platform; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $platform = $cdp->{$iid}; next unless defined $platform; $c_platform{$iid} = $platform; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $platform = $lldp->{$iid}; next unless defined $platform; @@ -629,9 +631,9 @@ Returns reference to hash. Key: iid Value: remote IPv4 address If multiple entries exist with the same local port, c_if(), with the same IPv4 address, c_ip(), it may be a duplicate entry. -If multiple entries exist with the same local port, c_if(), with different IPv4 -addresses, c_ip(), there is either a non-FDP/LLDP device in between two or -more devices or multiple devices which are not directly connected. +If multiple entries exist with the same local port, c_if(), with different +IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two +or more devices or multiple devices which are not directly connected. Use the data from the Layer2 Topology Table below to dig deeper. diff --git a/Info/Layer3/HP9300.pm b/Info/Layer3/HP9300.pm index ced218c2..cf3eb4d0 100644 --- a/Info/Layer3/HP9300.pm +++ b/Info/Layer3/HP9300.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -37,63 +37,64 @@ use SNMP::Info::FDP; use SNMP::Info::LLDP; @SNMP::Info::Layer3::HP9300::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP - SNMP::Info::Layer3 Exporter/; + SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::HP9300::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, - %SNMP::Info::LLDP::MIBS, - %SNMP::Info::FDP::MIBS, - 'HP-SN-ROOT-MIB' => 'hp', - 'HP-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', - 'HP-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::LLDP::MIBS, + %SNMP::Info::FDP::MIBS, + 'HP-SN-ROOT-MIB' => 'hp', + 'HP-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', + 'HP-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::LLDP::GLOBALS, - %SNMP::Info::FDP::GLOBALS, - 'mac' => 'ifPhysAddress.1', - 'chassis' => 'entPhysicalDescr.1', - 'temp' => 'snChasActualTemperature', - 'ps1_type' => 'snChasPwrSupplyDescription.1', - 'ps1_status' => 'snChasPwrSupplyOperStatus.1', - 'fan' => 'snChasFanOperStatus.1', + %SNMP::Info::Layer3::GLOBALS, + %SNMP::Info::LLDP::GLOBALS, + %SNMP::Info::FDP::GLOBALS, + 'mac' => 'ifPhysAddress.1', + 'chassis' => 'entPhysicalDescr.1', + 'temp' => 'snChasActualTemperature', + 'ps1_type' => 'snChasPwrSupplyDescription.1', + 'ps1_status' => 'snChasPwrSupplyOperStatus.1', + 'fan' => 'snChasFanOperStatus.1', - ); +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::LLDP::FUNCS, - %SNMP::Info::FDP::FUNCS, - # HP-SN-SWITCH-GROUP-MIB - # snSwPortInfoTable - Switch Port Information Group - # Fully qualify these since FDP class will load - # FOUNDRY-SN-SWITCH-GROUP-MIB which contains the same leaf names - 'sw_index' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortIfIndex', - 'sw_duplex' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoChnMode', - 'sw_type' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoMediaType', - 'sw_speed' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoSpeed', - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::LLDP::FUNCS, + %SNMP::Info::FDP::FUNCS, + + # HP-SN-SWITCH-GROUP-MIB + # snSwPortInfoTable - Switch Port Information Group + # Fully qualify these since FDP class will load + # FOUNDRY-SN-SWITCH-GROUP-MIB which contains the same leaf names + 'sw_index' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortIfIndex', + 'sw_duplex' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoChnMode', + 'sw_type' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoMediaType', + 'sw_speed' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoSpeed', +); %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::LLDP::MUNGE, - %SNMP::Info::FDP::MUNGE, - ); + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE, + %SNMP::Info::FDP::MUNGE, +); sub i_ignore { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; my $interfaces = $hp9300->interfaces($partial) || {}; my %i_ignore; - foreach my $if (keys %$interfaces) { - if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i){ + foreach my $if ( keys %$interfaces ) { + if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) { $i_ignore{$if}++; } } @@ -101,19 +102,19 @@ sub i_ignore { } sub i_duplex { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; - my $sw_index = $hp9300->sw_index($partial); - my $sw_duplex= $hp9300->sw_duplex($partial); + my $sw_index = $hp9300->sw_index($partial); + my $sw_duplex = $hp9300->sw_duplex($partial); - unless (defined $sw_index and defined $sw_duplex){ - return $hp9300->SUPER::i_duplex(); + unless ( defined $sw_index and defined $sw_duplex ) { + return $hp9300->SUPER::i_duplex(); } - + my %i_duplex; - foreach my $sw_port (keys %$sw_duplex){ - my $iid = $sw_index->{$sw_port}; + foreach my $sw_port ( keys %$sw_duplex ) { + my $iid = $sw_index->{$sw_port}; my $duplex = $sw_duplex->{$sw_port}; next if $duplex =~ /none/i; $i_duplex{$iid} = 'half' if $duplex =~ /half/i; @@ -124,17 +125,17 @@ sub i_duplex { sub model { my $hp9300 = shift; - my $id = $hp9300->id(); - my $model = &SNMP::translateObj($id); - + my $id = $hp9300->id(); + my $model = &SNMP::translateObj($id); + return $id unless defined $model; - + $model =~ s/^hpSwitch//; return $model; } -sub os { +sub os { return 'hp'; } @@ -149,7 +150,7 @@ sub os_ver { # Some older ones don't have this value,so we cull it from the description my $descr = $hp9300->description(); - if ($descr =~ m/Version (\d\S*)/) { + if ( $descr =~ m/Version (\d\S*)/ ) { return $1; } @@ -167,7 +168,7 @@ sub serial { # If no chassis serial use first module serial my $mod_serials = $hp9300->snAgentConfigModuleSerialNumber(); - foreach my $mod (sort keys %$mod_serials){ + foreach my $mod ( sort keys %$mod_serials ) { my $serial = $mod_serials->{$mod} || ''; next unless defined $serial; return $serial; @@ -178,20 +179,20 @@ sub serial { } sub interfaces { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; my $i_descr = $hp9300->i_description($partial) || {}; - my $i_name = $hp9300->i_name($partial) || {}; + my $i_name = $hp9300->i_name($partial) || {}; # Use ifName for EdgeIrons else use ifDescr - foreach my $iid (keys %$i_name){ + foreach my $iid ( keys %$i_name ) { my $name = $i_name->{$iid}; next unless defined $name; - $i_descr->{$iid} = $name + $i_descr->{$iid} = $name if $name =~ /^port\d+/i; } - + return $i_descr; } @@ -204,21 +205,21 @@ sub hasCDP { } sub c_ip { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; my $cdp = $hp9300->SUPER::c_ip($partial) || {}; - my $lldp = $hp9300->lldp_ip($partial) || {}; + my $lldp = $hp9300->lldp_ip($partial) || {}; my %c_ip; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $ip = $cdp->{$iid}; next unless defined $ip; $c_ip{$iid} = $ip; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $ip = $lldp->{$iid}; next unless defined $ip; @@ -228,21 +229,21 @@ sub c_ip { } sub c_if { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; - my $lldp = $hp9300->lldp_if($partial) || {};; + my $lldp = $hp9300->lldp_if($partial) || {}; my $cdp = $hp9300->SUPER::c_if($partial) || {}; - + my %c_if; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $if = $cdp->{$iid}; next unless defined $if; $c_if{$iid} = $if; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $if = $lldp->{$iid}; next unless defined $if; @@ -252,21 +253,21 @@ sub c_if { } sub c_port { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; - my $lldp = $hp9300->lldp_port($partial) || {}; + my $lldp = $hp9300->lldp_port($partial) || {}; my $cdp = $hp9300->SUPER::c_port($partial) || {}; - + my %c_port; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $port = $cdp->{$iid}; next unless defined $port; $c_port{$iid} = $port; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $port = $lldp->{$iid}; next unless defined $port; @@ -276,21 +277,21 @@ sub c_port { } sub c_id { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; - my $lldp = $hp9300->lldp_id($partial) || {}; + my $lldp = $hp9300->lldp_id($partial) || {}; my $cdp = $hp9300->SUPER::c_id($partial) || {}; my %c_id; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $id = $cdp->{$iid}; next unless defined $id; $c_id{$iid} = $id; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $id = $lldp->{$iid}; next unless defined $id; @@ -300,21 +301,21 @@ sub c_id { } sub c_platform { - my $hp9300 = shift; + my $hp9300 = shift; my $partial = shift; - my $lldp = $hp9300->lldp_rem_sysdesc($partial) || {}; + my $lldp = $hp9300->lldp_rem_sysdesc($partial) || {}; my $cdp = $hp9300->SUPER::c_platform($partial) || {}; my %c_platform; - foreach my $iid (keys %$cdp){ + foreach my $iid ( keys %$cdp ) { my $platform = $cdp->{$iid}; next unless defined $platform; $c_platform{$iid} = $platform; } - foreach my $iid (keys %$lldp){ + foreach my $iid ( keys %$lldp ) { my $platform = $lldp->{$iid}; next unless defined $platform; @@ -553,9 +554,9 @@ Returns reference to hash. Key: iid Value: remote IPv4 address If multiple entries exist with the same local port, c_if(), with the same IPv4 address, c_ip(), it may be a duplicate entry. -If multiple entries exist with the same local port, c_if(), with different IPv4 -addresses, c_ip(), there is either a non-FDP/LLDP device in between two or -more devices or multiple devices which are not directly connected. +If multiple entries exist with the same local port, c_if(), with different +IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two +or more devices or multiple devices which are not directly connected. Use the data from the Layer2 Topology Table below to dig deeper. diff --git a/Info/Layer3/Juniper.pm b/Info/Layer3/Juniper.pm index 448970ac..ac34cf65 100644 --- a/Info/Layer3/Juniper.pm +++ b/Info/Layer3/Juniper.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Bill Fenner # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,47 +34,40 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Juniper::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer3::MIBS, - 'JUNIPER-CHASSIS-DEFINES-MIB' => 'jnxChassisDefines', - 'JUNIPER-MIB' => 'jnxBoxAnatomy', - ); + %SNMP::Info::Layer3::MIBS, + 'JUNIPER-CHASSIS-DEFINES-MIB' => 'jnxChassisDefines', + 'JUNIPER-MIB' => 'jnxBoxAnatomy', +); -%GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'serial' => 'jnxBoxSerialNo.0', - ); +%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, 'serial' => 'jnxBoxSerialNo.0', ); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - ); +%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub vendor { - return 'juniper'; + return 'juniper'; } sub os { - return 'junos'; + return 'junos'; } sub os_ver { my $juniper = shift; - my $descr = $juniper->description(); + my $descr = $juniper->description(); return unless defined $descr; - if ($descr =~ m/kernel JUNOS (\S+)/) { - return $1; + if ( $descr =~ m/kernel JUNOS (\S+)/ ) { + return $1; } return; } @@ -82,12 +75,14 @@ sub os_ver { sub model { my $l3 = shift; my $id = $l3->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::Juniper::model() - Device does not support sysObjectID\n" if $l3->debug(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::Juniper::model() - Device does not support sysObjectID\n" + if $l3->debug(); return; } - + my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -103,21 +98,21 @@ sub serial { } sub i_vlan { - my ($juniper) = shift; - my ($partial) = shift; + my ($juniper) = shift; + my ($partial) = shift; - my ($i_type) = $juniper->i_type($partial); - my ($i_descr) = $juniper->i_description($partial); - my %i_vlan; + my ($i_type) = $juniper->i_type($partial); + my ($i_descr) = $juniper->i_description($partial); + my %i_vlan; - foreach my $idx (keys %$i_descr) { - if ($i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135) { - if ($i_descr->{$idx} =~ /\.(\d+)$/) { - $i_vlan{$idx} = $1; - } - } - } - return \%i_vlan; + foreach my $idx ( keys %$i_descr ) { + if ( $i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135 ) { + if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) { + $i_vlan{$idx} = $1; + } + } + } + return \%i_vlan; } 1; diff --git a/Info/Layer3/Microsoft.pm b/Info/Layer3/Microsoft.pm index 6e2b52c4..8171863d 100644 --- a/Info/Layer3/Microsoft.pm +++ b/Info/Layer3/Microsoft.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,35 +34,27 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Microsoft::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Microsoft::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Microsoft::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - ); +%MIBS = ( %SNMP::Info::Layer3::MIBS, ); -%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, - ); +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub vendor { - return 'microsoft'; + return 'microsoft'; } sub os { - return 'windows'; + return 'windows'; } sub os_ver { @@ -70,28 +62,30 @@ sub os_ver { } sub model { - return 'Windows Router' + return 'Windows Router'; } + sub serial { - return ''; + return ''; } + # $l3->interfaces() - Map the Interfaces to their physical names # Add interface number to interface name because if MS Win # have identical interface cards ("HP NC7782 Gigabit Server Adapter" # for example), than MS Win return identical ifDescr sub interfaces { - my $l3 = shift; + my $l3 = shift; my $partial = shift; - my $interfaces = $l3->i_index($partial); + my $interfaces = $l3->i_index($partial); my $descriptions = $l3->i_description($partial); my %interfaces = (); - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $desc = $descriptions->{$iid}; next unless defined $desc; - $interfaces{$iid} = sprintf("(%U) %s", $iid, $desc); + $interfaces{$iid} = sprintf( "(%U) %s", $iid, $desc ); } return \%interfaces; diff --git a/Info/Layer3/N1600.pm b/Info/Layer3/N1600.pm index ae803b12..ded9c755 100644 --- a/Info/Layer3/N1600.pm +++ b/Info/Layer3/N1600.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -35,51 +35,55 @@ use Exporter; use SNMP::Info::Layer3; use SNMP::Info::SONMP; -@SNMP::Info::Layer3::N1600::ISA = qw/SNMP::Info::Layer3 SNMP::Info::SONMP Exporter/; +@SNMP::Info::Layer3::N1600::ISA + = qw/SNMP::Info::Layer3 SNMP::Info::SONMP Exporter/; @SNMP::Info::Layer3::N1600::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( %SNMP::Info::Layer3::MIBS, - %SNMP::Info::SONMP::MIBS, - 'SWL2MGMT-MIB' => 'swL2MgmtMIB', - 'RAPID-CITY' => 'rapidCity', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + %SNMP::Info::SONMP::MIBS, + 'SWL2MGMT-MIB' => 'swL2MgmtMIB', + 'RAPID-CITY' => 'rapidCity', +); -%GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - ); +%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::SONMP::GLOBALS, ); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::SONMP::FUNCS, - # SWL2MGMT-MIB - # swL2PortInfoTable - 'n1600_nway_status' => 'swL2PortInfoNwayStatus', - # swL2PortCtrlTable - 'n1600_nway_state' => 'swL2PortCtrlNwayState', - ); +%FUNCS = ( + %SNMP::Info::Layer3::FUNCS, + %SNMP::Info::SONMP::FUNCS, + + # SWL2MGMT-MIB + # swL2PortInfoTable + 'n1600_nway_status' => 'swL2PortInfoNwayStatus', + + # swL2PortCtrlTable + 'n1600_nway_state' => 'swL2PortCtrlNwayState', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::SONMP::MUNGE, - ); + + # Inherit all the built in munging + %SNMP::Info::Layer3::MUNGE, + %SNMP::Info::SONMP::MUNGE, +); # Method OverRides sub model { my $n1600 = shift; - my $id = $n1600->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::N1600::model() - Device does not support sysObjectID\n" if $n1600->debug(); + my $id = $n1600->id(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::N1600::model() - Device does not support sysObjectID\n" + if $n1600->debug(); return; } - + my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -101,7 +105,7 @@ sub os_ver { my $descr = $n1600->description(); return unless defined $descr; - if ($descr =~ m/(\d+\.\d+\.\d+\.\d+)/){ + if ( $descr =~ m/(\d+\.\d+\.\d+\.\d+)/ ) { return $1; } @@ -109,13 +113,13 @@ sub os_ver { } sub interfaces { - my $n1600 = shift; + my $n1600 = shift; my $partial = shift; my $i_index = $n1600->i_index($partial) || {}; - + my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; @@ -126,13 +130,13 @@ sub interfaces { } sub i_duplex { - my $n1600 = shift; + my $n1600 = shift; my $partial = shift; my $nway_status = $n1600->n1600_nway_status($partial) || {}; - + my %i_duplex; - foreach my $iid (keys %$nway_status){ + foreach my $iid ( keys %$nway_status ) { my $duplex = $nway_status->{$iid}; next unless defined $duplex; next if $duplex =~ /other/i; @@ -143,13 +147,13 @@ sub i_duplex { } sub i_duplex_admin { - my $n1600 = shift; + my $n1600 = shift; my $partial = shift; my $nway_state = $n1600->n1600_nway_state($partial) || {}; - + my %i_duplex; - foreach my $iid (keys %$nway_state){ + foreach my $iid ( keys %$nway_state ) { my $duplex = $nway_state->{$iid}; next unless defined $duplex; next if $duplex =~ /other/i; diff --git a/Info/Layer3/NetSNMP.pm b/Info/Layer3/NetSNMP.pm index bf08f34f..0c3d3cec 100644 --- a/Info/Layer3/NetSNMP.pm +++ b/Info/Layer3/NetSNMP.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Bill Fenner # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,33 +34,29 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::NetSNMP::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::NetSNMP::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::NetSNMP::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer3::MIBS, - 'UCD-SNMP-MIB' => 'versionTag', - 'NET-SNMP-TC' => 'netSnmpAgentOIDs', - 'HOST-RESOURCES-MIB' => 'hrSystem', - ); + %SNMP::Info::Layer3::MIBS, + 'UCD-SNMP-MIB' => 'versionTag', + 'NET-SNMP-TC' => 'netSnmpAgentOIDs', + 'HOST-RESOURCES-MIB' => 'hrSystem', +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'netsnmp_vers' => 'versionTag', - 'hrSystemUptime' => 'hrSystemUptime', - ); + %SNMP::Info::Layer3::GLOBALS, + 'netsnmp_vers' => 'versionTag', + 'hrSystemUptime' => 'hrSystemUptime', +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - ); +%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub vendor { return 'Net-SNMP'; @@ -68,19 +64,19 @@ sub vendor { sub os { my $netsnmp = shift; - my $descr = $netsnmp->description(); + my $descr = $netsnmp->description(); - return $1 if ($descr =~ /^(\S+)\s+/); + return $1 if ( $descr =~ /^(\S+)\s+/ ); return; } sub os_ver { my $netsnmp = shift; - my $descr = $netsnmp->description(); - my $vers = $netsnmp->netsnmp_vers(); - my $os_ver = undef; + my $descr = $netsnmp->description(); + my $vers = $netsnmp->netsnmp_vers(); + my $os_ver = undef; - $os_ver = $1 if ($descr =~ /^\S+\s+\S+\s+(\S+)\s+/); + $os_ver = $1 if ( $descr =~ /^\S+\s+\S+\s+(\S+)\s+/ ); if ($vers) { $os_ver = "???" unless defined($os_ver); $os_ver .= " / Net-SNMP " . $vers; @@ -109,15 +105,16 @@ sub uptime { } sub i_ignore { - my $l3 = shift; + my $l3 = shift; my $partial = shift; - + my $interfaces = $l3->interfaces($partial) || {}; my %i_ignore; - foreach my $if (keys %$interfaces) { + foreach my $if ( keys %$interfaces ) { + # lo0 etc - if ($interfaces->{$if} =~ /\blo\d*\b/i){ + if ( $interfaces->{$if} =~ /\blo\d*\b/i ) { $i_ignore{$if}++; } } diff --git a/Info/Layer3/Netscreen.pm b/Info/Layer3/Netscreen.pm index 3e43c5c1..c86d1e09 100644 --- a/Info/Layer3/Netscreen.pm +++ b/Info/Layer3/Netscreen.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,36 +34,29 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Netscreen::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Netscreen::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Netscreen::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - 'NETSCREEN-SMI' => 'netscreenSetting', - 'NETSCREEN-PRODUCTS-MIB' => 'netscreenGeneric', - 'NETSCREEN-INTERFACE-MIB' => 'nsIfIndex', - 'NETSCREEN-SET-GEN-MIB' => 'nsSetGenSwVer', - ); +%MIBS = ( + %SNMP::Info::Layer3::MIBS, + 'NETSCREEN-SMI' => 'netscreenSetting', + 'NETSCREEN-PRODUCTS-MIB' => 'netscreenGeneric', + 'NETSCREEN-INTERFACE-MIB' => 'nsIfIndex', + 'NETSCREEN-SET-GEN-MIB' => 'nsSetGenSwVer', +); -%GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'os_version' => 'nsSetGenSwVer', - ); +%GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, 'os_version' => 'nsSetGenSwVer', ); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - ); +%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub layers { - return '01001100'; + return '01001100'; } sub vendor { @@ -78,8 +71,8 @@ sub os_ver { my $netscreen = shift; my $descr = $netscreen->description(); - if ( $descr =~ m/version (\d\S*) \(SN: /) { - return $1; + if ( $descr =~ m/version (\d\S*) \(SN: / ) { + return $1; } return; } @@ -91,9 +84,9 @@ sub serial { my $serial = $e_serial->{1} || undef; - return $1 if (defined $serial and $serial =~ /(\d+)/); + return $1 if ( defined $serial and $serial =~ /(\d+)/ ); my $descr = $netscreen->description(); - if ( $descr =~ m/version .*\(SN: (\d\S*),/) { + if ( $descr =~ m/version .*\(SN: (\d\S*),/ ) { return $1; } return; diff --git a/Info/Layer3/Passport.pm b/Info/Layer3/Passport.pm index 3966b093..c808ae03 100644 --- a/Info/Layer3/Passport.pm +++ b/Info/Layer3/Passport.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,8 +36,9 @@ use SNMP::Info::SONMP; use SNMP::Info::RapidCity; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Passport::ISA = qw/SNMP::Info::SONMP SNMP::Info::RapidCity - SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Passport::ISA + = qw/SNMP::Info::SONMP SNMP::Info::RapidCity + SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Passport::EXPORT_OK = qw//; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; @@ -45,38 +46,36 @@ use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; $VERSION = '1.09'; %MIBS = ( - %SNMP::Info::Layer3::MIBS, - %SNMP::Info::RapidCity::MIBS, - %SNMP::Info::SONMP::MIBS, - ); + %SNMP::Info::Layer3::MIBS, %SNMP::Info::RapidCity::MIBS, + %SNMP::Info::SONMP::MIBS, +); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - %SNMP::Info::RapidCity::GLOBALS, - %SNMP::Info::SONMP::GLOBALS, - ); + %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::RapidCity::GLOBALS, + %SNMP::Info::SONMP::GLOBALS, +); %FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - %SNMP::Info::RapidCity::FUNCS, - %SNMP::Info::SONMP::FUNCS, - ); - + %SNMP::Info::Layer3::FUNCS, %SNMP::Info::RapidCity::FUNCS, + %SNMP::Info::SONMP::FUNCS, +); + %MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - %SNMP::Info::RapidCity::MUNGE, - %SNMP::Info::SONMP::MUNGE, - ); + %SNMP::Info::Layer3::MUNGE, %SNMP::Info::RapidCity::MUNGE, + %SNMP::Info::SONMP::MUNGE, +); sub model { my $passport = shift; - my $id = $passport->id(); - - unless (defined $id){ - print " SNMP::Info::Layer3::Passport::model() - Device does not support sysObjectID\n" if $passport->debug(); + my $id = $passport->id(); + + unless ( defined $id ) { + print + " SNMP::Info::Layer3::Passport::model() - Device does not support sysObjectID\n" + if $passport->debug(); return; } - + my $model = &SNMP::translateObj($id); return $id unless defined $model; @@ -95,15 +94,16 @@ sub os { sub os_ver { my $passport = shift; - my $descr = $passport->description(); + my $descr = $passport->description(); return unless defined $descr; #ERS / Passport - if ($descr =~ m/(\d+\.\d+\.\d+\.\d+)/){ + if ( $descr =~ m/(\d+\.\d+\.\d+\.\d+)/ ) { return $1; } + #Accelar - if ($descr =~ m/(\d+\.\d+\.\d+)/){ + if ( $descr =~ m/(\d+\.\d+\.\d+)/ ) { return $1; } return; @@ -111,13 +111,13 @@ sub os_ver { sub i_index { my $passport = shift; - my $partial = shift; + my $partial = shift; my $i_index = $passport->orig_i_index($partial); my $model = $passport->model(); my %if_index; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; @@ -125,29 +125,33 @@ sub i_index { } # Get VLAN Virtual Router Interfaces - if (!defined $partial or (defined $model and - (($partial > 2000 and $model =~ /(86|83|81|16)/) or - ($partial > 256 and $model =~ /(105|11[05]0|12[05])/)))) { - + if (!defined $partial + or (defined $model + and ( ( $partial > 2000 and $model =~ /(86|83|81|16)/ ) + or ( $partial > 256 and $model =~ /(105|11[05]0|12[05])/ ) ) + ) + ) + { + my $vlan_index = $passport->rc_vlan_if() || {}; - - foreach my $vid (keys %$vlan_index){ + + foreach my $vid ( keys %$vlan_index ) { my $v_index = $vlan_index->{$vid}; next unless defined $v_index; next if $v_index == 0; - next if (defined $partial and $v_index !~ /^$partial$/); + next if ( defined $partial and $v_index !~ /^$partial$/ ); $if_index{$v_index} = $v_index; } } - if (defined $model and $model =~ /(86)/) { + if ( defined $model and $model =~ /(86)/ ) { my $cpu_index = $passport->rc_cpu_ifindex($partial) || {}; my $virt_ip = $passport->rc_virt_ip(); - + # Get CPU Ethernet Interfaces - foreach my $cid (keys %$cpu_index){ + foreach my $cid ( keys %$cpu_index ) { my $c_index = $cpu_index->{$cid}; next unless defined $c_index; next if $c_index == 0; @@ -156,7 +160,8 @@ sub i_index { } # Check for Virtual Mgmt Interface - unless ($virt_ip eq '0.0.0.0') { + unless ( $virt_ip eq '0.0.0.0' ) { + # Make up an index number, 1 is not reserved AFAIK $if_index{1} = 1; } @@ -166,58 +171,63 @@ sub i_index { sub interfaces { my $passport = shift; - my $partial = shift; + my $partial = shift; - my $i_index = $passport->i_index($partial); - my $model = $passport->model(); + my $i_index = $passport->i_index($partial); + my $model = $passport->model(); my $index_factor = $passport->index_factor(); - my $port_offset = $passport->port_offset(); - my $vlan_index = {}; + my $port_offset = $passport->port_offset(); + my $vlan_index = {}; my %reverse_vlan; my $vlan_id = {}; - - if (!defined $partial or (defined $model and - (($partial > 2000 and $model =~ /(86|83|81|16)/) or - ($partial > 256 and $model =~ /(105|11[05]0|12[05])/)))) { - $vlan_index = $passport->rc_vlan_if(); - %reverse_vlan = reverse %$vlan_index; - $vlan_id = $passport->rc_vlan_id(); + + if (!defined $partial + or (defined $model + and ( ( $partial > 2000 and $model =~ /(86|83|81|16)/ ) + or ( $partial > 256 and $model =~ /(105|11[05]0|12[05])/ ) ) + ) + ) + { + $vlan_index = $passport->rc_vlan_if(); + %reverse_vlan = reverse %$vlan_index; + $vlan_id = $passport->rc_vlan_id(); } - + my %if; - foreach my $iid (keys %$i_index){ + foreach my $iid ( keys %$i_index ) { my $index = $i_index->{$iid}; next unless defined $index; - if (($index == 1) and ($model =~ /(86)/)) { + if ( ( $index == 1 ) and ( $model =~ /(86)/ ) ) { $if{$index} = 'Cpu.Virtual'; } - elsif (($index == 192) and ($model eq '8603')) { + elsif ( ( $index == 192 ) and ( $model eq '8603' ) ) { $if{$index} = 'Cpu.3'; } - elsif (($index == 320) and ($model =~ /(8606|8610|8610co)/)) { + elsif ( ( $index == 320 ) and ( $model =~ /(8606|8610|8610co)/ ) ) { $if{$index} = 'Cpu.5'; } - elsif (($index == 384) and ($model =~ /(8606|8610|8610co)/)) { + elsif ( ( $index == 384 ) and ( $model =~ /(8606|8610|8610co)/ ) ) { $if{$index} = 'Cpu.6'; } - elsif (($index > 2000 and $model =~ /(86|83|81|16)/) or - ($index > 256 and $model =~ /(105|11[05]0|12[05])/)) { + elsif (( $index > 2000 and $model =~ /(86|83|81|16)/ ) + or ( $index > 256 and $model =~ /(105|11[05]0|12[05])/ ) ) + { - my $v_index = $reverse_vlan{$iid}; - my $v_id = $vlan_id->{$v_index}; - next unless defined $v_id; - my $v_port = 'Vlan'."$v_id"; - $if{$index} = $v_port; - } + my $v_index = $reverse_vlan{$iid}; + my $v_id = $vlan_id->{$v_index}; + next unless defined $v_id; + my $v_port = 'Vlan' . "$v_id"; + $if{$index} = $v_port; + } else { - my $port = ($index % $index_factor) + $port_offset; - my $slot = int($index / $index_factor); + my $port = ( $index % $index_factor ) + $port_offset; + my $slot = int( $index / $index_factor ); my $slotport = "$slot.$port"; $if{$iid} = $slotport; @@ -230,13 +240,13 @@ sub interfaces { sub i_mac { my $passport = shift; - my $partial = shift; + my $partial = shift; my $i_mac = $passport->orig_i_mac($partial) || {}; - my $model = $passport->model(); + my $model = $passport->model(); my %if_mac; - foreach my $iid (keys %$i_mac){ + foreach my $iid ( keys %$i_mac ) { my $mac = $i_mac->{$iid}; next unless defined $mac; @@ -244,31 +254,35 @@ sub i_mac { } # Get VLAN Virtual Router Interfaces - if (!defined $partial or (defined $model and - (($partial > 2000 and $model =~ /(86|83|81|16)/) or - ($partial > 256 and $model =~ /(105|11[05]0|12[05])/)))) { + if (!defined $partial + or (defined $model + and ( ( $partial > 2000 and $model =~ /(86|83|81|16)/ ) + or ( $partial > 256 and $model =~ /(105|11[05]0|12[05])/ ) ) + ) + ) + { - my $vlan_index = $passport->rc_vlan_if() || {}; - my $vlan_mac = $passport->rc_vlan_mac() || {}; + my $vlan_index = $passport->rc_vlan_if() || {}; + my $vlan_mac = $passport->rc_vlan_mac() || {}; - foreach my $iid (keys %$vlan_mac){ + foreach my $iid ( keys %$vlan_mac ) { my $v_mac = $vlan_mac->{$iid}; next unless defined $v_mac; - my $v_id = $vlan_index->{$iid}; + my $v_id = $vlan_index->{$iid}; next unless defined $v_id; - next if (defined $partial and $v_id !~ /^$partial$/); + next if ( defined $partial and $v_id !~ /^$partial$/ ); $if_mac{$v_id} = $v_mac; } } - - if (defined $model and $model =~ /(86)/) { + + if ( defined $model and $model =~ /(86)/ ) { my $cpu_mac = $passport->rc_cpu_mac($partial) || {}; - my $virt_ip = $passport->rc_virt_ip() || '0.0.0.0'; + my $virt_ip = $passport->rc_virt_ip() || '0.0.0.0'; # Get CPU Ethernet Interfaces - foreach my $iid (keys %$cpu_mac){ + foreach my $iid ( keys %$cpu_mac ) { my $mac = $cpu_mac->{$iid}; next unless defined $mac; @@ -276,18 +290,20 @@ sub i_mac { } # Check for Virtual Mgmt Interface - unless (($virt_ip eq '0.0.0.0') or (defined $partial and $partial ne "1")) { + unless ( ( $virt_ip eq '0.0.0.0' ) + or ( defined $partial and $partial ne "1" ) ) + { my $chassis_base_mac = $passport->rc_base_mac(); - if (defined $chassis_base_mac) { + if ( defined $chassis_base_mac ) { my @virt_mac = split /:/, $chassis_base_mac; - $virt_mac[0] = hex($virt_mac[0]); - $virt_mac[1] = hex($virt_mac[1]); - $virt_mac[2] = hex($virt_mac[2]); - $virt_mac[3] = hex($virt_mac[3]); - $virt_mac[4] = hex($virt_mac[4]) + 0x03; - $virt_mac[5] = hex($virt_mac[5]) + 0xF8; + $virt_mac[0] = hex( $virt_mac[0] ); + $virt_mac[1] = hex( $virt_mac[1] ); + $virt_mac[2] = hex( $virt_mac[2] ); + $virt_mac[3] = hex( $virt_mac[3] ); + $virt_mac[4] = hex( $virt_mac[4] ) + 0x03; + $virt_mac[5] = hex( $virt_mac[5] ) + 0xF8; - my $mac = join(':',map { sprintf "%02x",$_ } @virt_mac); + my $mac = join( ':', map { sprintf "%02x", $_ } @virt_mac ); $if_mac{1} = $mac; } @@ -298,13 +314,13 @@ sub i_mac { sub i_description { my $passport = shift; - my $partial = shift; + my $partial = shift; my $i_descr = $passport->orig_i_description($partial) || {}; - my $model = $passport->model(); + my $model = $passport->model(); my %descr; - foreach my $iid (keys %$i_descr){ + foreach my $iid ( keys %$i_descr ) { my $if_descr = $i_descr->{$iid}; next unless defined $if_descr; @@ -312,80 +328,94 @@ sub i_description { } # Get VLAN Virtual Router Interfaces - if (!defined $partial or (defined $model and - (($partial > 2000 and $model =~ /(86|83|81|16)/) or - ($partial > 256 and $model =~ /(105|11[05]0|12[05])/)))) { + if (!defined $partial + or (defined $model + and ( ( $partial > 2000 and $model =~ /(86|83|81|16)/ ) + or ( $partial > 256 and $model =~ /(105|11[05]0|12[05])/ ) ) + ) + ) + { - my $v_descr = $passport->v_name(); + my $v_descr = $passport->v_name(); my $vlan_index = $passport->rc_vlan_if(); - foreach my $vid (keys %$v_descr){ + foreach my $vid ( keys %$v_descr ) { my $vl_descr = $v_descr->{$vid}; next unless defined $vl_descr; - my $v_id = $vlan_index->{$vid}; + my $v_id = $vlan_index->{$vid}; next unless defined $v_id; - next if (defined $partial and $v_id !~ /^$partial$/); + next if ( defined $partial and $v_id !~ /^$partial$/ ); $descr{$v_id} = $vl_descr; } } return \%descr; } - + sub i_name { my $passport = shift; - my $partial = shift; + my $partial = shift; - my $model = $passport->model(); - my $i_index = $passport->i_index($partial) || {}; - my $rc_alias = $passport->rc_alias($partial) || {}; - my $i_name2 = $passport->orig_i_name($partial) || {}; - my $v_name = {}; + my $model = $passport->model(); + my $i_index = $passport->i_index($partial) || {}; + my $rc_alias = $passport->rc_alias($partial) || {}; + my $i_name2 = $passport->orig_i_name($partial) || {}; + my $v_name = {}; my $vlan_index = {}; my %reverse_vlan; - if (!defined $partial or (defined $model and - (($partial > 2000 and $model =~ /(86|83|81|16)/) or - ($partial > 256 and $model =~ /(105|11[05]0|12[05])/)))) { - $v_name = $passport->v_name() || {}; - $vlan_index = $passport->rc_vlan_if() || {}; - %reverse_vlan = reverse %$vlan_index; - } + if (!defined $partial + or (defined $model + and ( ( $partial > 2000 and $model =~ /(86|83|81|16)/ ) + or ( $partial > 256 and $model =~ /(105|11[05]0|12[05])/ ) ) + ) + ) + { + $v_name = $passport->v_name() || {}; + $vlan_index = $passport->rc_vlan_if() || {}; + %reverse_vlan = reverse %$vlan_index; + } my %i_name; - foreach my $iid (keys %$i_index){ - - if (($iid == 1) and ($model =~ /(86)/)) { + foreach my $iid ( keys %$i_index ) { + + if ( ( $iid == 1 ) and ( $model =~ /(86)/ ) ) { $i_name{$iid} = 'CPU Virtual Management IP'; } - elsif (($iid == 192) and ($model eq '8603')) { + elsif ( ( $iid == 192 ) and ( $model eq '8603' ) ) { $i_name{$iid} = 'CPU 3 Ethernet Port'; } - elsif (($iid == 320) and ($model =~ /(8606|8610|8610co)/)) { + elsif ( ( $iid == 320 ) and ( $model =~ /(8606|8610|8610co)/ ) ) { $i_name{$iid} = 'CPU 5 Ethernet Port'; } - elsif (($iid == 384) and ($model =~ /(8606|8610|8610co)/)) { + elsif ( ( $iid == 384 ) and ( $model =~ /(8606|8610|8610co)/ ) ) { $i_name{$iid} = 'CPU 6 Ethernet Port'; } - elsif (($iid > 2000 and defined $model and $model =~ /(86|83|81|16)/) or - ($iid > 256 and defined $model and $model =~ /(105|11[05]0|12[05])/)) { + elsif ( + ( $iid > 2000 and defined $model and $model =~ /(86|83|81|16)/ ) + or ( $iid > 256 + and defined $model + and $model =~ /(105|11[05]0|12[05])/ ) + ) + { my $vlan_index = $reverse_vlan{$iid}; - my $vlan_name = $v_name->{$vlan_index}; + my $vlan_name = $v_name->{$vlan_index}; next unless defined $vlan_name; $i_name{$iid} = $vlan_name; } else { - my $name = $i_name2->{$iid}; + my $name = $i_name2->{$iid}; my $alias = $rc_alias->{$iid}; - $i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ? - $alias : - $name; + $i_name{$iid} + = ( defined $alias and $alias !~ /^\s*$/ ) + ? $alias + : $name; } } @@ -394,65 +424,65 @@ sub i_name { sub ip_index { my $passport = shift; - my $partial = shift; + my $partial = shift; - my $model = $passport->model(); + my $model = $passport->model(); my $ip_index = $passport->orig_ip_index($partial) || {}; my %ip_index; - foreach my $ip (keys %$ip_index){ - my $iid = $ip_index->{$ip}; + foreach my $ip ( keys %$ip_index ) { + my $iid = $ip_index->{$ip}; next unless defined $iid; - + $ip_index{$ip} = $iid; } # Only 8600 has CPU and Virtual Management IP - if (defined $model and $model =~ /(86)/) { + if ( defined $model and $model =~ /(86)/ ) { - my $cpu_ip = $passport->rc_cpu_ip($partial) || {}; - my $virt_ip = $passport->rc_virt_ip($partial); + my $cpu_ip = $passport->rc_cpu_ip($partial) || {}; + my $virt_ip = $passport->rc_virt_ip($partial); # Get CPU Ethernet IP - foreach my $cid (keys %$cpu_ip){ + foreach my $cid ( keys %$cpu_ip ) { my $c_ip = $cpu_ip->{$cid}; next unless defined $c_ip; $ip_index{$c_ip} = $cid; } - # Get Virtual Mgmt IP - $ip_index{$virt_ip} = 1 if (defined $virt_ip); + # Get Virtual Mgmt IP + $ip_index{$virt_ip} = 1 if ( defined $virt_ip ); } - + return \%ip_index; } sub ip_netmask { my $passport = shift; - my $partial = shift; + my $partial = shift; - my $model = $passport->model(); + my $model = $passport->model(); my $ip_mask = $passport->orig_ip_netmask($partial) || {}; my %ip_index; - foreach my $iid (keys %$ip_mask){ - my $mask = $ip_mask->{$iid}; + foreach my $iid ( keys %$ip_mask ) { + my $mask = $ip_mask->{$iid}; next unless defined $mask; - + $ip_index{$iid} = $mask; } # Only 8600 has CPU and Virtual Management IP - if (defined $model and $model =~ /(86)/) { + if ( defined $model and $model =~ /(86)/ ) { - my $cpu_ip = $passport->rc_cpu_ip($partial) || {}; - my $cpu_mask = $passport->rc_cpu_mask($partial) || {}; - my $virt_ip = $passport->rc_virt_ip($partial); - my $virt_mask = $passport->rc_virt_mask($partial) || {}; + my $cpu_ip = $passport->rc_cpu_ip($partial) || {}; + my $cpu_mask = $passport->rc_cpu_mask($partial) || {}; + my $virt_ip = $passport->rc_virt_ip($partial); + my $virt_mask = $passport->rc_virt_mask($partial) || {}; # Get CPU Ethernet IP - foreach my $iid (keys %$cpu_mask){ + foreach my $iid ( keys %$cpu_mask ) { my $c_ip = $cpu_ip->{$iid}; next unless defined $c_ip; my $c_mask = $cpu_mask->{$iid}; @@ -462,66 +492,75 @@ sub ip_netmask { } # Get Virtual Mgmt IP - $ip_index{$virt_ip} = $virt_mask if (defined $virt_mask and defined $virt_ip); + $ip_index{$virt_ip} = $virt_mask + if ( defined $virt_mask and defined $virt_ip ); } - + return \%ip_index; } sub root_ip { - my $passport = shift; - my $model = $passport->model(); - my $rc_ip_addr = $passport->rc_ip_addr(); - my $rc_ip_type = $passport->rc_ip_type(); - my $virt_ip = $passport->rc_virt_ip(); - my $router_ip = $passport->router_ip(); + my $passport = shift; + my $model = $passport->model(); + my $rc_ip_addr = $passport->rc_ip_addr(); + my $rc_ip_type = $passport->rc_ip_type(); + my $virt_ip = $passport->rc_virt_ip(); + my $router_ip = $passport->router_ip(); my $sonmp_topo_port = $passport->sonmp_topo_port(); - my $sonmp_topo_ip = $passport->sonmp_topo_ip(); + my $sonmp_topo_ip = $passport->sonmp_topo_ip(); # Only 8600 and 1600 have CLIP or Management Virtual IP - if (defined $model and $model =~ /(86|16)/) { + if ( defined $model and $model =~ /(86|16)/ ) { + # Return CLIP (CircuitLess IP) - foreach my $iid (keys %$rc_ip_type){ + foreach my $iid ( keys %$rc_ip_type ) { my $ip_type = $rc_ip_type->{$iid}; - next unless ((defined $ip_type) and ($ip_type =~ /circuitLess/i)); + next + unless ( ( defined $ip_type ) + and ( $ip_type =~ /circuitLess/i ) ); my $ip = $rc_ip_addr->{$iid}; next unless defined $ip; - + return $ip if $passport->snmp_connect_ip($ip); } # Return Management Virtual IP address - if ( (defined $virt_ip) and ($virt_ip ne '0.0.0.0') ) { + if ( ( defined $virt_ip ) and ( $virt_ip ne '0.0.0.0' ) ) { return $virt_ip if $passport->snmp_connect_ip($virt_ip); } } # Return OSPF Router ID - if ((defined $router_ip) and ($router_ip ne '0.0.0.0')) { - foreach my $iid (keys %$rc_ip_addr){ + if ( ( defined $router_ip ) and ( $router_ip ne '0.0.0.0' ) ) { + foreach my $iid ( keys %$rc_ip_addr ) { my $ip = $rc_ip_addr->{$iid}; next unless $router_ip eq $ip; return $router_ip if $passport->snmp_connect_ip($router_ip); } } - # Otherwise Return SONMP Advertised IP Address - foreach my $entry (keys %$sonmp_topo_port){ + # Otherwise Return SONMP Advertised IP Address + foreach my $entry ( keys %$sonmp_topo_port ) { my $port = $sonmp_topo_port->{$entry}; next unless $port == 0; my $ip = $sonmp_topo_ip->{$entry}; - return $ip if ( (defined $ip) and ($ip ne '0.0.0.0') and ($passport->snmp_connect_ip($ip)) ); + return $ip + if (( defined $ip ) + and ( $ip ne '0.0.0.0' ) + and ( $passport->snmp_connect_ip($ip) ) ); } return; } # Required for SNMP::Info::SONMP sub index_factor { - my $passport = shift; - my $model = $passport->model(); + my $passport = shift; + my $model = $passport->model(); my $index_factor = 64; + # Older Accelar models use base 16 instead of 64 - $index_factor = 16 if (defined $model and $model =~ /(105|11[05]0|12[05])/); + $index_factor = 16 + if ( defined $model and $model =~ /(105|11[05]0|12[05])/ ); return $index_factor; } @@ -536,12 +575,12 @@ sub port_offset { # Bridge MIB does not map Bridge Port to ifIndex correctly sub bp_index { my $passport = shift; - my $partial = shift; + my $partial = shift; my $if_index = $passport->i_index($partial) || {}; my %bp_index; - foreach my $iid (keys %$if_index){ + foreach my $iid ( keys %$if_index ) { $bp_index{$iid} = $iid; } return \%bp_index; @@ -552,7 +591,7 @@ sub bp_index { sub e_index { my $passport = shift; - my $model = $passport->model(); + my $model = $passport->model(); my $rc_ps_t = $passport->rc_ps_type() || {}; # We're going to hack an index: Slot/Mda/Postion @@ -562,49 +601,52 @@ sub e_index { # Make up a chassis index $rc_e_index{1} = 1; - + # Power supplies are common, handle them first - foreach my $idx (keys %$rc_ps_t){ + foreach my $idx ( keys %$rc_ps_t ) { next unless $idx; + # We should never have 90 slots, they will also # sort numerically at the bottom - my $index = $idx + 90 ."0000"; + my $index = $idx + 90 . "0000"; $rc_e_index{$index} = $index; } + # Older Accelars use RAPID-CITY::rcCardTable - if (defined $model and $model =~ /(105|11[05]0|12[05])/) { - my $rc_c_t = $passport->rc_c_type() || {}; - foreach my $idx (keys %$rc_c_t){ + if ( defined $model and $model =~ /(105|11[05]0|12[05])/ ) { + my $rc_c_t = $passport->rc_c_type() || {}; + foreach my $idx ( keys %$rc_c_t ) { next unless $idx; - my $index = "$idx"."0000"; + my $index = "$idx" . "0000"; $rc_e_index{$index} = $index; $index++; $rc_e_index{$index} = $index; } } + # All newer models use RAPID-CITY::rc2kCardTable else { - my $rc2_c_t = $passport->rc2k_c_ftype() || {}; + my $rc2_c_t = $passport->rc2k_c_ftype() || {}; my $rc2_m_t = $passport->rc2k_mda_type() || {}; - - foreach my $idx (keys %$rc2_c_t){ + + foreach my $idx ( keys %$rc2_c_t ) { next unless $idx; - my $index = "$idx"."0000"; - for ( 0 .. 2) { + my $index = "$idx" . "0000"; + for ( 0 .. 2 ) { $rc_e_index{$index} = $index; - $index ++; + $index++; } } - foreach my $idx (keys %$rc2_m_t){ + foreach my $idx ( keys %$rc2_m_t ) { next unless $idx; next if $idx == 0; - my ($slot, $mda) = split /\./,$idx; - $mda = sprintf ("%02d", $mda); + my ( $slot, $mda ) = split /\./, $idx; + $mda = sprintf( "%02d", $mda ); - my $index = "$idx"."$mda"."00"; + my $index = "$idx" . "$mda" . "00"; $rc_e_index{$index} = $index; $index++; $rc_e_index{$index} = $index; @@ -616,19 +658,19 @@ sub e_index { sub e_class { my $passport = shift; - my $rc_e_idx = $passport->e_index() || {}; + my $rc_e_idx = $passport->e_index() || {}; my %rc_e_class; - foreach my $iid (keys %$rc_e_idx){ - if ($iid == 1) { + foreach my $iid ( keys %$rc_e_idx ) { + if ( $iid == 1 ) { $rc_e_class{$iid} = 'chassis'; } - elsif ($iid =~/^9(\d)/ and length $iid > 5) { + elsif ( $iid =~ /^9(\d)/ and length $iid > 5 ) { $rc_e_class{$iid} = 'powerSupply'; } - elsif ($iid =~/0000$/) { + elsif ( $iid =~ /0000$/ ) { $rc_e_class{$iid} = 'container'; - } + } else { $rc_e_class{$iid} = 'module'; } @@ -645,58 +687,60 @@ sub e_descr { $rc_ch =~ s/a//; my %rc_e_descr; - + # Chassis $rc_e_descr{1} = $rc_ch; # Power supplies are common, handle them first - foreach my $idx (keys %$rc_ps){ + foreach my $idx ( keys %$rc_ps ) { next unless $idx; my $ps = $rc_ps->{$idx}; next unless $ps; my $index = $idx + 90 . "0000"; $rc_e_descr{$index} = $ps; } + # Older Accelars use RAPID-CITY::rcCardTable - if (defined $model and $model =~ /(105|11[05]0|12[05])/) { - my $rc_c_t = $passport->rc_c_type() || {}; - foreach my $idx (keys %$rc_c_t){ + if ( defined $model and $model =~ /(105|11[05]0|12[05])/ ) { + my $rc_c_t = $passport->rc_c_type() || {}; + foreach my $idx ( keys %$rc_c_t ) { next unless $idx; my $type = $rc_c_t->{$idx}; next unless $type; - my $index = "$idx"."0000"; - $rc_e_descr{$index} = "Slot "."$idx"; + my $index = "$idx" . "0000"; + $rc_e_descr{$index} = "Slot " . "$idx"; $index++; $rc_e_descr{$index} = $type; } } + # All newer models use RAPID-CITY::rc2kCardTable else { - my $rc2_cf = $passport->rc2k_c_fdesc() || {}; - my $rc2_cb = $passport->rc2k_c_bdesc() || {}; + my $rc2_cf = $passport->rc2k_c_fdesc() || {}; + my $rc2_cb = $passport->rc2k_c_bdesc() || {}; my $rc2_m = $passport->rc2k_mda_desc() || {}; - - foreach my $idx (keys %$rc2_cf){ + + foreach my $idx ( keys %$rc2_cf ) { next unless $idx; my $cf = $rc2_cf->{$idx}; next unless $idx; my $cb = $rc2_cb->{$idx}; - my $index = "$idx"."0000"; - $rc_e_descr{$index} = "Slot "."$idx"; + my $index = "$idx" . "0000"; + $rc_e_descr{$index} = "Slot " . "$idx"; $index++; $rc_e_descr{$index} = $cf; $index++; $rc_e_descr{$index} = $cb; } - foreach my $idx (keys %$rc2_m){ + foreach my $idx ( keys %$rc2_m ) { next unless $idx; my $cm = $rc2_m->{$idx}; next unless $cm; - my ($slot, $mda) = split /\./,$idx; - $mda = sprintf ("%02d", $mda); + my ( $slot, $mda ) = split /\./, $idx; + $mda = sprintf( "%02d", $mda ); - my $index = "$idx"."$mda"."00"; + my $index = "$idx" . "$mda" . "00"; $rc_e_descr{$index} = $cm; } } @@ -716,53 +760,55 @@ sub e_type { $rc_e_type{1} = $rc_ch; # Power supplies are common, handle them first - foreach my $idx (keys %$rc_ps){ + foreach my $idx ( keys %$rc_ps ) { next unless $idx; my $ps = $rc_ps->{$idx}; next unless $ps; my $index = $idx + 90 . "0000"; $rc_e_type{$index} = $ps; } + # Older Accelars use RAPID-CITY::rcCardTable - if (defined $model and $model =~ /(105|11[05]0|12[05])/) { - my $rc_c_t = $passport->rc_c_type() || {}; - foreach my $idx (keys %$rc_c_t){ + if ( defined $model and $model =~ /(105|11[05]0|12[05])/ ) { + my $rc_c_t = $passport->rc_c_type() || {}; + foreach my $idx ( keys %$rc_c_t ) { next unless $idx; my $type = $rc_c_t->{$idx}; next unless $type; - my $index = "$idx"."0000"; + my $index = "$idx" . "0000"; $rc_e_type{$index} = "zeroDotZero"; $index++; $rc_e_type{$index} = $type; } } + # All newer models use RAPID-CITY::rc2kCardTable else { - my $rc2_cf = $passport->rc2k_c_ftype() || {}; - my $rc2_cb = $passport->rc2k_c_btype() || {}; + my $rc2_cf = $passport->rc2k_c_ftype() || {}; + my $rc2_cb = $passport->rc2k_c_btype() || {}; my $rc2_m = $passport->rc2k_mda_type() || {}; - - foreach my $idx (keys %$rc2_cf){ + + foreach my $idx ( keys %$rc2_cf ) { next unless $idx; my $cf = $rc2_cf->{$idx}; next unless $idx; my $cb = $rc2_cb->{$idx}; - my $index = "$idx"."0000"; + my $index = "$idx" . "0000"; $rc_e_type{$index} = "zeroDotZero"; $index++; $rc_e_type{$index} = $cf; $index++; $rc_e_type{$index} = $cb; } - foreach my $idx (keys %$rc2_m){ + foreach my $idx ( keys %$rc2_m ) { next unless $idx; my $cm = $rc2_m->{$idx}; next unless $cm; - my ($slot, $mda) = split /\./,$idx; - $mda = sprintf ("%02d", $mda); + my ( $slot, $mda ) = split /\./, $idx; + $mda = sprintf( "%02d", $mda ); - my $index = "$idx"."$mda"."00"; + my $index = "$idx" . "$mda" . "00"; $rc_e_type{$index} = $cm; } } @@ -773,35 +819,38 @@ sub e_name { my $passport = shift; my $model = $passport->model(); - my $rc_e_idx = $passport->e_index() || {}; + my $rc_e_idx = $passport->e_index() || {}; my %rc_e_name; - foreach my $iid (keys %$rc_e_idx){ + foreach my $iid ( keys %$rc_e_idx ) { - if ($iid == 1) { + if ( $iid == 1 ) { $rc_e_name{$iid} = 'Chassis'; next; } - my $mod = int (substr($iid, -4, 2)); - my $slot = substr($iid, -6, 2); + my $mod = int( substr( $iid, -4, 2 ) ); + my $slot = substr( $iid, -6, 2 ); - if ($iid =~/^9(\d)/ and length $iid > 5) { + if ( $iid =~ /^9(\d)/ and length $iid > 5 ) { $rc_e_name{$iid} = "Power Supply $1"; } - elsif ($iid =~/(00){2}$/) { + elsif ( $iid =~ /(00){2}$/ ) { $rc_e_name{$iid} = "Slot $slot"; } - elsif ($iid =~/(00){1}$/) { + elsif ( $iid =~ /(00){1}$/ ) { $rc_e_name{$iid} = "Card $slot, MDA $mod"; } - elsif (defined $model and $model =~ /(105|11[05]0|12[05])/ and $iid =~ /1$/) { + elsif ( defined $model + and $model =~ /(105|11[05]0|12[05])/ + and $iid =~ /1$/ ) + { $rc_e_name{$iid} = "Card $slot"; } - elsif ($iid =~ /1$/) { + elsif ( $iid =~ /1$/ ) { $rc_e_name{$iid} = "Card $slot (front)"; } - elsif ($iid =~ /2$/) { + elsif ( $iid =~ /2$/ ) { $rc_e_name{$iid} = "Card $slot (back)"; } } @@ -820,49 +869,51 @@ sub e_hwver { $rc_e_hwver{1} = $passport->rc_ch_rev(); # Power supplies are common, handle them first - foreach my $idx (keys %$rc_ps){ + foreach my $idx ( keys %$rc_ps ) { next unless $idx; my $ps = $rc_ps->{$idx}; next unless $ps; my $index = $idx + 90 . "0000"; $rc_e_hwver{$index} = $ps; } + # Older Accelars use RAPID-CITY::rcCardTable - if (defined $model and $model =~ /(105|11[05]0|12[05])/) { - my $rc_c_t = $passport->rc_c_rev() || {}; - foreach my $idx (keys %$rc_c_t){ + if ( defined $model and $model =~ /(105|11[05]0|12[05])/ ) { + my $rc_c_t = $passport->rc_c_rev() || {}; + foreach my $idx ( keys %$rc_c_t ) { next unless $idx; my $type = $rc_c_t->{$idx}; next unless $type; - my $index = "$idx"."0001"; + my $index = "$idx" . "0001"; $rc_e_hwver{$index} = $type; } } + # All newer models use RAPID-CITY::rc2kCardTable else { - my $rc2_cf = $passport->rc2k_c_frev() || {}; - my $rc2_cb = $passport->rc2k_c_brev() || {}; + my $rc2_cf = $passport->rc2k_c_frev() || {}; + my $rc2_cb = $passport->rc2k_c_brev() || {}; my $rc2_m = $passport->rc2k_mda_rev() || {}; - - foreach my $idx (keys %$rc2_cf){ + + foreach my $idx ( keys %$rc2_cf ) { next unless $idx; my $cf = $rc2_cf->{$idx}; next unless $idx; my $cb = $rc2_cb->{$idx}; - my $index = "$idx"."0001"; + my $index = "$idx" . "0001"; $rc_e_hwver{$index} = $cf; $index++; $rc_e_hwver{$index} = $cb; } - foreach my $idx (keys %$rc2_m){ + foreach my $idx ( keys %$rc2_m ) { next unless $idx; my $cm = $rc2_m->{$idx}; next unless $cm; - my ($slot, $mda) = split /\./,$idx; - $mda = sprintf ("%02d", $mda); + my ( $slot, $mda ) = split /\./, $idx; + $mda = sprintf( "%02d", $mda ); - my $index = "$idx"."$mda"."00"; + my $index = "$idx" . "$mda" . "00"; $rc_e_hwver{$index} = $cm; } } @@ -872,10 +923,10 @@ sub e_hwver { sub e_vendor { my $passport = shift; - my $rc_e_idx = $passport->e_index() || {}; + my $rc_e_idx = $passport->e_index() || {}; my %rc_e_vendor; - foreach my $iid (keys %$rc_e_idx){ + foreach my $iid ( keys %$rc_e_idx ) { $rc_e_vendor{$iid} = 'nortel'; } return \%rc_e_vendor; @@ -893,49 +944,51 @@ sub e_serial { $rc_e_serial{1} = $passport->rc_serial(); # Power supplies are common, handle them first - foreach my $idx (keys %$rc_ps){ + foreach my $idx ( keys %$rc_ps ) { next unless $idx; my $ps = $rc_ps->{$idx}; next unless $ps; my $index = $idx + 90 . "0000"; $rc_e_serial{$index} = $ps; } + # Older Accelars use RAPID-CITY::rcCardTable - if (defined $model and $model =~ /(105|11[05]0|12[05])/) { - my $rc_c_t = $passport->rc_c_serial() || {}; - foreach my $idx (keys %$rc_c_t){ + if ( defined $model and $model =~ /(105|11[05]0|12[05])/ ) { + my $rc_c_t = $passport->rc_c_serial() || {}; + foreach my $idx ( keys %$rc_c_t ) { next unless $idx; my $type = $rc_c_t->{$idx}; next unless $type; - my $index = "$idx"."0001"; + my $index = "$idx" . "0001"; $rc_e_serial{$index} = $type; } } + # All newer models use RAPID-CITY::rc2kCardTable else { - my $rc2_cf = $passport->rc2k_c_fserial() || {}; - my $rc2_cb = $passport->rc2k_c_bserial() || {}; + my $rc2_cf = $passport->rc2k_c_fserial() || {}; + my $rc2_cb = $passport->rc2k_c_bserial() || {}; my $rc2_m = $passport->rc2k_mda_serial() || {}; - - foreach my $idx (keys %$rc2_cf){ + + foreach my $idx ( keys %$rc2_cf ) { next unless $idx; my $cf = $rc2_cf->{$idx}; next unless $idx; my $cb = $rc2_cb->{$idx}; - my $index = "$idx"."0001"; + my $index = "$idx" . "0001"; $rc_e_serial{$index} = $cf; $index++; $rc_e_serial{$index} = $cb; } - foreach my $idx (keys %$rc2_m){ + foreach my $idx ( keys %$rc2_m ) { next unless $idx; my $cm = $rc2_m->{$idx}; next unless $cm; - my ($slot, $mda) = split /\./,$idx; - $mda = sprintf ("%02d", $mda); + my ( $slot, $mda ) = split /\./, $idx; + $mda = sprintf( "%02d", $mda ); - my $index = "$idx"."$mda"."00"; + my $index = "$idx" . "$mda" . "00"; $rc_e_serial{$index} = $cm; } } @@ -945,22 +998,22 @@ sub e_serial { sub e_pos { my $passport = shift; - my $rc_e_idx = $passport->e_index() || {}; + my $rc_e_idx = $passport->e_index() || {}; my %rc_e_pos; - foreach my $iid (keys %$rc_e_idx){ + foreach my $iid ( keys %$rc_e_idx ) { next unless $iid; - if ($iid == 1) { + if ( $iid == 1 ) { $rc_e_pos{$iid} = -1; next; } - my $sub = int (substr($iid, -2, 2)); - my $mod = int (substr($iid, -4, 2)); - my $slot = substr($iid, -6, 2); - if ($iid =~/(00){2}$/) { + my $sub = int( substr( $iid, -2, 2 ) ); + my $mod = int( substr( $iid, -4, 2 ) ); + my $slot = substr( $iid, -6, 2 ); + if ( $iid =~ /(00){2}$/ ) { $rc_e_pos{$iid} = $slot; } - elsif ($iid =~/(00){1}$/) { + elsif ( $iid =~ /(00){1}$/ ) { $rc_e_pos{$iid} = $mod * 100; } else { @@ -973,21 +1026,21 @@ sub e_pos { sub e_parent { my $passport = shift; - my $rc_e_idx = $passport->e_index() || {}; + my $rc_e_idx = $passport->e_index() || {}; my %rc_e_parent; - foreach my $iid (keys %$rc_e_idx){ + foreach my $iid ( keys %$rc_e_idx ) { next unless $iid; - if ($iid == 1) { + if ( $iid == 1 ) { $rc_e_parent{$iid} = 0; next; } - my $slot = substr($iid, -6, 2); - if ($iid =~/(00){1,2}$/) { + my $slot = substr( $iid, -6, 2 ); + if ( $iid =~ /(00){1,2}$/ ) { $rc_e_parent{$iid} = 1; } else { - $rc_e_parent{$iid} = "$slot"."0000"; + $rc_e_parent{$iid} = "$slot" . "0000"; } } return \%rc_e_parent; @@ -1148,13 +1201,14 @@ Slot and port numbers on the Passport switches are determined by the formula: port = (C) + port_offset, slot = int(C). -The physical port name is returned as slot.port. CPU Ethernet ports are prefixed -with CPU and VLAN interfaces are returned as the VLAN ID prefixed with Vlan. +The physical port name is returned as slot.port. CPU Ethernet ports are +prefixed with CPU and VLAN interfaces are returned as the VLAN ID prefixed +with Vlan. =item $passport->i_mac() -MAC address of the interface. Note this is just the MAC of the port, not anything -connected to it. +MAC address of the interface. Note this is just the MAC of the port, not +anything connected to it. =item $passport->i_description() @@ -1163,8 +1217,8 @@ human and machine friendly. Not always. =item $passport->i_name() -Crosses rc_alias() (C) with ifAlias() and returns the human set port -name if exists. +Crosses rc_alias() (C) with ifAlias() and returns the human set +port name if exists. =item $passport->ip_index() diff --git a/Info/Layer3/Sun.pm b/Info/Layer3/Sun.pm index be0130d4..4f8db83c 100644 --- a/Info/Layer3/Sun.pm +++ b/Info/Layer3/Sun.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,69 +34,65 @@ use strict; use Exporter; use SNMP::Info::Layer3; -@SNMP::Info::Layer3::Sun::ISA = qw/SNMP::Info::Layer3 Exporter/; +@SNMP::Info::Layer3::Sun::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Sun::EXPORT_OK = qw//; -use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; +use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - %SNMP::Info::Layer3::MIBS, - ); +%MIBS = ( %SNMP::Info::Layer3::MIBS, ); %GLOBALS = ( - %SNMP::Info::Layer3::GLOBALS, - 'sun_hostid' => '.1.3.6.1.4.1.42.3.1.2.0', - 'motd' => '.1.3.6.1.4.1.42.3.1.3.0', - ); + %SNMP::Info::Layer3::GLOBALS, + 'sun_hostid' => '.1.3.6.1.4.1.42.3.1.2.0', + 'motd' => '.1.3.6.1.4.1.42.3.1.3.0', +); -%FUNCS = ( - %SNMP::Info::Layer3::FUNCS, - ); +%FUNCS = ( %SNMP::Info::Layer3::FUNCS, ); -%MUNGE = ( - %SNMP::Info::Layer3::MUNGE, - ); +%MUNGE = ( %SNMP::Info::Layer3::MUNGE, ); sub vendor { - return 'sun'; + return 'sun'; } sub os { - return 'sun'; + return 'sun'; } sub os_ver { - my $sun = shift; + my $sun = shift; my $descr = $sun->motd(); return unless defined $descr; - if ($descr =~ m/SunOS (\S+)/) { - return $1; + if ( $descr =~ m/SunOS (\S+)/ ) { + return $1; } return; } sub model { - return 'Solaris Router' + return 'Solaris Router'; } + sub serial { - my $sun = shift; - my $serial = unpack("H*", $sun->sun_hostid()); - return $serial; + my $sun = shift; + my $serial = unpack( "H*", $sun->sun_hostid() ); + return $serial; } sub i_ignore { - my $l3 = shift; + my $l3 = shift; my $partial = shift; my $interfaces = $l3->interfaces($partial) || {}; my %i_ignore; - foreach my $if (keys %$interfaces) { - # lo0 - if ($interfaces->{$if} =~ /\blo0\b/i){ + foreach my $if ( keys %$interfaces ) { + + # lo0 + if ( $interfaces->{$if} =~ /\blo0\b/i ) { $i_ignore{$if}++; } } diff --git a/Info/MAU.pm b/Info/MAU.pm index b2cd8b6c..580b88ed 100644 --- a/Info/MAU.pm +++ b/Info/MAU.pm @@ -5,21 +5,21 @@ # # Copyright (c) 2002,2003 Regents of the University of California # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -36,98 +36,103 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::MAU::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ('MAU-MIB' => 'mauMod'); +%MIBS = ( 'MAU-MIB' => 'mauMod' ); -%GLOBALS = ( - ); +%GLOBALS = (); %FUNCS = ( - # Interface MAU Table - 'mau_index' => 'ifMauIfIndex', - 'mau_link' => 'ifMauType', - 'mau_status' => 'ifMauStatus', - 'mau_up' => 'ifMauMediaAvailable', - 'mau_type' => 'ifMauTypeList', - 'mau_type_admin' => 'ifMauDefaultType', - # Interface Auto-Negotiation Table - 'mau_auto' => 'ifMauAutoNegSupported', - 'mau_autostat' => 'ifMauAutoNegAdminStatus', - 'mau_autosent' => 'ifMauAutoNegCapAdvertised', - 'mau_autorec' => 'ifMauAutoNegCapReceived', - ); + + # Interface MAU Table + 'mau_index' => 'ifMauIfIndex', + 'mau_link' => 'ifMauType', + 'mau_status' => 'ifMauStatus', + 'mau_up' => 'ifMauMediaAvailable', + 'mau_type' => 'ifMauTypeList', + 'mau_type_admin' => 'ifMauDefaultType', + + # Interface Auto-Negotiation Table + 'mau_auto' => 'ifMauAutoNegSupported', + 'mau_autostat' => 'ifMauAutoNegAdminStatus', + 'mau_autosent' => 'ifMauAutoNegCapAdvertised', + 'mau_autorec' => 'ifMauAutoNegCapReceived', +); %MUNGE = ( - # Inherit all the built in munging - %SNMP::Info::MUNGE, - # Add ones for our class - 'mau_type' => \&munge_int2bin, - 'mau_autosent' => \&munge_int2bin, - 'mau_autorec' => \&munge_int2bin, - ); + # Inherit all the built in munging + %SNMP::Info::MUNGE, + + # Add ones for our class + 'mau_type' => \&munge_int2bin, + 'mau_autosent' => \&munge_int2bin, + 'mau_autorec' => \&munge_int2bin, +); sub munge_int2bin { my $int = shift; return unless defined $int; - return unpack("B32", pack("N", $int)); + return unpack( "B32", pack( "N", $int ) ); } -sub _isfullduplex{ - my $mau = shift; +sub _isfullduplex { + my $mau = shift; my $mautype = shift; my @full_types = qw/11 13 16 18 20/; - foreach my $type ( @full_types ) { - return 1 if (substr($mautype,32-$type,1) eq '1') + foreach my $type (@full_types) { + return 1 if ( substr( $mautype, 32 - $type, 1 ) eq '1' ); } return 0; } -sub _ishalfduplex{ - my $mau = shift; +sub _ishalfduplex { + my $mau = shift; my $mautype = shift; my @half_types = qw/10 12 15 17 19/; - foreach my $type ( @half_types ) { - return 1 if (substr($mautype,32-$type,1) eq '1') + foreach my $type (@half_types) { + return 1 if ( substr( $mautype, 32 - $type, 1 ) eq '1' ); } return 0; } my %_mau_i_speed_map = ( - '10' => '10 Mbps', - '100' => '100 Mbps', - '1000' => '1.0 Gbps', - '10Gig' => '10 Gbps', + '10' => '10 Mbps', + '100' => '100 Mbps', + '1000' => '1.0 Gbps', + '10Gig' => '10 Gbps', ); sub mau_i_speed_admin { my $mau = shift; - my $mau_index = $mau->mau_index(); + my $mau_index = $mau->mau_index(); my $mau_type_admin = $mau->mau_type_admin(); my %i_speed_admin; - foreach my $mau_port (keys %$mau_type_admin){ + foreach my $mau_port ( keys %$mau_type_admin ) { my $iid = $mau_index->{$mau_port}; next unless defined $iid; my $type_adminoid = $mau_type_admin->{$mau_port}; - my $type_admin = &SNMP::translateObj($type_adminoid); + my $type_admin = &SNMP::translateObj($type_adminoid); next unless defined $type_admin; - if ($type_adminoid eq '.0.0') { - $i_speed_admin{$iid} = 'auto'; - } elsif ($type_admin =~ /^dot3MauType(.*)Base/ && $_mau_i_speed_map{$1}) { - $i_speed_admin{$iid} = $_mau_i_speed_map{$1}; - } + if ( $type_adminoid eq '.0.0' ) { + $i_speed_admin{$iid} = 'auto'; + } + elsif ($type_admin =~ /^dot3MauType(.*)Base/ + && $_mau_i_speed_map{$1} ) + { + $i_speed_admin{$iid} = $_mau_i_speed_map{$1}; + } } return \%i_speed_admin; } @@ -136,22 +141,23 @@ sub mau_i_duplex { my $mau = shift; my $mau_index = $mau->mau_index(); - my $mau_link = $mau->mau_link(); + my $mau_link = $mau->mau_link(); my %i_duplex; - foreach my $mau_port (keys %$mau_link){ + foreach my $mau_port ( keys %$mau_link ) { my $iid = $mau_index->{$mau_port}; next unless defined $iid; my $linkoid = $mau_link->{$mau_port}; - my $link = &SNMP::translateObj($linkoid); + my $link = &SNMP::translateObj($linkoid); next unless defined $link; my $duplex = undef; - if ($link =~ /fd$/i) { + if ( $link =~ /fd$/i ) { $duplex = 'full'; - } elsif ($link =~ /hd$/i){ + } + elsif ( $link =~ /hd$/i ) { $duplex = 'half'; } @@ -161,46 +167,55 @@ sub mau_i_duplex { } sub mau_i_duplex_admin { - my $mau = shift; + my $mau = shift; my $partial = shift; - my $mau_index = $mau->mau_index(); + my $mau_index = $mau->mau_index(); my %rev_mau_index = reverse %$mau_index; - my $mau_autostat = defined $partial ? $mau->mau_autostat($rev_mau_index{$partial}) : $mau->mau_autostat(); - my $mau_type_admin = defined $partial ? $mau->mau_type_admin($rev_mau_index{$partial}) : $mau->mau_type_admin(); + my $mau_autostat + = defined $partial + ? $mau->mau_autostat( $rev_mau_index{$partial} ) + : $mau->mau_autostat(); + my $mau_type_admin + = defined $partial + ? $mau->mau_type_admin( $rev_mau_index{$partial} ) + : $mau->mau_type_admin(); # Older HP4000's don't implement ifMauDefaultType, but we can # figure out from ifMauAutoNegCapAdvertised what we'd like. - if (!defined($mau_type_admin)) { - if (defined($mau_index)) { - return mau_i_duplex_admin_old($mau,$mau_index,$mau_autostat); - } else { + if ( !defined($mau_type_admin) ) { + if ( defined($mau_index) ) { + return mau_i_duplex_admin_old( $mau, $mau_index, $mau_autostat ); + } + else { return; } } my %i_duplex_admin; - foreach my $mau_port (keys %$mau_type_admin){ + foreach my $mau_port ( keys %$mau_type_admin ) { my $iid = $mau_index->{$mau_port}; next unless defined $iid; my $autostat = $mau_autostat->{$mau_port}; - if (defined $autostat and $autostat =~ /enabled/i){ + if ( defined $autostat and $autostat =~ /enabled/i ) { $i_duplex_admin{$iid} = 'auto'; next; - } + } my $type_adminoid = $mau_type_admin->{$mau_port}; - my $type_admin = &SNMP::translateObj($type_adminoid); + my $type_admin = &SNMP::translateObj($type_adminoid); next unless defined $type_admin; my $duplex = undef; - if ($type_admin =~ /fd$/i) { + if ( $type_admin =~ /fd$/i ) { $duplex = 'full'; - } elsif ($type_admin =~ /hd$/i){ + } + elsif ( $type_admin =~ /hd$/i ) { $duplex = 'half'; - } elsif ($type_admin eq 'zeroDotZero') { + } + elsif ( $type_admin eq 'zeroDotZero' ) { $duplex = 'auto'; } @@ -210,8 +225,8 @@ sub mau_i_duplex_admin { } sub mau_i_duplex_admin_old { - my $mau = shift; - my $mau_index = shift; + my $mau = shift; + my $mau_index = shift; my $mau_autostat = shift; my $interfaces = $mau->interfaces(); @@ -220,23 +235,23 @@ sub mau_i_duplex_admin_old { my %mau_reverse = reverse %$mau_index; my %i_duplex_admin; - foreach my $iid (keys %$interfaces){ + foreach my $iid ( keys %$interfaces ) { my $mau_index = $mau_reverse{$iid}; next unless defined $mau_index; my $autostat = $mau_autostat->{$mau_index}; - + # HP25xx has this value - if (defined $autostat and $autostat =~ /enabled/i){ + if ( defined $autostat and $autostat =~ /enabled/i ) { $i_duplex_admin{$iid} = 'auto'; next; - } - + } + my $type = $mau_autosent->{$mau_index}; - + next unless defined $type; - if ($type == 0) { + if ( $type == 0 ) { $i_duplex_admin{$iid} = 'none'; next; } @@ -244,13 +259,14 @@ sub mau_i_duplex_admin_old { my $full = $mau->_isfullduplex($type); my $half = $mau->_ishalfduplex($type); - if ($full and !$half){ + if ( $full and !$half ) { $i_duplex_admin{$iid} = 'full'; - } elsif ($half) { + } + elsif ($half) { $i_duplex_admin{$iid} = 'half'; - } - } - + } + } + return \%i_duplex_admin; } @@ -289,8 +305,8 @@ devices like HP Switches. MAU = Media Access Unit. The MAU table contains link and duplex info for the port itself and the device connected to that port. -Normally you use or create a subclass of SNMP::Info that inherits this one. Do -not use directly. +Normally you use or create a subclass of SNMP::Info that inherits this one. +Do not use directly. For debugging purposes call the class directly as you would SNMP::Info @@ -450,13 +466,13 @@ capabilities of the device on the other end. =item $mau->_isfullduplex(bitstring) - Boolean. Checks to see if any of the full_duplex types from mau_type() are - high. Currently bits 11,13,16,18,20. + Boolean. Checks to see if any of the full_duplex types from mau_type() + are high. Currently bits 11,13,16,18,20. =item $mau->_ishalfduplex(bitstring) - Boolean. Checks to see if any of the half_duplex types from mau_type() are - high. Currently bits 10,12,15,17,19. + Boolean. Checks to see if any of the half_duplex types from mau_type() + are high. Currently bits 10,12,15,17,19. =back diff --git a/Info/NortelStack.pm b/Info/NortelStack.pm index 7ef1e47e..cb9e3744 100644 --- a/Info/NortelStack.pm +++ b/Info/NortelStack.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Eric Miller # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,67 +34,74 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::NortelStack::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; -$VERSION = '1.09'; +$VERSION = '1.09'; -%MIBS = ( - # S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below - 'S5-AGENT-MIB' => 's5AgMyGrpIndx', - 'S5-CHASSIS-MIB' => 's5ChasType', - 'S5-REG-MIB' => 's5ChasTypeVal', - ); +%MIBS = ( + + # S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below + 'S5-AGENT-MIB' => 's5AgMyGrpIndx', + 'S5-CHASSIS-MIB' => 's5ChasType', + 'S5-REG-MIB' => 's5ChasTypeVal', +); %GLOBALS = ( - # From S5-AGENT-MIB - 'ns_ag_ver' => 's5AgInfoVer', - 'ns_op_mode' => 's5AgSysCurrentOperationalMode', - 'ns_auto_pvid' => 's5AgSysAutoPvid', - 'tftp_host' => 's5AgSysTftpServerAddress', - 'tftp_file' => 's5AgSysBinaryConfigFilename', - 'tftp_action' => 's5AgInfoFileAction', - 'tftp_result' => 's5AgInfoFileStatus', - 'vlan' => 's5AgSysManagementVlanId', - # From S5-CHASSIS-MIB - 'ns_serial' => 's5ChasSerNum', - 'ns_ch_type' => 's5ChasType', - 'ns_cfg_chg' => 's5ChasGblConfChngs', - 'ns_cfg_time' => 's5ChasGblConfLstChng', - ); -%FUNCS = ( - # From S5-AGENT-MIB::s5AgMyIfTable - 'i_cfg_file' => 's5AgMyIfCfgFname', - 'i_cfg_host' => 's5AgMyIfLdSvrAddr', - # From S5-CHASSIS-MIB::s5ChasGrpTable - 'ns_grp_type' => 's5ChasGrpType', - # From S5-CHASSIS-MIB::s5ChasComTable - 'ns_com_grp_idx' => 's5ChasComGrpIndx', - 'ns_com_idx' => 's5ChasComIndx', - 'ns_com_sub_idx' => 's5ChasComSubIndx', - 'ns_com_type' => 's5ChasComType', - 'ns_com_descr' => 's5ChasComDescr', - 'ns_com_ver' => 's5ChasComVer', - 'ns_com_serial' => 's5ChasComSerNum', - # From S5-CHASSIS-MIB::s5ChasStoreTable - 'ns_store_grp_idx' => 's5ChasStoreGrpIndx', - 'ns_store_com_idx' => 's5ChasStoreComIndx', - 'ns_store_sub_idx' => 's5ChasStoreSubIndx', - 'ns_store_idx' => 's5ChasStoreIndx', - 'ns_store_type' => 's5ChasStoreType', - 'ns_store_size' => 's5ChasStoreCurSize', - 'ns_store_ver' => 's5ChasStoreCntntVer', - ); + # From S5-AGENT-MIB + 'ns_ag_ver' => 's5AgInfoVer', + 'ns_op_mode' => 's5AgSysCurrentOperationalMode', + 'ns_auto_pvid' => 's5AgSysAutoPvid', + 'tftp_host' => 's5AgSysTftpServerAddress', + 'tftp_file' => 's5AgSysBinaryConfigFilename', + 'tftp_action' => 's5AgInfoFileAction', + 'tftp_result' => 's5AgInfoFileStatus', + 'vlan' => 's5AgSysManagementVlanId', + + # From S5-CHASSIS-MIB + 'ns_serial' => 's5ChasSerNum', + 'ns_ch_type' => 's5ChasType', + 'ns_cfg_chg' => 's5ChasGblConfChngs', + 'ns_cfg_time' => 's5ChasGblConfLstChng', +); + +%FUNCS = ( + + # From S5-AGENT-MIB::s5AgMyIfTable + 'i_cfg_file' => 's5AgMyIfCfgFname', + 'i_cfg_host' => 's5AgMyIfLdSvrAddr', + + # From S5-CHASSIS-MIB::s5ChasGrpTable + 'ns_grp_type' => 's5ChasGrpType', + + # From S5-CHASSIS-MIB::s5ChasComTable + 'ns_com_grp_idx' => 's5ChasComGrpIndx', + 'ns_com_idx' => 's5ChasComIndx', + 'ns_com_sub_idx' => 's5ChasComSubIndx', + 'ns_com_type' => 's5ChasComType', + 'ns_com_descr' => 's5ChasComDescr', + 'ns_com_ver' => 's5ChasComVer', + 'ns_com_serial' => 's5ChasComSerNum', + + # From S5-CHASSIS-MIB::s5ChasStoreTable + 'ns_store_grp_idx' => 's5ChasStoreGrpIndx', + 'ns_store_com_idx' => 's5ChasStoreComIndx', + 'ns_store_sub_idx' => 's5ChasStoreSubIndx', + 'ns_store_idx' => 's5ChasStoreIndx', + 'ns_store_type' => 's5ChasStoreType', + 'ns_store_size' => 's5ChasStoreCurSize', + 'ns_store_ver' => 's5ChasStoreCntntVer', +); %MUNGE = ( - 'ns_ch_type' => \&SNMP::Info::munge_e_type, - 'ns_grp_type' => \&munge_ns_grp_type, - 'ns_com_type' => \&SNMP::Info::munge_e_type, - 'ns_store_type' => \&SNMP::Info::munge_e_type, - ); + 'ns_ch_type' => \&SNMP::Info::munge_e_type, + 'ns_grp_type' => \&munge_ns_grp_type, + 'ns_com_type' => \&SNMP::Info::munge_e_type, + 'ns_store_type' => \&SNMP::Info::munge_e_type, +); sub os_ver { my $stack = shift; @@ -102,13 +109,13 @@ sub os_ver { my $ver = $stack->ns_ag_ver(); return unless defined $ver; - if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){ + if ( $ver =~ m/(\d+\.\d+\.\d+\.\d+)/ ) { return $1; - } - if ($ver =~ m/V(\d+\.\d+\.\d+)/i){ + } + if ( $ver =~ m/V(\d+\.\d+\.\d+)/i ) { return $1; - } - return; + } + return; } sub os_bin { @@ -117,13 +124,13 @@ sub os_bin { my $ver = $stack->ns_ag_ver(); return unless defined $ver; - if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/i){ - return $1; - } - if ($ver =~ m/V(\d+\.\d+.\d+)/i){ + if ( $ver =~ m/(\d+\.\d+\.\d+\.\d+)/i ) { return $1; } - return; + if ( $ver =~ m/V(\d+\.\d+.\d+)/i ) { + return $1; + } + return; } # Need to override here since overridden in Layer2 and Layer3 classes @@ -132,33 +139,33 @@ sub serial { my $ver = $stack->ns_serial(); return $ver unless !defined $ver; - + return; } # Pseudo ENTITY-MIB methods for older switches with don't support ENTITY-MIB # This class supports both stackable and chassis based switches, identify if -# we have a stackable so that we return appropriate entPhysicalClass +# we have a stackable so that we return appropriate entPhysicalClass sub _ns_e_is_virtual { - my $stack = shift; + my $stack = shift; - # We really only need one value, but we want this cached since most methods - # call it at least via ns_e_index() + # We really only need one value, but we want this cached since most + # methods call it at least via ns_e_index() my $v_test = $stack->s5ChasComRelPos() || {}; return $v_test->{'8.1.0'}; } # Identify is the stackable is actually a stack vs. single switch sub _ns_e_is_stack { - my $stack = shift; + my $stack = shift; my $s_test = $stack->ns_e_class() || {}; - - foreach my $iid (keys %$s_test){ + + foreach my $iid ( keys %$s_test ) { my $class = $s_test->{$iid}; next unless defined $class; - return 1 if ($class eq 'stack'); + return 1 if ( $class eq 'stack' ); } return 0; } @@ -171,20 +178,22 @@ sub ns_e_index { my $is_virtual = $stack->_ns_e_is_virtual(); my %ns_e_index; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { + # Skip backplane, power, sensor, fan, clock - these aren't in the # newer devices ENTITY-MIB we're emulating - next if ($iid =~ /^[24567]/); - next if (($is_virtual) and ($iid =~ /^8/ or $iid eq '1.0.0')); + next if ( $iid =~ /^[24567]/ ); + next if ( ($is_virtual) and ( $iid =~ /^8/ or $iid eq '1.0.0' ) ); + # Format into consistent integer format so that numeric sorting works - my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); + my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid ); $ns_e_index{$iid} = $index; } return \%ns_e_index; } sub ns_e_class { - my $stack = shift; + my $stack = shift; my $partial = shift; my $ns_e_idx = $stack->ns_e_index($partial) || {}; @@ -193,18 +202,18 @@ sub ns_e_class { my $is_virtual = $stack->_ns_e_is_virtual(); my %ns_e_class; - foreach my $iid (keys %$ns_e_idx){ - my ($grp, $idx, $sub) = split (/\./,$iid); + foreach my $iid ( keys %$ns_e_idx ) { + my ( $grp, $idx, $sub ) = split( /\./, $iid ); next unless defined $grp; my $class = $classes->{$grp}; next unless defined $class; my $enc = $ns_grp_enc->{$grp}; # Handle quirks of dealing with both stacks and chassis - if ((!$is_virtual) and ($grp == 1)) { + if ( ( !$is_virtual ) and ( $grp == 1 ) ) { $class = 'module'; } - if (($is_virtual) and ($grp == 3) and !($idx % $enc)) { + if ( ($is_virtual) and ( $grp == 3 ) and !( $idx % $enc ) ) { $class = 'chassis'; } @@ -217,11 +226,11 @@ sub ns_e_descr { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_descr = $stack->ns_com_descr($partial) || {}; my %ns_e_descr; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { my $descr = $ns_e_descr->{$iid}; next unless defined $descr; @@ -231,29 +240,29 @@ sub ns_e_descr { } sub ns_e_name { - my $stack = shift; + my $stack = shift; my $partial = shift; - my $ns_class = $stack->ns_e_class() || {}; - my $ns_e_idx = $stack->ns_e_index() || {}; + my $ns_class = $stack->ns_e_class() || {}; + my $ns_e_idx = $stack->ns_e_index() || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $is_virtual = $stack->_ns_e_is_virtual(); my %ns_e_name; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { - my ($grp, $idx, $sub) = split (/\./,$iid); + my ( $grp, $idx, $sub ) = split( /\./, $iid ); my $class = $ns_class->{$iid}; next unless defined $class; my $enc = $ns_grp_enc->{$grp}; - if ((!$is_virtual) and ($grp == 1)) { + if ( ( !$is_virtual ) and ( $grp == 1 ) ) { $ns_e_name{$iid} = 'Supervisory Module'; } - elsif ($class eq 'stack') { + elsif ( $class eq 'stack' ) { $ns_e_name{$iid} = 'Stack Master Unit'; } - elsif ($class eq 'chassis') { + elsif ( $class eq 'chassis' ) { if ($is_virtual) { my $unit = $idx / $enc; $ns_e_name{$iid} = "Switch Unit $unit"; @@ -262,13 +271,13 @@ sub ns_e_name { $ns_e_name{$iid} = "Chassis"; } } - elsif ($class eq 'module') { + elsif ( $class eq 'module' ) { if ($is_virtual) { - my $unit = int ($idx / $enc); + my $unit = int( $idx / $enc ); my $mda = $idx % $enc; $ns_e_name{$iid} = "Switch Unit $unit, MDA $mda"; } - elsif ($sub != 0) { + elsif ( $sub != 0 ) { $ns_e_name{$iid} = "Module Slot $idx, Subcomponent $sub"; } else { @@ -287,7 +296,7 @@ sub ns_e_hwver { my $ns_e_ver = $stack->ns_com_ver($partial) || {}; my %ns_e_hwver; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { my $ver = $ns_e_ver->{$iid}; next unless defined $ver; @@ -303,7 +312,7 @@ sub ns_e_vendor { my $ns_e_idx = $stack->ns_e_index($partial) || {}; my %ns_e_vendor; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { my $vendor = 'nortel'; $ns_e_vendor{$iid} = $vendor; @@ -315,11 +324,11 @@ sub ns_e_serial { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_serial = $stack->ns_com_serial($partial) || {}; my %ns_e_serial; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { my $serial = $ns_e_serial->{$iid}; next unless defined $serial; @@ -332,17 +341,17 @@ sub ns_e_type { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_type = $stack->ns_com_type($partial) || {}; my $is_stack = $stack->_ns_e_is_stack(); my $ch_type = $stack->ns_ch_type(); my %ns_e_type; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { my $type = $ns_e_type->{$iid}; next unless defined $type; - - if ($is_stack and $iid =~ /^1/) { + + if ( $is_stack and $iid =~ /^1/ ) { $type = $ch_type; } $ns_e_type{$iid} = $type; @@ -354,18 +363,18 @@ sub ns_e_pos { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $is_stack = $stack->_ns_e_is_stack(); my $is_virtual = $stack->_ns_e_is_virtual(); my %ns_e_pos; - foreach my $iid (keys %$ns_e_idx){ - my ($grp, $pos, $idx) = split (/\./,$iid); + foreach my $iid ( keys %$ns_e_idx ) { + my ( $grp, $pos, $idx ) = split( /\./, $iid ); next unless defined $grp; next unless defined $pos; - if ($grp == 1) { + if ( $grp == 1 ) { if ($is_stack) { $pos = -1; } @@ -373,22 +382,22 @@ sub ns_e_pos { $pos = 99; } } - elsif ($grp == 3 and $idx == 0 ) { + elsif ( $grp == 3 and $idx == 0 ) { my $enc = $ns_grp_enc->{$grp}; - if ($is_virtual and ($pos % $enc)) { - $pos = int ($pos % $enc); + if ( $is_virtual and ( $pos % $enc ) ) { + $pos = int( $pos % $enc ); } - elsif ($is_virtual and !$is_stack and !($pos % $enc)) { + elsif ( $is_virtual and !$is_stack and !( $pos % $enc ) ) { $pos = -1; } - elsif ($is_virtual and !($pos % $enc)) { - $pos = ($pos / $enc); + elsif ( $is_virtual and !( $pos % $enc ) ) { + $pos = ( $pos / $enc ); } } - elsif (!$is_stack and $grp == 3) { + elsif ( !$is_stack and $grp == 3 ) { $pos = $idx; } - elsif ($grp == 8) { + elsif ( $grp == 8 ) { $pos = -1; } $ns_e_pos{$iid} = $pos; @@ -400,23 +409,23 @@ sub ns_e_fwver { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; - my $ns_e_ver = $stack->ns_store_ver($partial) || {}; - my $ns_e_type = $stack->ns_store_type($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_ver = $stack->ns_store_ver($partial) || {}; + my $ns_e_type = $stack->ns_store_type($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; - my $is_virt = $stack->_ns_e_is_virtual(); + my $is_virt = $stack->_ns_e_is_virtual(); my %ns_e_fwver; - foreach my $iid (keys %$ns_e_type){ + foreach my $iid ( keys %$ns_e_type ) { my $type = $ns_e_type->{$iid}; next unless defined $type; next unless $type =~ /(rom|boot|fw)/i; - my $ver = $ns_e_ver->{$iid}; + my $ver = $ns_e_ver->{$iid}; next unless defined $ver; $iid =~ s/\.\d+$//; - + if ($is_virt) { - my ($grp, $idx, $pos) = split (/\./,$iid); + my ( $grp, $idx, $pos ) = split( /\./, $iid ); my $enc = $ns_grp_enc->{$grp}; $idx = $idx * $enc; $iid = "3.$idx.$pos"; @@ -430,23 +439,23 @@ sub ns_e_swver { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; - my $ns_e_ver = $stack->ns_store_ver($partial) || {}; - my $ns_e_type = $stack->ns_store_type($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_ver = $stack->ns_store_ver($partial) || {}; + my $ns_e_type = $stack->ns_store_type($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; - my $is_virt = $stack->_ns_e_is_virtual(); + my $is_virt = $stack->_ns_e_is_virtual(); my %ns_e_swver; - foreach my $iid (keys %$ns_e_type){ + foreach my $iid ( keys %$ns_e_type ) { my $type = $ns_e_type->{$iid}; next unless defined $type; next unless $type =~ /(flash)/i; - my $ver = $ns_e_ver->{$iid}; + my $ver = $ns_e_ver->{$iid}; next unless defined $ver; $iid =~ s/\.\d+$//; if ($is_virt) { - my ($grp, $idx, $pos) = split (/\./,$iid); + my ( $grp, $idx, $pos ) = split( /\./, $iid ); my $enc = $ns_grp_enc->{$grp}; $idx = $idx * $enc; $iid = "3.$idx.$pos"; @@ -460,20 +469,20 @@ sub ns_e_parent { my $stack = shift; my $partial = shift; - my $ns_e_idx = $stack->ns_e_index($partial) || {}; + my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $is_stack = $stack->_ns_e_is_stack(); my $is_virtual = $stack->_ns_e_is_virtual(); my %ns_e_parent; - foreach my $iid (keys %$ns_e_idx){ + foreach my $iid ( keys %$ns_e_idx ) { my $index = $ns_e_idx->{$iid}; - my ($grp, $idx, $pos) = split (/\./,$iid); + my ( $grp, $idx, $pos ) = split( /\./, $iid ); next unless defined $grp; - if ($grp == 8) { - $ns_e_parent{$iid} = '0'; + if ( $grp == 8 ) { + $ns_e_parent{$iid} = '0'; } - if ($grp == 1) { + if ( $grp == 1 ) { if ($is_stack) { $ns_e_parent{$iid} = '0'; } @@ -481,27 +490,28 @@ sub ns_e_parent { $ns_e_parent{$iid} = '080100'; } } - if ($grp == 3) { + if ( $grp == 3 ) { my $enc = $ns_grp_enc->{$grp}; - if ($idx % $enc) { - my $npos = ($idx % $enc) * $enc; - my @parent = ($grp, $npos, $pos); - my $parent = join('',map { sprintf "%02d",$_ } @parent); + if ( $idx % $enc ) { + my $npos = ( $idx % $enc ) * $enc; + my @parent = ( $grp, $npos, $pos ); + my $parent = join( '', map { sprintf "%02d", $_ } @parent ); $ns_e_parent{$iid} = $parent; } elsif ($is_stack) { $ns_e_parent{$iid} = '010100'; } - elsif ($is_virtual and !$is_stack) { + elsif ( $is_virtual and !$is_stack ) { $ns_e_parent{$iid} = 0; } - elsif ($pos == 0) { + elsif ( $pos == 0 ) { $ns_e_parent{$iid} = '080100'; } else { my $parent = $iid; $parent =~ s/\.\d+$/\.00/; - $parent = join('',map { sprintf "%02d",$_ } split /\./, $parent); + $parent = join( '', map { sprintf "%02d", $_ } split /\./, + $parent ); $ns_e_parent{$iid} = $parent; } } @@ -512,21 +522,21 @@ sub ns_e_parent { sub munge_ns_grp_type { my $oid = shift; - + my %e_class = ( - Sup => 'stack', - Bkpl => 'backplane', - Brd => 'module', - Pwr => 'powerSupply', - TmpSnr => 'sensor', - Fan => 'fan', - Clk => 'other', - Unit => 'chassis', - ); + Sup => 'stack', + Bkpl => 'backplane', + Brd => 'module', + Pwr => 'powerSupply', + TmpSnr => 'sensor', + Fan => 'fan', + Clk => 'other', + Unit => 'chassis', + ); my $name = &SNMP::translateObj($oid); $name =~ s/s5ChasGrp//; - if ((defined($name)) and (exists($e_class{$name}))) { + if ( ( defined($name) ) and ( exists( $e_class{$name} ) ) ) { $name = $e_class{$name}; } return $name if defined($name); @@ -712,8 +722,8 @@ server =item $stack->ns_com_grp_idx() -Returns reference to hash. Key: Table entry, Value: Index of the chassis level -group which contains this component. +Returns reference to hash. Key: Table entry, Value: Index of the chassis +level group which contains this component. (C) diff --git a/Info/PowerEthernet.pm b/Info/PowerEthernet.pm index bc7f3ea4..d62ecfd0 100644 --- a/Info/PowerEthernet.pm +++ b/Info/PowerEthernet.pm @@ -3,21 +3,21 @@ # # Copyright (c) 2008 Bill Fenner # All rights reserved. -# -# Redistribution and use in source and binary forms, with or without +# +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,32 +34,32 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::PowerEthernet::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::PowerEthernet::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::PowerEthernet::EXPORT_OK = qw//; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; $VERSION = '1.09'; -%MIBS = ('POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus'); +%MIBS = ( 'POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus' ); -%GLOBALS = ( - ); +%GLOBALS = (); -%FUNCS = ( - # parts of pethPsePortTable - 'peth_port_admin' => 'pethPsePortAdminEnable', - 'peth_port_status' => 'pethPsePortDetectionStatus', - 'peth_port_class' => 'pethPsePortPowerClassifications', - # pethMainPseTable - 'peth_power_watts' => 'pethMainPsePower', - 'peth_power_status' => 'pethMainPseOperStatus', - 'peth_power_consumption' => 'pethMainPseConsumptionPower', - 'peth_power_threshold' => 'pethMainPseUsageThreshold', - ); +%FUNCS = ( -%MUNGE = ( - ); + # parts of pethPsePortTable + 'peth_port_admin' => 'pethPsePortAdminEnable', + 'peth_port_status' => 'pethPsePortDetectionStatus', + 'peth_port_class' => 'pethPsePortPowerClassifications', + + # pethMainPseTable + 'peth_power_watts' => 'pethMainPsePower', + 'peth_power_status' => 'pethMainPseOperStatus', + 'peth_power_consumption' => 'pethMainPseConsumptionPower', + 'peth_power_threshold' => 'pethMainPseUsageThreshold', +); + +%MUNGE = (); # POWER-ETHERNET-MIB doesn't define a mapping of its # "module"/"port" index to ifIndex. Different vendors @@ -69,21 +69,22 @@ $VERSION = '1.09'; # If there is a module != 1, this heuristic doesn't work # so returns undef. sub peth_port_ifindex { - my $peth = shift; + my $peth = shift; my $partial = shift; my $peth_port_status = $peth->peth_port_status($partial); my $peth_port_ifindex; - foreach my $i (keys %$peth_port_status) { - my ($module, $port) = split(/\./, $i); - if ($module != 1) { - # This heuristic won't work, so say that we got nothing. - # If you have this case, you have to write a device-specific - # version of this function. - return; - } - $peth_port_ifindex->{$i} = $port; + foreach my $i ( keys %$peth_port_status ) { + my ( $module, $port ) = split( /\./, $i ); + if ( $module != 1 ) { + + # This heuristic won't work, so say that we got nothing. + # If you have this case, you have to write a device-specific + # version of this function. + return; + } + $peth_port_ifindex->{$i} = $port; } return $peth_port_ifindex; } @@ -122,7 +123,8 @@ F is used to describe PoE (IEEE 802.3af) Create or use a device subclass that inherit this class. Do not use directly. -For debugging purposes you can call this class directly as you would SNMP::Info +For debugging purposes you can call this class directly as you would +SNMP::Info my $poe = new SNMP::Info::PowerEthernet (...); diff --git a/Info/RapidCity.pm b/Info/RapidCity.pm index 11262829..968ec179 100644 --- a/Info/RapidCity.pm +++ b/Info/RapidCity.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,120 +34,129 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::RapidCity::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::RapidCity::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::RapidCity::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'RAPID-CITY' => 'rapidCity', - ); +%MIBS = ( 'RAPID-CITY' => 'rapidCity', ); %GLOBALS = ( - 'rc_serial' => 'rcChasSerialNumber', - 'chassis' => 'rcChasType', - 'slots' => 'rcChasNumSlots', - 'tftp_host' => 'rcTftpHost', - 'tftp_file' => 'rcTftpFile', - 'tftp_action' => 'rcTftpAction', - 'tftp_result' => 'rcTftpResult', - 'rc_ch_rev' => 'rcChasHardwareRevision', - 'rc_base_mac' => 'rc2kChassisBaseMacAddr', - 'rc_virt_ip' => 'rcSysVirtualIpAddr', - 'rc_virt_mask' => 'rcSysVirtualNetMask', - ); + 'rc_serial' => 'rcChasSerialNumber', + 'chassis' => 'rcChasType', + 'slots' => 'rcChasNumSlots', + 'tftp_host' => 'rcTftpHost', + 'tftp_file' => 'rcTftpFile', + 'tftp_action' => 'rcTftpAction', + 'tftp_result' => 'rcTftpResult', + 'rc_ch_rev' => 'rcChasHardwareRevision', + 'rc_base_mac' => 'rc2kChassisBaseMacAddr', + 'rc_virt_ip' => 'rcSysVirtualIpAddr', + 'rc_virt_mask' => 'rcSysVirtualNetMask', +); -%FUNCS = ( - # From RAPID-CITY::rcPortTable - 'rc_index' => 'rcPortIndex', - 'rc_duplex' => 'rcPortOperDuplex', - 'rc_duplex_admin' => 'rcPortAdminDuplex', - 'rc_speed_admin' => 'rcPortAdminSpeed', - 'rc_auto' => 'rcPortAutoNegotiate', - 'rc_alias' => 'rcPortName', - # From RAPID-CITY::rc2kCpuEthernetPortTable - 'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex', - 'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus', - 'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus', - 'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr', - 'rc_cpu_mask' => 'rc2kCpuEthernetPortMask', - 'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate', - 'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex', - 'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex', - 'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed', - 'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed', - 'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr', - # From RAPID-CITY::rcVlanPortTable - 'rc_i_vlan_if' => 'rcVlanPortIndex', - 'rc_i_vlan_num' => 'rcVlanPortNumVlanIds', - 'rc_i_vlan' => 'rcVlanPortVlanIds', - 'rc_i_vlan_type' => 'rcVlanPortType', - 'rc_i_vlan_pvid' => 'rcVlanPortDefaultVlanId', - 'rc_i_vlan_tag' => 'rcVlanPortPerformTagging', - # From RAPID-CITY::rcVlanTable - 'rc_vlan_id' => 'rcVlanId', - 'v_name' => 'rcVlanName', - 'rc_vlan_color' => 'rcVlanColor', - 'rc_vlan_if' => 'rcVlanIfIndex', - 'rc_vlan_stg' => 'rcVlanStgId', - 'rc_vlan_type' => 'rcVlanType', - 'rc_vlan_members' => 'rcVlanPortMembers', - 'rc_vlan_no_join' => 'rcVlanNotAllowToJoin', - 'rc_vlan_mac' => 'rcVlanMacAddress', - 'rc_vlan_rstatus' => 'rcVlanRowStatus', - # From RAPID-CITY::rcIpAddrTable - 'rc_ip_index' => 'rcIpAdEntIfIndex', - 'rc_ip_addr' => 'rcIpAdEntAddr', - 'rc_ip_type' => 'rcIpAdEntIfType', - # From RAPID-CITY::rcChasFanTable - 'rc_fan_op' => 'rcChasFanOperStatus', - # From RAPID-CITY::rcChasPowerSupplyTable - 'rc_ps_op' => 'rcChasPowerSupplyOperStatus', - # From RAPID-CITY::rcChasPowerSupplyDetailTable - 'rc_ps_type' => 'rcChasPowerSupplyDetailType', - 'rc_ps_serial' => 'rcChasPowerSupplyDetailSerialNumber', - 'rc_ps_rev' => 'rcChasPowerSupplyDetailHardwareRevision', - 'rc_ps_part' => 'rcChasPowerSupplyDetailPartNumber', - 'rc_ps_detail' => 'rcChasPowerSupplyDetailDescription', - # From RAPID-CITY::rcCardTable - 'rc_c_type' => 'rcCardType', - 'rc_c_serial' => 'rcCardSerialNumber', - 'rc_c_rev' => 'rcCardHardwareRevision', - 'rc_c_part' => 'rcCardPartNumber', - # From RAPID-CITY::rc2kCardTable - 'rc2k_c_ftype' => 'rc2kCardFrontType', - 'rc2k_c_fdesc' => 'rc2kCardFrontDescription', - 'rc2k_c_fserial' => 'rc2kCardFrontSerialNum', - 'rc2k_c_frev' => 'rc2kCardFrontHwVersion', - 'rc2k_c_fpart' => 'rc2kCardFrontPartNumber', - 'rc2k_c_fdate' => 'rc2kCardFrontDateCode', - 'rc2k_c_fdev' => 'rc2kCardFrontDeviations', - 'rc2k_c_btype' => 'rc2kCardBackType', - 'rc2k_c_bdesc' => 'rc2kCardBackDescription', - 'rc2k_c_bserial' => 'rc2kCardBackSerialNum', - 'rc2k_c_brev' => 'rc2kCardBackHwVersion', - 'rc2k_c_bpart' => 'rc2kCardBackPartNumber', - 'rc2k_c_bdate' => 'rc2kCardBackDateCode', - 'rc2k_c_bdev' => 'rc2kCardBackDeviations', - # From RAPID-CITY::rc2kMdaCardTable - 'rc2k_mda_type' => 'rc2kMdaCardType', - 'rc2k_mda_desc' => 'rc2kMdaCardDescription', - 'rc2k_mda_serial' => 'rc2kMdaCardSerialNum', - 'rc2k_mda_rev' => 'rc2kMdaCardHwVersion', - 'rc2k_mda_part' => 'rc2kMdaCardPartNumber', - 'rc2k_mda_date' => 'rc2kMdaCardDateCode', - 'rc2k_mda_dev' => 'rc2kMdaCardDeviations', - ); +%FUNCS = ( + + # From RAPID-CITY::rcPortTable + 'rc_index' => 'rcPortIndex', + 'rc_duplex' => 'rcPortOperDuplex', + 'rc_duplex_admin' => 'rcPortAdminDuplex', + 'rc_speed_admin' => 'rcPortAdminSpeed', + 'rc_auto' => 'rcPortAutoNegotiate', + 'rc_alias' => 'rcPortName', + + # From RAPID-CITY::rc2kCpuEthernetPortTable + 'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex', + 'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus', + 'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus', + 'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr', + 'rc_cpu_mask' => 'rc2kCpuEthernetPortMask', + 'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate', + 'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex', + 'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex', + 'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed', + 'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed', + 'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr', + + # From RAPID-CITY::rcVlanPortTable + 'rc_i_vlan_if' => 'rcVlanPortIndex', + 'rc_i_vlan_num' => 'rcVlanPortNumVlanIds', + 'rc_i_vlan' => 'rcVlanPortVlanIds', + 'rc_i_vlan_type' => 'rcVlanPortType', + 'rc_i_vlan_pvid' => 'rcVlanPortDefaultVlanId', + 'rc_i_vlan_tag' => 'rcVlanPortPerformTagging', + + # From RAPID-CITY::rcVlanTable + 'rc_vlan_id' => 'rcVlanId', + 'v_name' => 'rcVlanName', + 'rc_vlan_color' => 'rcVlanColor', + 'rc_vlan_if' => 'rcVlanIfIndex', + 'rc_vlan_stg' => 'rcVlanStgId', + 'rc_vlan_type' => 'rcVlanType', + 'rc_vlan_members' => 'rcVlanPortMembers', + 'rc_vlan_no_join' => 'rcVlanNotAllowToJoin', + 'rc_vlan_mac' => 'rcVlanMacAddress', + 'rc_vlan_rstatus' => 'rcVlanRowStatus', + + # From RAPID-CITY::rcIpAddrTable + 'rc_ip_index' => 'rcIpAdEntIfIndex', + 'rc_ip_addr' => 'rcIpAdEntAddr', + 'rc_ip_type' => 'rcIpAdEntIfType', + + # From RAPID-CITY::rcChasFanTable + 'rc_fan_op' => 'rcChasFanOperStatus', + + # From RAPID-CITY::rcChasPowerSupplyTable + 'rc_ps_op' => 'rcChasPowerSupplyOperStatus', + + # From RAPID-CITY::rcChasPowerSupplyDetailTable + 'rc_ps_type' => 'rcChasPowerSupplyDetailType', + 'rc_ps_serial' => 'rcChasPowerSupplyDetailSerialNumber', + 'rc_ps_rev' => 'rcChasPowerSupplyDetailHardwareRevision', + 'rc_ps_part' => 'rcChasPowerSupplyDetailPartNumber', + 'rc_ps_detail' => 'rcChasPowerSupplyDetailDescription', + + # From RAPID-CITY::rcCardTable + 'rc_c_type' => 'rcCardType', + 'rc_c_serial' => 'rcCardSerialNumber', + 'rc_c_rev' => 'rcCardHardwareRevision', + 'rc_c_part' => 'rcCardPartNumber', + + # From RAPID-CITY::rc2kCardTable + 'rc2k_c_ftype' => 'rc2kCardFrontType', + 'rc2k_c_fdesc' => 'rc2kCardFrontDescription', + 'rc2k_c_fserial' => 'rc2kCardFrontSerialNum', + 'rc2k_c_frev' => 'rc2kCardFrontHwVersion', + 'rc2k_c_fpart' => 'rc2kCardFrontPartNumber', + 'rc2k_c_fdate' => 'rc2kCardFrontDateCode', + 'rc2k_c_fdev' => 'rc2kCardFrontDeviations', + 'rc2k_c_btype' => 'rc2kCardBackType', + 'rc2k_c_bdesc' => 'rc2kCardBackDescription', + 'rc2k_c_bserial' => 'rc2kCardBackSerialNum', + 'rc2k_c_brev' => 'rc2kCardBackHwVersion', + 'rc2k_c_bpart' => 'rc2kCardBackPartNumber', + 'rc2k_c_bdate' => 'rc2kCardBackDateCode', + 'rc2k_c_bdev' => 'rc2kCardBackDeviations', + + # From RAPID-CITY::rc2kMdaCardTable + 'rc2k_mda_type' => 'rc2kMdaCardType', + 'rc2k_mda_desc' => 'rc2kMdaCardDescription', + 'rc2k_mda_serial' => 'rc2kMdaCardSerialNum', + 'rc2k_mda_rev' => 'rc2kMdaCardHwVersion', + 'rc2k_mda_part' => 'rc2kMdaCardPartNumber', + 'rc2k_mda_date' => 'rc2kMdaCardDateCode', + 'rc2k_mda_dev' => 'rc2kMdaCardDeviations', +); %MUNGE = ( - 'rc_base_mac' => \&SNMP::Info::munge_mac, - 'rc_vlan_mac' => \&SNMP::Info::munge_mac, - 'rc_cpu_mac' => \&SNMP::Info::munge_mac, - 'rc_vlan_members' => \&SNMP::Info::munge_port_list, - 'rc_vlan_no_join' => \&SNMP::Info::munge_port_list, - ); + 'rc_base_mac' => \&SNMP::Info::munge_mac, + 'rc_vlan_mac' => \&SNMP::Info::munge_mac, + 'rc_cpu_mac' => \&SNMP::Info::munge_mac, + 'rc_vlan_members' => \&SNMP::Info::munge_port_list, + 'rc_vlan_no_join' => \&SNMP::Info::munge_port_list, +); # Need to override here since overridden in Layer2 and Layer3 classes sub serial { @@ -155,33 +164,33 @@ sub serial { my $ver = $rapidcity->rc_serial(); return $ver unless !defined $ver; - + return; } sub i_duplex { my $rapidcity = shift; - my $partial = shift; - - my $rc_duplex = $rapidcity->rc_duplex($partial) || {}; + my $partial = shift; + + my $rc_duplex = $rapidcity->rc_duplex($partial) || {}; my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex($partial) || {}; my %i_duplex; - foreach my $if (keys %$rc_duplex){ + foreach my $if ( keys %$rc_duplex ) { my $duplex = $rc_duplex->{$if}; - next unless defined $duplex; - + next unless defined $duplex; + $duplex = 'half' if $duplex =~ /half/i; $duplex = 'full' if $duplex =~ /full/i; - $i_duplex{$if}=$duplex; + $i_duplex{$if} = $duplex; } - + # Get CPU Ethernet Interfaces for 8600 Series - foreach my $iid (keys %$rc_cpu_duplex){ + foreach my $iid ( keys %$rc_cpu_duplex ) { my $c_duplex = $rc_cpu_duplex->{$iid}; next unless defined $c_duplex; - $i_duplex{$iid} = $c_duplex; + $i_duplex{$iid} = $c_duplex; } return \%i_duplex; @@ -189,104 +198,104 @@ sub i_duplex { sub i_duplex_admin { my $rapidcity = shift; - my $partial = shift; + my $partial = shift; - my $rc_duplex_admin = $rapidcity->rc_duplex_admin() || {}; - my $rc_auto = $rapidcity->rc_auto($partial) || {}; - my $rc_cpu_auto = $rapidcity->rc_cpu_auto($partial) || {}; + my $rc_duplex_admin = $rapidcity->rc_duplex_admin() || {}; + my $rc_auto = $rapidcity->rc_auto($partial) || {}; + my $rc_cpu_auto = $rapidcity->rc_cpu_auto($partial) || {}; my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin($partial) || {}; - + my %i_duplex_admin; - foreach my $if (keys %$rc_duplex_admin){ + foreach my $if ( keys %$rc_duplex_admin ) { my $duplex = $rc_duplex_admin->{$if}; next unless defined $duplex; - my $auto = $rc_auto->{$if}||'false'; - - my $string = 'other'; - $string = 'half' if ($duplex =~ /half/i and $auto =~ /false/i); - $string = 'full' if ($duplex =~ /full/i and $auto =~ /false/i); - $string = 'auto' if $auto =~ /true/i; + my $auto = $rc_auto->{$if} || 'false'; - $i_duplex_admin{$if}=$string; + my $string = 'other'; + $string = 'half' if ( $duplex =~ /half/i and $auto =~ /false/i ); + $string = 'full' if ( $duplex =~ /full/i and $auto =~ /false/i ); + $string = 'auto' if $auto =~ /true/i; + + $i_duplex_admin{$if} = $string; } - + # Get CPU Ethernet Interfaces for 8600 Series - foreach my $iid (keys %$rc_cpu_duplex_admin){ + foreach my $iid ( keys %$rc_cpu_duplex_admin ) { my $c_duplex = $rc_cpu_duplex_admin->{$iid}; next unless defined $c_duplex; my $c_auto = $rc_cpu_auto->{$iid}; - my $string = 'other'; - $string = 'half' if ($c_duplex =~ /half/i and $c_auto =~ /false/i); - $string = 'full' if ($c_duplex =~ /full/i and $c_auto =~ /false/i); - $string = 'auto' if $c_auto =~ /true/i; + my $string = 'other'; + $string = 'half' if ( $c_duplex =~ /half/i and $c_auto =~ /false/i ); + $string = 'full' if ( $c_duplex =~ /full/i and $c_auto =~ /false/i ); + $string = 'auto' if $c_auto =~ /true/i; - $i_duplex_admin{$iid} = $string; + $i_duplex_admin{$iid} = $string; } - + return \%i_duplex_admin; } sub set_i_duplex_admin { my $rapidcity = shift; - my ($duplex, $iid) = @_; + my ( $duplex, $iid ) = @_; $duplex = lc($duplex); - return unless ($duplex =~ /(half|full|auto)/ and $iid =~ /\d+/); + return unless ( $duplex =~ /(half|full|auto)/ and $iid =~ /\d+/ ); # map a textual duplex to an integer one the switch understands my %duplexes = qw/full 2 half 1/; - my $i_auto = $rapidcity->rc_auto($iid); + my $i_auto = $rapidcity->rc_auto($iid); - if ($duplex eq "auto") { - return $rapidcity->set_rc_auto('1', $iid); + if ( $duplex eq "auto" ) { + return $rapidcity->set_rc_auto( '1', $iid ); } - elsif (($duplex ne "auto") and ($i_auto->{$iid} eq "1")) { - return unless ($rapidcity->set_rc_auto('2', $iid)); - return $rapidcity->set_rc_duplex_admin($duplexes{$duplex}, $iid); + elsif ( ( $duplex ne "auto" ) and ( $i_auto->{$iid} eq "1" ) ) { + return unless ( $rapidcity->set_rc_auto( '2', $iid ) ); + return $rapidcity->set_rc_duplex_admin( $duplexes{$duplex}, $iid ); } else { - return $rapidcity->set_rc_duplex_admin($duplexes{$duplex}, $iid); + return $rapidcity->set_rc_duplex_admin( $duplexes{$duplex}, $iid ); } return; } sub set_i_speed_admin { my $rapidcity = shift; - my ($speed, $iid) = @_; + my ( $speed, $iid ) = @_; + + return unless ( $speed =~ /(10|100|1000|auto)/i and $iid =~ /\d+/ ); - return unless ($speed =~ /(10|100|1000|auto)/i and $iid =~ /\d+/); - # map a textual duplex to an integer one the switch understands - my %speeds = qw/10 1 100 2 1000 3/; + my %speeds = qw/10 1 100 2 1000 3/; my $i_auto = $rapidcity->rc_auto($iid); - if ($speed eq "auto") { - return $rapidcity->set_rc_auto('1', $iid); + if ( $speed eq "auto" ) { + return $rapidcity->set_rc_auto( '1', $iid ); } - elsif (($speed ne "auto") and ($i_auto->{$iid} eq "1")) { - return unless ($rapidcity->set_rc_auto('2', $iid)); - return $rapidcity->set_rc_speed_admin($speeds{$speed}, $iid); + elsif ( ( $speed ne "auto" ) and ( $i_auto->{$iid} eq "1" ) ) { + return unless ( $rapidcity->set_rc_auto( '2', $iid ) ); + return $rapidcity->set_rc_speed_admin( $speeds{$speed}, $iid ); } else { - return $rapidcity->set_rc_speed_admin($speeds{$speed}, $iid); - } + return $rapidcity->set_rc_speed_admin( $speeds{$speed}, $iid ); + } return; } sub v_index { my $rapidcity = shift; - my $partial = shift; + my $partial = shift; return $rapidcity->rc_vlan_id($partial); } sub i_vlan { my $rapidcity = shift; - my $partial = shift; + my $partial = shift; my $i_pvid = $rapidcity->rc_i_vlan_pvid($partial) || {}; - + return $i_pvid; } @@ -296,18 +305,18 @@ sub i_vlan_membership { my $rc_v_ports = $rapidcity->rc_vlan_members(); my $i_vlan_membership = {}; - foreach my $vlan (keys %$rc_v_ports) { + foreach my $vlan ( keys %$rc_v_ports ) { my $portlist = $rc_v_ports->{$vlan}; - my $ret = []; + my $ret = []; # Convert portlist bit array to ifIndex array - for (my $i = 0; $i <= scalar(@$portlist); $i++) { - push(@{$ret}, $i) if (@$portlist[$i]); + for ( my $i = 0; $i <= scalar(@$portlist); $i++ ) { + push( @{$ret}, $i ) if ( @$portlist[$i] ); } #Create HoA ifIndex -> VLAN array - foreach my $port (@{$ret}) { - push(@{$i_vlan_membership->{$port}}, $vlan); + foreach my $port ( @{$ret} ) { + push( @{ $i_vlan_membership->{$port} }, $vlan ); } } return $i_vlan_membership; @@ -315,12 +324,13 @@ sub i_vlan_membership { sub set_i_pvid { my $rapidcity = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $rapidcity->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $rapidcity->_validate_vlan_param( $vlan_id, $ifindex ) ); - unless ( $rapidcity->set_rc_i_vlan_pvid($vlan_id, $ifindex) ) { - $rapidcity->error_throw("Unable to change PVID to $vlan_id on IfIndex: $ifindex"); + unless ( $rapidcity->set_rc_i_vlan_pvid( $vlan_id, $ifindex ) ) { + $rapidcity->error_throw( + "Unable to change PVID to $vlan_id on IfIndex: $ifindex"); return; } return 1; @@ -328,9 +338,10 @@ sub set_i_pvid { sub set_i_vlan { my $rapidcity = shift; - my ($new_vlan_id, $ifindex) = @_; + my ( $new_vlan_id, $ifindex ) = @_; - return unless ( $rapidcity->_validate_vlan_param ($new_vlan_id, $ifindex) ); + return + unless ( $rapidcity->_validate_vlan_param( $new_vlan_id, $ifindex ) ); my $vlan_p_type = $rapidcity->rc_i_vlan_type($ifindex); unless ( $vlan_p_type->{$ifindex} =~ /access/ ) { @@ -342,10 +353,13 @@ sub set_i_vlan { # Store current untagged VLAN to remove it from the port list later my $old_vlan_id = $i_pvid->{$ifindex}; + # Check that haven't been given the same VLAN we are currently using - if ($old_vlan_id eq $new_vlan_id) { - $rapidcity->error_throw("Current PVID: $old_vlan_id and New VLAN: $new_vlan_id the same, no change."); - return; + if ( $old_vlan_id eq $new_vlan_id ) { + $rapidcity->error_throw( + "Current PVID: $old_vlan_id and New VLAN: $new_vlan_id the same, no change." + ); + return; } print "Changing VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" @@ -353,107 +367,132 @@ sub set_i_vlan { # Check if port in forbidden list for the VLAN, haven't seen this used, # but we'll check anyway - return unless - ($rapidcity->_check_forbidden_ports($new_vlan_id, $ifindex)); + return + unless ( + $rapidcity->_check_forbidden_ports( $new_vlan_id, $ifindex ) ); my $old_vlan_members = $rapidcity->rc_vlan_members($old_vlan_id); my $new_vlan_members = $rapidcity->rc_vlan_members($new_vlan_id); - print "Modifying egress list for VLAN: $new_vlan_id \n" if $rapidcity->debug(); - my $new_egress = $rapidcity->modify_port_list($new_vlan_members->{$new_vlan_id},$ifindex,'1'); + print "Modifying egress list for VLAN: $new_vlan_id \n" + if $rapidcity->debug(); + my $new_egress + = $rapidcity->modify_port_list( $new_vlan_members->{$new_vlan_id}, + $ifindex, '1' ); - print "Modifying egress list for VLAN: $old_vlan_id \n" if $rapidcity->debug(); - my $old_egress = $rapidcity->modify_port_list($old_vlan_members->{$old_vlan_id},$ifindex,'0'); + print "Modifying egress list for VLAN: $old_vlan_id \n" + if $rapidcity->debug(); + my $old_egress + = $rapidcity->modify_port_list( $old_vlan_members->{$old_vlan_id}, + $ifindex, '0' ); my $vlan_set = [ - ['rc_vlan_members',"$new_vlan_id","$new_egress"], -# ['rc_vlan_members',"$old_vlan_id","$old_egress"], + [ 'rc_vlan_members', "$new_vlan_id", "$new_egress" ], + + # ['rc_vlan_members',"$old_vlan_id","$old_egress"], ]; - return unless - ($rapidcity->set_multi($vlan_set)); + return + unless ( $rapidcity->set_multi($vlan_set) ); - my $vlan_set2 = [ - ['rc_vlan_members',"$old_vlan_id","$old_egress"], - ]; + my $vlan_set2 = [ [ 'rc_vlan_members', "$old_vlan_id", "$old_egress" ], ]; - return unless - ($rapidcity->set_multi($vlan_set2)); + return + unless ( $rapidcity->set_multi($vlan_set2) ); - # Set new untagged / native VLAN - # Some models/versions do this for us also, so check to see if we need to set + # Set new untagged / native VLAN + # Some models/versions do this for us also, so check to see if we need to set $i_pvid = $rapidcity->rc_i_vlan_pvid($ifindex); my $cur_i_pvid = $i_pvid->{$ifindex}; print "Current PVID: $cur_i_pvid\n" if $rapidcity->debug(); - unless ($cur_i_pvid eq $new_vlan_id) { - return unless ($rapidcity->set_i_pvid($new_vlan_id, $ifindex)); + unless ( $cur_i_pvid eq $new_vlan_id ) { + return unless ( $rapidcity->set_i_pvid( $new_vlan_id, $ifindex ) ); } - print "Successfully changed VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" if $rapidcity->debug(); + print + "Successfully changed VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" + if $rapidcity->debug(); return 1; } sub set_add_i_vlan_tagged { my $rapidcity = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $rapidcity->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $rapidcity->_validate_vlan_param( $vlan_id, $ifindex ) ); - print "Adding VLAN: $vlan_id to IfIndex: $ifindex\n" if $rapidcity->debug(); + print "Adding VLAN: $vlan_id to IfIndex: $ifindex\n" + if $rapidcity->debug(); - # Check if port in forbidden list for the VLAN, haven't seen this used, but we'll check anyway - return unless ($rapidcity->_check_forbidden_ports($vlan_id, $ifindex)); +# Check if port in forbidden list for the VLAN, haven't seen this used, but we'll check anyway + return + unless ( $rapidcity->_check_forbidden_ports( $vlan_id, $ifindex ) ); my $iv_members = $rapidcity->rc_vlan_members($vlan_id); - print "Modifying egress list for VLAN: $vlan_id \n" if $rapidcity->debug(); - my $new_egress = $rapidcity->modify_port_list($iv_members->{$vlan_id},$ifindex,'1'); + print "Modifying egress list for VLAN: $vlan_id \n" + if $rapidcity->debug(); + my $new_egress + = $rapidcity->modify_port_list( $iv_members->{$vlan_id}, $ifindex, + '1' ); - unless ( $rapidcity->set_qb_v_egress($new_egress, $vlan_id) ) { - print "Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n" if $rapidcity->debug(); + unless ( $rapidcity->set_qb_v_egress( $new_egress, $vlan_id ) ) { + print + "Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n" + if $rapidcity->debug(); return; } - print "Successfully added IfIndex: $ifindex to VLAN: $vlan_id egress list\n" if $rapidcity->debug(); + print + "Successfully added IfIndex: $ifindex to VLAN: $vlan_id egress list\n" + if $rapidcity->debug(); return 1; } sub set_remove_i_vlan_tagged { my $rapidcity = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; - return unless ( $rapidcity->_validate_vlan_param ($vlan_id, $ifindex) ); + return unless ( $rapidcity->_validate_vlan_param( $vlan_id, $ifindex ) ); - print "Removing VLAN: $vlan_id from IfIndex: $ifindex\n" if $rapidcity->debug(); + print "Removing VLAN: $vlan_id from IfIndex: $ifindex\n" + if $rapidcity->debug(); my $iv_members = $rapidcity->rc_vlan_members($vlan_id); - print "Modifying egress list for VLAN: $vlan_id \n" if $rapidcity->debug(); - my $new_egress = $rapidcity->modify_port_list($iv_members->{$vlan_id},$ifindex,'0'); + print "Modifying egress list for VLAN: $vlan_id \n" + if $rapidcity->debug(); + my $new_egress + = $rapidcity->modify_port_list( $iv_members->{$vlan_id}, $ifindex, + '0' ); - unless ( $rapidcity->set_qb_v_egress($new_egress, $vlan_id) ) { - print "Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n" if $rapidcity->debug(); + unless ( $rapidcity->set_qb_v_egress( $new_egress, $vlan_id ) ) { + print + "Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n" + if $rapidcity->debug(); return; } - print "Successfully removed IfIndex: $ifindex from VLAN: $vlan_id egress list\n" if $rapidcity->debug(); + print + "Successfully removed IfIndex: $ifindex from VLAN: $vlan_id egress list\n" + if $rapidcity->debug(); return 1; } - sub set_create_vlan { my $rapidcity = shift; - my ($name, $vlan_id) = @_; - return unless ($vlan_id =~ /\d+/); + my ( $name, $vlan_id ) = @_; + return unless ( $vlan_id =~ /\d+/ ); my $vlan_set = [ - ['v_name',"$vlan_id","$name"], - ['rc_vlan_rstatus',"$vlan_id",4], + [ 'v_name', "$vlan_id", "$name" ], + [ 'rc_vlan_rstatus', "$vlan_id", 4 ], ]; - unless ($rapidcity->set_multi($vlan_set)){ - print "Error: Unable to create VLAN: $vlan_id\n" if $rapidcity->debug(); + unless ( $rapidcity->set_multi($vlan_set) ) { + print "Error: Unable to create VLAN: $vlan_id\n" + if $rapidcity->debug(); return; } @@ -463,9 +502,9 @@ sub set_create_vlan { sub set_delete_vlan { my $rapidcity = shift; my ($vlan_id) = shift; - return unless ($vlan_id =~ /^\d+$/); + return unless ( $vlan_id =~ /^\d+$/ ); - unless ( $rapidcity->set_rc_vlan_rstatus('6', $vlan_id) ) { + unless ( $rapidcity->set_rc_vlan_rstatus( '6', $vlan_id ) ) { $rapidcity->error_throw("Unable to delete VLAN: $vlan_id"); return; } @@ -473,18 +512,23 @@ sub set_delete_vlan { } # -# These are internal methods and are not documented. Do not use directly. +# These are internal methods and are not documented. Do not use directly. # sub _check_forbidden_ports { my $rapidcity = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; my $iv_forbidden = $rapidcity->rc_vlan_no_join($vlan_id); - my @forbidden_ports = split(//, unpack("B*", $iv_forbidden->{$vlan_id})); + my @forbidden_ports + = split( //, unpack( "B*", $iv_forbidden->{$vlan_id} ) ); print "Forbidden ports: @forbidden_ports\n" if $rapidcity->debug(); - if ( defined($forbidden_ports[$ifindex]) and ($forbidden_ports[$ifindex] eq "1")) { - $rapidcity->error_throw("IfIndex: $ifindex in forbidden list for VLAN: $vlan_id unable to add"); + if ( defined( $forbidden_ports[$ifindex] ) + and ( $forbidden_ports[$ifindex] eq "1" ) ) + { + $rapidcity->error_throw( + "IfIndex: $ifindex in forbidden list for VLAN: $vlan_id unable to add" + ); return; } return 1; @@ -492,14 +536,18 @@ sub _check_forbidden_ports { sub _validate_vlan_param { my $rapidcity = shift; - my ($vlan_id, $ifindex) = @_; + my ( $vlan_id, $ifindex ) = @_; # VID and ifIndex should both be numeric - unless ( defined $vlan_id and defined $ifindex and $vlan_id =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { + unless (defined $vlan_id + and defined $ifindex + and $vlan_id =~ /^\d+$/ + and $ifindex =~ /^\d+$/ ) + { $rapidcity->error_throw("Invalid parameter"); return; } - + # Check that ifIndex exists on device my $index = $rapidcity->interfaces($ifindex); @@ -510,7 +558,8 @@ sub _validate_vlan_param { #Check that VLAN exists on device unless ( $rapidcity->rc_vlan_id($vlan_id) ) { - $rapidcity->error_throw("VLAN $vlan_id does not exist or is not operational"); + $rapidcity->error_throw( + "VLAN $vlan_id does not exist or is not operational"); return; } @@ -1002,16 +1051,17 @@ Returns VLAN IDs =head1 SET METHODS -These are methods that provide SNMP set functionality for overridden methods or -provide a simpler interface to complex set operations. See -L for general information on set operations. +These are methods that provide SNMP set functionality for overridden methods +or provide a simpler interface to complex set operations. See +L for general information on set +operations. =over =item $rapidcity->set_i_speed_admin(speed, ifIndex) -Sets port speed, must be supplied with speed and port C. Speed choices -are 'auto', '10', '100', '1000'. +Sets port speed, must be supplied with speed and port C. Speed +choices are 'auto', '10', '100', '1000'. Example: my %if_map = reverse %{$rapidcity->interfaces()}; @@ -1031,9 +1081,9 @@ choices are 'auto', 'half', 'full'. =item $rapidcity->set_i_vlan(vlan, ifIndex) Changes an access (untagged) port VLAN, must be supplied with the numeric -VLAN ID and port C. This method will modify the port's VLAN membership -and PVID (default VLAN). This method should only be used on end station -(non-trunk) ports. +VLAN ID and port C. This method will modify the port's VLAN +membership and PVID (default VLAN). This method should only be used on end +station (non-trunk) ports. Example: my %if_map = reverse %{$rapidcity->interfaces()}; @@ -1053,8 +1103,8 @@ port C. This method only changes the PVID, to modify an access =item $rapidcity->set_add_i_vlan_tagged(vlan, ifIndex) -Adds the port to the egress list of the VLAN, must be supplied with the numeric -VLAN ID and port C. +Adds the port to the egress list of the VLAN, must be supplied with the +numeric VLAN ID and port C. Example: my %if_map = reverse %{$rapidcity->interfaces()}; diff --git a/Info/SONMP.pm b/Info/SONMP.pm index 54578166..842b8d7b 100644 --- a/Info/SONMP.pm +++ b/Info/SONMP.pm @@ -4,20 +4,20 @@ # Copyright (c) 2008 Eric Miller # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# * Neither the name of the University of California, Santa Cruz nor the -# names of its contributors may be used to endorse or promote products +# * Neither the name of the University of California, Santa Cruz nor the +# names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# +# 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 @@ -34,37 +34,36 @@ use strict; use Exporter; use SNMP::Info; -@SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/; +@SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::SONMP::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; $VERSION = '1.09'; -%MIBS = ( - 'SYNOPTICS-ROOT-MIB' => 'synoptics', - 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop', - ); +%MIBS = ( + 'SYNOPTICS-ROOT-MIB' => 'synoptics', + 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop', +); %GLOBALS = ( - 'cdp_id' => 's5EnMsTopIpAddr', - 'cdp_run' => 's5EnMsTopStatus', - ); + 'cdp_id' => 's5EnMsTopIpAddr', + 'cdp_run' => 's5EnMsTopStatus', +); -%FUNCS = ( - # From S5-ETH-MULTISEG-TOPOLOGY-MIB::TopNmmTable - 'sonmp_topo_slot' => 's5EnMsTopNmmSlot', - 'sonmp_topo_port' => 's5EnMsTopNmmPort', - 'sonmp_topo_ip' => 's5EnMsTopNmmIpAddr', - 'sonmp_topo_seg' => 's5EnMsTopNmmSegId', - 'sonmp_topo_mac' => 's5EnMsTopNmmMacAddr', - 'sonmp_topo_platform' => 's5EnMsTopNmmChassisType', - 'sonmp_topo_localseg' => 's5EnMsTopNmmLocalSeg', - ); +%FUNCS = ( -%MUNGE = ( - 'sonmp_topo_mac' => \&SNMP::Info::munge_mac - ); + # From S5-ETH-MULTISEG-TOPOLOGY-MIB::TopNmmTable + 'sonmp_topo_slot' => 's5EnMsTopNmmSlot', + 'sonmp_topo_port' => 's5EnMsTopNmmPort', + 'sonmp_topo_ip' => 's5EnMsTopNmmIpAddr', + 'sonmp_topo_seg' => 's5EnMsTopNmmSegId', + 'sonmp_topo_mac' => 's5EnMsTopNmmMacAddr', + 'sonmp_topo_platform' => 's5EnMsTopNmmChassisType', + 'sonmp_topo_localseg' => 's5EnMsTopNmmLocalSeg', +); + +%MUNGE = ( 'sonmp_topo_mac' => \&SNMP::Info::munge_mac ); sub index_factor { return 32; @@ -84,56 +83,59 @@ sub hasCDP { } sub c_if { - my $sonmp = shift; + my $sonmp = shift; my $partial = shift; my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; my $sonmp_topo_slot = $sonmp->sonmp_topo_slot($partial) || {}; - my $index_factor = $sonmp->index_factor(); - my $slot_offset = $sonmp->slot_offset(); - my $port_offset = $sonmp->port_offset(); - my $model = $sonmp->model(); + my $index_factor = $sonmp->index_factor(); + my $slot_offset = $sonmp->slot_offset(); + my $port_offset = $sonmp->port_offset(); + my $model = $sonmp->model(); my %c_if; - foreach my $entry (keys %$sonmp_topo_port){ + foreach my $entry ( keys %$sonmp_topo_port ) { my $port = $sonmp_topo_port->{$entry}; next unless defined $port; next if $port == 0; my $slot = $sonmp_topo_slot->{$entry} || 0; - if ($model eq 'Baystack Hub') { - my $comidx = $slot; - if (! ($comidx % 5)) { - $slot = ($slot / 5); - } elsif ($comidx =~ /[16]$/) { - $slot = int($slot/5); - $port = 25; - } elsif ($comidx =~ /[27]$/) { - $slot = int($slot/5); - $port = 26; + if ( $model eq 'Baystack Hub' ) { + my $comidx = $slot; + if ( !( $comidx % 5 ) ) { + $slot = ( $slot / 5 ); + } + elsif ( $comidx =~ /[16]$/ ) { + $slot = int( $slot / 5 ); + $port = 25; + } + elsif ( $comidx =~ /[27]$/ ) { + $slot = int( $slot / 5 ); + $port = 26; } } - my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset); - + my $index = ( ( $slot - $slot_offset ) * $index_factor ) + + ( $port - $port_offset ); + $c_if{$entry} = $index; } return \%c_if; } sub c_ip { - my $sonmp = shift; + my $sonmp = shift; my $partial = shift; my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; - my $sonmp_topo_ip = $sonmp->sonmp_topo_ip($partial) || {}; + my $sonmp_topo_ip = $sonmp->sonmp_topo_ip($partial) || {}; my %c_ip; - foreach my $entry (keys %$sonmp_topo_ip){ + foreach my $entry ( keys %$sonmp_topo_ip ) { my $port = $sonmp_topo_port->{$entry}; next unless defined $port; next if $port == 0; - + my $ip = $sonmp_topo_ip->{$entry}; $c_ip{$entry} = $ip; } @@ -141,54 +143,57 @@ sub c_ip { } sub c_port { - my $sonmp = shift; + my $sonmp = shift; my $partial = shift; - my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; - my $sonmp_topo_seg = $sonmp->sonmp_topo_seg($partial) || {}; + my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; + my $sonmp_topo_seg = $sonmp->sonmp_topo_seg($partial) || {}; my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {}; my %c_port; - foreach my $entry (keys %$sonmp_topo_seg){ + foreach my $entry ( keys %$sonmp_topo_seg ) { my $port = $sonmp_topo_port->{$entry}; next unless defined $port; next if $port == 0; - my $seg = $sonmp_topo_seg->{$entry}; + my $seg = $sonmp_topo_seg->{$entry}; my $platform = $sonmp_topo_platform->{$entry}; + # AP-222x Series does not adhere to port numbering - if ($platform =~ /AccessPoint/i) { + if ( $platform =~ /AccessPoint/i ) { $c_port{$entry} = 'dp0'; } - # BayHubs send the lower three bytes of the MAC not the slot/port - elsif ($seg > 4000) { + + # BayHubs send the lower three bytes of the MAC not the slot/port + elsif ( $seg > 4000 ) { $c_port{$entry} = 'unknown'; } else { + # Segment id is (256 * remote slot_num) + (remote_port) my $remote_port = $seg % 256; - my $remote_slot = int($seg / 256); - - $c_port{$entry} = "$remote_slot.$remote_port"; + my $remote_slot = int( $seg / 256 ); + + $c_port{$entry} = "$remote_slot.$remote_port"; } } return \%c_port; } sub c_platform { - my $sonmp = shift; + my $sonmp = shift; my $partial = shift; - my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; + my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {}; my %c_platform; - foreach my $entry (keys %$sonmp_topo_platform){ + foreach my $entry ( keys %$sonmp_topo_platform ) { my $port = $sonmp_topo_port->{$entry}; next unless defined $port; next if $port == 0; - my $platform = $sonmp_topo_platform->{$entry}; + my $platform = $sonmp_topo_platform->{$entry}; $c_platform{$entry} = $platform; } @@ -199,14 +204,15 @@ sub mac { my $sonmp = shift; my $sonmp_topo_port = $sonmp->sonmp_topo_port(); - my $sonmp_topo_mac = $sonmp->sonmp_topo_mac(); - - foreach my $entry (keys %$sonmp_topo_port){ + my $sonmp_topo_mac = $sonmp->sonmp_topo_mac(); + + foreach my $entry ( keys %$sonmp_topo_port ) { my $port = $sonmp_topo_port->{$entry}; next unless $port == 0; my $mac = $sonmp_topo_mac->{$entry}; return $mac; } + # Topology turned off, not supported. return; } @@ -259,11 +265,13 @@ interface to the SynOptics Network Management Protocol (SONMP) information through SNMP. SONMP is a Layer 2 protocol that supplies topology information of devices that -also speak SONMP, mostly switches and hubs. SONMP is implemented in SynOptics, -Bay, and Nortel devices. SONMP has been rebranded by Bay then Nortel and is -know by several different names, most recently Nortel Discovery Protocol (NDP). +also speak SONMP, mostly switches and hubs. SONMP is implemented in +SynOptics, Bay, and Nortel devices. SONMP has been rebranded by Bay then +Nortel and is know by several different names, most recently Nortel +Discovery Protocol (NDP). -Create or use a device subclass that inherits this class. Do not use directly. +Create or use a device subclass that inherits this class. Do not use +directly. Each device implements a subset of the global and cache entries. Check the return value to see if that data is held by the device. @@ -340,7 +348,8 @@ Returns reference to hash. Key: Table entry, Value:slot number =item $sonmp->sonmp_topo_port() -Returns reference to hash. Key: Table entry, Value:Port Number (interface iid) +Returns reference to hash. Key: Table entry, Value:Port Number +(interface iid) (C) @@ -370,8 +379,8 @@ Returns reference to hash. Key: Table entry, Value:Remote Device Type =item $sonmp->sonmp_topo_localseg -Returns reference to hash. Key: Table entry, Value: Boolean, if bay_topo_seg() -is local. +Returns reference to hash. Key: Table entry, Value: Boolean, if +bay_topo_seg() is local. (C) @@ -391,8 +400,8 @@ Returns reference to hash. Key: IID, Value: Local port (interfaces) Returns reference to hash. Key: IID, Value: Remote IP address -If multiple entries exist with the same local port, c_if(), with different IPv4 -addresses, c_ip(), there is either a non SONMP device in between two or +If multiple entries exist with the same local port, c_if(), with different +IPv4 addresses, c_ip(), there is either a non SONMP device in between two or more devices or multiple devices which are not directly connected. Use the data from the Layer2 Topology Table below to dig deeper.