This commit is contained in:
Eric Miller
2008-07-20 03:30:56 +00:00
parent 6c7df418af
commit 158596cede
69 changed files with 7547 additions and 6963 deletions

View File

@@ -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 {