- Moved i_duplex and i_duplex_admin routines over from L2::HP so they could

be used by other classes (foundry...)
- removed DEBUG and INIT references.
- rev'd to 1.0
This commit is contained in:
Max Baker
2005-01-28 08:44:26 +00:00
parent 7944613d42
commit 61ac00d7fb

View File

@@ -1,5 +1,5 @@
# SNMP::Info::MAU - Media Access Unit - RFC 2668 # SNMP::Info::MAU - Media Access Unit - RFC 2668
# Max Baker <max@warped.org> # Max Baker
# #
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond. # Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
# #
@@ -30,7 +30,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::MAU; package SNMP::Info::MAU;
$VERSION = 0.9; $VERSION = 1.0;
# $Id$ # $Id$
use strict; use strict;
@@ -42,11 +42,6 @@ use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
@SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::MAU::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::MAU::EXPORT_OK = qw//; @SNMP::Info::MAU::EXPORT_OK = qw//;
$DEBUG=0;
$SNMP::debugging=$DEBUG;
$INIT = 0;
%MIBS = ('MAU-MIB' => 'mauMod'); %MIBS = ('MAU-MIB' => 'mauMod');
%GLOBALS = ( %GLOBALS = (
@@ -105,6 +100,81 @@ sub _ishalfduplex{
return 0; return 0;
} }
sub mau_i_duplex {
my $mau = shift;
my $mau_index = $mau->mau_index();
my $mau_link = $mau->mau_link();
my %i_duplex;
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);
next unless defined $link;
my $duplex = undef;
if ($link =~ /fd$/i) {
$duplex = 'full';
} elsif ($link =~ /hd$/i){
$duplex = 'half';
}
$i_duplex{$iid} = $duplex if defined $duplex;
}
return \%i_duplex;
}
sub mau_i_duplex_admin {
my $mau = shift;
my $interfaces = $mau->interfaces();
my $mau_index = $mau->mau_index();
my $mau_auto = $mau->mau_auto();
my $mau_autostat = $mau->mau_autostat();
my $mau_typeadmin = $mau->mau_type_admin();
my $mau_autosent = $mau->mau_autosent();
my %mau_reverse = reverse %$mau_index;
my %i_duplex_admin;
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){
$i_duplex_admin{$iid} = 'auto';
next;
}
my $type = $mau_autosent->{$mau_index};
next unless defined $type;
if ($type == 0) {
$i_duplex_admin{$iid} = 'none';
next;
}
my $full = $mau->_isfullduplex($type);
my $half = $mau->_ishalfduplex($type);
if ($full and !$half){
$i_duplex_admin{$iid} = 'full';
} elsif ($half) {
$i_duplex_admin{$iid} = 'half';
}
}
return \%i_duplex_admin;
}
1; 1;
__END__ __END__
@@ -115,7 +185,7 @@ SNMP::Info::MAU - Perl5 Interface to Medium Access Unit (MAU) MIB (RFC2668) via
=head1 AUTHOR =head1 AUTHOR
Max Baker (C<max@warped.org>) Max Baker
=head1 SYNOPSIS =head1 SYNOPSIS