perltidy
This commit is contained in:
@@ -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<s3EnetPortLinkStatus>) for each port. Translates on/off to up/down.
|
||||
Returns (C<s3EnetPortLinkStatus>) for each port. Translates on/off to
|
||||
up/down.
|
||||
|
||||
=item $s3000->i_up_admin()
|
||||
|
||||
@@ -522,7 +528,8 @@ C<SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable> 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<s3EnetTopNmmPort>)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user