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

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