migrate from EUMM to Module::Build

This commit is contained in:
Oliver Gorwits
2017-06-28 22:40:15 +01:00
parent 433b87b9df
commit 44b19153f1
132 changed files with 52 additions and 2239 deletions

View File

@@ -0,0 +1,240 @@
# SNMP::Info::Layer1::Allied
# $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
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Allied;
use strict;
use Exporter;
use SNMP::Info::Layer1;
@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/;
$VERSION = '3.35';
# Set for No CDP
%GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, 'root_ip' => 'actualIPAddr', );
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
'ati_p_name' => 'portName',
'ati_up' => 'linkTestLED',
);
%MIBS = ( %SNMP::Info::Layer1::MIBS, 'ATI-MIB' => 'atiPortGroupIndex' );
%MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
sub vendor {
return 'allied';
}
sub os {
return 'allied';
}
sub os_ver {
my $allied = shift;
my $descr = $allied->description();
if ( $descr =~ m/version (\d+\.\d+)/ ) {
return $1;
}
}
sub model {
my $allied = shift;
my $desc = $allied->description();
if ( $desc =~ /(AT-\d{4}\S{1})/ ) {
return $1;
}
return;
}
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) || {};
foreach my $port ( keys %$ati_p_name ) {
my $name = $ati_p_name->{$port};
$i_name->{$port} = $name if ( defined $name and $name !~ /^\s*$/ );
}
return $i_name;
}
sub i_up {
my $allied = shift;
my $partial = shift;
my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial );
my $ati_up = $allied->ati_up($partial) || {};
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';
}
return $i_up;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::Allied - SNMP Interface to old Allied Hubs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $allied = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myhub',
Community => 'public',
Version => 1
)
or die "Can't connect to DestHost.\n";
my $class = $allied->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Allied device through SNMP. See inherited classes' documentation for
inherited methods.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer1
=back
=head2 Required MIBs
=over
=item F<ATI-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=head2 Overrides
=over
=item $allied->vendor()
Returns 'allied' :)
=item $allied->os()
Returns 'allied'
=item $allied->os_ver()
Culls Version from description()
=item $allied->root_ip()
Returns IP Address of Managed Hub.
(C<actualIpAddr>)
=item $allied->model()
Tries to cull out C<AT-nnnnX> out of the description field.
=back
=head2 Global Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE METHODS
=head2 Overrides
=over
=item $allied->i_name()
Returns reference to map of IIDs to human-set port name.
=item $allied->i_up()
Returns reference to map of IIDs to link status. Changes
the values of ati_up() to 'up' and 'down'.
=back
=head2 Allied MIB
=over
=item $allied->ati_p_name()
(C<portName>)
=item $allied->ati_up()
(C<linkTestLED>)
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -0,0 +1,294 @@
# SNMP::Info::Layer1::Asante
# $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
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Asante;
use strict;
use Exporter;
use SNMP::Info::Layer1;
@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/;
$VERSION = '3.35';
# Set for No CDP
%GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, );
%FUNCS = (
%SNMP::Info::Layer1::FUNCS,
'asante_port' => 'ePortIndex',
'asante_group' => 'ePortGrpIndex',
'i_type' => 'ePortGrpIndex',
'asante_up' => 'ePortStateLinkStatus',
);
%MIBS = ( %SNMP::Info::Layer1::MIBS, 'ASANTE-AH1012-MIB' => 'asante' );
%MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
sub interfaces {
my $asante = shift;
my $partial = shift;
my $rptr_port = $asante->rptr_port($partial) || {};
my %interfaces;
foreach my $port ( keys %$rptr_port ) {
$interfaces{$port} = $port;
}
return \%interfaces;
}
sub os {
return 'asante';
}
sub os_ver {
my $asante = shift;
my $descr = $asante->description();
if ( $descr =~ /software v(\d+\.\d+)/ ) {
return $1;
}
}
sub vendor {
return 'asante';
}
sub model {
my $asante = shift;
my $id = $asante->id();
my $model = &SNMP::translateObj($id);
return $model;
}
sub i_up {
my $asante = shift;
my $partial = shift;
my $asante_up = $asante->asante_up($partial) || {};
my $i_up = {};
foreach my $port ( keys %$asante_up ) {
my $up = $asante_up->{$port};
$i_up->{$port} = 'down' if $up =~ /on/;
$i_up->{$port} = 'up' if $up =~ /off/;
}
return $i_up;
}
sub i_speed {
my $asante = shift;
my $partial = shift;
my $i_speed = $asante->orig_i_speed($partial) || {};
my %i_speed;
$i_speed{"1.2"} = $i_speed->{1};
return \%i_speed;
}
sub i_mac {
my $asante = shift;
my $partial = shift;
my $i_mac = $asante->orig_i_mac($partial) || {};
my %i_mac;
$i_mac{"1.2"} = $i_mac->{1};
return \%i_mac;
}
sub i_description {
return;
}
sub i_name {
my $asante = shift;
my $partial = shift;
my $i_name = $asante->orig_i_descr($partial) || {};
my %i_name;
$i_name{"1.2"} = $i_name->{1};
return \%i_name;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::Asante - SNMP Interface to old Asante 1012 Hubs
=head1 AUTHOR
Max Baker
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $asante = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $asante->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Asante device through SNMP.
=head2 Inherited Classes
=over
=item SNMP::Info::Layer1
=back
=head2 Required MIBs
=over
=item F<ASANTE-AH1012-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
=head2 Overrides
=over
=item $asante->os()
Returns 'asante'
=item $asante->os_ver()
Culls software version from description()
=item $asante->vendor()
Returns 'asante' :)
=item $asante->model()
Cross references $asante->id() to the F<ASANTE-AH1012-MIB> and returns
the results.
=back
=head2 Global Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE METHODS
=head2 Overrides
=over
=item $asante->interfaces()
Returns reference to the map between IID and physical Port.
=item $asante->i_description()
Description of the interface.
=item $asante->i_mac()
MAC address of the interface. Note this is just the MAC of the port, not
anything connected to it.
=item $asante->i_name()
Returns reference to map of IIDs to human-set port name.
=item $asante->i_up()
Returns reference to map of IIDs to link status. Changes
the values of asante_up() to 'up' and 'down'.
=item $asante->i_speed()
Speed of the link, human format.
=back
=head2 Asante MIB
=over
=item $asante->ati_p_name()
(C<portName>)
=item $asante->ati_up()
(C<linkTestLED>)
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

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

View File

@@ -0,0 +1,444 @@
# SNMP::Info::Layer1::Cyclades
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Cyclades;
use strict;
use Exporter;
use SNMP::Info::Layer1;
@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 = '3.35';
%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',
);
%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.
sub layers {
return '01000001';
}
sub os {
return 'cyclades';
}
sub vendor {
return 'cyclades';
}
sub model {
my $cyclades = shift;
my $model = $cyclades->cy_model();
return unless defined $model;
return lc($model);
}
# Extend interface methods to include serial ports
#
# Partials don't really help in this class, but implemented
# for consistency
sub i_index {
my $cyclades = shift;
my $partial = shift;
my $orig_index = $cyclades->orig_i_index($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {};
my %i_index;
foreach my $iid ( keys %$orig_index ) {
my $index = $orig_index->{$iid};
next unless defined $index;
$i_index{$iid} = $index;
}
# Use alternative labeling system for the serial port, listening socket
# to avoid conflicts with ifIndex.
foreach my $iid ( keys %$cy_index ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
$i_index{$index} = $index;
}
return \%i_index;
}
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 %if;
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 ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $name = $cy_p_tty->{$iid};
next unless defined $name;
$if{$index} = $name;
}
return \%if;
}
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;
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 ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $speed = $cy_p_speed->{$iid};
next unless defined $speed;
$i_speed{$index} = $speed;
}
return \%i_speed;
}
sub i_up {
my $cyclades = shift;
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 %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 ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $up = $cy_p_up->{$iid};
next unless defined $up;
$i_up{$index} = $up;
}
return \%i_up;
}
sub i_description {
my $cyclades = shift;
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 %descr;
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 ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $desc = $cy_p_desc->{$iid};
next unless defined $desc;
$descr{$index} = $desc;
}
return \%descr;
}
sub i_name {
my $cyclades = shift;
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 %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 ) {
my $index = $cy_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $name = $cy_p_desc->{$iid};
next unless defined $name;
$i_name{$index} = $name;
}
return \%i_name;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::Cyclades - SNMP Interface to Cyclades terminal servers
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $cyclades = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $cyclades->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Cyclades device through SNMP.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $cyclades = new SNMP::Info::Layer1::Cyclades(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer1
=back
=head2 Required MIBs
=over
=item F<CYCLADES-ACS-SYS-MIB>
=item F<CYCLADES-ACS-CONF-MIB>
=item F<CYCLADES-ACS-INFO-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer1/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $cyclades->os_ver()
(C<cyACSversion>)
=item $cyclades->serial()
(C<cyACSDevId>)
=item $cyclades->root_ip()
(C<cyEthIPaddr>)
=item $cyclades->ps1_status()
(C<cyACSPw1>)
=item $cyclades->ps2_status()
(C<cyACSPw2>)
=back
=head2 Overrides
=over
=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.
=item $cyclades->vendor()
Returns 'cyclades'
=item $cyclades->os()
Returns 'cyclades'
=item $cyclades->model()
Returns lower case (C<cyACSpname>)
=back
=head2 Globals imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $cyclades->i_index()
Returns reference to map of IIDs to Interface index.
Extended to include serial ports. Serial ports are indexed with the
alternative labeling system for the serial port, the listening socket port
C<cySPortSocketPort> to avoid conflicts with C<ifIndex>.
=item $cyclades->interfaces()
Returns reference to map of IIDs to physical ports. Extended to include
serial ports, C<cyISPortTty>.
=item $cyclades->i_speed()
Returns interface speed. Extended to include serial ports, C<cyISPortSpeed>.
=item $cyclades->i_up()
Returns link status for each port. Extended to include serial ports,
C<cyISPortSigCD>.
=item $cyclades->i_description()
Returns description of each port. Extended to include serial ports,
C<cyISPortName>.
=item $cyclades->i_name()
Returns name of each port. Extended to include serial ports, C<cyISPortName>.
=back
=head2 Table Methods imported from SNMP::Info::Layer1
See L<SNMP::Info::Layer1/"TABLE METHODS"> for details.
=cut

View File

@@ -0,0 +1,555 @@
# SNMP::Info::Layer1::S3000
# $Id$
#
# Copyright (c) 2008 Eric Miller
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::S3000;
use strict;
use Exporter;
use SNMP::Info::Layer2;
@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 = '3.35';
%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',
);
%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';
}
sub os {
return 'synoptics';
}
sub vendor {
return 'nortel';
}
sub model {
my $s3000 = shift;
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 $model;
}
sub os_ver {
my $s3000 = shift;
my $major_ver = $s3000->s3000_major_ver() || 0;
my $minor_ver = $s3000->s3000_minor_ver() || 0;
my $maint_ver = $s3000->s3000_maint_ver() || 0;
my $ver = "$major_ver.$minor_ver.$maint_ver";
return $ver;
}
sub mac {
my $s3000 = shift;
my $topo_port = $s3000->s3000_topo_port();
my $topo_mac = $s3000->s3000_topo_mac();
foreach my $entry ( keys %$topo_port ) {
my $port = $topo_port->{$entry};
next unless $port == 0;
my $mac = $topo_mac->{$entry};
return $mac;
}
# Topology turned off, not supported.
return;
}
# Hubs do not support ifMIB requirements for get MAC
# and port status
sub i_index {
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 ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
# We need to make up an index for multiple board instances.
my $index = ( $board * 256 ) + $port;
$i_index{$iid} = $index;
}
return \%i_index;
}
# Partials don't really help in this class, but implemented
# for consistency
sub interfaces {
my $s3000 = shift;
my $partial = shift;
my $i_index = $s3000->i_index() || {};
my %if;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
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 $slotport = "$slot.$port";
$if{$index} = $slotport;
}
return \%if;
}
sub i_duplex {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my %i_duplex;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# Hubs only function half duplex
my $duplex = 'half';
$i_duplex{$index} = $duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my %i_duplex_admin;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# Hubs only function half duplex
my $duplex = 'half';
$i_duplex_admin{$index} = $duplex;
}
return \%i_duplex_admin;
}
sub i_speed {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my %i_speed;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
# These hubs only support 10 Mbs
my $speed = '10000000';
$i_speed{$index} = $speed;
}
return \%i_speed;
}
sub i_up {
my $s3000 = shift;
my $partial = shift;
my $port_index = $s3000->i_index() || {};
my $link_stat = $s3000->s3000_up() || {};
my %i_up;
foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid};
next unless defined $index;
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 = 'down' if $link_stat =~ /off/i;
$i_up{$index} = $link_stat;
}
return \%i_up;
}
sub i_up_admin {
my $s3000 = shift;
my $partial = shift;
my $i_index = $s3000->i_index() || {};
my $link_stat = $s3000->s3000_up_admin() || {};
my %i_up_admin;
foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid};
next unless defined $index;
next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid};
next unless defined $link_stat;
$i_up_admin{$index} = $link_stat;
}
return \%i_up_admin;
}
sub set_i_up_admin {
# map setting to those the hub will understand
my %setting = qw/up 2 down 3/;
my $s3000 = shift;
my ( $setting, $iid ) = @_;
my $i_index = $s3000->i_index() || {};
my %reverse_i_index = reverse %$i_index;
$setting = lc($setting);
return 0 unless defined $setting{$setting};
$iid = $reverse_i_index{$iid};
return $s3000->set_s3000_up_admin( $setting{$setting}, $iid );
}
# Hubs do not support the standard Bridge MIB
sub bp_index {
my $s3000 = shift;
my $partial = shift;
my $b_index = $s3000->s3000_nb_index() || {};
my $p_index = $s3000->s3000_np_index() || {};
my $model = $s3000->model();
my %bp_index;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
my $index = ( $board * 256 ) + $port;
next if ( defined $partial and $index !~ /^$partial$/ );
$bp_index{$index} = $index;
}
return \%bp_index;
}
sub fw_mac {
my $s3000 = shift;
my $partial = shift;
return $s3000->SUPER::fw_mac($partial);
}
sub fw_port {
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 %fw_port;
foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid};
next unless defined $board;
my $port = $p_index->{$iid} || 0;
my $index = ( $board * 256 ) + $port;
$fw_port{$iid} = $index;
}
return \%fw_port;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer1::S3000 - SNMP Interface to Synoptics / Nortel Hubs
=head1 AUTHOR
Eric Miller
=head1 SYNOPSIS
#Let SNMP::Info determine the correct subclass for you.
my $s3000 = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $s3000->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a
Bay hub device through SNMP. Also provides device MAC to port mapping through
the proprietary MIB.
For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above.
my $s3000 = new SNMP::Info::Layer1::S3000(...);
=head2 Inherited Classes
=over
=item SNMP::Info::Layer2
=back
=head2 Required MIBs
=over
=item F<SYNOPTICS-COMMON-MIB>
=item F<SYNOPTICS-ETHERNET-MIB>
=back
=head2 Inherited MIBs
See L<SNMP::Info::Layer2/"Required MIBs"> for its MIB requirements.
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $s3000->vendor()
Returns 'nortel'
=item $s3000->os()
Returns 'synoptics'
=item $s3000->model()
Cross references $s3000->id() to the F<SYNOPTICS-MIB> and returns
the results.
Removes C<sreg-> from the model name and returns only the numeric model
identifier.
=item $stack->os_ver()
Returns the software version specified as major.minor.maint.
(C<s3AgentSwMajorVer>).(C<s3AgentSwMinorVer>).(C<s3AgentSwMaintVer>)
=item $stack->os_bin()
Returns the firmware version. (C<s3AgentFwVer>)
=item $s3000->mac()
Returns MAC of the advertised IP address of the device.
=back
=head2 Overrides
=over
=item $s3000->layers()
Returns 00000011. Class emulates Layer 2 functionality through proprietary
MIBs.
=back
=head2 Globals imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"GLOBALS"> for details.
=head1 TABLE METHODS
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $s3000->i_index()
Returns reference to map of IIDs to Interface index.
Since hubs do not support C<ifIndex>, the interface index is created using the
formula (board * 256 + port). This is required to support devices with more
than one module.
=item $s3000->interfaces()
Returns reference to map of IIDs to physical ports.
=item $s3000->i_duplex()
Returns half, hubs do not support full duplex.
=item $s3000->i_duplex_admin()
Returns half, hubs do not support full duplex.
=item $s3000->i_speed()
Returns 10000000. The hubs only support 10 Mbs Ethernet.
=item $s3000->i_up()
Returns (C<s3EnetPortLinkStatus>) for each port. Translates on/off to
up/down.
=item $s3000->i_up_admin()
Returns (C<s3EnetPortPartStatus>) for each port.
=item $s3000->set_i_up_admin(state, ifIndex)
Sets port state, must be supplied with state and port C<ifIndex>
State choices are 'up' or 'down'
Example:
my %if_map = reverse %{$s3000->interfaces()};
$s3000->set_i_up_admin('down', $if_map{'1.1'})
or die "Couldn't change port state. ",$s3000->error(1);
=item $s3000->bp_index()
Simulates bridge MIB by returning reference to a hash containing the index for
both the keys and values.
=item $s3000->fw_port()
Returns reference to map of IIDs of the
C<SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable> to the Interface index.
=item $s3000->fw_mac()
(C<s3EnetShowNodesMacAddress>)
=item $s3000->s3000_topo_port()
Returns reference to hash. Key: Table entry, Value:Port Number
(interface iid)
(C<s3EnetTopNmmPort>)
=item $s3000->s3000_topo_mac()
(C<s3EnetTopNmmMacAddr>)
Returns reference to hash. Key: Table entry, Value:Remote MAC address
=back
=head2 Table Methods imported from SNMP::Info::Layer2
See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=cut