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

1222
Info.pm

File diff suppressed because it is too large Load Diff

View File

@@ -34,117 +34,126 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::Airespace::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Airespace::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Airespace::EXPORT_OK = qw//; @SNMP::Info::Airespace::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::MIBS,
'AIRESPACE-WIRELESS-MIB' => 'bsnAPName', 'AIRESPACE-WIRELESS-MIB' => 'bsnAPName',
'AIRESPACE-SWITCHING-MIB' => 'agentInventorySerialNumber', 'AIRESPACE-SWITCHING-MIB' => 'agentInventorySerialNumber',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS,
'airespace_type' => 'agentInventoryMachineType', 'airespace_type' => 'agentInventoryMachineType',
'airespace_model' => 'agentInventoryMachineModel', 'airespace_model' => 'agentInventoryMachineModel',
'airespace_serial' => 'agentInventorySerialNumber', 'airespace_serial' => 'agentInventorySerialNumber',
'airespace_maint_ver' => 'agentInventoryMaintenanceLevel', 'airespace_maint_ver' => 'agentInventoryMaintenanceLevel',
'airespace_mac' => 'agentInventoryBurnedInMacAddress', 'airespace_mac' => 'agentInventoryBurnedInMacAddress',
'airespace_os' => 'agentInventoryOperatingSystem', 'airespace_os' => 'agentInventoryOperatingSystem',
'airespace_vendor' => 'agentInventoryManufacturerName', 'airespace_vendor' => 'agentInventoryManufacturerName',
'airespace_prod_name' => 'agentInventoryProductName', 'airespace_prod_name' => 'agentInventoryProductName',
'os_ver' => 'agentInventoryProductVersion', 'os_ver' => 'agentInventoryProductVersion',
'airespace_bssid_mode' => 'agentNetworkBroadcastSsidMode', 'airespace_bssid_mode' => 'agentNetworkBroadcastSsidMode',
'airespace_mc_mode' => 'agentNetworkMulticastMode', 'airespace_mc_mode' => 'agentNetworkMulticastMode',
'airespace_lwapp_mode' => 'agentSwitchLwappTransportMode', 'airespace_lwapp_mode' => 'agentSwitchLwappTransportMode',
'airespace_ul_mode' => 'agentTransferUploadMode', 'airespace_ul_mode' => 'agentTransferUploadMode',
'airespace_ul_ip' => 'agentTransferUploadServerIP', 'airespace_ul_ip' => 'agentTransferUploadServerIP',
'airespace_ul_path' => 'agentTransferUploadPath', 'airespace_ul_path' => 'agentTransferUploadPath',
'airespace_ul_file' => 'agentTransferUploadFilename', 'airespace_ul_file' => 'agentTransferUploadFilename',
'airespace_ul_type' => 'agentTransferUploadDataType', 'airespace_ul_type' => 'agentTransferUploadDataType',
'airespace_ul_start' => 'agentTransferUploadStart', 'airespace_ul_start' => 'agentTransferUploadStart',
'airespace_ul_status' => 'agentTransferUploadStatus', 'airespace_ul_status' => 'agentTransferUploadStatus',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS,
# AIRESPACE-WIRELESS-MIB::bsnDot11EssTable
'airespace_ess_idx' => 'bsnDot11EssIndex',
'airespace_ess_ssid' => 'bsnDot11EssSsid',
'airespace_ess_macflt' => 'bsnDot11EssMacFiltering',
'airespace_ess_status' => 'bsnDot11EssAdminStatus',
'airespace_ess_sec_auth' => 'bsnDot11EssSecurityAuthType',
'airespace_ess_radio_pol' => 'bsnDot11EssRadioPolicy',
'airespace_ess_qos' => 'bsnDot11EssQualityOfService',
'airespace_ess_ifname' => 'bsnDot11EssInterfaceName',
'airespace_ess_aclname' => 'bsnDot11EssAclName',
# AIRESPACE-WIRELESS-MIB::bsnAPTable
'airespace_ap_mac' => 'bsnAPDot3MacAddress',
'airespace_ap_name' => 'bsnAPName',
'airespace_ap_ip' => 'bsnApIpAddress',
'airespace_ap_loc' => 'bsnAPLocation',
'airespace_ap_sw' => 'bsnAPSoftwareVersion',
'airespace_ap_fw' => 'bsnAPBootVersion',
'airespace_ap_model' => 'bsnAPModel',
'airespace_ap_serial' => 'bsnAPSerialNumber',
'airespace_ap_type' => 'bsnAPType',
'airespace_ap_status' => 'bsnAPAdminStatus',
# AIRESPACE-WIRELESS-MIB::bsnAPIfTable
'airespace_apif_slot' => 'bsnAPIfSlotId',
'airespace_apif_type' => 'bsnAPIfType',
'airespace_apif_ch_num' => 'bsnAPIfPhyChannelNumber',
'airespace_apif_power' => 'bsnAPIfPhyTxPowerLevel',
'airespace_apif' => 'bsnAPIfOperStatus',
'airespace_apif_oride' => 'bsnAPIfWlanOverride',
'airespace_apif_admin' => 'bsnAPIfAdminStatus',
# AIRESPACE-WIRELESS-MIB::bsnMobileStationTable
'airespace_sta_mac' => 'bsnMobileStationAPMacAddr',
'fw_mac' => 'bsnMobileStationMacAddress',
'airespace_sta_slot' => 'bsnMobileStationAPIfSlotId',
'airespace_sta_ess_idx' => 'bsnMobileStationEssIndex',
'airespace_sta_ssid' => 'bsnMobileStationSsid',
'airespace_sta_delete' => 'bsnMobileStationDeleteAction',
# AIRESPACE-WIRELESS-MIB::bsnUsersTable
'airespace_user_name' => 'bsnUserName',
'airespace_user_pw' => 'bsnUserPassword',
'airespace_user_ess_idx' => 'bsnUserEssIndex',
'airespace_user_access' => 'bsnUserAccessMode',
'airespace_user_type' => 'bsnUserType',
'airespace_user_ifname' => 'bsnUserInterfaceName',
'airespace_user_rstat' => 'bsnUserRowStatus',
# AIRESPACE-WIRELESS-MIB::bsnBlackListClientTable
'airespace_bl_mac' => 'bsnBlackListClientMacAddress',
'airespace_bl_descr' => 'bsnBlackListClientDescription',
'airespace_bl_rstat' => 'bsnBlackListClientRowStatus',
# AIRESPACE-WIRELESS-MIB::bsnAPIfWlanOverrideTable
'airespace_oride_id' => 'bsnAPIfWlanOverrideId',
'airespace_oride_ssid' => 'bsnAPIfWlanOverrideSsid',
# AIRESPACE-SWITCHING-MIB::agentInterfaceConfigTable
'airespace_if_name' => 'agentInterfaceName',
'airespace_if_vlan' => 'agentInterfaceVlanId',
'airespace_if_type' => 'agentInterfaceType',
'airespace_if_mac' => 'agentInterfaceMacAddress',
'airespace_if_ip' => 'agentInterfaceIPAddress',
'airespace_if_mask' => 'agentInterfaceIPNetmask',
'airespace_if_acl' => 'agentInterfaceAclName',
'airespace_if_rstat' => 'agentInterfaceRowStatus',
# AIRESPACE-SWITCHING-MIB::agentPortConfigTable
'airespace_duplex_admin' => 'agentPortPhysicalMode',
'airespace_duplex' => 'agentPortPhysicalStatus',
);
%MUNGE = ( # AIRESPACE-WIRELESS-MIB::bsnDot11EssTable
%SNMP::Info::MUNGE, 'airespace_ess_idx' => 'bsnDot11EssIndex',
'airespace_ap_mac' => \&SNMP::Info::munge_mac, 'airespace_ess_ssid' => 'bsnDot11EssSsid',
'fw_port' => \&SNMP::Info::munge_mac, 'airespace_ess_macflt' => 'bsnDot11EssMacFiltering',
'airespace_bl_mac' => \&SNMP::Info::munge_mac, 'airespace_ess_status' => 'bsnDot11EssAdminStatus',
'airespace_if_mac' => \&SNMP::Info::munge_mac, 'airespace_ess_sec_auth' => 'bsnDot11EssSecurityAuthType',
'airespace_sta_mac' => \&SNMP::Info::munge_mac, 'airespace_ess_radio_pol' => 'bsnDot11EssRadioPolicy',
); 'airespace_ess_qos' => 'bsnDot11EssQualityOfService',
'airespace_ess_ifname' => 'bsnDot11EssInterfaceName',
'airespace_ess_aclname' => 'bsnDot11EssAclName',
# AIRESPACE-WIRELESS-MIB::bsnAPTable
'airespace_ap_mac' => 'bsnAPDot3MacAddress',
'airespace_ap_name' => 'bsnAPName',
'airespace_ap_ip' => 'bsnApIpAddress',
'airespace_ap_loc' => 'bsnAPLocation',
'airespace_ap_sw' => 'bsnAPSoftwareVersion',
'airespace_ap_fw' => 'bsnAPBootVersion',
'airespace_ap_model' => 'bsnAPModel',
'airespace_ap_serial' => 'bsnAPSerialNumber',
'airespace_ap_type' => 'bsnAPType',
'airespace_ap_status' => 'bsnAPAdminStatus',
# AIRESPACE-WIRELESS-MIB::bsnAPIfTable
'airespace_apif_slot' => 'bsnAPIfSlotId',
'airespace_apif_type' => 'bsnAPIfType',
'airespace_apif_ch_num' => 'bsnAPIfPhyChannelNumber',
'airespace_apif_power' => 'bsnAPIfPhyTxPowerLevel',
'airespace_apif' => 'bsnAPIfOperStatus',
'airespace_apif_oride' => 'bsnAPIfWlanOverride',
'airespace_apif_admin' => 'bsnAPIfAdminStatus',
# AIRESPACE-WIRELESS-MIB::bsnMobileStationTable
'airespace_sta_mac' => 'bsnMobileStationAPMacAddr',
'fw_mac' => 'bsnMobileStationMacAddress',
'airespace_sta_slot' => 'bsnMobileStationAPIfSlotId',
'airespace_sta_ess_idx' => 'bsnMobileStationEssIndex',
'airespace_sta_ssid' => 'bsnMobileStationSsid',
'airespace_sta_delete' => 'bsnMobileStationDeleteAction',
# AIRESPACE-WIRELESS-MIB::bsnUsersTable
'airespace_user_name' => 'bsnUserName',
'airespace_user_pw' => 'bsnUserPassword',
'airespace_user_ess_idx' => 'bsnUserEssIndex',
'airespace_user_access' => 'bsnUserAccessMode',
'airespace_user_type' => 'bsnUserType',
'airespace_user_ifname' => 'bsnUserInterfaceName',
'airespace_user_rstat' => 'bsnUserRowStatus',
# AIRESPACE-WIRELESS-MIB::bsnBlackListClientTable
'airespace_bl_mac' => 'bsnBlackListClientMacAddress',
'airespace_bl_descr' => 'bsnBlackListClientDescription',
'airespace_bl_rstat' => 'bsnBlackListClientRowStatus',
# AIRESPACE-WIRELESS-MIB::bsnAPIfWlanOverrideTable
'airespace_oride_id' => 'bsnAPIfWlanOverrideId',
'airespace_oride_ssid' => 'bsnAPIfWlanOverrideSsid',
# AIRESPACE-SWITCHING-MIB::agentInterfaceConfigTable
'airespace_if_name' => 'agentInterfaceName',
'airespace_if_vlan' => 'agentInterfaceVlanId',
'airespace_if_type' => 'agentInterfaceType',
'airespace_if_mac' => 'agentInterfaceMacAddress',
'airespace_if_ip' => 'agentInterfaceIPAddress',
'airespace_if_mask' => 'agentInterfaceIPNetmask',
'airespace_if_acl' => 'agentInterfaceAclName',
'airespace_if_rstat' => 'agentInterfaceRowStatus',
# AIRESPACE-SWITCHING-MIB::agentPortConfigTable
'airespace_duplex_admin' => 'agentPortPhysicalMode',
'airespace_duplex' => 'agentPortPhysicalStatus',
);
%MUNGE = (
%SNMP::Info::MUNGE,
'airespace_ap_mac' => \&SNMP::Info::munge_mac,
'fw_port' => \&SNMP::Info::munge_mac,
'airespace_bl_mac' => \&SNMP::Info::munge_mac,
'airespace_if_mac' => \&SNMP::Info::munge_mac,
'airespace_sta_mac' => \&SNMP::Info::munge_mac,
);
sub layers { sub layers {
return '00000011'; return '00000011';
@@ -152,7 +161,7 @@ sub layers {
sub serial { sub serial {
my $airespace = shift; my $airespace = shift;
my $sn = $airespace->airespace_serial(); my $sn = $airespace->airespace_serial();
return unless defined $sn; return unless defined $sn;
return $sn; return $sn;
@@ -165,12 +174,12 @@ sub i_index {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->orig_i_index($partial) || {}; my $i_index = $airespace->orig_i_index($partial) || {};
my $ap_index = $airespace->airespace_apif_slot($partial) || {}; my $ap_index = $airespace->airespace_apif_slot($partial) || {};
my $if_index = $airespace->airespace_if_name($partial) || {}; my $if_index = $airespace->airespace_if_name($partial) || {};
my %if_index; my %if_index;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
@@ -178,20 +187,21 @@ sub i_index {
} }
# Get Attached APs as Interfaces # Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){ foreach my $ap_id ( keys %$ap_index ) {
if ($ap_id =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)\.(\d+)/) { if ( $ap_id =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)\.(\d+)/ ) {
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$1)); my $mac = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $1 ) );
my $slot = $2; my $slot = $2;
next unless ( (defined $mac) and (defined $slot) ); next unless ( ( defined $mac ) and ( defined $slot ) );
$if_index{$ap_id} = "$mac.$slot"; $if_index{$ap_id} = "$mac.$slot";
} }
} }
# Get Switch Interfaces from Interface Config Table # Get Switch Interfaces from Interface Config Table
foreach my $if_id (keys %$if_index){ foreach my $if_id ( keys %$if_index ) {
my $name = $if_index->{$if_id}; my $name = $if_index->{$if_id};
next unless defined $name; next unless defined $name;
$if_index{$if_id} = $name; $if_index{$if_id} = $name;
@@ -204,19 +214,19 @@ sub interfaces {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
$if{$iid} = "1.$index"; $if{$iid} = "1.$index";
} }
else { else {
$if{$iid} = $index; $if{$iid} = $index;
} }
} }
return \%if; return \%if;
@@ -226,22 +236,22 @@ sub i_name {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my $i_name = $airespace->orig_i_name($partial) || {}; my $i_name = $airespace->orig_i_name($partial) || {};
my $ap_name = $airespace->airespace_ap_name($partial) || {}; my $ap_name = $airespace->airespace_ap_name($partial) || {};
my %i_name; my %i_name;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $name = $i_name->{$iid}; my $name = $i_name->{$iid};
next unless defined $name; next unless defined $name;
$i_name{$iid} = $name; $i_name{$iid} = $name;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $idx = $iid; my $idx = $iid;
$idx =~ s/\.\d+$//; $idx =~ s/\.\d+$//;
my $name = $ap_name->{$idx}; my $name = $ap_name->{$idx};
@@ -260,22 +270,22 @@ sub i_description {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my $i_descr = $airespace->orig_i_description($partial) || {}; my $i_descr = $airespace->orig_i_description($partial) || {};
my $ap_loc = $airespace->airespace_ap_loc($partial) || {}; my $ap_loc = $airespace->airespace_ap_loc($partial) || {};
my %descr; my %descr;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $descr = $i_descr->{$iid}; my $descr = $i_descr->{$iid};
next unless defined $descr; next unless defined $descr;
$descr{$iid} = $descr; $descr{$iid} = $descr;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $idx = $iid; my $idx = $iid;
$idx =~ s/\.\d+$//; $idx =~ s/\.\d+$//;
my $name = $ap_loc->{$idx}; my $name = $ap_loc->{$idx};
@@ -294,23 +304,23 @@ sub i_type {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my $i_descr = $airespace->orig_i_type($partial) || {}; my $i_descr = $airespace->orig_i_type($partial) || {};
my $apif_type = $airespace->airespace_apif_type($partial) || {}; my $apif_type = $airespace->airespace_apif_type($partial) || {};
my $if_type = $airespace->airespace_if_type($partial) || {}; my $if_type = $airespace->airespace_if_type($partial) || {};
my %i_type; my %i_type;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $descr = $i_descr->{$iid}; my $descr = $i_descr->{$iid};
next unless defined $descr; next unless defined $descr;
$i_type{$iid} = $descr; $i_type{$iid} = $descr;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $type = $apif_type->{$iid}; my $type = $apif_type->{$iid};
next unless defined $type; next unless defined $type;
$i_type{$iid} = $type; $i_type{$iid} = $type;
@@ -328,22 +338,22 @@ sub i_up {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my $i_up = $airespace->orig_i_up($partial) || {}; my $i_up = $airespace->orig_i_up($partial) || {};
my $apif_up = $airespace->airespace_apif($partial) || {}; my $apif_up = $airespace->airespace_apif($partial) || {};
my %i_up; my %i_up;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $stat = $i_up->{$iid}; my $stat = $i_up->{$iid};
next unless defined $stat; next unless defined $stat;
$i_up{$iid} = $stat; $i_up{$iid} = $stat;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $stat = $apif_up->{$iid}; my $stat = $apif_up->{$iid};
next unless defined $stat; next unless defined $stat;
$i_up{$iid} = $stat; $i_up{$iid} = $stat;
@@ -353,29 +363,29 @@ sub i_up {
next; next;
} }
} }
return \%i_up; return \%i_up;
} }
sub i_up_admin { sub i_up_admin {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my $i_up = $airespace->orig_i_up($partial) || {}; my $i_up = $airespace->orig_i_up($partial) || {};
my $apif_up = $airespace->airespace_apif_admin($partial) || {}; my $apif_up = $airespace->airespace_apif_admin($partial) || {};
my %i_up_admin; my %i_up_admin;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $stat = $i_up->{$iid}; my $stat = $i_up->{$iid};
next unless defined $stat; next unless defined $stat;
$i_up_admin{$iid} = $stat; $i_up_admin{$iid} = $stat;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $stat = $apif_up->{$iid}; my $stat = $apif_up->{$iid};
next unless defined $stat; next unless defined $stat;
$i_up_admin{$iid} = $stat; $i_up_admin{$iid} = $stat;
@@ -385,23 +395,23 @@ sub i_up_admin {
next; next;
} }
} }
return \%i_up_admin; return \%i_up_admin;
} }
sub i_mac { sub i_mac {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my $i_mac = $airespace->orig_i_mac($partial) || {}; my $i_mac = $airespace->orig_i_mac($partial) || {};
my $if_mac = $airespace->airespace_if_mac($partial) || {}; my $if_mac = $airespace->airespace_if_mac($partial) || {};
my %i_mac; my %i_mac;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $mac = $i_mac->{$iid}; my $mac = $i_mac->{$iid};
next unless defined $mac; next unless defined $mac;
$i_mac{$iid} = $mac; $i_mac{$iid} = $mac;
@@ -418,41 +428,41 @@ sub i_mac {
$i_mac{$iid} = $mac; $i_mac{$iid} = $mac;
} }
} }
return \%i_mac; return \%i_mac;
} }
sub i_vlan { sub i_vlan {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $if_vlan = $airespace->airespace_if_vlan($partial) || {}; my $if_vlan = $airespace->airespace_if_vlan($partial) || {};
my %i_vlan; my %i_vlan;
foreach my $iid (keys %$if_vlan){ foreach my $iid ( keys %$if_vlan ) {
my $vlan = $if_vlan->{$iid}; my $vlan = $if_vlan->{$iid};
next unless defined $vlan; next unless defined $vlan;
$i_vlan{$iid} = $vlan; $i_vlan{$iid} = $vlan;
} }
return \%i_vlan; return \%i_vlan;
} }
sub i_duplex { sub i_duplex {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $ap_duplex = $airespace->airespace_duplex($partial) || {}; my $ap_duplex = $airespace->airespace_duplex($partial) || {};
my %i_duplex; my %i_duplex;
foreach my $if (keys %$ap_duplex){ foreach my $if ( keys %$ap_duplex ) {
my $duplex = $ap_duplex->{$if}; my $duplex = $ap_duplex->{$if};
next unless defined $duplex; next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i; $duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex{$if}=$duplex; $i_duplex{$if} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
@@ -461,17 +471,17 @@ sub i_duplex_admin {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $ap_duplex_admin = $airespace->airespace_duplex_admin($partial) || {}; my $ap_duplex_admin = $airespace->airespace_duplex_admin($partial) || {};
my %i_duplex_admin; my %i_duplex_admin;
foreach my $if (keys %$ap_duplex_admin){ foreach my $if ( keys %$ap_duplex_admin ) {
my $duplex = $ap_duplex_admin->{$if}; my $duplex = $ap_duplex_admin->{$if};
next unless defined $duplex; next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i; $duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex_admin{$if}=$duplex; $i_duplex_admin{$if} = $duplex;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
@@ -481,20 +491,20 @@ sub ip_index {
my $partial = shift; my $partial = shift;
my $ip_index = $airespace->orig_ip_index($partial) || {}; my $ip_index = $airespace->orig_ip_index($partial) || {};
my $if_ip = $airespace->airespace_if_ip() || {}; my $if_ip = $airespace->airespace_if_ip() || {};
my %ip_index; my %ip_index;
foreach my $ip (keys %$ip_index){ foreach my $ip ( keys %$ip_index ) {
my $iid = $ip_index->{$ip}; my $iid = $ip_index->{$ip};
next unless defined $iid; next unless defined $iid;
$ip_index{$ip} = $iid; $ip_index{$ip} = $iid;
} }
foreach my $iid (keys %$if_ip){ foreach my $iid ( keys %$if_ip ) {
my $ip = $if_ip->{$iid}; my $ip = $if_ip->{$iid};
next unless defined $ip; next unless defined $ip;
next if (defined $partial and $partial !~ /$ip/); next if ( defined $partial and $partial !~ /$ip/ );
$ip_index{$ip} = $iid; $ip_index{$ip} = $iid;
} }
@@ -507,21 +517,21 @@ sub ip_netmask {
my $partial = shift; my $partial = shift;
my $ip_mask = $airespace->orig_ip_netmask($partial) || {}; my $ip_mask = $airespace->orig_ip_netmask($partial) || {};
my $if_ip = $airespace->airespace_if_ip() || {}; my $if_ip = $airespace->airespace_if_ip() || {};
my $if_mask = $airespace->airespace_if_mask() || {}; my $if_mask = $airespace->airespace_if_mask() || {};
my %ip_netmask; my %ip_netmask;
foreach my $ip (keys %$ip_mask){ foreach my $ip ( keys %$ip_mask ) {
my $mask = $ip_mask->{$ip}; my $mask = $ip_mask->{$ip};
next unless defined $mask; next unless defined $mask;
$ip_netmask{$ip} = $mask; $ip_netmask{$ip} = $mask;
} }
foreach my $iid (keys %$if_mask){ foreach my $iid ( keys %$if_mask ) {
my $ip = $if_ip->{$iid}; my $ip = $if_ip->{$iid};
next unless defined $ip; next unless defined $ip;
next if (defined $partial and $partial !~ /$ip/); next if ( defined $partial and $partial !~ /$ip/ );
my $mask = $if_mask->{$iid}; my $mask = $if_mask->{$iid};
next unless defined $mask; next unless defined $mask;
@@ -536,10 +546,10 @@ sub bp_index {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $i_index = $airespace->i_index($partial) || {}; my $i_index = $airespace->i_index($partial) || {};
my %bp_index; my %bp_index;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
@@ -553,11 +563,11 @@ sub fw_port {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $sta_mac = $airespace->airespace_sta_mac($partial) || {}; my $sta_mac = $airespace->airespace_sta_mac($partial) || {};
my $sta_slot = $airespace->airespace_sta_slot($partial) || {}; my $sta_slot = $airespace->airespace_sta_slot($partial) || {};
my %fw_port; my %fw_port;
foreach my $iid (keys %$sta_mac){ foreach my $iid ( keys %$sta_mac ) {
my $mac = $sta_mac->{$iid}; my $mac = $sta_mac->{$iid};
next unless defined $mac; next unless defined $mac;
my $slot = $sta_slot->{$iid}; my $slot = $sta_slot->{$iid};
@@ -573,30 +583,30 @@ sub i_ssidlist {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $apif_override = $airespace->airespace_apif_oride($partial) || {}; my $apif_override = $airespace->airespace_apif_oride($partial) || {};
my $apif_type = $airespace->airespace_apif_type($partial) || {}; my $apif_type = $airespace->airespace_apif_type($partial) || {};
my $ssids = $airespace->airespace_ess_ssid() || {}; my $ssids = $airespace->airespace_ess_ssid() || {};
my $ssid_policy = $airespace->airespace_ess_radio_pol() || {}; my $ssid_policy = $airespace->airespace_ess_radio_pol() || {};
my $ssid_status = $airespace->airespace_ess_status() || {}; my $ssid_status = $airespace->airespace_ess_status() || {};
my $ovride_ssids = $airespace->airespace_oride_ssid($partial) || {}; my $ovride_ssids = $airespace->airespace_oride_ssid($partial) || {};
my %i_ssidlist; my %i_ssidlist;
foreach my $iid (keys %$apif_override){ foreach my $iid ( keys %$apif_override ) {
my $override = $apif_override->{$iid}; my $override = $apif_override->{$iid};
next unless defined $override; next unless defined $override;
next unless $override =~ /disable/i ; next unless $override =~ /disable/i;
my $ap_type = $apif_type->{$iid}; my $ap_type = $apif_type->{$iid};
next unless defined $ap_type; next unless defined $ap_type;
$ap_type =~ s/dot11//; $ap_type =~ s/dot11//;
foreach my $idx (keys %$ssids){ foreach my $idx ( keys %$ssids ) {
my $ssid = $ssids->{$idx}; my $ssid = $ssids->{$idx};
next unless defined $ssid; next unless defined $ssid;
my $status = $ssid_status->{$idx}; my $status = $ssid_status->{$idx};
next unless defined $status; next unless defined $status;
next if ( $status =~ /disable/ ); next if ( $status =~ /disable/ );
my $policy = $ssid_policy->{$idx}; my $policy = $ssid_policy->{$idx};
next unless $policy =~ /$ap_type/ or $policy =~ /all/; next unless $policy =~ /$ap_type/ or $policy =~ /all/;
$i_ssidlist{"$iid.$idx"} = $ssid; $i_ssidlist{"$iid.$idx"} = $ssid;
@@ -604,7 +614,7 @@ sub i_ssidlist {
next; next;
} }
foreach my $iid (keys %$ovride_ssids){ foreach my $iid ( keys %$ovride_ssids ) {
my $ssid = $ovride_ssids->{$iid}; my $ssid = $ovride_ssids->{$iid};
next unless $ssid; next unless $ssid;
@@ -618,14 +628,14 @@ sub i_ssidbcast {
my $airespace = shift; my $airespace = shift;
my $partial = shift; my $partial = shift;
my $ssidlist = $airespace->i_ssidlist($partial) || {}; my $ssidlist = $airespace->i_ssidlist($partial) || {};
my $bc_mode = $airespace->airespace_bssid_mode() || 'enable'; my $bc_mode = $airespace->airespace_bssid_mode() || 'enable';
my %bcmap = qw/enable 1 disable 0/; my %bcmap = qw/enable 1 disable 0/;
my $broadcast = $bcmap{$bc_mode}; my $broadcast = $bcmap{$bc_mode};
my %i_ssidbcast; my %i_ssidbcast;
foreach my $iid (keys %$ssidlist){ foreach my $iid ( keys %$ssidlist ) {
$i_ssidbcast{$iid} = $broadcast; $i_ssidbcast{$iid} = $broadcast;
} }
@@ -639,7 +649,7 @@ sub i_80211channel {
my $ch_list = $airespace->airespace_apif_ch_num($partial) || {}; my $ch_list = $airespace->airespace_apif_ch_num($partial) || {};
my %i_80211channel; my %i_80211channel;
foreach my $iid (keys %$ch_list){ foreach my $iid ( keys %$ch_list ) {
my $ch = $ch_list->{$iid}; my $ch = $ch_list->{$iid};
$ch =~ s/ch//; $ch =~ s/ch//;
$i_80211channel{$iid} = $ch; $i_80211channel{$iid} = $ch;
@@ -648,7 +658,6 @@ sub i_80211channel {
return \%i_80211channel; return \%i_80211channel;
} }
# Pseudo ENTITY-MIB methods # Pseudo ENTITY-MIB methods
sub e_index { sub e_index {
@@ -657,17 +666,20 @@ sub e_index {
my $ap_model = $airespace->airespace_ap_model() || {}; my $ap_model = $airespace->airespace_ap_model() || {};
my %e_index; my %e_index;
# Chassis # Chassis
$e_index{1} = 1; $e_index{1} = 1;
# We're going to hack an index to capture APs # We're going to hack an index to capture APs
foreach my $idx (keys %$ap_model){ foreach my $idx ( keys %$ap_model ) {
# Create the integer index by joining the last three octets of the MAC.
# Hopefully, this will be unique since the manufacturer should be # Create the integer index by joining the last three octets of the MAC.
# limited to Airespace and Cisco. We can't use the entire MAC since # Hopefully, this will be unique since the manufacturer should be
# we would exceed the intger size limit. # limited to Airespace and Cisco. We can't use the entire MAC since
if ($idx =~ /(\d+\.\d+\.\d+)$/) { # we would exceed the intger size limit.
my $index = int (join('',map { sprintf "%03d",$_ } split /\./, $1)); if ( $idx =~ /(\d+\.\d+\.\d+)$/ ) {
my $index = int(
join( '', map { sprintf "%03d", $_ } split /\./, $1 ) );
$e_index{$idx} = $index; $e_index{$idx} = $index;
} }
} }
@@ -680,10 +692,11 @@ sub e_class {
my $e_idx = $airespace->e_index() || {}; my $e_idx = $airespace->e_index() || {};
my %e_class; my %e_class;
foreach my $iid (keys %$e_idx){ foreach my $iid ( keys %$e_idx ) {
if ($iid eq 1) { if ( $iid eq 1 ) {
$e_class{$iid} = 'chassis'; $e_class{$iid} = 'chassis';
} }
# This isn't a valid PhysicalClass, but we're hacking this anyway # This isn't a valid PhysicalClass, but we're hacking this anyway
else { else {
$e_class{$iid} = 'ap'; $e_class{$iid} = 'ap';
@@ -698,11 +711,12 @@ sub e_name {
my $ap_name = $airespace->airespace_ap_name() || {}; my $ap_name = $airespace->airespace_ap_name() || {};
my %e_name; my %e_name;
# Chassis # Chassis
$e_name{1} = 'WLAN Controller'; $e_name{1} = 'WLAN Controller';
# APs # APs
foreach my $iid (keys %$ap_name){ foreach my $iid ( keys %$ap_name ) {
$e_name{$iid} = 'AP'; $e_name{$iid} = 'AP';
} }
return \%e_name; return \%e_name;
@@ -712,19 +726,20 @@ sub e_descr {
my $airespace = shift; my $airespace = shift;
my $ap_model = $airespace->airespace_ap_model() || {}; my $ap_model = $airespace->airespace_ap_model() || {};
my $ap_name = $airespace->airespace_ap_name() || {}; my $ap_name = $airespace->airespace_ap_name() || {};
my $ap_loc = $airespace->airespace_ap_loc() || {}; my $ap_loc = $airespace->airespace_ap_loc() || {};
my %e_descr; my %e_descr;
# Chassis # Chassis
$e_descr{1} = $airespace->airespace_prod_name(); $e_descr{1} = $airespace->airespace_prod_name();
# APs # APs
foreach my $iid (keys %$ap_name){ foreach my $iid ( keys %$ap_name ) {
my $name = $ap_name->{$iid}; my $name = $ap_name->{$iid};
next unless defined $name; next unless defined $name;
my $model = $ap_model->{$iid} || 'AP'; my $model = $ap_model->{$iid} || 'AP';
my $loc = $ap_loc->{$iid} || 'unknown'; my $loc = $ap_loc->{$iid} || 'unknown';
$e_descr{$iid} = "$model: $name ($loc)"; $e_descr{$iid} = "$model: $name ($loc)";
} }
@@ -737,11 +752,12 @@ sub e_model {
my $ap_model = $airespace->airespace_ap_model() || {}; my $ap_model = $airespace->airespace_ap_model() || {};
my %e_model; my %e_model;
# Chassis # Chassis
$e_model{1} = $airespace->airespace_model(); $e_model{1} = $airespace->airespace_model();
# APs # APs
foreach my $iid (keys %$ap_model){ foreach my $iid ( keys %$ap_model ) {
my $model = $ap_model->{$iid}; my $model = $ap_model->{$iid};
next unless defined $model; next unless defined $model;
@@ -756,11 +772,12 @@ sub e_type {
my $ap_type = $airespace->airespace_ap_type() || {}; my $ap_type = $airespace->airespace_ap_type() || {};
my %e_type; my %e_type;
# Chassis # Chassis
$e_type{1} = $airespace->airespace_type(); $e_type{1} = $airespace->airespace_type();
# APs # APs
foreach my $iid (keys %$ap_type){ foreach my $iid ( keys %$ap_type ) {
my $type = $ap_type->{$iid}; my $type = $ap_type->{$iid};
next unless defined $type; next unless defined $type;
@@ -775,11 +792,12 @@ sub e_fwver {
my $ap_fw = $airespace->airespace_ap_fw() || {}; my $ap_fw = $airespace->airespace_ap_fw() || {};
my %e_fwver; my %e_fwver;
# Chassis # Chassis
$e_fwver{1} = $airespace->airespace_maint_ver(); $e_fwver{1} = $airespace->airespace_maint_ver();
# APs # APs
foreach my $iid (keys %$ap_fw){ foreach my $iid ( keys %$ap_fw ) {
my $fw = $ap_fw->{$iid}; my $fw = $ap_fw->{$iid};
next unless defined $fw; next unless defined $fw;
@@ -791,10 +809,10 @@ sub e_fwver {
sub e_vendor { sub e_vendor {
my $airespace = shift; my $airespace = shift;
my $e_idx = $airespace->e_index() || {}; my $e_idx = $airespace->e_index() || {};
my %e_vendor; my %e_vendor;
foreach my $iid (keys %$e_idx){ foreach my $iid ( keys %$e_idx ) {
$e_vendor{$iid} = 'cisco'; $e_vendor{$iid} = 'cisco';
} }
return \%e_vendor; return \%e_vendor;
@@ -806,11 +824,12 @@ sub e_serial {
my $ap_serial = $airespace->airespace_ap_serial() || {}; my $ap_serial = $airespace->airespace_ap_serial() || {};
my %e_serial; my %e_serial;
# Chassis # Chassis
$e_serial{1} = $airespace->airespace_serial(); $e_serial{1} = $airespace->airespace_serial();
# APs # APs
foreach my $iid (keys %$ap_serial){ foreach my $iid ( keys %$ap_serial ) {
my $serial = $ap_serial->{$iid}; my $serial = $ap_serial->{$iid};
next unless defined $serial; next unless defined $serial;
@@ -822,12 +841,12 @@ sub e_serial {
sub e_pos { sub e_pos {
my $airespace = shift; my $airespace = shift;
my $e_idx = $airespace->e_index() || {}; my $e_idx = $airespace->e_index() || {};
my %e_pos; my %e_pos;
my $pos = 0; my $pos = 0;
foreach my $iid (sort keys %$e_idx){ foreach my $iid ( sort keys %$e_idx ) {
if ($iid eq 1) { if ( $iid eq 1 ) {
$e_pos{$iid} = -1; $e_pos{$iid} = -1;
next; next;
} }
@@ -845,11 +864,12 @@ sub e_swver {
my $ap_sw = $airespace->airespace_ap_sw() || {}; my $ap_sw = $airespace->airespace_ap_sw() || {};
my %e_swver; my %e_swver;
# Chassis # Chassis
$e_swver{1} = $airespace->airespace_os(); $e_swver{1} = $airespace->airespace_os();
# APs # APs
foreach my $iid (keys %$ap_sw){ foreach my $iid ( keys %$ap_sw ) {
my $sw = $ap_sw->{$iid}; my $sw = $ap_sw->{$iid};
next unless defined $sw; next unless defined $sw;
@@ -861,11 +881,11 @@ sub e_swver {
sub e_parent { sub e_parent {
my $airespace = shift; my $airespace = shift;
my $e_idx = $airespace->e_index() || {}; my $e_idx = $airespace->e_index() || {};
my %e_parent; my %e_parent;
foreach my $iid (sort keys %$e_idx){ foreach my $iid ( sort keys %$e_idx ) {
if ($iid eq 1) { if ( $iid eq 1 ) {
$e_parent{$iid} = 0; $e_parent{$iid} = 0;
next; next;
} }
@@ -998,8 +1018,8 @@ Layer3 mode.
=item $airespace->airespace_ul_mode() =item $airespace->airespace_ul_mode()
Transfer upload mode configures the mode to use when uploading from the switch. Transfer upload mode configures the mode to use when uploading from the
Normal usage tftp. switch. Normal usage tftp.
(C<agentTransferUploadMode>) (C<agentTransferUploadMode>)
@@ -1012,8 +1032,8 @@ valid only when the Transfer Mode is tftp.
=item $airespace->airespace_ul_path() =item $airespace->airespace_ul_path()
Transfer upload tftp path configures the directory path where the file is to be Transfer upload tftp path configures the directory path where the file is to
uploaded to. The switch remembers the last file path used. be uploaded to. The switch remembers the last file path used.
(C<agentTransferUploadPath>) (C<agentTransferUploadPath>)
@@ -1023,7 +1043,8 @@ uploaded to. The switch remembers the last file path used.
=item $airespace->airespace_ul_type() =item $airespace->airespace_ul_type()
Transfer upload datatype configures the type of file to upload from the switch. Transfer upload datatype configures the type of file to upload from the
switch.
The types for upload are: The types for upload are:
config(2) config(2)
@@ -1518,8 +1539,8 @@ only.
=item $airespace->i_duplex_admin() =item $airespace->i_duplex_admin()
Returns reference to hash of IIDs to admin duplex setting. Ethernet interfaces Returns reference to hash of IIDs to admin duplex setting. Ethernet
only. interfaces only.
=item $airespace->ip_index() =item $airespace->ip_index()
@@ -1548,8 +1569,8 @@ airespace_sta_slot() combined to match the interface iid.
=head2 Pseudo F<ENTITY-MIB> information =head2 Pseudo F<ENTITY-MIB> information
These methods emulate F<ENTITY-MIB> Physical Table methods using These methods emulate F<ENTITY-MIB> Physical Table methods using
F<AIRESPACE-SWITCHING-MIB> and F<AIRESPACE-WIRELESS-MIB>. Thin APs are included F<AIRESPACE-SWITCHING-MIB> and F<AIRESPACE-WIRELESS-MIB>. Thin APs are
as subcomponents of the wireless controller. included as subcomponents of the wireless controller.
=over =over

View File

@@ -37,113 +37,126 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::Bridge::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Bridge::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Bridge::EXPORT_OK = qw//; @SNMP::Info::Bridge::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/; use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ('BRIDGE-MIB' => 'dot1dBaseBridgeAddress', %MIBS = (
'Q-BRIDGE-MIB' => 'dot1qPvid', 'BRIDGE-MIB' => 'dot1dBaseBridgeAddress',
); 'Q-BRIDGE-MIB' => 'dot1qPvid',
);
%GLOBALS = ( %GLOBALS = (
'b_mac' => 'dot1dBaseBridgeAddress', 'b_mac' => 'dot1dBaseBridgeAddress',
'b_ports' => 'dot1dBaseNumPorts', 'b_ports' => 'dot1dBaseNumPorts',
'b_type' => 'dot1dBaseType', 'b_type' => 'dot1dBaseType',
# Spanning Tree Protocol
'stp_ver' => 'dot1dStpProtocolSpecification', # Spanning Tree Protocol
'stp_time' => 'dot1dStpTimeSinceTopologyChange', 'stp_ver' => 'dot1dStpProtocolSpecification',
'stp_root' => 'dot1dStpDesignatedRoot', 'stp_time' => 'dot1dStpTimeSinceTopologyChange',
# Q-BRIDGE-MIB 'stp_root' => 'dot1dStpDesignatedRoot',
'qb_vlans_max' => 'dot1qMaxSupportedVlans',
'qb_vlans' => 'dot1qNumVlans', # Q-BRIDGE-MIB
'qb_next_vlan_index' => 'dot1qNextFreeLocalVlanIndex', 'qb_vlans_max' => 'dot1qMaxSupportedVlans',
); 'qb_vlans' => 'dot1qNumVlans',
'qb_next_vlan_index' => 'dot1qNextFreeLocalVlanIndex',
);
%FUNCS = ( %FUNCS = (
# Forwarding Table: Dot1dTpFdbEntry
'fw_mac' => 'dot1dTpFdbAddress', # Forwarding Table: Dot1dTpFdbEntry
'fw_port' => 'dot1dTpFdbPort', 'fw_mac' => 'dot1dTpFdbAddress',
'fw_status' => 'dot1dTpFdbStatus', 'fw_port' => 'dot1dTpFdbPort',
# Bridge Port Table: Dot1dBasePortEntry 'fw_status' => 'dot1dTpFdbStatus',
'bp_index' => 'dot1dBasePortIfIndex',
'bp_port' => 'dot1dBasePortCircuit', # Bridge Port Table: Dot1dBasePortEntry
# Bridge Static (Destination-Address Filtering) Database 'bp_index' => 'dot1dBasePortIfIndex',
'bs_mac' => 'dot1dStaticAddress', 'bp_port' => 'dot1dBasePortCircuit',
'bs_port' => 'dot1dStaticReceivePort',
'bs_to' => 'dot1dStaticAllowedToGoTo', # Bridge Static (Destination-Address Filtering) Database
'bs_status' => 'dot1dStaticStatus', 'bs_mac' => 'dot1dStaticAddress',
# Spanning Tree Protocol Table : dot1dStpPortTable 'bs_port' => 'dot1dStaticReceivePort',
'stp_p_id' => 'dot1dStpPort', 'bs_to' => 'dot1dStaticAllowedToGoTo',
'stp_p_priority' => 'dot1dStpPortPriority', 'bs_status' => 'dot1dStaticStatus',
'stp_p_state' => 'dot1dStpPortState',
'stp_p_cost' => 'dot1dStpPortPathCost', # Spanning Tree Protocol Table : dot1dStpPortTable
'stp_p_root' => 'dot1dStpPortDesignatedRoot', 'stp_p_id' => 'dot1dStpPort',
'stp_p_bridge' => 'dot1dStpPortDesignatedBridge', 'stp_p_priority' => 'dot1dStpPortPriority',
'stp_p_port' => 'dot1dStpPortDesignatedPort', 'stp_p_state' => 'dot1dStpPortState',
# Q-BRIDGE-MIB : dot1qPortVlanTable 'stp_p_cost' => 'dot1dStpPortPathCost',
'qb_i_vlan' => 'dot1qPvid', 'stp_p_root' => 'dot1dStpPortDesignatedRoot',
'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes', 'stp_p_bridge' => 'dot1dStpPortDesignatedBridge',
'qb_i_vlan_in_flt' => 'dot1qPortIngressFiltering', 'stp_p_port' => 'dot1dStpPortDesignatedPort',
# Q-BRIDGE-MIB : dot1qVlanCurrentTable
'qb_cv_egress' => 'dot1qVlanCurrentEgressPorts', # Q-BRIDGE-MIB : dot1qPortVlanTable
'qb_cv_untagged' => 'dot1qVlanCurrentUntaggedPorts', 'qb_i_vlan' => 'dot1qPvid',
'qb_cv_stat' => 'dot1qVlanStatus', 'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes',
# Q-BRIDGE-MIB : dot1qVlanStaticTable 'qb_i_vlan_in_flt' => 'dot1qPortIngressFiltering',
'v_name' => 'dot1qVlanStaticName',
'qb_v_egress' => 'dot1qVlanStaticEgressPorts', # Q-BRIDGE-MIB : dot1qVlanCurrentTable
'qb_v_fbdn_egress' => 'dot1qVlanForbiddenEgressPorts', 'qb_cv_egress' => 'dot1qVlanCurrentEgressPorts',
'qb_v_untagged' => 'dot1qVlanStaticUntaggedPorts', 'qb_cv_untagged' => 'dot1qVlanCurrentUntaggedPorts',
'qb_v_stat' => 'dot1qVlanStaticRowStatus', 'qb_cv_stat' => 'dot1qVlanStatus',
# VLAN Forwarding Table: Dot1qTpFdbEntry
'qb_fw_port' => 'dot1qTpFdbPort', # Q-BRIDGE-MIB : dot1qVlanStaticTable
'qb_fw_status' => 'dot1qTpFdbStatus', 'v_name' => 'dot1qVlanStaticName',
); 'qb_v_egress' => 'dot1qVlanStaticEgressPorts',
'qb_v_fbdn_egress' => 'dot1qVlanForbiddenEgressPorts',
'qb_v_untagged' => 'dot1qVlanStaticUntaggedPorts',
'qb_v_stat' => 'dot1qVlanStaticRowStatus',
# VLAN Forwarding Table: Dot1qTpFdbEntry
'qb_fw_port' => 'dot1qTpFdbPort',
'qb_fw_status' => 'dot1qTpFdbStatus',
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
# Add ones for our class
'b_mac' => \&SNMP::Info::munge_mac,
'fw_mac' => \&SNMP::Info::munge_mac,
'bs_mac' => \&SNMP::Info::munge_mac,
'stp_root' => \&SNMP::Info::munge_mac,
'stp_p_root' => \&SNMP::Info::munge_prio_mac,
'stp_p_bridge' => \&SNMP::Info::munge_prio_mac,
'stp_p_port' => \&SNMP::Info::munge_prio_mac,
'qb_cv_egress' => \&SNMP::Info::munge_port_list,
'qb_cv_untagged' => \&SNMP::Info::munge_port_list,
'qb_v_egress' => \&SNMP::Info::munge_port_list,
'qb_v_fbdn_egress' => \&SNMP::Info::munge_port_list,
'qb_v_untagged' => \&SNMP::Info::munge_port_list,
); # Inherit all the built in munging
%SNMP::Info::MUNGE,
# Add ones for our class
'b_mac' => \&SNMP::Info::munge_mac,
'fw_mac' => \&SNMP::Info::munge_mac,
'bs_mac' => \&SNMP::Info::munge_mac,
'stp_root' => \&SNMP::Info::munge_mac,
'stp_p_root' => \&SNMP::Info::munge_prio_mac,
'stp_p_bridge' => \&SNMP::Info::munge_prio_mac,
'stp_p_port' => \&SNMP::Info::munge_prio_mac,
'qb_cv_egress' => \&SNMP::Info::munge_port_list,
'qb_cv_untagged' => \&SNMP::Info::munge_port_list,
'qb_v_egress' => \&SNMP::Info::munge_port_list,
'qb_v_fbdn_egress' => \&SNMP::Info::munge_port_list,
'qb_v_untagged' => \&SNMP::Info::munge_port_list,
);
# break up the Dot1qTpFdbEntry INDEX into FDB ID and MAC Address. # break up the Dot1qTpFdbEntry INDEX into FDB ID and MAC Address.
sub _qb_fdbtable_index { sub _qb_fdbtable_index {
my $idx = shift; my $idx = shift;
my @values = split(/\./, $idx); my @values = split( /\./, $idx );
my $fdb_id = shift(@values); my $fdb_id = shift(@values);
return ($fdb_id, join(':',map { sprintf "%02x",$_ } @values)); return ( $fdb_id, join( ':', map { sprintf "%02x", $_ } @values ) );
} }
sub qb_fw_mac { sub qb_fw_mac {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $qb_fw_port = $bridge->qb_fw_port($partial); my $qb_fw_port = $bridge->qb_fw_port($partial);
my $qb_fw_mac = {}; my $qb_fw_mac = {};
foreach my $idx (keys %$qb_fw_port) { foreach my $idx ( keys %$qb_fw_port ) {
my($fdb_id, $mac) = _qb_fdbtable_index($idx); my ( $fdb_id, $mac ) = _qb_fdbtable_index($idx);
$qb_fw_mac->{$idx} = $mac; $qb_fw_mac->{$idx} = $mac;
} }
return $qb_fw_mac; return $qb_fw_mac;
} }
sub qb_i_vlan_t { sub qb_i_vlan_t {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $qb_i_vlan = $bridge->qb_i_vlan($partial); my $qb_i_vlan = $bridge->qb_i_vlan($partial);
@@ -151,8 +164,8 @@ sub qb_i_vlan_t {
my $i_vlan = {}; my $i_vlan = {};
foreach my $if (keys %$qb_i_vlan){ foreach my $if ( keys %$qb_i_vlan ) {
my $vlan = $qb_i_vlan->{$if}; my $vlan = $qb_i_vlan->{$if};
my $tagged = $qb_i_vlan_type->{$if} || ''; my $tagged = $qb_i_vlan_type->{$if} || '';
next unless defined $vlan; next unless defined $vlan;
$i_vlan->{$if} = $tagged eq 'admitOnlyVlanTagged' ? 'trunk' : $vlan; $i_vlan->{$if} = $tagged eq 'admitOnlyVlanTagged' ? 'trunk' : $vlan;
@@ -161,46 +174,46 @@ sub qb_i_vlan_t {
} }
sub i_stp_state { sub i_stp_state {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $bp_index = $bridge->bp_index($partial); my $bp_index = $bridge->bp_index($partial);
my $stp_p_state = $bridge->stp_p_state($partial); my $stp_p_state = $bridge->stp_p_state($partial);
my %i_stp_state; my %i_stp_state;
foreach my $index (keys %$stp_p_state){ foreach my $index ( keys %$stp_p_state ) {
my $state = $stp_p_state->{$index}; my $state = $stp_p_state->{$index};
my $iid = $bp_index->{$index}; my $iid = $bp_index->{$index};
next unless defined $iid; next unless defined $iid;
next unless defined $state; next unless defined $state;
$i_stp_state{$iid}=$state; $i_stp_state{$iid} = $state;
} }
return \%i_stp_state; return \%i_stp_state;
} }
sub i_stp_port { sub i_stp_port {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $bp_index = $bridge->bp_index($partial); my $bp_index = $bridge->bp_index($partial);
my $stp_p_port = $bridge->stp_p_port($partial); my $stp_p_port = $bridge->stp_p_port($partial);
my %i_stp_port; my %i_stp_port;
foreach my $index (keys %$stp_p_port){ foreach my $index ( keys %$stp_p_port ) {
my $bridge = $stp_p_port->{$index}; my $bridge = $stp_p_port->{$index};
my $iid = $bp_index->{$index}; my $iid = $bp_index->{$index};
next unless defined $iid; next unless defined $iid;
next unless defined $bridge; next unless defined $bridge;
$i_stp_port{$iid}=$bridge; $i_stp_port{$iid} = $bridge;
} }
return \%i_stp_port; return \%i_stp_port;
} }
sub i_stp_id { sub i_stp_id {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $bp_index = $bridge->bp_index($partial); my $bp_index = $bridge->bp_index($partial);
@@ -208,43 +221,43 @@ sub i_stp_id {
my %i_stp_id; my %i_stp_id;
foreach my $index (keys %$stp_p_id){ foreach my $index ( keys %$stp_p_id ) {
my $bridge = $stp_p_id->{$index}; my $bridge = $stp_p_id->{$index};
my $iid = $bp_index->{$index}; my $iid = $bp_index->{$index};
next unless defined $iid; next unless defined $iid;
next unless defined $bridge; next unless defined $bridge;
$i_stp_id{$iid}=$bridge; $i_stp_id{$iid} = $bridge;
} }
return \%i_stp_id; return \%i_stp_id;
} }
sub i_stp_bridge { sub i_stp_bridge {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $bp_index = $bridge->bp_index($partial); my $bp_index = $bridge->bp_index($partial);
my $stp_p_bridge = $bridge->stp_p_bridge($partial); my $stp_p_bridge = $bridge->stp_p_bridge($partial);
my %i_stp_bridge; my %i_stp_bridge;
foreach my $index (keys %$stp_p_bridge){ foreach my $index ( keys %$stp_p_bridge ) {
my $bridge = $stp_p_bridge->{$index}; my $bridge = $stp_p_bridge->{$index};
my $iid = $bp_index->{$index}; my $iid = $bp_index->{$index};
next unless defined $iid; next unless defined $iid;
next unless defined $bridge; next unless defined $bridge;
$i_stp_bridge{$iid}=$bridge; $i_stp_bridge{$iid} = $bridge;
} }
return \%i_stp_bridge; return \%i_stp_bridge;
} }
# Non-accessible, but needed for consistency with other classes # Non-accessible, but needed for consistency with other classes
sub v_index { sub v_index {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $v_name = $bridge->v_name($partial); my $v_name = $bridge->v_name($partial);
my %v_index; my %v_index;
foreach my $idx (keys %$v_name) { foreach my $idx ( keys %$v_name ) {
$v_index{$idx} = $idx; $v_index{$idx} = $idx;
} }
return \%v_index; return \%v_index;
@@ -254,7 +267,7 @@ sub i_vlan {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $index = $bridge->bp_index(); my $index = $bridge->bp_index();
# If given a partial it will be an ifIndex, we need to use dot1dBasePort # If given a partial it will be an ifIndex, we need to use dot1dBasePort
if ($partial) { if ($partial) {
@@ -262,13 +275,13 @@ sub i_vlan {
$partial = $r_index{$partial}; $partial = $r_index{$partial};
} }
my $i_pvid = $bridge->qb_i_vlan($partial) || {}; my $i_pvid = $bridge->qb_i_vlan($partial) || {};
my $i_vlan = {}; my $i_vlan = {};
foreach my $bport (keys %$i_pvid) { foreach my $bport ( keys %$i_pvid ) {
my $vlan = $i_pvid->{$bport}; my $vlan = $i_pvid->{$bport};
my $ifindex = $index->{$bport}; my $ifindex = $index->{$bport};
unless (defined $ifindex) { unless ( defined $ifindex ) {
print " Port $bport has no bp_index mapping. Skipping.\n" print " Port $bport has no bp_index mapping. Skipping.\n"
if $DEBUG; if $DEBUG;
next; next;
@@ -280,10 +293,10 @@ sub i_vlan {
} }
sub i_vlan_membership { sub i_vlan_membership {
my $bridge = shift; my $bridge = shift;
my $partial = shift; my $partial = shift;
my $index = $bridge->bp_index(); my $index = $bridge->bp_index();
# Use VlanCurrentTable if available since it will include dynamic # Use VlanCurrentTable if available since it will include dynamic
# VLANs. However, some devices do not populate the table. # VLANs. However, some devices do not populate the table.
@@ -294,29 +307,29 @@ sub i_vlan_membership {
# zero partial for no time filter. # zero partial for no time filter.
# my $v_ports = $bridge->qb_cv_egress() || $bridge->qb_v_egress(); # my $v_ports = $bridge->qb_cv_egress() || $bridge->qb_v_egress();
my $v_ports = $bridge->qb_v_egress() || {}; my $v_ports = $bridge->qb_v_egress() || {};
my $i_vlan_membership = {}; my $i_vlan_membership = {};
foreach my $idx (keys %$v_ports) { foreach my $idx ( keys %$v_ports ) {
next unless (defined $v_ports->{$idx}); next unless ( defined $v_ports->{$idx} );
my $portlist = $v_ports->{$idx}; my $portlist = $v_ports->{$idx};
my $ret = []; my $ret = [];
my $vlan; my $vlan;
# Strip TimeFilter if we're using VlanCurrentTable # Strip TimeFilter if we're using VlanCurrentTable
($vlan = $idx) =~ s/^\d+\.//; ( $vlan = $idx ) =~ s/^\d+\.//;
# Convert portlist bit array to bp_index array # Convert portlist bit array to bp_index array
for (my $i = 0; $i <= $#$portlist; $i++) { for ( my $i = 0; $i <= $#$portlist; $i++ ) {
push(@{$ret}, $i+1) if (@$portlist[$i]); push( @{$ret}, $i + 1 ) if ( @$portlist[$i] );
} }
#Create HoA ifIndex -> VLAN array #Create HoA ifIndex -> VLAN array
foreach my $port (@{$ret}) { foreach my $port ( @{$ret} ) {
my $ifindex = $index->{$port}; my $ifindex = $index->{$port};
next unless (defined($ifindex)); # shouldn't happen next unless ( defined($ifindex) ); # shouldn't happen
next if (defined $partial and $ifindex !~ /^$partial$/); next if ( defined $partial and $ifindex !~ /^$partial$/ );
push(@{$i_vlan_membership->{$ifindex}}, $vlan); push( @{ $i_vlan_membership->{$ifindex} }, $vlan );
} }
} }
return $i_vlan_membership; return $i_vlan_membership;
@@ -355,15 +368,19 @@ sub set_remove_i_vlan_tagged {
# #
sub _check_forbidden_ports { sub _check_forbidden_ports {
my $bridge = shift; my $bridge = shift;
my ($vlan_id, $index) = @_; my ( $vlan_id, $index ) = @_;
return unless ($vlan_id =~ /\d+/ and $index =~ /\d+/); return unless ( $vlan_id =~ /\d+/ and $index =~ /\d+/ );
my $iv_forbidden = $bridge->qb_v_fbdn_egress($vlan_id); my $iv_forbidden = $bridge->qb_v_fbdn_egress($vlan_id);
my $forbidden_ports = $iv_forbidden->{$vlan_id}; my $forbidden_ports = $iv_forbidden->{$vlan_id};
print "Forbidden ports: @$forbidden_ports\n" if $bridge->debug(); print "Forbidden ports: @$forbidden_ports\n" if $bridge->debug();
if ( defined(@$forbidden_ports[$index-1]) and (@$forbidden_ports[$index-1] eq "1")) { if ( defined( @$forbidden_ports[ $index - 1 ] )
print "Error: Index: $index in forbidden list for VLAN: $vlan_id unable to add.\n" if $bridge->debug(); and ( @$forbidden_ports[ $index - 1 ] eq "1" ) )
{
print
"Error: Index: $index in forbidden list for VLAN: $vlan_id unable to add.\n"
if $bridge->debug();
return; return;
} }
return 1; return 1;
@@ -371,11 +388,14 @@ sub _check_forbidden_ports {
sub _validate_vlan_param { sub _validate_vlan_param {
my $bridge = shift; my $bridge = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
# VID and ifIndex should both be numeric # VID and ifIndex should both be numeric
unless ( defined $vlan_id and defined $ifindex and unless (defined $vlan_id
$vlan_id =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { and defined $ifindex
and $vlan_id =~ /^\d+$/
and $ifindex =~ /^\d+$/ )
{
$bridge->error_throw("Invalid parameter."); $bridge->error_throw("Invalid parameter.");
return; return;
} }
@@ -389,21 +409,22 @@ sub _validate_vlan_param {
} }
#Check that VLAN exists on device #Check that VLAN exists on device
my $vtp_vlans = $bridge->load_qb_cv_stat() || $bridge->load_qb_v_stat(); my $vtp_vlans = $bridge->load_qb_cv_stat() || $bridge->load_qb_v_stat();
my $vlan_exists = 0; my $vlan_exists = 0;
foreach my $iid (keys %$vtp_vlans) { foreach my $iid ( keys %$vtp_vlans ) {
my $vlan = 0; my $vlan = 0;
my $state = $vtp_vlans->{$iid}; my $state = $vtp_vlans->{$iid};
next unless defined $state; next unless defined $state;
if ($iid =~ /(\d+)$/ ) { if ( $iid =~ /(\d+)$/ ) {
$vlan = $1; $vlan = $1;
} }
$vlan_exists = 1 if ( $vlan_id eq $vlan ); $vlan_exists = 1 if ( $vlan_id eq $vlan );
} }
unless ( $vlan_exists ) { unless ($vlan_exists) {
$bridge->error_throw("VLAN $vlan_id does not exist or is not operational."); $bridge->error_throw(
"VLAN $vlan_id does not exist or is not operational.");
return; return;
} }
@@ -457,8 +478,8 @@ Max Baker
F<BRIDGE-MIB> is used by most Layer 2 devices, and holds information like the F<BRIDGE-MIB> is used by most Layer 2 devices, and holds information like the
MAC Forwarding Table and Spanning Tree Protocol info. MAC Forwarding Table and Spanning Tree Protocol info.
F<Q-BRIDGE-MIB> holds 802.1q information -- VLANs and Trunking. Cisco tends not F<Q-BRIDGE-MIB> holds 802.1q information -- VLANs and Trunking. Cisco tends
to use this MIB, but some proprietary ones. HP and some nicer vendors use not to use this MIB, but some proprietary ones. HP and some nicer vendors use
this. This is from C<RFC2674_q>. this. This is from C<RFC2674_q>.
Create or use a subclass of SNMP::Info that inherits this class. Do not use Create or use a subclass of SNMP::Info that inherits this class. Do not use

View File

@@ -37,7 +37,7 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CDP::EXPORT_OK = qw//; @SNMP::Info::CDP::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/; use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
@@ -45,47 +45,47 @@ use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
$VERSION = '1.09'; $VERSION = '1.09';
# Five data structures required by SNMP::Info # Five data structures required by SNMP::Info
%MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' ); %MIBS = ( 'CISCO-CDP-MIB' => 'cdpGlobalRun' );
# Notice we dont inherit the default GLOBALS and FUNCS # Notice we dont inherit the default GLOBALS and FUNCS
# only the default MUNGE. # only the default MUNGE.
%GLOBALS = ( %GLOBALS = (
'cdp_run' => 'cdpGlobalRun', 'cdp_run' => 'cdpGlobalRun',
'cdp_interval' => 'cdpGlobalMessageInterval', 'cdp_interval' => 'cdpGlobalMessageInterval',
'cdp_holdtime' => 'cdpGlobalHoldTime', 'cdp_holdtime' => 'cdpGlobalHoldTime',
'cdp_id' => 'cdpGlobalDeviceId', 'cdp_id' => 'cdpGlobalDeviceId',
); );
%FUNCS = ( %FUNCS = (
'c_index' => 'cdpCacheIfIndex', 'c_index' => 'cdpCacheIfIndex',
'c_proto' => 'cdpCacheAddressType', 'c_proto' => 'cdpCacheAddressType',
'c_addr' => 'cdpCacheAddress', 'c_addr' => 'cdpCacheAddress',
'c_ver' => 'cdpCacheVersion', 'c_ver' => 'cdpCacheVersion',
'c_id' => 'cdpCacheDeviceId', 'c_id' => 'cdpCacheDeviceId',
'c_port' => 'cdpCacheDevicePort', 'c_port' => 'cdpCacheDevicePort',
'c_platform' => 'cdpCachePlatform', 'c_platform' => 'cdpCachePlatform',
'c_capabilities' => 'cdpCacheCapabilities', 'c_capabilities' => 'cdpCacheCapabilities',
'c_domain' => 'cdpCacheVTPMgmtDomain', 'c_domain' => 'cdpCacheVTPMgmtDomain',
'c_vlan' => 'cdpCacheNativeVLAN', 'c_vlan' => 'cdpCacheNativeVLAN',
'c_duplex' => 'cdpCacheDuplex', 'c_duplex' => 'cdpCacheDuplex',
'c_power' => 'cdpCachePowerConsumption', 'c_power' => 'cdpCachePowerConsumption',
); );
%MUNGE = ( %MUNGE = (
'c_capabilities' => \&SNMP::Info::munge_caps, 'c_capabilities' => \&SNMP::Info::munge_caps,
'c_platform' => \&SNMP::Info::munge_null, 'c_platform' => \&SNMP::Info::munge_null,
'c_domain' => \&SNMP::Info::munge_null, 'c_domain' => \&SNMP::Info::munge_null,
'c_port' => \&SNMP::Info::munge_null, 'c_port' => \&SNMP::Info::munge_null,
'c_id' => \&SNMP::Info::munge_null, 'c_id' => \&SNMP::Info::munge_null,
'c_ver' => \&SNMP::Info::munge_null, 'c_ver' => \&SNMP::Info::munge_null,
'c_ip' => \&SNMP::Info::munge_ip, 'c_ip' => \&SNMP::Info::munge_ip,
'c_power' => \&munge_power, 'c_power' => \&munge_power,
); );
sub munge_power { sub munge_power {
my $power = shift; my $power = shift;
my $decimal = substr($power, -3); my $decimal = substr( $power, -3 );
$power =~ s/$decimal$/\.$decimal/; $power =~ s/$decimal$/\.$decimal/;
return $power; return $power;
} }
@@ -95,12 +95,12 @@ sub hasCDP {
my $ver = $cdp->{_version}; my $ver = $cdp->{_version};
# SNMP v1 clients dont have the globals # SNMP v1 clients dont have the globals
if (defined $ver and $ver == 1){ if ( defined $ver and $ver == 1 ) {
my $c_ip = $cdp->c_ip(); my $c_ip = $cdp->c_ip();
# See if anything in cdp cache, if so we have cdp # See if anything in cdp cache, if so we have cdp
return 1 if (defined $c_ip and scalar(keys %$c_ip)) ; return 1 if ( defined $c_ip and scalar( keys %$c_ip ) );
return; return;
} }
@@ -108,46 +108,49 @@ sub hasCDP {
} }
sub c_if { sub c_if {
my $cdp = shift; my $cdp = shift;
# See if by some miracle Cisco implemented the cdpCacheIfIndex entry # See if by some miracle Cisco implemented the cdpCacheIfIndex entry
my $c_index = $cdp->c_index(); my $c_index = $cdp->c_index();
return $c_index if defined $c_index; return $c_index if defined $c_index;
# Nope, didn't think so. Now we fake it. # Nope, didn't think so. Now we fake it.
my $c_ip = $cdp->c_ip(); my $c_ip = $cdp->c_ip();
unless (defined $c_ip){ unless ( defined $c_ip ) {
$cdp->error_throw("SNMP::Info::CDP:c_if() - Device doesn't have cdp_ip() data. Can't fake cdp_index()"); $cdp->error_throw(
"SNMP::Info::CDP:c_if() - Device doesn't have cdp_ip() data. Can't fake cdp_index()"
);
return; return;
} }
my %c_if; my %c_if;
foreach my $key (keys %$c_ip){ foreach my $key ( keys %$c_ip ) {
next unless defined $key; next unless defined $key;
my $iid = $key; my $iid = $key;
# Truncate .1 from cdp cache entry
$iid =~ s/\.\d+$//; # Truncate .1 from cdp cache entry
$c_if{$key} = $iid; $iid =~ s/\.\d+$//;
$c_if{$key} = $iid;
} }
return \%c_if; return \%c_if;
} }
sub c_ip { sub c_ip {
my $cdp = shift; my $cdp = shift;
my $partial = shift; my $partial = shift;
my $c_addr = $cdp->c_addr($partial) || {}; my $c_addr = $cdp->c_addr($partial) || {};
my $c_proto = $cdp->c_proto($partial) || {}; my $c_proto = $cdp->c_proto($partial) || {};
my %c_ip; my %c_ip;
foreach my $key (keys %$c_addr) { foreach my $key ( keys %$c_addr ) {
my $addr = $c_addr->{$key}; my $addr = $c_addr->{$key};
my $proto = $c_proto->{$key}; my $proto = $c_proto->{$key};
next unless defined $addr; next unless defined $addr;
next if (defined $proto and $proto ne 'ip'); next if ( defined $proto and $proto ne 'ip' );
my $ip = join('.',unpack('C4',$addr)); my $ip = join( '.', unpack( 'C4', $addr ) );
$c_ip{$key} = $ip; $c_ip{$key} = $ip;
} }
return \%c_ip; return \%c_ip;

View File

@@ -42,43 +42,45 @@ use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
'CISCO-CONFIG-COPY-MIB' => 'ccCopyTable', 'CISCO-CONFIG-COPY-MIB' => 'ccCopyTable',
'CISCO-FLASH-MIB' => 'ciscoFlashCopyTable', 'CISCO-FLASH-MIB' => 'ciscoFlashCopyTable',
'OLD-CISCO-SYS-MIB' => 'writeMem', 'OLD-CISCO-SYS-MIB' => 'writeMem',
); );
%GLOBALS = ( %GLOBALS = (
# OLD-CISCO-SYS-MIB
'old_write_mem' => 'writeMem', # OLD-CISCO-SYS-MIB
'old_write_net' => 'writeNet', 'old_write_mem' => 'writeMem',
); 'old_write_net' => 'writeNet',
);
%FUNCS = ( %FUNCS = (
# CISCO-COPY-CONFIG-MIB::ccCopyTable
'config_protocol' => 'ccCopyProtocol',
'config_source_type' => 'ccCopySourceFileType',
'config_dest_type' => 'ccCopyDestFileType',
'config_server_addr' => 'ccCopyServerAddress',
'config_filename' => 'ccCopyFileName',
'config_username' => 'ccCopyUserName',
'config_password' => 'ccCopyUserPassword',
'config_notify_complete' => 'ccCopyNotificationOnCompletion',
'config_copy_state' => 'ccCopyState',
'config_copy_start_time' => 'ccCopyTimeStarted',
'config_copy_complete_time' => 'ccCopyTimeCompleted',
'config_fail_cause' => 'ccCopyFailCause',
'config_row_status' => 'ccCopyEntryRowStatus',
# CISCO-FLASH-MIB::ciscoFlashCopyTable
'flash_copy_cmd' => 'ciscoFlashCopyCommand',
'flash_copy_protocol' => 'ciscoFlashCopyProtocol',
'flash_copy_address' => 'ciscoFlashCopyServerAddress',
'flash_copy_source' => 'ciscoFlashCopySourceName',
'flash_copy_dest' => 'ciscoFlashCopyDestinationName',
'flash_copy_row_status' => 'ciscoFlashCopyEntryStatus',
);
%MUNGE = ( # CISCO-COPY-CONFIG-MIB::ccCopyTable
); 'config_protocol' => 'ccCopyProtocol',
'config_source_type' => 'ccCopySourceFileType',
'config_dest_type' => 'ccCopyDestFileType',
'config_server_addr' => 'ccCopyServerAddress',
'config_filename' => 'ccCopyFileName',
'config_username' => 'ccCopyUserName',
'config_password' => 'ccCopyUserPassword',
'config_notify_complete' => 'ccCopyNotificationOnCompletion',
'config_copy_state' => 'ccCopyState',
'config_copy_start_time' => 'ccCopyTimeStarted',
'config_copy_complete_time' => 'ccCopyTimeCompleted',
'config_fail_cause' => 'ccCopyFailCause',
'config_row_status' => 'ccCopyEntryRowStatus',
# CISCO-FLASH-MIB::ciscoFlashCopyTable
'flash_copy_cmd' => 'ciscoFlashCopyCommand',
'flash_copy_protocol' => 'ciscoFlashCopyProtocol',
'flash_copy_address' => 'ciscoFlashCopyServerAddress',
'flash_copy_source' => 'ciscoFlashCopySourceName',
'flash_copy_dest' => 'ciscoFlashCopyDestinationName',
'flash_copy_row_status' => 'ciscoFlashCopyEntryStatus',
);
%MUNGE = ();
sub copy_run_tftp { sub copy_run_tftp {
my $ciscoconfig = shift; my $ciscoconfig = shift;
@@ -87,58 +89,71 @@ sub copy_run_tftp {
srand( time() ^ ( $$ + ( $$ << 15 ) ) ); srand( time() ^ ( $$ + ( $$ << 15 ) ) );
my $rand = int( rand( 1 << 24 ) ); my $rand = int( rand( 1 << 24 ) );
print "Saving running config to $tftphost as $tftpfile\n" if $ciscoconfig->debug(); print "Saving running config to $tftphost as $tftpfile\n"
if $ciscoconfig->debug();
#Try new method first fall back to old method #Try new method first fall back to old method
if ( $ciscoconfig->set_config_protocol( 1, $rand ) ) { if ( $ciscoconfig->set_config_protocol( 1, $rand ) ) {
print "Using new method, row iid: $rand\n" if $ciscoconfig->debug(); print "Using new method, row iid: $rand\n" if $ciscoconfig->debug();
#Check each set, delete created row if any fail #Check each set, delete created row if any fail
unless ( $ciscoconfig->set_config_source_type( 4, $rand ) ) { unless ( $ciscoconfig->set_config_source_type( 4, $rand ) ) {
$ciscoconfig->error_throw("Setting source type failed"); $ciscoconfig->error_throw("Setting source type failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Setting source type failed and failed to delete row $rand"); $ciscoconfig->error_throw(
"Setting source type failed and failed to delete row $rand"
);
} }
return; return;
} }
unless ( $ciscoconfig->set_config_dest_type( 1, $rand ) ) { unless ( $ciscoconfig->set_config_dest_type( 1, $rand ) ) {
$ciscoconfig->error_throw("Setting destination type failed"); $ciscoconfig->error_throw("Setting destination type failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Setting dest type failed and failed to delete row $rand"); $ciscoconfig->error_throw(
"Setting dest type failed and failed to delete row $rand"
);
} }
return; return;
} }
unless ( $ciscoconfig->set_config_server_addr( $tftphost, $rand ) ) { unless ( $ciscoconfig->set_config_server_addr( $tftphost, $rand ) ) {
$ciscoconfig->error_throw("Setting tftp server failed"); $ciscoconfig->error_throw("Setting tftp server failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Setting tftp server failed and failed to delete row $rand"); $ciscoconfig->error_throw(
"Setting tftp server failed and failed to delete row $rand"
);
} }
return; return;
} }
unless ( $ciscoconfig->set_config_filename( $tftpfile, $rand ) ) { unless ( $ciscoconfig->set_config_filename( $tftpfile, $rand ) ) {
$ciscoconfig->error_throw("Setting file name failed"); $ciscoconfig->error_throw("Setting file name failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Setting file name failed and failed to delete row $rand"); $ciscoconfig->error_throw(
"Setting file name failed and failed to delete row $rand"
);
} }
return; return;
} }
unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) {
$ciscoconfig->error_throw("Initiating transfer failed"); $ciscoconfig->error_throw("Initiating transfer failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Initiating transfer failed and failed to delete row $rand"); $ciscoconfig->error_throw(
"Initiating transfer failed and failed to delete row $rand"
);
} }
return; return;
} }
my $status = 0; my $status = 0;
my $timer = 0; my $timer = 0;
# Hard-coded timeout of approximately 5 minutes, we can wrap this in an
# option later if needed # Hard-coded timeout of approximately 5 minutes, we can wrap this in an
# option later if needed
my $timeout = 300; my $timeout = 300;
while ( $status !~ /successful|failed/ ) { while ( $status !~ /successful|failed/ ) {
my $t = $ciscoconfig->config_copy_state($rand); my $t = $ciscoconfig->config_copy_state($rand);
$status = $t->{$rand}; $status = $t->{$rand};
last if $status =~ /successful|failed/; last if $status =~ /successful|failed/;
$timer += 1; $timer += 1;
if ($timer >= $timeout) { if ( $timer >= $timeout ) {
$status = 'failed'; $status = 'failed';
last; last;
} }
@@ -146,7 +161,7 @@ sub copy_run_tftp {
} }
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug(); print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug();
} }
if ( $status eq 'successful' ) { if ( $status eq 'successful' ) {
@@ -162,8 +177,8 @@ sub copy_run_tftp {
print "Using old method\n" if $ciscoconfig->debug(); print "Using old method\n" if $ciscoconfig->debug();
unless ( $ciscoconfig->set_old_write_net( $tftpfile, $tftphost ) ) { unless ( $ciscoconfig->set_old_write_net( $tftpfile, $tftphost ) ) {
$ciscoconfig->error_throw("Save operation failed"); $ciscoconfig->error_throw("Save operation failed");
return; return;
} }
return 1; return 1;
@@ -179,32 +194,37 @@ sub copy_run_start {
if ( $ciscoconfig->set_config_source_type( 4, $rand ) ) { if ( $ciscoconfig->set_config_source_type( 4, $rand ) ) {
print "Using new method, row iid: $rand\n" if $ciscoconfig->debug(); print "Using new method, row iid: $rand\n" if $ciscoconfig->debug();
#Check each set, delete created row if any fail #Check each set, delete created row if any fail
unless ( $ciscoconfig->set_config_dest_type( 3, $rand ) ) { unless ( $ciscoconfig->set_config_dest_type( 3, $rand ) ) {
$ciscoconfig->error_throw("Setting dest type failed"); $ciscoconfig->error_throw("Setting dest type failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Setting dest type failed and failed to delete row $rand"); $ciscoconfig->error_throw(
"Setting dest type failed and failed to delete row $rand"
);
} }
return; return;
} }
unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 1, $rand ) ) {
$ciscoconfig->error_throw("Initiating save failed"); $ciscoconfig->error_throw("Initiating save failed");
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
$ciscoconfig->error_throw("Initiating save failed and failed to delete row $rand"); $ciscoconfig->error_throw(
} "Initiating save failed and failed to delete row $rand");
}
return; return;
} }
my $status = 0; my $status = 0;
my $timer = 0; my $timer = 0;
# Hard-coded timeout of approximately 5 minutes, we can wrap this in an
# option later if needed # Hard-coded timeout of approximately 5 minutes, we can wrap this in an
# option later if needed
my $timeout = 300; my $timeout = 300;
while ( $status !~ /successful|failed/ ) { while ( $status !~ /successful|failed/ ) {
my $t = $ciscoconfig->config_copy_state($rand); my $t = $ciscoconfig->config_copy_state($rand);
$status = $t->{$rand}; $status = $t->{$rand};
last if $status =~ /successful|failed/; last if $status =~ /successful|failed/;
$timer += 1; $timer += 1;
if ($timer >= $timeout) { if ( $timer >= $timeout ) {
$status = 'failed'; $status = 'failed';
last; last;
} }
@@ -212,7 +232,7 @@ sub copy_run_start {
} }
unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) { unless ( $ciscoconfig->set_config_row_status( 6, $rand ) ) {
print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug(); print "Failed deleting row, iid $rand\n" if $ciscoconfig->debug();
} }
if ( $status eq 'successful' ) { if ( $status eq 'successful' ) {
@@ -227,9 +247,9 @@ sub copy_run_start {
} }
print "Using old method\n" if $ciscoconfig->debug(); print "Using old method\n" if $ciscoconfig->debug();
unless ( $ciscoconfig->set_old_write_mem( 1 ) ) { unless ( $ciscoconfig->set_old_write_mem(1) ) {
$ciscoconfig->error_throw("Save operation failed"); $ciscoconfig->error_throw("Save operation failed");
return; return;
} }
return 1; return 1;
@@ -408,9 +428,10 @@ Table of Flash copy operation entries.
=head1 SET METHODS =head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods or These are methods that provide SNMP set functionality for overridden methods
provide a simpler interface to complex set operations. See or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set operations. L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over =over
@@ -420,9 +441,9 @@ Store the running configuration on a TFTP server. Equivalent to the CLI
commands "copy running-config tftp" or "write net". commands "copy running-config tftp" or "write net".
This method attempts to use newer "copy running-config tftp" procedure first This method attempts to use newer "copy running-config tftp" procedure first
and then the older "write net" procedure if that fails. The newer procedure is and then the older "write net" procedure if that fails. The newer procedure
supported Cisco devices with the F<CISCO-CONFIG-COPY-MIB> available, Cisco IOS is supported Cisco devices with the F<CISCO-CONFIG-COPY-MIB> available, Cisco
software release 12.0 or on some devices as early as release 11.2P. The IOS software release 12.0 or on some devices as early as release 11.2P. The
older procedure has been depreciated by Cisco and is utilized only to support older procedure has been depreciated by Cisco and is utilized only to support
devices running older code revisions. devices running older code revisions.
@@ -436,11 +457,12 @@ Copy the running configuration to the start up configuration. Equivalent to
the CLI command C<"copy running-config startup-config"> or C<"write mem">. the CLI command C<"copy running-config startup-config"> or C<"write mem">.
This method attempts to use newer C<"copy running-config startup-config"> This method attempts to use newer C<"copy running-config startup-config">
procedure first and then the older C<"write mem"> procedure if that fails. The procedure first and then the older C<"write mem"> procedure if that fails.
newer procedure is supported Cisco devices with the F<CISCO-CONFIG-COPY-MIB> The newer procedure is supported Cisco devices with the
available, Cisco IOS software release 12.0 or on some devices as early as F<CISCO-CONFIG-COPY-MIB> available, Cisco IOS software release 12.0 or on
release 11.2P. The older procedure has been depreciated by Cisco and is some devices as early as release 11.2P. The older procedure has been
utilized only to support devices running older code revisions. depreciated by Cisco and is utilized only to support devices running older
code revisions.
Example: Example:
$ciscoconfig->copy_run_start() $ciscoconfig->copy_run_start()

View File

@@ -1,4 +1,3 @@
package SNMP::Info::CiscoImage;
# $Id$ # $Id$
# #
# Copyright (c) 2005 Matt Tuttle # Copyright (c) 2005 Matt Tuttle
@@ -28,30 +27,26 @@ package SNMP::Info::CiscoImage;
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CiscoImage;
use strict; use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoImage::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoImage::EXPORT_OK = qw//; @SNMP::Info::CiscoImage::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'CISCO-IMAGE-MIB' => 'ciscoImageString', );
'CISCO-IMAGE-MIB' => 'ciscoImageString',
);
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = ( 'ci_images' => 'ciscoImageString', );
'ci_images' => 'ciscoImageString',
);
%MUNGE = ( %MUNGE = ();
);
1; 1;
__END__ __END__
@@ -68,13 +63,13 @@ Matt Tuttle (C<mtuttle@americanhebrewacademy.org>)
# Let SNMP::Info determine the correct subclass for you. # Let SNMP::Info determine the correct subclass for you.
my $ci = new SNMP::Info( my $ci = new SNMP::Info(
AutoSpecify => 1, AutoSpecify => 1,
Debug => 1, Debug => 1,
# These arguments are passed directly on to SNMP::Session # These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch', DestHost => 'myswitch',
Community => 'public', Community => 'public',
Version => 2 Version => 2
) )
or die "Can't connect to DestHost.\n"; or die "Can't connect to DestHost.\n";
my $class = $ci->class(); my $class = $ci->class();

View File

@@ -33,85 +33,94 @@ package SNMP::Info::CiscoPortSecurity;
use strict; use strict;
use Exporter; use Exporter;
@SNMP::Info::CiscoPortSecurity::ISA = qw/Exporter/; @SNMP::Info::CiscoPortSecurity::ISA = qw/Exporter/;
@SNMP::Info::CiscoPortSecurity::EXPORT_OK = qw//; @SNMP::Info::CiscoPortSecurity::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PAECAPABILITIES/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PAECAPABILITIES/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB', 'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB',
'CISCO-PAE-MIB' => 'ciscoPaeMIB', 'CISCO-PAE-MIB' => 'ciscoPaeMIB',
'IEEE8021-PAE-MIB' => 'dot1xAuthLastEapolFrameSource', 'IEEE8021-PAE-MIB' => 'dot1xAuthLastEapolFrameSource',
); );
%GLOBALS = ( %GLOBALS = (
# CISCO-PORT-SECURITY-MIB
'cps_clear' => 'cpsGlobalClearSecureMacAddresses',
'cps_notify' => 'cpsGlobalSNMPNotifControl',
'cps_rate' => 'cpsGlobalSNMPNotifRate',
'cps_enable' => 'cpsGlobalPortSecurityEnable',
'cps_mac_count' => 'cpsGlobalTotalSecureAddress',
'cps_mac_max' => 'cpsGlobalMaxSecureAddress',
);
%FUNCS = ( # CISCO-PORT-SECURITY-MIB
# CISCO-PORT-SECURITY-MIB::cpsIfConfigTable 'cps_clear' => 'cpsGlobalClearSecureMacAddresses',
'cps_i_limit_val' => 'cpsIfInvalidSrcRateLimitValue', 'cps_notify' => 'cpsGlobalSNMPNotifControl',
'cps_i_limit' => 'cpsIfInvalidSrcRateLimitEnable', 'cps_rate' => 'cpsGlobalSNMPNotifRate',
'cps_i_sticky' => 'cpsIfStickyEnable', 'cps_enable' => 'cpsGlobalPortSecurityEnable',
'cps_i_clear_type' => 'cpsIfClearSecureMacAddresses', 'cps_mac_count' => 'cpsGlobalTotalSecureAddress',
'cps_i_shutdown' => 'cpsIfShutdownTimeout', 'cps_mac_max' => 'cpsGlobalMaxSecureAddress',
'cps_i_flood' => 'cpsIfUnicastFloodingEnable', );
'cps_i_clear' => 'cpsIfClearSecureAddresses',
'cps_i_mac' => 'cpsIfSecureLastMacAddress',
'cps_i_count' => 'cpsIfViolationCount',
'cps_i_action' => 'cpsIfViolationAction',
'cps_i_mac_static' => 'cpsIfStaticMacAddrAgingEnable',
'cps_i_mac_type' => 'cpsIfSecureMacAddrAgingType',
'cps_i_mac_age' => 'cpsIfSecureMacAddrAgingTime',
'cps_i_mac_count' => 'cpsIfCurrentSecureMacAddrCount',
'cps_i_mac_max' => 'cpsIfMaxSecureMacAddr',
'cps_i_status' => 'cpsIfPortSecurityStatus',
'cps_i_enable' => 'cpsIfPortSecurityEnable',
# CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
'cps_i_v_mac_count' => 'cpsIfVlanCurSecureMacAddrCount',
'cps_i_v_mac_max' => 'cpsIfVlanMaxSecureMacAddr',
'cps_i_v' => 'cpsIfVlanIndex',
# CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
'cps_i_v_mac_status' => 'cpsIfVlanSecureMacAddrRowStatus',
'cps_i_v_mac_age' => 'cpsIfVlanSecureMacAddrRemainAge',
'cps_i_v_mac_type' => 'cpsIfVlanSecureMacAddrType',
'cps_i_v_vlan' => 'cpsIfVlanSecureVlanIndex',
'cps_i_v_mac' => 'cpsIfVlanSecureMacAddress',
# CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
'cps_m_status' => 'cpsSecureMacAddrRowStatus',
'cps_m_age' => 'cpsSecureMacAddrRemainingAge',
'cps_m_type' => 'cpsSecureMacAddrType',
'cps_m_mac' => 'cpsSecureMacAddress',
# IEEE8021-PAE-MIB::dot1xPaePortEntry
'pae_i_capabilities' => 'dot1xPaePortCapabilities',
'pae_i_last_eapol_frame_source' => 'dot1xAuthLastEapolFrameSource',
);
%MUNGE = ( %FUNCS = (
'cps_i_mac' => \&SNMP::Info::munge_mac,
'cps_m_mac' => \&SNMP::Info::munge_mac,
'cps_i_v_mac' => \&SNMP::Info::munge_mac,
'pae_i_last_eapol_frame_source' => \&SNMP::Info::munge_mac,
'pae_i_capabilities' => \&munge_pae_capabilities,
);
%PAECAPABILITIES = (0 => 'dot1xPaePortAuthCapable', # CISCO-PORT-SECURITY-MIB::cpsIfConfigTable
1 => 'dot1xPaePortSuppCapable'); 'cps_i_limit_val' => 'cpsIfInvalidSrcRateLimitValue',
'cps_i_limit' => 'cpsIfInvalidSrcRateLimitEnable',
'cps_i_sticky' => 'cpsIfStickyEnable',
'cps_i_clear_type' => 'cpsIfClearSecureMacAddresses',
'cps_i_shutdown' => 'cpsIfShutdownTimeout',
'cps_i_flood' => 'cpsIfUnicastFloodingEnable',
'cps_i_clear' => 'cpsIfClearSecureAddresses',
'cps_i_mac' => 'cpsIfSecureLastMacAddress',
'cps_i_count' => 'cpsIfViolationCount',
'cps_i_action' => 'cpsIfViolationAction',
'cps_i_mac_static' => 'cpsIfStaticMacAddrAgingEnable',
'cps_i_mac_type' => 'cpsIfSecureMacAddrAgingType',
'cps_i_mac_age' => 'cpsIfSecureMacAddrAgingTime',
'cps_i_mac_count' => 'cpsIfCurrentSecureMacAddrCount',
'cps_i_mac_max' => 'cpsIfMaxSecureMacAddr',
'cps_i_status' => 'cpsIfPortSecurityStatus',
'cps_i_enable' => 'cpsIfPortSecurityEnable',
# CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
'cps_i_v_mac_count' => 'cpsIfVlanCurSecureMacAddrCount',
'cps_i_v_mac_max' => 'cpsIfVlanMaxSecureMacAddr',
'cps_i_v' => 'cpsIfVlanIndex',
# CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
'cps_i_v_mac_status' => 'cpsIfVlanSecureMacAddrRowStatus',
'cps_i_v_mac_age' => 'cpsIfVlanSecureMacAddrRemainAge',
'cps_i_v_mac_type' => 'cpsIfVlanSecureMacAddrType',
'cps_i_v_vlan' => 'cpsIfVlanSecureVlanIndex',
'cps_i_v_mac' => 'cpsIfVlanSecureMacAddress',
# CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
'cps_m_status' => 'cpsSecureMacAddrRowStatus',
'cps_m_age' => 'cpsSecureMacAddrRemainingAge',
'cps_m_type' => 'cpsSecureMacAddrType',
'cps_m_mac' => 'cpsSecureMacAddress',
# IEEE8021-PAE-MIB::dot1xPaePortEntry
'pae_i_capabilities' => 'dot1xPaePortCapabilities',
'pae_i_last_eapol_frame_source' => 'dot1xAuthLastEapolFrameSource',
);
%MUNGE = (
'cps_i_mac' => \&SNMP::Info::munge_mac,
'cps_m_mac' => \&SNMP::Info::munge_mac,
'cps_i_v_mac' => \&SNMP::Info::munge_mac,
'pae_i_last_eapol_frame_source' => \&SNMP::Info::munge_mac,
'pae_i_capabilities' => \&munge_pae_capabilities,
);
%PAECAPABILITIES = (
0 => 'dot1xPaePortAuthCapable',
1 => 'dot1xPaePortSuppCapable'
);
sub munge_pae_capabilities { sub munge_pae_capabilities {
my $bits = shift; my $bits = shift;
return unless defined $bits; return unless defined $bits;
my @vals = map($PAECAPABILITIES{$_},sprintf("%x",unpack('b*',$bits))); my @vals
return join(' ',@vals); = map( $PAECAPABILITIES{$_}, sprintf( "%x", unpack( 'b*', $bits ) ) );
return join( ' ', @vals );
} }
1; 1;

View File

@@ -34,41 +34,37 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoPower::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoPower::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoPower::EXPORT_OK = qw//; @SNMP::Info::CiscoPower::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ('CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex'); %MIBS = ( 'CISCO-POWER-ETHERNET-EXT-MIB' => 'cpeExtPsePortEntPhyIndex' );
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = ( 'cpeth_ent_phy' => 'cpeExtPsePortEntPhyIndex', );
'cpeth_ent_phy' => 'cpeExtPsePortEntPhyIndex',
);
%MUNGE = ( %MUNGE = ();
);
# Cisco overcame the limitation of the module.port index of the # Cisco overcame the limitation of the module.port index of the
# pethPsePortTable by adding another mapping table, which maps # pethPsePortTable by adding another mapping table, which maps
# a pethPsePortTable row to an entPhysicalTable index, which can # a pethPsePortTable row to an entPhysicalTable index, which can
# then be mapped to ifIndex. # then be mapped to ifIndex.
sub peth_port_ifindex { sub peth_port_ifindex {
my $cpeth = shift; my $cpeth = shift;
my $partial = shift; my $partial = shift;
my $ent_phy = $cpeth->cpeth_ent_phy($partial); my $ent_phy = $cpeth->cpeth_ent_phy($partial);
my $e_port = $cpeth->e_port(); my $e_port = $cpeth->e_port();
my $peth_port_ifindex = {}; my $peth_port_ifindex = {};
foreach my $i (keys %$ent_phy) { foreach my $i ( keys %$ent_phy ) {
if ($e_port->{$ent_phy->{$i}}) { if ( $e_port->{ $ent_phy->{$i} } ) {
$peth_port_ifindex->{$i} = $e_port->{$ent_phy->{$i}}; $peth_port_ifindex->{$i} = $e_port->{ $ent_phy->{$i} };
} }
} }
return $peth_port_ifindex; return $peth_port_ifindex;
} }
@@ -111,7 +107,8 @@ contains.
Create or use a device subclass that inherit this class. Do not use directly. Create or use a device subclass that inherit this class. Do not use directly.
For debugging purposes you can call this class directly as you would SNMP::Info For debugging purposes you can call this class directly as you would
SNMP::Info
my $poe = new SNMP::Info::CiscoPower (...); my $poe = new SNMP::Info::CiscoPower (...);

View File

@@ -34,43 +34,44 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoQOS::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoQOS::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoQOS::EXPORT_OK = qw//; @SNMP::Info::CiscoQOS::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex', );
'CISCO-CLASS-BASED-QOS-MIB' => 'cbQosIfIndex',
);
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = (
# CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable
'qos_i_index' => 'cbQosIfIndex',
'qos_i_type' => 'cbQosIfType',
'qos_pol_direction' => 'cbQosPolicyDirection',
# CISCO-CLASS-BASED-QOS-MIB::cbQosObjectsTable
'qos_obj_conf_index' => 'cbQosConfigIndex',
'qos_obj_type' => 'cbQosObjectsType',
'qos_obj_parent' => 'cbQosParentObjectsIndex',
# CISCO-CLASS-BASED-QOS-MIB::cbQosCMCfgTable
'qos_cm_name' => 'cbQosCMName',
'qos_cm_desc' => 'cbQosCMDesc',
'qos_cm_info' => 'cbQosCMInfo',
# CISCO-CLASS-BASED-QOS-MIB::cbQosCMStatsTable
'qos_octet_pre' => 'cbQosCMPrePolicyByte',
'qos_octet_post' => 'cbQosCMPostPolicyByte',
# CISCO-CLASS-BASED-QOS-MIB::cbQosQueueingCfgTable
'qos_queueingcfg_bw' => 'cbQosQueueingCfgBandwidth',
'qos_queueingcfg_bw_units' => 'cbQosQueueingCfgBandwidthUnits',
);
%MUNGE = ( # CISCO-CLASS-BASED-QOS-MIB::cbQosServicePolicyTable
); 'qos_i_index' => 'cbQosIfIndex',
'qos_i_type' => 'cbQosIfType',
'qos_pol_direction' => 'cbQosPolicyDirection',
# CISCO-CLASS-BASED-QOS-MIB::cbQosObjectsTable
'qos_obj_conf_index' => 'cbQosConfigIndex',
'qos_obj_type' => 'cbQosObjectsType',
'qos_obj_parent' => 'cbQosParentObjectsIndex',
# CISCO-CLASS-BASED-QOS-MIB::cbQosCMCfgTable
'qos_cm_name' => 'cbQosCMName',
'qos_cm_desc' => 'cbQosCMDesc',
'qos_cm_info' => 'cbQosCMInfo',
# CISCO-CLASS-BASED-QOS-MIB::cbQosCMStatsTable
'qos_octet_pre' => 'cbQosCMPrePolicyByte',
'qos_octet_post' => 'cbQosCMPostPolicyByte',
# CISCO-CLASS-BASED-QOS-MIB::cbQosQueueingCfgTable
'qos_queueingcfg_bw' => 'cbQosQueueingCfgBandwidth',
'qos_queueingcfg_bw_units' => 'cbQosQueueingCfgBandwidthUnits',
);
%MUNGE = ();
1; 1;
__END__ __END__

View File

@@ -34,28 +34,25 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoRTT::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoRTT::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoRTT::EXPORT_OK = qw//; @SNMP::Info::CiscoRTT::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner', );
'CISCO-RTTMON-MIB' => 'rttMonCtrlAdminOwner',
);
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = (
# CISCO-RTTMON-MIB
'rtt_desc' => 'rttMonCtrlAdminOwner',
'rtt_last' => 'rttMonLatestRttOperCompletionTime',
);
%MUNGE = ( # CISCO-RTTMON-MIB
); 'rtt_desc' => 'rttMonCtrlAdminOwner',
'rtt_last' => 'rttMonLatestRttOperCompletionTime',
);
%MUNGE = ();
1; 1;
__END__ __END__

View File

@@ -34,87 +34,91 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoStack::EXPORT_OK = qw//; @SNMP::Info::CiscoStack::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'CISCO-STACK-MIB' => 'ciscoStackMIB', );
'CISCO-STACK-MIB' => 'ciscoStackMIB',
);
%GLOBALS = ( %GLOBALS = (
'sysip' => 'sysIpAddr', 'sysip' => 'sysIpAddr',
'netmask' => 'sysNetMask', 'netmask' => 'sysNetMask',
'broadcast' => 'sysBroadcast', 'broadcast' => 'sysBroadcast',
'serial1' => 'chassisSerialNumber', 'serial1' => 'chassisSerialNumber',
'serial2' => 'chassisSerialNumberString', 'serial2' => 'chassisSerialNumberString',
'model1' => 'chassisModel', 'model1' => 'chassisModel',
'ps1_type' => 'chassisPs1Type', 'ps1_type' => 'chassisPs1Type',
'ps1_status' => 'chassisPs1Status', 'ps1_status' => 'chassisPs1Status',
'ps2_type' => 'chassisPs2Type', 'ps2_type' => 'chassisPs2Type',
'ps2_status' => 'chassisPs2Status', 'ps2_status' => 'chassisPs2Status',
'slots' => 'chassisNumSlots', 'slots' => 'chassisNumSlots',
'fan' => 'chassisFanStatus', 'fan' => 'chassisFanStatus',
); );
%FUNCS = ( %FUNCS = (
# CISCO-STACK-MIB::moduleEntry
# These are blades in a catalyst device
'm_type' => 'moduleType',
'm_model' => 'moduleModel',
'm_serial' => 'moduleSerialNumber',
'm_status' => 'moduleStatus',
'm_name' => 'moduleName',
'm_ports' => 'moduleNumPorts',
'm_ports_status' => 'modulePortStatus',
'm_hwver' => 'moduleHwVersion',
'm_fwver' => 'moduleFwVersion',
'm_swver' => 'moduleSwVersion',
# Router Blades :
'm_ip' => 'moduleIPAddress',
'm_sub1' => 'moduleSubType',
'm_sub2' => 'moduleSubType2',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
'p_rx_flow_control' => 'portOperRxFlowControl',
'p_tx_flow_control' => 'portOperTxFlowControl',
'p_rx_flow_control_admin' => 'portAdminRxFlowControl',
'p_tx_flow_control_admin' => 'portAdminTxFlowControl',
'p_oidx' => 'portCrossIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
);
%MUNGE = ( # CISCO-STACK-MIB::moduleEntry
'm_ports_status' => \&munge_port_status, # These are blades in a catalyst device
'p_duplex_admin' => \&SNMP::Info::munge_bits, 'm_type' => 'moduleType',
); 'm_model' => 'moduleModel',
'm_serial' => 'moduleSerialNumber',
'm_status' => 'moduleStatus',
'm_name' => 'moduleName',
'm_ports' => 'moduleNumPorts',
'm_ports_status' => 'modulePortStatus',
'm_hwver' => 'moduleHwVersion',
'm_fwver' => 'moduleFwVersion',
'm_swver' => 'moduleSwVersion',
%PORTSTAT = (1 => 'other', # Router Blades :
2 => 'ok', 'm_ip' => 'moduleIPAddress',
3 => 'minorFault', 'm_sub1' => 'moduleSubType',
4 => 'majorFault'); 'm_sub2' => 'moduleSubType2',
# CISCO-STACK-MIB::portEntry
'p_name' => 'portName',
'p_type' => 'portType',
'p_status' => 'portOperStatus',
'p_status2' => 'portAdditionalStatus',
'p_speed' => 'portAdminSpeed',
'p_duplex' => 'portDuplex',
'p_port' => 'portIfIndex',
'p_rx_flow_control' => 'portOperRxFlowControl',
'p_tx_flow_control' => 'portOperTxFlowControl',
'p_rx_flow_control_admin' => 'portAdminRxFlowControl',
'p_tx_flow_control_admin' => 'portAdminTxFlowControl',
'p_oidx' => 'portCrossIndex',
# CISCO-STACK-MIB::PortCpbEntry
'p_speed_admin' => 'portCpbSpeed',
'p_duplex_admin' => 'portCpbDuplex',
);
%MUNGE = (
'm_ports_status' => \&munge_port_status,
'p_duplex_admin' => \&SNMP::Info::munge_bits,
);
%PORTSTAT = (
1 => 'other',
2 => 'ok',
3 => 'minorFault',
4 => 'majorFault'
);
# Changes binary byte describing each port into ascii, and returns # Changes binary byte describing each port into ascii, and returns
# an ascii list separated by spaces. # an ascii list separated by spaces.
sub munge_port_status { sub munge_port_status {
my $status = shift; my $status = shift;
my @vals = map($PORTSTAT{$_},unpack('C*',$status)); my @vals = map( $PORTSTAT{$_}, unpack( 'C*', $status ) );
return join(' ',@vals); return join( ' ', @vals );
} }
sub serial { sub serial {
my $stack = shift; my $stack = shift;
my $serial1 = $stack->serial1(); my $serial1 = $stack->serial1();
my $serial2 = $stack->serial2(); my $serial2 = $stack->serial2();
@@ -141,24 +145,26 @@ sub serial {
# checked in the device class. # checked in the device class.
sub i_duplex { sub i_duplex {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $p_port = $stack->p_port() || {}; my $p_port = $stack->p_port() || {};
my $p_duplex = $stack->p_duplex() || {}; my $p_duplex = $stack->p_duplex() || {};
my $p_duplex_cap = $stack->p_duplex_admin() || {}; my $p_duplex_cap = $stack->p_duplex_admin() || {};
my $i_duplex = {}; my $i_duplex = {};
foreach my $port (keys %$p_duplex) { foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port}; my $iid = $p_port->{$port};
next unless defined $iid; next unless defined $iid;
next if (defined $partial and $iid !~ /^$partial$/); next if ( defined $partial and $iid !~ /^$partial$/ );
# Test for gigabit # Test for gigabit
if ($p_duplex_cap->{$port} == 0) { if ( $p_duplex_cap->{$port} == 0 ) {
$i_duplex->{$iid} = 'full'; $i_duplex->{$iid} = 'full';
} }
# Auto is not a valid operational state # Auto is not a valid operational state
elsif ($p_duplex->{$port} eq 'auto') { elsif ( $p_duplex->{$port} eq 'auto' ) {
next; next;
} }
else { else {
@@ -173,25 +179,27 @@ sub i_duplex {
# duplex will be auto, otherwise use portDuplex. # duplex will be auto, otherwise use portDuplex.
sub i_duplex_admin { sub i_duplex_admin {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $p_port = $stack->p_port() || {}; my $p_port = $stack->p_port() || {};
my $p_duplex = $stack->p_duplex() || {}; my $p_duplex = $stack->p_duplex() || {};
my $p_duplex_cap = $stack->p_duplex_admin() || {}; my $p_duplex_cap = $stack->p_duplex_admin() || {};
my $p_speed = $stack->p_speed() || {}; my $p_speed = $stack->p_speed() || {};
my $i_duplex_admin = {}; my $i_duplex_admin = {};
foreach my $port (keys %$p_duplex) { foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port}; my $iid = $p_port->{$port};
next unless defined $iid; next unless defined $iid;
next if (defined $partial and $iid !~ /^$partial$/); next if ( defined $partial and $iid !~ /^$partial$/ );
# Test for gigabit # Test for gigabit
if ($p_duplex_cap->{$port} == 0) { if ( $p_duplex_cap->{$port} == 0 ) {
$i_duplex_admin->{$iid} = 'full'; $i_duplex_admin->{$iid} = 'full';
} }
# Check admin speed for auto # Check admin speed for auto
elsif ($p_speed->{$port} =~ /auto/) { elsif ( $p_speed->{$port} =~ /auto/ ) {
$i_duplex_admin->{$iid} = 'auto'; $i_duplex_admin->{$iid} = 'auto';
} }
else { else {
@@ -202,34 +210,37 @@ sub i_duplex_admin {
} }
sub i_speed_admin { sub i_speed_admin {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my %i_speed_admin; my %i_speed_admin;
my $p_port = $stack->p_port(); my $p_port = $stack->p_port();
my %mapping = reverse %$p_port; my %mapping = reverse %$p_port;
my $p_speed = $stack->p_speed($mapping{$partial}); my $p_speed = $stack->p_speed( $mapping{$partial} );
my %speeds = ('autoDetect' => 'auto', my %speeds = (
'autoDetect10100' => 'auto', 'autoDetect' => 'auto',
's10000000' => '10 Mbps', 'autoDetect10100' => 'auto',
's100000000' => '100 Mbps', 's10000000' => '10 Mbps',
's1000000000' => '1.0 Gbps', 's100000000' => '100 Mbps',
's10G' => '10 Gbps', 's1000000000' => '1.0 Gbps',
); 's10G' => '10 Gbps',
);
%i_speed_admin = map { $p_port->{$_} => $speeds{$p_speed->{$_}} } keys %$p_port; %i_speed_admin
= map { $p_port->{$_} => $speeds{ $p_speed->{$_} } } keys %$p_port;
return \%i_speed_admin; return \%i_speed_admin;
} }
sub set_i_speed_admin { sub set_i_speed_admin {
# map speeds to those the switch will understand # map speeds to those the switch will understand
my %speeds = qw/auto 1 10 10000000 100 100000000 1000 1000000000/; my %speeds = qw/auto 1 10 10000000 100 100000000 1000 1000000000/;
my $stack = shift; my $stack = shift;
my ($speed, $iid) = @_; my ( $speed, $iid ) = @_;
my $p_port = $stack->p_port() || {}; my $p_port = $stack->p_port() || {};
my %reverse_p_port = reverse %$p_port; my %reverse_p_port = reverse %$p_port;
$speed = lc($speed); $speed = lc($speed);
@@ -238,24 +249,27 @@ sub set_i_speed_admin {
$iid = $reverse_p_port{$iid}; $iid = $reverse_p_port{$iid};
return $stack->set_p_speed ($speeds{$speed}, $iid); return $stack->set_p_speed( $speeds{$speed}, $iid );
} }
sub set_i_duplex_admin { sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands # map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/; my %duplexes = qw/half 1 full 2 auto 4/;
my $stack = shift; my $stack = shift;
my ($duplex, $iid) = @_; my ( $duplex, $iid ) = @_;
if ($duplex eq 'auto') { if ( $duplex eq 'auto' ) {
$stack->error_throw("Software doesn't support setting auto duplex with $stack->error_throw(
"Software doesn't support setting auto duplex with
set_i_duplex_admin() you must use set_i_duplex_admin() you must use
set_i_speed_admin() and set both speed and duplex set_i_speed_admin() and set both speed and duplex
to auto"); to auto"
);
return 0; return 0;
} }
my $p_port = $stack->p_port() || {}; my $p_port = $stack->p_port() || {};
my %reverse_p_port = reverse %$p_port; my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex); $duplex = lc($duplex);
@@ -264,7 +278,7 @@ sub set_i_duplex_admin {
$iid = $reverse_p_port{$iid}; $iid = $reverse_p_port{$iid};
return $stack->set_p_duplex($duplexes{$duplex}, $iid); return $stack->set_p_duplex( $duplexes{$duplex}, $iid );
} }
1; 1;
@@ -553,9 +567,9 @@ To see the status of port 4 :
Can be either C<on> C<off> or C<disagree> Can be either C<on> C<off> or C<disagree>
"Indicates the receive flow control operational status of the port. If the port "Indicates the receive flow control operational status of the port. If the
could not agree with the far end on a link protocol, its operational status port could not agree with the far end on a link protocol, its operational
will be disagree(3)." status will be disagree(3)."
C<portOperRxFlowControl> C<portOperRxFlowControl>
@@ -576,8 +590,8 @@ Can be either C<on> C<off> or C<desired>
"Indicates the receive flow control administrative status set on the port. If "Indicates the receive flow control administrative status set on the port. If
the status is set to on(1), the port will require the far end to send flow the status is set to on(1), the port will require the far end to send flow
control. If the status is set to off(2), the port will not allow far end to control. If the status is set to off(2), the port will not allow far end to
send flow control. If the status is set to desired(3), the port will allow the send flow control. If the status is set to desired(3), the port will allow
far end to send the flow control." the far end to send the flow control."
C<portAdminRxFlowControl> C<portAdminRxFlowControl>
@@ -585,11 +599,11 @@ C<portAdminRxFlowControl>
Can be either C<on> C<off> or C<desired> Can be either C<on> C<off> or C<desired>
"Indicates the transmit flow control administrative status set on the port. If "Indicates the transmit flow control administrative status set on the port.
the status is set to on(1), the port will send flow control to the far end. If If the status is set to on(1), the port will send flow control to the far end. If
the status is set to off(2), the port will not send flow control to the far the status is set to off(2), the port will not send flow control to the far
end. If the status is set to desired(3), the port will send flow control to the end. If the status is set to desired(3), the port will send flow control to
far end if the far end supports it." the far end if the far end supports it."
C<portAdminTxFlowControl> C<portAdminTxFlowControl>

View File

@@ -37,59 +37,65 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoStats::EXPORT_OK = qw//; @SNMP::Info::CiscoStats::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
'SNMPv2-MIB' => 'sysDescr', 'SNMPv2-MIB' => 'sysDescr',
'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec', 'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec',
'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed', 'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed',
'OLD-CISCO-SYSTEM-MIB' => 'writeMem', 'OLD-CISCO-SYSTEM-MIB' => 'writeMem',
'CISCO-PRODUCTS-MIB' => 'sysName', 'CISCO-PRODUCTS-MIB' => 'sysName',
# some older catalysts live here
'CISCO-STACK-MIB' => 'wsc1900sysID', # some older catalysts live here
'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis', 'CISCO-STACK-MIB' => 'wsc1900sysID',
'CISCO-FLASH-MIB' => 'ciscoFlashDeviceSize', 'CISCO-ENTITY-VENDORTYPE-OID-MIB' => 'cevChassis',
); 'CISCO-FLASH-MIB' => 'ciscoFlashDeviceSize',
);
%GLOBALS = ( %GLOBALS = (
'description' => 'sysDescr', 'description' => 'sysDescr',
# We will use the numeric OID's so that we don't require people
# to install v1 MIBs, which can conflict.
# OLD-CISCO-CPU-MIB:avgBusyPer
'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0',
'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0',
'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0',
# CISCO-PROCESS-MIB
'cat_cpu' => 'cpmCPUTotal5sec.9',
'cat_cpu_1min' => 'cpmCPUTotal1min.9',
'cat_cpu_5min' => 'cpmCPUTotal5min.9',
# OLD-CISCO-SYSTEM-MIB
'write_mem' => 'writeMem',
);
%FUNCS = ( # We will use the numeric OID's so that we don't require people
# CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolTable # to install v1 MIBs, which can conflict.
'cisco_mem_free' => 'ciscoMemoryPoolFree', # OLD-CISCO-CPU-MIB:avgBusyPer
'cisco_mem_used' => 'ciscoMemoryPoolUsed', 'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0',
# CISCO-FLASH-MIB::ciscoFlashDeviceTable 'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0',
'cisco_flash_size' => 'ciscoFlashDeviceSize', 'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0',
);
%MUNGE = ( # CISCO-PROCESS-MIB
); 'cat_cpu' => 'cpmCPUTotal5sec.9',
'cat_cpu_1min' => 'cpmCPUTotal1min.9',
'cat_cpu_5min' => 'cpmCPUTotal5min.9',
# OLD-CISCO-SYSTEM-MIB
'write_mem' => 'writeMem',
);
%FUNCS = (
# CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolTable
'cisco_mem_free' => 'ciscoMemoryPoolFree',
'cisco_mem_used' => 'ciscoMemoryPoolUsed',
# CISCO-FLASH-MIB::ciscoFlashDeviceTable
'cisco_flash_size' => 'ciscoFlashDeviceSize',
);
%MUNGE = ();
sub os { sub os {
my $l2 = shift; my $l2 = shift;
my $descr = $l2->description() || ''; my $descr = $l2->description() || '';
# order here matters - there are Catalysts that run IOS and have catalyst in their description field. # order here matters - there are Catalysts that run IOS and have catalyst
return 'ios' if ($descr =~ /IOS/); # in their description field.
return 'catalyst' if ($descr =~ /catalyst/i); return 'ios' if ( $descr =~ /IOS/ );
return 'catalyst' if ( $descr =~ /catalyst/i );
return; return;
} }
@@ -99,19 +105,25 @@ sub os_ver {
my $descr = $l2->description(); my $descr = $l2->description();
# Older Catalysts # Older Catalysts
if (defined $os and $os eq 'catalyst' and defined $descr and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/){ if ( defined $os
and $os eq 'catalyst'
and defined $descr
and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/ )
{
return $1; return $1;
} }
# Newer Catalysts and IOS devices # Newer Catalysts and IOS devices
if (defined $descr and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ ){ if ( defined $descr
and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ )
{
return $1; return $1;
} }
return; return;
} }
sub cpu { sub cpu {
my $self = shift; my $self = shift;
my $ios_cpu = $self->ios_cpu(); my $ios_cpu = $self->ios_cpu();
return $ios_cpu if defined $ios_cpu; return $ios_cpu if defined $ios_cpu;
my $cat_cpu = $self->cat_cpu(); my $cat_cpu = $self->cat_cpu();
@@ -119,7 +131,7 @@ sub cpu {
} }
sub cpu_1min { sub cpu_1min {
my $self = shift; my $self = shift;
my $ios_cpu_1min = $self->ios_cpu_1min(); my $ios_cpu_1min = $self->ios_cpu_1min();
return $ios_cpu_1min if defined $ios_cpu_1min; return $ios_cpu_1min if defined $ios_cpu_1min;
my $cat_cpu_1min = $self->cat_cpu_1min(); my $cat_cpu_1min = $self->cat_cpu_1min();
@@ -127,7 +139,7 @@ sub cpu_1min {
} }
sub cpu_5min { sub cpu_5min {
my $self = shift; my $self = shift;
my $ios_cpu_5min = $self->ios_cpu_5min(); my $ios_cpu_5min = $self->ios_cpu_5min();
return $ios_cpu_5min if defined $ios_cpu_5min; return $ios_cpu_5min if defined $ios_cpu_5min;
my $cat_cpu_5min = $self->cat_cpu_5min(); my $cat_cpu_5min = $self->cat_cpu_5min();
@@ -141,7 +153,7 @@ sub mem_free {
my $cisco_mem_free = $self->cisco_mem_free() || {}; my $cisco_mem_free = $self->cisco_mem_free() || {};
foreach my $mem_free_val (values %$cisco_mem_free) { foreach my $mem_free_val ( values %$cisco_mem_free ) {
$mem_free += $mem_free_val; $mem_free += $mem_free_val;
} }
@@ -155,7 +167,7 @@ sub mem_used {
my $cisco_mem_used = $self->cisco_mem_used() || {}; my $cisco_mem_used = $self->cisco_mem_used() || {};
foreach my $mem_used_val (values %$cisco_mem_used) { foreach my $mem_used_val ( values %$cisco_mem_used ) {
$mem_used += $mem_used_val; $mem_used += $mem_used_val;
} }
@@ -170,10 +182,10 @@ sub mem_total {
my $cisco_mem_free = $self->cisco_mem_free() || {}; my $cisco_mem_free = $self->cisco_mem_free() || {};
my $cisco_mem_used = $self->cisco_mem_used() || {}; my $cisco_mem_used = $self->cisco_mem_used() || {};
foreach my $mem_entry (keys %$cisco_mem_free){ foreach my $mem_entry ( keys %$cisco_mem_free ) {
my $mem_free = $cisco_mem_free->{$mem_entry} || 0; my $mem_free = $cisco_mem_free->{$mem_entry} || 0;
my $mem_used = $cisco_mem_used->{$mem_entry} || 0; my $mem_used = $cisco_mem_used->{$mem_entry} || 0;
$mem_total += ($mem_free + $mem_used); $mem_total += ( $mem_free + $mem_used );
} }
return $mem_total; return $mem_total;
} }
@@ -185,7 +197,7 @@ sub flashmem_total {
my $flash_sizes = $self->cisco_flash_size; my $flash_sizes = $self->cisco_flash_size;
foreach my $flash_index (keys %$flash_sizes) { foreach my $flash_index ( keys %$flash_sizes ) {
$flashmem_total += $flash_sizes->{$flash_index}; $flashmem_total += $flash_sizes->{$flash_index};
} }
@@ -197,7 +209,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco Devices SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco
Devices
=head1 AUTHOR =head1 AUTHOR
@@ -207,13 +220,13 @@ Max Baker
# Let SNMP::Info determine the correct subclass for you. # Let SNMP::Info determine the correct subclass for you.
my $ciscostats = new SNMP::Info( my $ciscostats = new SNMP::Info(
AutoSpecify => 1, AutoSpecify => 1,
Debug => 1, Debug => 1,
# These arguments are passed directly on to SNMP::Session # These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch', DestHost => 'myswitch',
Community => 'public', Community => 'public',
Version => 2 Version => 2
) )
or die "Can't connect to DestHost.\n"; or die "Can't connect to DestHost.\n";
my $class = $ciscostats->class(); my $class = $ciscostats->class();
@@ -221,8 +234,8 @@ Max Baker
=head1 DESCRIPTION =head1 DESCRIPTION
SNMP::Info::CiscoStats is a subclass of SNMP::Info that provides cpu, memory, os and SNMP::Info::CiscoStats is a subclass of SNMP::Info that provides cpu, memory,
version information about Cisco Devices. os and version information about Cisco Devices.
Use or create in a subclass of SNMP::Info. Do not use directly. Use or create in a subclass of SNMP::Info. Do not use directly.

View File

@@ -36,118 +36,125 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::CiscoVTP::EXPORT_OK = qw//; @SNMP::Info::CiscoVTP::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
'CISCO-VTP-MIB' => 'vtpVlanName', 'CISCO-VTP-MIB' => 'vtpVlanName',
'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry', 'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry',
'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex', 'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex',
); );
%GLOBALS = ( %GLOBALS = (
'vtp_version' => 'vtpVersion', 'vtp_version' => 'vtpVersion',
'vtp_maxstore' => 'vtpMaxVlanStorage', 'vtp_maxstore' => 'vtpMaxVlanStorage',
'vtp_notify' => 'vtpNotificationsEnabled', 'vtp_notify' => 'vtpNotificationsEnabled',
'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled', 'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled',
'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled', 'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled',
'vtp_trunk_set_serial' => 'vlanTrunkPortSetSerialNo', 'vtp_trunk_set_serial' => 'vlanTrunkPortSetSerialNo',
); );
%FUNCS = ( %FUNCS = (
# CISCO-VTP-MIB::managementDomainTable
'vtp_d_index' => 'managementDomainIndex',
'vtp_d_name' => 'managementDomainName',
'vtp_d_mode' => 'managementDomainLocalMode',
'vtp_d_rev' => 'managementDomainConfigRevNumber',
'vtp_d_updater' => 'managementDomainLastUpdater',
'vtp_d_last' => 'managementDomainLastChange',
'vtp_d_status' => 'managementDomainRowStatus',
'vtp_d_tftp' => 'managementDomainTftpServer',
'vtp_d_tftp_path' => 'managementDomainTftpPathname',
'vtp_d_pruning' => 'managementDomainPruningState',
'vtp_d_ver' => 'managementDomainVersionInUse',
# CISCO-VTP-MIB::vtpVlanTable
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
'v_said' => 'vtpVlanDot10Said',
'v_ring' => 'vtpVlanRingNumber',
'v_bridge' => 'vtpVlanBridgeNumber',
'v_stp' => 'vtpVlanStpType',
'v_parent' => 'vtpVlanParentVlan',
'v_trans1' => 'vtpVlanTranslationalVlan1',
'v_trans2' => 'vtpVlanTranslationalVlan2',
'v_btype' => 'vtpVlanBridgeType',
'v_hop_are' => 'vtpVlanAreHopCount',
'v_hop_ste' => 'vtpVlanSteHopCount',
'v_crf' => 'vtpVlanIsCRFBackup',
'v_type_ext' => 'vtpVlanTypeExt',
'v_if' => 'vtpVlanIfIndex',
# CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable
'i_vlan_type' => 'vmVlanType',
'i_vlan2' => 'vmVlan',
'i_vlan_stat' => 'vmPortStatus',
'i_vlan_1' => 'vmVlans',
'i_vlan_2' => 'vmVlans2k',
'i_vlan_3' => 'vmVlans3k',
'i_vlan_4' => 'vmVlans4k',
# CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable
'i_voice_vlan' => 'vmVoiceVlanId',
# CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB
'v_cvi_if' => 'cviRoutedVlanIfIndex',
# CISCO-VTP-MIB::vlanTrunkPortTable
'vtp_trunk_mgmt_dom' => 'vlanTrunkPortManagementDomain',
'vtp_trunk_encaps_t' => 'vlanTrunkPortEncapsulationType',
'vtp_trunk_vlans' => 'vlanTrunkPortVlansEnabled',
'vtp_trunk_vlans_2k' => 'vlanTrunkPortVlansEnabled2k',
'vtp_trunk_vlans_3k' => 'vlanTrunkPortVlansEnabled3k',
'vtp_trunk_vlans_4k' => 'vlanTrunkPortVlansEnabled4k',
'vtp_trunk_native' => 'vlanTrunkPortNativeVlan',
'i_pvid' => 'vlanTrunkPortNativeVlan',
'vtp_trunk_rstat' => 'vlanTrunkPortRowStatus',
'vtp_trunk_dyn' => 'vlanTrunkPortDynamicState',
'vtp_trunk_dyn_stat' => 'vlanTrunkPortDynamicStatus',
'vtp_trunk_vtp' => 'vlanTrunkPortVtpEnabled',
'vtp_trunk_encaps' => 'vlanTrunkPortEncapsulationOperType',
# TODO Add these tables if someone wants them..
# vtpEditControlTable
# vtpVlanEditTable
# vtpStatsTable
);
%MUNGE = ( # CISCO-VTP-MIB::managementDomainTable
); 'vtp_d_index' => 'managementDomainIndex',
'vtp_d_name' => 'managementDomainName',
'vtp_d_mode' => 'managementDomainLocalMode',
'vtp_d_rev' => 'managementDomainConfigRevNumber',
'vtp_d_updater' => 'managementDomainLastUpdater',
'vtp_d_last' => 'managementDomainLastChange',
'vtp_d_status' => 'managementDomainRowStatus',
'vtp_d_tftp' => 'managementDomainTftpServer',
'vtp_d_tftp_path' => 'managementDomainTftpPathname',
'vtp_d_pruning' => 'managementDomainPruningState',
'vtp_d_ver' => 'managementDomainVersionInUse',
# CISCO-VTP-MIB::vtpVlanTable
'v_state' => 'vtpVlanState',
'v_type' => 'vtpVlanType',
'v_name' => 'vtpVlanName',
'v_mtu' => 'vtpVlanMtu',
'v_said' => 'vtpVlanDot10Said',
'v_ring' => 'vtpVlanRingNumber',
'v_bridge' => 'vtpVlanBridgeNumber',
'v_stp' => 'vtpVlanStpType',
'v_parent' => 'vtpVlanParentVlan',
'v_trans1' => 'vtpVlanTranslationalVlan1',
'v_trans2' => 'vtpVlanTranslationalVlan2',
'v_btype' => 'vtpVlanBridgeType',
'v_hop_are' => 'vtpVlanAreHopCount',
'v_hop_ste' => 'vtpVlanSteHopCount',
'v_crf' => 'vtpVlanIsCRFBackup',
'v_type_ext' => 'vtpVlanTypeExt',
'v_if' => 'vtpVlanIfIndex',
# CISCO-VLAN-MEMBERSHIP-MIB::vmMembershipTable
'i_vlan_type' => 'vmVlanType',
'i_vlan2' => 'vmVlan',
'i_vlan_stat' => 'vmPortStatus',
'i_vlan_1' => 'vmVlans',
'i_vlan_2' => 'vmVlans2k',
'i_vlan_3' => 'vmVlans3k',
'i_vlan_4' => 'vmVlans4k',
# CISCO-VLAN-MEMBERSHIP-MIB::vmVoiceVlanTable
'i_voice_vlan' => 'vmVoiceVlanId',
# CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB
'v_cvi_if' => 'cviRoutedVlanIfIndex',
# CISCO-VTP-MIB::vlanTrunkPortTable
'vtp_trunk_mgmt_dom' => 'vlanTrunkPortManagementDomain',
'vtp_trunk_encaps_t' => 'vlanTrunkPortEncapsulationType',
'vtp_trunk_vlans' => 'vlanTrunkPortVlansEnabled',
'vtp_trunk_vlans_2k' => 'vlanTrunkPortVlansEnabled2k',
'vtp_trunk_vlans_3k' => 'vlanTrunkPortVlansEnabled3k',
'vtp_trunk_vlans_4k' => 'vlanTrunkPortVlansEnabled4k',
'vtp_trunk_native' => 'vlanTrunkPortNativeVlan',
'i_pvid' => 'vlanTrunkPortNativeVlan',
'vtp_trunk_rstat' => 'vlanTrunkPortRowStatus',
'vtp_trunk_dyn' => 'vlanTrunkPortDynamicState',
'vtp_trunk_dyn_stat' => 'vlanTrunkPortDynamicStatus',
'vtp_trunk_vtp' => 'vlanTrunkPortVtpEnabled',
'vtp_trunk_encaps' => 'vlanTrunkPortEncapsulationOperType',
# TODO Add these tables if someone wants them..
# vtpEditControlTable
# vtpVlanEditTable
# vtpStatsTable
);
%MUNGE = ();
sub v_index { sub v_index {
my $vtp = shift; my $vtp = shift;
my $partial = shift; my $partial = shift;
my $v_name = $vtp->v_name($partial); my $v_name = $vtp->v_name($partial);
my %v_index; my %v_index;
foreach my $idx (keys %$v_name) { foreach my $idx ( keys %$v_name ) {
my ($mgmtdomain, $vlan) = split(/\./, $idx); my ( $mgmtdomain, $vlan ) = split( /\./, $idx );
$v_index{$idx} = $vlan; $v_index{$idx} = $vlan;
} }
return \%v_index; return \%v_index;
} }
sub i_vlan { sub i_vlan {
my $vtp = shift; my $vtp = shift;
my $partial = shift; my $partial = shift;
my $port_vlan = $vtp->vtp_trunk_native($partial) || {}; my $port_vlan = $vtp->vtp_trunk_native($partial) || {};
my $i_vlan = $vtp->i_vlan2($partial) || {}; my $i_vlan = $vtp->i_vlan2($partial) || {};
my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {}; my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {};
my %i_vlans; my %i_vlans;
# Get access ports # Get access ports
foreach my $port (keys %$i_vlan) { foreach my $port ( keys %$i_vlan ) {
my $vlan = $i_vlan->{$port}; my $vlan = $i_vlan->{$port};
next unless defined $vlan; next unless defined $vlan;
@@ -155,7 +162,7 @@ sub i_vlan {
} }
# Get trunk ports # Get trunk ports
foreach my $port (keys %$port_vlan) { foreach my $port ( keys %$port_vlan ) {
my $vlan = $port_vlan->{$port}; my $vlan = $port_vlan->{$port};
next unless defined $vlan; next unless defined $vlan;
my $stat = $trunk_dyn_stat->{$port}; my $stat = $trunk_dyn_stat->{$port};
@@ -173,8 +180,8 @@ sub i_vlan {
# Translate vlan.physical_interface -> iid # Translate vlan.physical_interface -> iid
# to iid -> vlan # to iid -> vlan
foreach my $i (keys %$v_cvi_if){ foreach my $i ( keys %$v_cvi_if ) {
my ($vlan,$phys) = split(/\./,$i); my ( $vlan, $phys ) = split( /\./, $i );
my $iid = $v_cvi_if->{$i}; my $iid = $v_cvi_if->{$i};
$i_vlans{$iid} = $vlan; $i_vlans{$iid} = $vlan;
@@ -185,59 +192,60 @@ sub i_vlan {
} }
sub i_vlan_membership { sub i_vlan_membership {
my $vtp = shift; my $vtp = shift;
my $partial = shift; my $partial = shift;
my $ports_vlans = $vtp->vtp_trunk_vlans($partial) || {}; my $ports_vlans = $vtp->vtp_trunk_vlans($partial) || {};
my $ports_vlans_2k = $vtp->vtp_trunk_vlans_2k($partial) || {}; my $ports_vlans_2k = $vtp->vtp_trunk_vlans_2k($partial) || {};
my $ports_vlans_3k = $vtp->vtp_trunk_vlans_3k($partial) || {}; my $ports_vlans_3k = $vtp->vtp_trunk_vlans_3k($partial) || {};
my $ports_vlans_4k = $vtp->vtp_trunk_vlans_4k($partial) || {}; my $ports_vlans_4k = $vtp->vtp_trunk_vlans_4k($partial) || {};
my $vtp_vlans = $vtp->v_state(); my $vtp_vlans = $vtp->v_state();
my $i_vlan = $vtp->i_vlan2($partial) || {}; my $i_vlan = $vtp->i_vlan2($partial) || {};
my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {}; my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {};
my $i_vlan_membership = {}; my $i_vlan_membership = {};
# Get access ports # Get access ports
foreach my $port (keys %$i_vlan) { foreach my $port ( keys %$i_vlan ) {
my $vlan = $i_vlan->{$port}; my $vlan = $i_vlan->{$port};
next unless defined $vlan; next unless defined $vlan;
my $stat = $trunk_dyn_stat->{$port}; my $stat = $trunk_dyn_stat->{$port};
if ( defined $stat and $stat =~ /notTrunking/ ) { if ( defined $stat and $stat =~ /notTrunking/ ) {
push(@{$i_vlan_membership->{$port}}, $vlan); push( @{ $i_vlan_membership->{$port} }, $vlan );
} }
} }
# Get trunk ports # Get trunk ports
my %oper_vlans; my %oper_vlans;
foreach my $iid (keys %$vtp_vlans) { foreach my $iid ( keys %$vtp_vlans ) {
my $vlan = 0; my $vlan = 0;
my $vtp_dom =0; my $vtp_dom = 0;
my $state = $vtp_vlans->{$iid}; my $state = $vtp_vlans->{$iid};
next unless defined $state; next unless defined $state;
next if $state !~ /operational/; next if $state !~ /operational/;
if ($iid =~ /(\d+)\.(\d+)/ ) { if ( $iid =~ /(\d+)\.(\d+)/ ) {
$vtp_dom = $1; $vtp_dom = $1;
$vlan = $2; $vlan = $2;
} }
$oper_vlans{$vlan}++; $oper_vlans{$vlan}++;
} }
foreach my $port (keys %$ports_vlans) { foreach my $port ( keys %$ports_vlans ) {
my $stat = $trunk_dyn_stat->{$port}; my $stat = $trunk_dyn_stat->{$port};
if ( defined $stat and $stat =~ /^trunking/ ) { if ( defined $stat and $stat =~ /^trunking/ ) {
my $k = 0; my $k = 0;
my $list1 = $ports_vlans->{$port} || '0'; my $list1 = $ports_vlans->{$port} || '0';
my $list2 = $ports_vlans_2k->{$port} || '0'; my $list2 = $ports_vlans_2k->{$port} || '0';
my $list3 = $ports_vlans_3k->{$port} || '0'; my $list3 = $ports_vlans_3k->{$port} || '0';
my $list4 = $ports_vlans_4k->{$port} || '0'; my $list4 = $ports_vlans_4k->{$port} || '0';
foreach my $list ("$list1", "$list2", "$list3", "$list4") { foreach my $list ( "$list1", "$list2", "$list3", "$list4" ) {
my $offset = 1024 * $k++; my $offset = 1024 * $k++;
next unless $list; next unless $list;
my $vlanlist = [split(//, unpack("B*", $list))]; my $vlanlist = [ split( //, unpack( "B*", $list ) ) ];
foreach my $vlan (keys %oper_vlans) { foreach my $vlan ( keys %oper_vlans ) {
push(@{$i_vlan_membership->{$port}}, $vlan) if (@$vlanlist[$vlan-$offset]); push( @{ $i_vlan_membership->{$port} }, $vlan )
if ( @$vlanlist[ $vlan - $offset ] );
} }
} }
} }
@@ -248,18 +256,22 @@ sub i_vlan_membership {
sub set_i_pvid { sub set_i_pvid {
my $vtp = shift; my $vtp = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
my $native_vlan = $vtp->vtp_trunk_native($ifindex); my $native_vlan = $vtp->vtp_trunk_native($ifindex);
if (defined $native_vlan) { if ( defined $native_vlan ) {
print "Changing native VLAN from $native_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n" if $vtp->debug(); print
"Changing native VLAN from $native_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n"
if $vtp->debug();
my $rv = $vtp->set_vtp_trunk_native($vlan_id, $ifindex); my $rv = $vtp->set_vtp_trunk_native( $vlan_id, $ifindex );
unless ($rv) { unless ($rv) {
$vtp->error_throw("Unable to change native VLAN to $vlan_id on IfIndex: $ifindex"); $vtp->error_throw(
"Unable to change native VLAN to $vlan_id on IfIndex: $ifindex"
);
return; return;
} }
return $rv; return $rv;
@@ -270,18 +282,21 @@ sub set_i_pvid {
sub set_i_vlan { sub set_i_vlan {
my $vtp = shift; my $vtp = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
my $i_vlan = $vtp->i_vlan2($ifindex); my $i_vlan = $vtp->i_vlan2($ifindex);
if (defined $i_vlan) { if ( defined $i_vlan ) {
print "Changing VLAN from $i_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n" if $vtp->debug(); print
"Changing VLAN from $i_vlan->{$ifindex} to $vlan_id on IfIndex: $ifindex\n"
if $vtp->debug();
my $rv = $vtp->set_i_vlan2($vlan_id, $ifindex); my $rv = $vtp->set_i_vlan2( $vlan_id, $ifindex );
unless ($rv) { unless ($rv) {
$vtp->error_throw("Unable to change VLAN to $vlan_id on IfIndex: $ifindex"); $vtp->error_throw(
"Unable to change VLAN to $vlan_id on IfIndex: $ifindex");
return; return;
} }
return $rv; return $rv;
@@ -292,36 +307,44 @@ sub set_i_vlan {
sub set_add_i_vlan_tagged { sub set_add_i_vlan_tagged {
my $vtp = shift; my $vtp = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
print "Adding VLAN: $vlan_id to ifIndex: $ifindex\n" if $vtp->debug(); print "Adding VLAN: $vlan_id to ifIndex: $ifindex\n" if $vtp->debug();
my $trunk_serial = $vtp->load_vtp_trunk_set_serial(); my $trunk_serial = $vtp->load_vtp_trunk_set_serial();
my $trunk_members = $vtp->vtp_trunk_vlans($ifindex); my $trunk_members = $vtp->vtp_trunk_vlans($ifindex);
unless (defined $trunk_members) { unless ( defined $trunk_members ) {
$vtp->error_throw("Can't find ifIndex: $ifindex - Is it a trunk port?"); $vtp->error_throw(
"Can't find ifIndex: $ifindex - Is it a trunk port?");
return; return;
} }
my @member_list = split(//, unpack("B*", $trunk_members->{$ifindex})); my @member_list = split( //, unpack( "B*", $trunk_members->{$ifindex} ) );
print "Original vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); print "Original vlan list for ifIndex: $ifindex: @member_list \n"
if $vtp->debug();
$member_list[$vlan_id] = '1'; $member_list[$vlan_id] = '1';
print "Modified vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); print "Modified vlan list for ifIndex: $ifindex: @member_list \n"
my $new_list = pack("B*", join('', @member_list)); if $vtp->debug();
my $new_list = pack( "B*", join( '', @member_list ) );
#Add VLAN to member list #Add VLAN to member list
my $list_rv = $vtp->set_vtp_trunk_vlans($new_list, $ifindex); my $list_rv = $vtp->set_vtp_trunk_vlans( $new_list, $ifindex );
unless ($list_rv) { unless ($list_rv) {
$vtp->error_throw("Unable to add VLAN: $vlan_id to ifIndex: $ifindex member list"); $vtp->error_throw(
"Unable to add VLAN: $vlan_id to ifIndex: $ifindex member list");
return; return;
} }
#Make sure no other SNMP manager was making modifications at the same time.
#Make sure no other SNMP manager was making modifications at the same time.
my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial); my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial);
unless ($serial_rv) { unless ($serial_rv) {
$vtp->error_throw("Unable to increment trunk set serial number - check configuration!"); $vtp->error_throw(
"Unable to increment trunk set serial number - check configuration!"
);
return; return;
} }
return 1; return 1;
@@ -329,36 +352,45 @@ sub set_add_i_vlan_tagged {
sub set_remove_i_vlan_tagged { sub set_remove_i_vlan_tagged {
my $vtp = shift; my $vtp = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $vtp->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $vtp->_validate_vlan_param( $vlan_id, $ifindex ) );
print "Removing VLAN: $vlan_id from ifIndex: $ifindex\n" if $vtp->debug(); print "Removing VLAN: $vlan_id from ifIndex: $ifindex\n" if $vtp->debug();
my $trunk_serial = $vtp->load_vtp_trunk_set_serial(); my $trunk_serial = $vtp->load_vtp_trunk_set_serial();
my $trunk_members = $vtp->vtp_trunk_vlans($ifindex); my $trunk_members = $vtp->vtp_trunk_vlans($ifindex);
unless (defined $trunk_members) { unless ( defined $trunk_members ) {
$vtp->error_throw("Can't find ifIndex: $ifindex - Is it a trunk port?"); $vtp->error_throw(
"Can't find ifIndex: $ifindex - Is it a trunk port?");
return; return;
} }
my @member_list = split(//, unpack("B*", $trunk_members->{$ifindex})); my @member_list = split( //, unpack( "B*", $trunk_members->{$ifindex} ) );
print "Original vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); print "Original vlan list for ifIndex: $ifindex: @member_list \n"
if $vtp->debug();
$member_list[$vlan_id] = '0'; $member_list[$vlan_id] = '0';
print "Modified vlan list for ifIndex: $ifindex: @member_list \n" if $vtp->debug(); print "Modified vlan list for ifIndex: $ifindex: @member_list \n"
my $new_list = pack("B*", join('', @member_list)); if $vtp->debug();
my $new_list = pack( "B*", join( '', @member_list ) );
#Remove VLAN to member list #Remove VLAN to member list
my $list_rv = $vtp->set_vtp_trunk_vlans($new_list, $ifindex); my $list_rv = $vtp->set_vtp_trunk_vlans( $new_list, $ifindex );
unless ($list_rv) { unless ($list_rv) {
$vtp->error_throw("Error: Unable to remove VLAN: $vlan_id from ifIndex: $ifindex member list"); $vtp->error_throw(
"Error: Unable to remove VLAN: $vlan_id from ifIndex: $ifindex member list"
);
return; return;
} }
#Make sure no other manager was making modifications at the same time. #Make sure no other manager was making modifications at the same time.
my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial); my $serial_rv = $vtp->set_vtp_trunk_set_serial($trunk_serial);
unless ($serial_rv) { unless ($serial_rv) {
$vtp->error_throw("Error: Unable to increment trunk set serial number - check configuration!"); $vtp->error_throw(
"Error: Unable to increment trunk set serial number - check configuration!"
);
return; return;
} }
return 1; return 1;
@@ -369,10 +401,14 @@ sub set_remove_i_vlan_tagged {
# #
sub _validate_vlan_param { sub _validate_vlan_param {
my $vtp = shift; my $vtp = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
# VID and ifIndex should both be numeric # VID and ifIndex should both be numeric
unless ( defined $vlan_id and defined $ifindex and $vlan_id =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { unless (defined $vlan_id
and defined $ifindex
and $vlan_id =~ /^\d+$/
and $ifindex =~ /^\d+$/ )
{
$vtp->error_throw("Invalid parameter"); $vtp->error_throw("Invalid parameter");
return; return;
} }
@@ -389,21 +425,22 @@ sub _validate_vlan_param {
my $vtp_vlans = $vtp->v_state(); my $vtp_vlans = $vtp->v_state();
my $vlan_exists = 0; my $vlan_exists = 0;
foreach my $iid (keys %$vtp_vlans) { foreach my $iid ( keys %$vtp_vlans ) {
my $vlan = 0; my $vlan = 0;
my $vtp_dom =0; my $vtp_dom = 0;
my $state = $vtp_vlans->{$iid}; my $state = $vtp_vlans->{$iid};
next unless defined $state; next unless defined $state;
next if $state !~ /operational/; next if $state !~ /operational/;
if ($iid =~ /(\d+)\.(\d+)/ ) { if ( $iid =~ /(\d+)\.(\d+)/ ) {
$vtp_dom = $1; $vtp_dom = $1;
$vlan = $2; $vlan = $2;
} }
$vlan_exists = 1 if ( $vlan_id eq $vlan ); $vlan_exists = 1 if ( $vlan_id eq $vlan );
} }
unless ( $vlan_exists ) { unless ($vlan_exists) {
$vtp->error_throw("VLAN $vlan_id does not exist or is not operational"); $vtp->error_throw(
"VLAN $vlan_id does not exist or is not operational");
return; return;
} }
@@ -769,9 +806,10 @@ Each bit represents a VLAN. This is 3072 through 4095
=head1 SET METHODS =head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods or These are methods that provide SNMP set functionality for overridden methods
provide a simpler interface to complex set operations. See or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set operations. L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over =over

View File

@@ -36,70 +36,67 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::Entity::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Entity::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Entity::EXPORT_OK = qw//; @SNMP::Info::Entity::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ('ENTITY-MIB' => 'entPhysicalSerialNum'); %MIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum' );
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = (
'e_alias' => 'entPhysicalAlias', 'e_alias' => 'entPhysicalAlias',
'e_class' => 'entPhysicalClass', 'e_class' => 'entPhysicalClass',
'e_descr' => 'entPhysicalDescr', 'e_descr' => 'entPhysicalDescr',
'e_fwver' => 'entPhysicalFirmwareRev', 'e_fwver' => 'entPhysicalFirmwareRev',
'e_fru' => 'entPhysicalIsFRU', 'e_fru' => 'entPhysicalIsFRU',
'e_hwver' => 'entPhysicalHardwareRev', 'e_hwver' => 'entPhysicalHardwareRev',
'e_id' => 'entPhysicalAssetID', 'e_id' => 'entPhysicalAssetID',
'e_map' => 'entAliasMappingIdentifier', 'e_map' => 'entAliasMappingIdentifier',
'e_model' => 'entPhysicalModelName', 'e_model' => 'entPhysicalModelName',
'e_name' => 'entPhysicalName', 'e_name' => 'entPhysicalName',
'e_parent' => 'entPhysicalContainedIn', 'e_parent' => 'entPhysicalContainedIn',
'e_pos' => 'entPhysicalParentRelPos', 'e_pos' => 'entPhysicalParentRelPos',
'e_serial' => 'entPhysicalSerialNum', 'e_serial' => 'entPhysicalSerialNum',
'e_swver' => 'entPhysicalSoftwareRev', 'e_swver' => 'entPhysicalSoftwareRev',
'e_type' => 'entPhysicalVendorType', 'e_type' => 'entPhysicalVendorType',
'e_vendor' => 'entPhysicalMfgName', 'e_vendor' => 'entPhysicalMfgName',
); );
%MUNGE = ( %MUNGE = ( 'e_type' => \&SNMP::Info::munge_e_type, );
'e_type' => \&SNMP::Info::munge_e_type,
);
# entPhysicalIndex is not-accessible. Create to facilitate emulation methods # entPhysicalIndex is not-accessible. Create to facilitate emulation methods
# in other classes # in other classes
sub e_index { sub e_index {
my $entity = shift; my $entity = shift;
my $partial = shift; my $partial = shift;
# Force use of MIB leaf to avoid inheritance issues in psuedo classes # Force use of MIB leaf to avoid inheritance issues in psuedo classes
my $e_descr = $entity->entPhysicalDescr($partial); my $e_descr = $entity->entPhysicalDescr($partial);
return unless ($e_descr); return unless ($e_descr);
my %e_index; my %e_index;
foreach my $iid (keys %$e_descr) { foreach my $iid ( keys %$e_descr ) {
$e_index{$iid} = $iid; $e_index{$iid} = $iid;
} }
return \%e_index; return \%e_index;
} }
sub e_port { sub e_port {
my $entity = shift; my $entity = shift;
my $partial = shift; my $partial = shift;
my $e_map = $entity->e_map($partial); my $e_map = $entity->e_map($partial);
my %e_port; my %e_port;
foreach my $e_id (keys %$e_map) { foreach my $e_id ( keys %$e_map ) {
my $id = $e_id; my $id = $e_id;
$id =~ s/\.0$//; $id =~ s/\.0$//;

View File

@@ -36,46 +36,43 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::EtherLike::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::EtherLike::EXPORT_OK = qw//; @SNMP::Info::EtherLike::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'ETHERLIKE-MIB' => 'etherMIB' );
'ETHERLIKE-MIB' => 'etherMIB'
);
%GLOBALS = (); %GLOBALS = ();
%FUNCS = ( %FUNCS = (
# EtherLike StatsTable
'el_chipset' => 'dot3StatsEtherChipSet',
'el_coll_excess' => 'dot3StatsExcessiveCollisions',
'el_coll_late' => 'dot3StatsLateCollisions',
'el_coll_mult' => 'dot3StatsMultipleCollisionFrames',
'el_coll_single' => 'dot3StatsSingleCollisionFrames',
'el_duplex' => 'dot3StatsDuplexStatus',
'el_error_alignment' => 'dot3StatsAlignmentErrors',
'el_error_fcs' => 'dot3StatsFCSErrors',
'el_error_cs' => 'dot3StatsCarrierSenseErrors',
'el_error_frame' => 'dot3StatsFrameTooLongs',
'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors',
'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors',
'el_error_sqe' => 'dot3StatsSQETestErrors',
'el_error_symbol' => 'dot3StatsSymbolErrors',
'el_index' => 'dot3StatsIndex',
'el_xmit_defer' => 'dot3StatsDeferredTransmissions',
# Ethernet-like Collision Statistics Group
'el_coll_count' => 'dot3CollCount',
'el_coll_freq' => 'dot3CollFrequencies'
);
%MUNGE = ( # EtherLike StatsTable
%SNMP::Info::MUNGE, 'el_chipset' => 'dot3StatsEtherChipSet',
'el_duplex' => \&munge_el_duplex, 'el_coll_excess' => 'dot3StatsExcessiveCollisions',
); 'el_coll_late' => 'dot3StatsLateCollisions',
'el_coll_mult' => 'dot3StatsMultipleCollisionFrames',
'el_coll_single' => 'dot3StatsSingleCollisionFrames',
'el_duplex' => 'dot3StatsDuplexStatus',
'el_error_alignment' => 'dot3StatsAlignmentErrors',
'el_error_fcs' => 'dot3StatsFCSErrors',
'el_error_cs' => 'dot3StatsCarrierSenseErrors',
'el_error_frame' => 'dot3StatsFrameTooLongs',
'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors',
'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors',
'el_error_sqe' => 'dot3StatsSQETestErrors',
'el_error_symbol' => 'dot3StatsSymbolErrors',
'el_index' => 'dot3StatsIndex',
'el_xmit_defer' => 'dot3StatsDeferredTransmissions',
# Ethernet-like Collision Statistics Group
'el_coll_count' => 'dot3CollCount',
'el_coll_freq' => 'dot3CollFrequencies'
);
%MUNGE = ( %SNMP::Info::MUNGE, 'el_duplex' => \&munge_el_duplex, );
sub munge_el_duplex { sub munge_el_duplex {
my $duplex = shift; my $duplex = shift;
@@ -85,7 +82,6 @@ sub munge_el_duplex {
return $duplex; return $duplex;
} }
1; 1;
__END__ __END__
@@ -111,7 +107,8 @@ Max Baker
my $class = $cdp->class(); my $class = $cdp->class();
print " Using device sub class : $class\n"; print " Using device sub class : $class\n";
# Find the duplex setting for a port on a device that implements ETHERLIKE-MIB # Find the duplex setting for a port on a device that implements
# ETHERLIKE-MIB
my $interfaces = $el->interfaces(); my $interfaces = $el->interfaces();
my $el_index = $el->el_index(); my $el_index = $el->el_index();
my $el_duplex = $el->el_duplex(); my $el_duplex = $el->el_duplex();

View File

@@ -37,51 +37,50 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::FDP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::FDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::FDP::EXPORT_OK = qw//; @SNMP::Info::FDP::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' );
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun'
);
%GLOBALS = ( %GLOBALS = (
# CDP-Compatibility
'cdp_interval' => 'snFdpGlobalMessageInterval',
'cdp_holdtime' => 'snFdpGlobalHoldTime',
'cdp_id' => 'snFdpGlobalDeviceId',
#
'fdp_run' => 'snFdpGlobalRun',
'fdp_interval' => 'snFdpGlobalMessageInterval',
'fdp_holdtime' => 'snFdpGlobalHoldTime',
'fdp_id' => 'snFdpGlobalDeviceId',
);
%FUNCS = ( # CDP-Compatibility
'c_index' => 'snFdpCacheIfIndex', 'cdp_interval' => 'snFdpGlobalMessageInterval',
'c_proto' => 'snFdpCacheAddressType', 'cdp_holdtime' => 'snFdpGlobalHoldTime',
'c_ip' => 'snFdpCacheAddress', 'cdp_id' => 'snFdpGlobalDeviceId',
'c_ver' => 'snFdpCacheVersion',
'c_id' => 'snFdpCacheDeviceId', #
'c_port' => 'snFdpCacheDevicePort', 'fdp_run' => 'snFdpGlobalRun',
'c_platform' => 'snFdpCachePlatform', 'fdp_interval' => 'snFdpGlobalMessageInterval',
'c_capabilities' => 'snFdpCacheCapabilities', 'fdp_holdtime' => 'snFdpGlobalHoldTime',
'c_domain' => 'snFdpCacheVTPMgmtDomain', 'fdp_id' => 'snFdpGlobalDeviceId',
'c_vlan' => 'snFdpCacheNativeVLAN', );
'c_duplex' => 'snFdpCacheDuplex',
); %FUNCS = (
'c_index' => 'snFdpCacheIfIndex',
'c_proto' => 'snFdpCacheAddressType',
'c_ip' => 'snFdpCacheAddress',
'c_ver' => 'snFdpCacheVersion',
'c_id' => 'snFdpCacheDeviceId',
'c_port' => 'snFdpCacheDevicePort',
'c_platform' => 'snFdpCachePlatform',
'c_capabilities' => 'snFdpCacheCapabilities',
'c_domain' => 'snFdpCacheVTPMgmtDomain',
'c_vlan' => 'snFdpCacheNativeVLAN',
'c_duplex' => 'snFdpCacheDuplex',
);
%MUNGE = ( %MUNGE = (
'c_capabilities' => \&SNMP::Info::munge_caps, 'c_capabilities' => \&SNMP::Info::munge_caps,
'c_ip' => \&SNMP::Info::munge_ip 'c_ip' => \&SNMP::Info::munge_ip
); );
sub cdp_run { sub cdp_run {
my $fdp = shift; my $fdp = shift;
my $fdp_run = $fdp->fdp_run(); my $fdp_run = $fdp->fdp_run();
# if fdp_run isn't implemented on device, assume FDP is on # if fdp_run isn't implemented on device, assume FDP is on
@@ -93,13 +92,15 @@ sub hasFDP {
my $fdp = shift; my $fdp = shift;
my $ver = $fdp->{_version}; my $ver = $fdp->{_version};
#my $ver = $fdp->fdp_ver; #my $ver = $fdp->fdp_ver;
# SNMP v1 clients dont have the globals # SNMP v1 clients dont have the globals
if (defined $ver and $ver == 1){ if ( defined $ver and $ver == 1 ) {
my $fdp_ip = $fdp->fdp_ip(); my $fdp_ip = $fdp->fdp_ip();
# See if anything in fdp cache, if so we have fdp # See if anything in fdp cache, if so we have fdp
return 1 if (defined $fdp_ip and scalar(keys %$fdp_ip)) ; return 1 if ( defined $fdp_ip and scalar( keys %$fdp_ip ) );
return; return;
} }
@@ -107,26 +108,29 @@ sub hasFDP {
} }
sub c_if { sub c_if {
my $fdp = shift; my $fdp = shift;
# See if by some miracle Cisco implemented the fdpCacheIfIndex entry # See if by some miracle Cisco implemented the fdpCacheIfIndex entry
my $fdp_index = $fdp->fdp_index(); my $fdp_index = $fdp->fdp_index();
return $fdp_index if defined $fdp_index; return $fdp_index if defined $fdp_index;
# Nope, didn't think so. Now we fake it. # Nope, didn't think so. Now we fake it.
my $fdp_ip = $fdp->c_ip(); my $fdp_ip = $fdp->c_ip();
unless (defined $fdp_ip){ unless ( defined $fdp_ip ) {
$fdp->error_throw("SNMP::Info::FDP:fdp_if() - Device doesn't have fdp_ip() data. Can't fake fdp_index()"); $fdp->error_throw(
"SNMP::Info::FDP:fdp_if() - Device doesn't have fdp_ip() data. Can't fake fdp_index()"
);
return; return;
} }
my %fdp_if; my %fdp_if;
foreach my $key (keys %$fdp_ip){ foreach my $key ( keys %$fdp_ip ) {
next unless defined $key; next unless defined $key;
my $iid = $key; my $iid = $key;
# Truncate .1 from fdp cache entry
$iid =~ s/\.\d+$//; # Truncate .1 from fdp cache entry
$fdp_if{$key} = $iid; $iid =~ s/\.\d+$//;
$fdp_if{$key} = $iid;
} }
return \%fdp_if; return \%fdp_if;

View File

@@ -33,62 +33,66 @@ package SNMP::Info::IEEE802dot11;
use strict; use strict;
use Exporter; use Exporter;
@SNMP::Info::IEEE802dot11::ISA = qw/Exporter/; @SNMP::Info::IEEE802dot11::ISA = qw/Exporter/;
@SNMP::Info::IEEE802dot11::EXPORT_OK = qw//; @SNMP::Info::IEEE802dot11::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'IEEE802dot11-MIB' => 'dot11DesiredSSID', );
'IEEE802dot11-MIB' => 'dot11DesiredSSID',
);
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = (
# dot11PhyOFDMTable
'dot11_cur_freq' => 'dot11CurrentFrequency',
# dot11PhyDSSSTable
'dot11_cur_ch' => 'dot11CurrentChannel',
# dot11PhyOperationTable
'dot11_phy_type' => 'dot11PHYType',
'dot11_reg_dom' => 'dot11CurrentRegDomain',
# dot11ResourceInfoTable
'dot11_prod_ver' => 'dot11manufacturerProductVersion',
'dot11_prod_name' => 'dot11manufacturerProductName',
'dot11_man_name' => 'dot11manufacturerName',
# dot11OperationTable
'dot11_mac' => 'dot11MACAddress',
# dot11StationConfigTable
'dot11_bss_type' => 'dot11DesiredBSSType',
'i_ssidlist' => 'dot11DesiredSSID',
'dot11_pwr_mode' => 'dot11PowerManagementMode',
'dot11_sta_id' => 'dot11StationID',
# dot11PhyTxPowerTable
'dot11_cur_tx_pwr' => 'dot11CurrentTxPowerLevel',
'dot11_tx_pwr_level_1' => 'dot11TxPowerLevel1',
'dot11_tx_pwr_level_2' => 'dot11TxPowerLevel2',
'dot11_tx_pwr_level_3' => 'dot11TxPowerLevel3',
'dot11_tx_pwr_level_4' => 'dot11TxPowerLevel4',
'dot11_tx_pwr_level_5' => 'dot11TxPowerLevel5',
'dot11_tx_pwr_level_6' => 'dot11TxPowerLevel6',
'dot11_tx_pwr_level_7' => 'dot11TxPowerLevel7',
'dot11_tx_pwr_level_8' => 'dot11TxPowerLevel8',
);
%MUNGE = ( # dot11PhyOFDMTable
'dot11_mac' => \&SNMP::Info::munge_mac, 'dot11_cur_freq' => 'dot11CurrentFrequency',
'dot11_sta_id' => \&SNMP::Info::munge_mac,
); # dot11PhyDSSSTable
'dot11_cur_ch' => 'dot11CurrentChannel',
# dot11PhyOperationTable
'dot11_phy_type' => 'dot11PHYType',
'dot11_reg_dom' => 'dot11CurrentRegDomain',
# dot11ResourceInfoTable
'dot11_prod_ver' => 'dot11manufacturerProductVersion',
'dot11_prod_name' => 'dot11manufacturerProductName',
'dot11_man_name' => 'dot11manufacturerName',
# dot11OperationTable
'dot11_mac' => 'dot11MACAddress',
# dot11StationConfigTable
'dot11_bss_type' => 'dot11DesiredBSSType',
'i_ssidlist' => 'dot11DesiredSSID',
'dot11_pwr_mode' => 'dot11PowerManagementMode',
'dot11_sta_id' => 'dot11StationID',
# dot11PhyTxPowerTable
'dot11_cur_tx_pwr' => 'dot11CurrentTxPowerLevel',
'dot11_tx_pwr_level_1' => 'dot11TxPowerLevel1',
'dot11_tx_pwr_level_2' => 'dot11TxPowerLevel2',
'dot11_tx_pwr_level_3' => 'dot11TxPowerLevel3',
'dot11_tx_pwr_level_4' => 'dot11TxPowerLevel4',
'dot11_tx_pwr_level_5' => 'dot11TxPowerLevel5',
'dot11_tx_pwr_level_6' => 'dot11TxPowerLevel6',
'dot11_tx_pwr_level_7' => 'dot11TxPowerLevel7',
'dot11_tx_pwr_level_8' => 'dot11TxPowerLevel8',
);
%MUNGE = (
'dot11_mac' => \&SNMP::Info::munge_mac,
'dot11_sta_id' => \&SNMP::Info::munge_mac,
);
sub vendor { sub vendor {
my $dot11 = shift; my $dot11 = shift;
my $names = $dot11->dot11_man_name(); my $names = $dot11->dot11_man_name();
foreach my $iid (keys %$names){ foreach my $iid ( keys %$names ) {
my $vendor = $names->{$iid}; my $vendor = $names->{$iid};
next unless defined $vendor; next unless defined $vendor;
if ( $vendor =~ /^(\S+)/ ) { if ( $vendor =~ /^(\S+)/ ) {
@@ -104,11 +108,11 @@ sub model {
my $names = $dot11->dot11_prod_name(); my $names = $dot11->dot11_prod_name();
foreach my $iid (keys %$names){ foreach my $iid ( keys %$names ) {
my $prod = $names->{$iid}; my $prod = $names->{$iid};
next unless defined $prod; next unless defined $prod;
return lc($prod); return lc($prod);
} }
return; return;
} }
@@ -117,7 +121,7 @@ sub os_ver {
my $versions = $dot11->dot11_prod_ver(); my $versions = $dot11->dot11_prod_ver();
foreach my $iid (keys %$versions){ foreach my $iid ( keys %$versions ) {
my $ver = $versions->{$iid}; my $ver = $versions->{$iid};
next unless defined $ver; next unless defined $ver;
if ( $ver =~ /([\d\.]+)/ ) { if ( $ver =~ /([\d\.]+)/ ) {
@@ -133,18 +137,18 @@ sub i_80211channel {
my $phy_type = $dot11->dot11_phy_type() || {}; my $phy_type = $dot11->dot11_phy_type() || {};
my $cur_freq = $dot11->dot11_cur_freq() || {}; my $cur_freq = $dot11->dot11_cur_freq() || {};
my $cur_ch = $dot11->dot11_cur_ch() || {}; my $cur_ch = $dot11->dot11_cur_ch() || {};
my %i_80211channel; my %i_80211channel;
foreach my $iid (keys %$phy_type){ foreach my $iid ( keys %$phy_type ) {
my $type = $phy_type->{$iid}; my $type = $phy_type->{$iid};
next unless defined $type; next unless defined $type;
if ($type =~ /dsss/) { if ( $type =~ /dsss/ ) {
my $ch = $cur_ch->{$iid}; my $ch = $cur_ch->{$iid};
next unless defined $ch; next unless defined $ch;
$i_80211channel{$iid} = $ch; $i_80211channel{$iid} = $ch;
} }
elsif ($type =~ /ofdm/) { elsif ( $type =~ /ofdm/ ) {
my $ch = $cur_freq->{$iid}; my $ch = $cur_freq->{$iid};
next unless defined $ch; next unless defined $ch;
$i_80211channel{$iid} = $ch; $i_80211channel{$iid} = $ch;
@@ -158,17 +162,20 @@ sub i_80211channel {
} }
sub dot11_cur_tx_pwr_mw { sub dot11_cur_tx_pwr_mw {
my $dot11 = shift; my $dot11 = shift;
my $partial = shift; my $partial = shift;
my $cur = $dot11->dot11_cur_tx_pwr($partial); my $cur = $dot11->dot11_cur_tx_pwr($partial);
my $dot11_cur_tx_pwr_mw = {}; my $dot11_cur_tx_pwr_mw = {};
foreach my $idx (keys %$cur) { foreach my $idx ( keys %$cur ) {
my $pwr = $cur->{$idx}; my $pwr = $cur->{$idx};
if ($pwr >= 1 && $pwr <= 8) { if ( $pwr >= 1 && $pwr <= 8 ) {
# ToDo - Look at string eval # ToDo - Look at string eval
my $mw = eval "\$dot11->dot11_tx_pwr_level_$pwr(\$idx)"; ## no critic my $mw
= eval "\$dot11->dot11_tx_pwr_level_$pwr(\$idx)"; ## no critic
$dot11_cur_tx_pwr_mw->{$idx} = $mw->{$idx}; $dot11_cur_tx_pwr_mw->{$idx} = $mw->{$idx};
} else { }
else {
next; next;
} }
} }
@@ -204,9 +211,9 @@ Eric Miller
=head1 DESCRIPTION =head1 DESCRIPTION
SNMP::Info::IEEE802dot11 is a subclass of SNMP::Info that provides an interface SNMP::Info::IEEE802dot11 is a subclass of SNMP::Info that provides an
to F<IEEE802dot11-MIB>. This MIB is used in standards based 802.11 wireless interface to F<IEEE802dot11-MIB>. This MIB is used in standards based
devices. 802.11 wireless devices.
Use or create a subclass of SNMP::Info that inherits this one. Use or create a subclass of SNMP::Info that inherits this one.
Do not use directly. Do not use directly.
@@ -270,8 +277,8 @@ interface.
=item $dot11->dot11_cur_tx_pwr_mw() =item $dot11->dot11_cur_tx_pwr_mw()
Returns reference to hash. Current transmit power, in milliwatts, of the radio Returns reference to hash. Current transmit power, in milliwatts, of the
interface. radio interface.
=back =back

View File

@@ -34,51 +34,53 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::LLDP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::LLDP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::LLDP::EXPORT_OK = qw//; @SNMP::Info::LLDP::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
'LLDP-MIB' => 'lldpLocSysCapEnabled', 'LLDP-MIB' => 'lldpLocSysCapEnabled',
'LLDP-EXT-DOT1-MIB' => 'lldpXdot1MIB', 'LLDP-EXT-DOT1-MIB' => 'lldpXdot1MIB',
'LLDP-EXT-DOT3-MIB' => 'lldpXdot3MIB', 'LLDP-EXT-DOT3-MIB' => 'lldpXdot3MIB',
); );
%GLOBALS = ( %GLOBALS = (
'lldp_sysname' => 'lldpLocSysName', 'lldp_sysname' => 'lldpLocSysName',
'lldp_sysdesc' => 'lldpLocSysDesc', 'lldp_sysdesc' => 'lldpLocSysDesc',
'lldp_sys_cap' => 'lldpLocSysCapEnabled', 'lldp_sys_cap' => 'lldpLocSysCapEnabled',
); );
%FUNCS = ( %FUNCS = (
# LLDP-MIB::lldpLocManAddrTable
'lldp_lman_addr' => 'lldpLocManAddrIfId',
# LLDP-MIB::lldpRemTable
'lldp_rem_id_type' => 'lldpRemChassisIdSubtype',
'lldp_rem_id' => 'lldpRemChassisId',
'lldp_rem_pid_type' => 'lldpRemPortIdSubtype',
'lldp_rem_pid' => 'lldpRemPortId',
'lldp_rem_desc' => 'lldpRemPortDesc',
'lldp_rem_sysname' => 'lldpRemSysName',
'lldp_rem_sysdesc' => 'lldpRemSysDesc',
'lldp_rem_sys_cap' => 'lldpRemSysCapEnabled',
# LLDP-MIB::lldpRemManAddrTable
'lldp_rman_addr' => 'lldpRemManAddrIfSubtype',
);
# LLDP-MIB::lldpLocManAddrTable
'lldp_lman_addr' => 'lldpLocManAddrIfId',
# LLDP-MIB::lldpRemTable
'lldp_rem_id_type' => 'lldpRemChassisIdSubtype',
'lldp_rem_id' => 'lldpRemChassisId',
'lldp_rem_pid_type' => 'lldpRemPortIdSubtype',
'lldp_rem_pid' => 'lldpRemPortId',
'lldp_rem_desc' => 'lldpRemPortDesc',
'lldp_rem_sysname' => 'lldpRemSysName',
'lldp_rem_sysdesc' => 'lldpRemSysDesc',
'lldp_rem_sys_cap' => 'lldpRemSysCapEnabled',
# LLDP-MIB::lldpRemManAddrTable
'lldp_rman_addr' => 'lldpRemManAddrIfSubtype',
);
%MUNGE = ( %MUNGE = (
'lldp_sysdesc' => \&SNMP::Info::munge_null, 'lldp_sysdesc' => \&SNMP::Info::munge_null,
'lldp_sysname' => \&SNMP::Info::munge_null, 'lldp_sysname' => \&SNMP::Info::munge_null,
'lldp_rem_sysname' => \&SNMP::Info::munge_null, 'lldp_rem_sysname' => \&SNMP::Info::munge_null,
'lldp_rem_sysdesc' => \&SNMP::Info::munge_null, 'lldp_rem_sysdesc' => \&SNMP::Info::munge_null,
'lldp_rem_port_desc' => \&SNMP::Info::munge_null, 'lldp_rem_port_desc' => \&SNMP::Info::munge_null,
'lldp_sys_cap' => \&SNMP::Info::munge_bits, 'lldp_sys_cap' => \&SNMP::Info::munge_bits,
'lldp_rem_sys_cap' => \&SNMP::Info::munge_bits, 'lldp_rem_sys_cap' => \&SNMP::Info::munge_bits,
); );
sub hasLLDP { sub hasLLDP {
my $lldp = shift; my $lldp = shift;
@@ -98,23 +100,23 @@ sub lldp_if {
my $addr = $lldp->lldp_rem_pid($partial) || {}; my $addr = $lldp->lldp_rem_pid($partial) || {};
my %lldp_if; my %lldp_if;
foreach my $key (keys %$addr) { foreach my $key ( keys %$addr ) {
my @aOID = split ('\.',$key); my @aOID = split( '\.', $key );
my $port = $aOID[1]; my $port = $aOID[1];
$lldp_if{$key} = $port; $lldp_if{$key} = $port;
} }
return \%lldp_if; return \%lldp_if;
} }
sub lldp_ip { sub lldp_ip {
my $lldp = shift; my $lldp = shift;
my $partial = shift; my $partial = shift;
my $rman_addr = $lldp->lldp_rman_addr($partial) || {}; my $rman_addr = $lldp->lldp_rman_addr($partial) || {};
my %lldp_ip; my %lldp_ip;
foreach my $key (keys %$rman_addr) { foreach my $key ( keys %$rman_addr ) {
my($index, $proto, $addr) = _lldp_addr_index($key); my ( $index, $proto, $addr ) = _lldp_addr_index($key);
next unless defined $index; next unless defined $index;
next unless $proto == 1; next unless $proto == 1;
$lldp_ip{$index} = $addr; $lldp_ip{$index} = $addr;
@@ -123,14 +125,14 @@ sub lldp_ip {
} }
sub lldp_addr { sub lldp_addr {
my $lldp = shift; my $lldp = shift;
my $partial = shift; my $partial = shift;
my $rman_addr = $lldp->lldp_rman_addr($partial) || {}; my $rman_addr = $lldp->lldp_rman_addr($partial) || {};
my %lldp_ip; my %lldp_ip;
foreach my $key (keys %$rman_addr) { foreach my $key ( keys %$rman_addr ) {
my($index, $proto, $addr) = _lldp_addr_index($key); my ( $index, $proto, $addr ) = _lldp_addr_index($key);
next unless defined $index; next unless defined $index;
$lldp_ip{$index} = $addr; $lldp_ip{$index} = $addr;
} }
@@ -138,24 +140,26 @@ sub lldp_addr {
} }
sub lldp_port { sub lldp_port {
my $lldp = shift; my $lldp = shift;
my $partial = shift; my $partial = shift;
my $pdesc = $lldp->lldp_rem_desc($partial) || {}; my $pdesc = $lldp->lldp_rem_desc($partial) || {};
my $pid = $lldp->lldp_rem_pid($partial) || {}; my $pid = $lldp->lldp_rem_pid($partial) || {};
my $ptype = $lldp->lldp_rem_pid_type($partial) || {}; my $ptype = $lldp->lldp_rem_pid_type($partial) || {};
my %lldp_port; my %lldp_port;
foreach my $key (sort keys %$pid) { foreach my $key ( sort keys %$pid ) {
my $port = $pdesc->{$key}; my $port = $pdesc->{$key};
unless ($port) { unless ($port) {
$port = $pid->{$key}; $port = $pid->{$key};
next unless $port; next unless $port;
my $type = $ptype->{$key}; my $type = $ptype->{$key};
next unless $type; next unless $type;
# May need to format other types in the future, i.e. Network address
if ($type =~ /mac/) { # May need to format other types in the future, i.e. Network address
$port = join(':',map { sprintf "%02x",$_ } unpack('C*',$port)); if ( $type =~ /mac/ ) {
$port = join( ':',
map { sprintf "%02x", $_ } unpack( 'C*', $port ) );
} }
} }
@@ -171,21 +175,22 @@ sub lldp_port {
} }
sub lldp_id { sub lldp_id {
my $lldp = shift; my $lldp = shift;
my $partial = shift; my $partial = shift;
my $ch_type = $lldp->lldp_rem_id_type($partial) || {}; my $ch_type = $lldp->lldp_rem_id_type($partial) || {};
my $ch = $lldp->lldp_rem_id($partial) || {}; my $ch = $lldp->lldp_rem_id($partial) || {};
my %lldp_id; my %lldp_id;
foreach my $key (keys %$ch) { foreach my $key ( keys %$ch ) {
my $id = $ch->{$key}; my $id = $ch->{$key};
next unless $id; next unless $id;
my $type = $ch_type->{$key}; my $type = $ch_type->{$key};
next unless $type; next unless $type;
# May need to format other types in the future # May need to format other types in the future
if ($type =~ /mac/) { if ( $type =~ /mac/ ) {
$id = join(':',map { sprintf "%02x",$_ } unpack('C*',$id)); $id = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $id ) );
} }
$lldp_id{$key} = $id; $lldp_id{$key} = $id;
} }
@@ -213,19 +218,23 @@ sub lldp_id {
# Break up the lldpRemManAddrTable INDEX into common index, protocol, # Break up the lldpRemManAddrTable INDEX into common index, protocol,
# and address. # and address.
sub _lldp_addr_index { sub _lldp_addr_index {
my $idx = shift; my $idx = shift;
my @oids = split(/\./, $idx); my @oids = split( /\./, $idx );
my $index = join('.', splice(@oids, 0, 3)); my $index = join( '.', splice( @oids, 0, 3 ) );
my $proto = shift(@oids); my $proto = shift(@oids);
my $length = shift(@oids); my $length = shift(@oids);
# IPv4 # IPv4
if ($proto == 1) { if ( $proto == 1 ) {
return ($index, $proto, join('.',@oids)); return ( $index, $proto, join( '.', @oids ) );
} }
# MAC # MAC
elsif ($proto == 6) { elsif ( $proto == 6 ) {
return ($index, $proto, join(':',map { sprintf "%02x",$_ } @oids)); return ( $index, $proto,
join( ':', map { sprintf "%02x", $_ } @oids ) );
} }
# TODO - Need to handle other protocols, i.e. IPv6 # TODO - Need to handle other protocols, i.e. IPv6
else { else {
return; return;

View File

@@ -36,39 +36,38 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::Layer1::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::Layer1::EXPORT_OK = qw//; @SNMP::Info::Layer1::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::MIBS, %MIBS = ( %SNMP::Info::MIBS, 'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex' );
'SNMP-REPEATER-MIB' => 'rptrPortGroupIndex'
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS,
'ports_managed' => 'ifNumber', 'ports_managed' => 'ifNumber',
'rptr_slots' => 'rptrGroupCapacity', 'rptr_slots' => 'rptrGroupCapacity',
'slots' => 'rptrGroupCapacity' 'slots' => 'rptrGroupCapacity'
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS,
'rptr_ports' => 'rptrGroupPortCapacity', 'rptr_ports' => 'rptrGroupPortCapacity',
'rptr_port' => 'rptrPortIndex', 'rptr_port' => 'rptrPortIndex',
'rptr_slot' => 'rptrPortGroupIndex', 'rptr_slot' => 'rptrPortGroupIndex',
'rptr_up_admin' => 'rptrPortAdminStatus', 'rptr_up_admin' => 'rptrPortAdminStatus',
'rptr_up' => 'rptrPortOperStatus', 'rptr_up' => 'rptrPortOperStatus',
'rptr_last_src' => 'rptrAddrTrackNewLastSrcAddress', 'rptr_last_src' => 'rptrAddrTrackNewLastSrcAddress',
); );
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE, # Inherit all the built in munging
'rptr_last_src'=> \&SNMP::Info::munge_mac, %SNMP::Info::MUNGE,
); 'rptr_last_src' => \&SNMP::Info::munge_mac,
);
# Method OverRides # Method OverRides
@@ -76,10 +75,10 @@ $VERSION = '1.09';
sub ports { sub ports {
my $l1 = shift; my $l1 = shift;
my $ports = $l1->ports_managed(); my $ports = $l1->ports_managed();
my $rptr_ports = $l1->rptr_ports(); my $rptr_ports = $l1->rptr_ports();
foreach my $group (keys %$rptr_ports){ foreach my $group ( keys %$rptr_ports ) {
$ports += $rptr_ports->{$group}; $ports += $rptr_ports->{$group};
} }
@@ -89,8 +88,8 @@ sub ports {
# $l1->model() - Looks at sysObjectID which gives the oid of the system # $l1->model() - Looks at sysObjectID which gives the oid of the system
# name, contained in a propriatry MIB. # name, contained in a propriatry MIB.
sub model { sub model {
my $l1 = shift; my $l1 = shift;
my $id = $l1->id(); my $id = $l1->id();
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
# HP # HP
@@ -103,13 +102,13 @@ sub model {
} }
sub vendor { sub vendor {
my $l1 = shift; my $l1 = shift;
my $descr = $l1->description(); my $descr = $l1->description();
return 'hp' if ($descr =~ /hp/i); return 'hp' if ( $descr =~ /hp/i );
return 'cisco' if ($descr =~ /(catalyst|cisco|ios)/i); return 'cisco' if ( $descr =~ /(catalyst|cisco|ios)/i );
return 'allied' if ($descr =~ /allied/i); return 'allied' if ( $descr =~ /allied/i );
return 'asante' if ($descr =~ /asante/i); return 'asante' if ( $descr =~ /asante/i );
return 'unknown'; return 'unknown';
@@ -117,28 +116,28 @@ sub vendor {
# By Default we'll use the description field # By Default we'll use the description field
sub interfaces { sub interfaces {
my $l1 = shift; my $l1 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l1->i_index($partial) || {}; my $interfaces = $l1->i_index($partial) || {};
my $rptr_port = $l1->rptr_port($partial) || {}; my $rptr_port = $l1->rptr_port($partial) || {};
foreach my $port (keys %$rptr_port){ foreach my $port ( keys %$rptr_port ) {
$interfaces->{$port} = $port; $interfaces->{$port} = $port;
} }
return $interfaces; return $interfaces;
} }
sub i_up_admin { sub i_up_admin {
my $l1 = shift; my $l1 = shift;
my $partial = shift; my $partial = shift;
my $i_up_admin = $l1->SUPER::i_up_admin($partial) || {}; my $i_up_admin = $l1->SUPER::i_up_admin($partial) || {};
my $rptr_up_admin = $l1->rptr_up_admin($partial) || {}; my $rptr_up_admin = $l1->rptr_up_admin($partial) || {};
foreach my $key (keys %$rptr_up_admin){ foreach my $key ( keys %$rptr_up_admin ) {
my $up = $rptr_up_admin->{$key}; my $up = $rptr_up_admin->{$key};
$i_up_admin->{$key} = 'up' if $up =~ /enabled/; $i_up_admin->{$key} = 'up' if $up =~ /enabled/;
$i_up_admin->{$key} = 'down' if $up =~ /disabled/; $i_up_admin->{$key} = 'down' if $up =~ /disabled/;
} }
@@ -146,13 +145,13 @@ sub i_up_admin {
} }
sub i_up { sub i_up {
my $l1 = shift; my $l1 = shift;
my $partial = shift; my $partial = shift;
my $i_up = $l1->SUPER::i_up($partial) || {}; my $i_up = $l1->SUPER::i_up($partial) || {};
my $rptr_up = $l1->rptr_up($partial) || {}; my $rptr_up = $l1->rptr_up($partial) || {};
foreach my $key (keys %$rptr_up){ foreach my $key ( keys %$rptr_up ) {
my $up = $rptr_up->{$key}; my $up = $rptr_up->{$key};
$i_up->{$key} = 'up' if $up =~ /operational/; $i_up->{$key} = 'up' if $up =~ /operational/;
} }

View File

@@ -36,7 +36,7 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer1; use SNMP::Info::Layer1;
@SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/; @SNMP::Info::Layer1::Allied::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Allied::EXPORT_OK = qw//; @SNMP::Info::Layer1::Allied::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -44,23 +44,17 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
# Set for No CDP # Set for No CDP
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, 'root_ip' => 'actualIPAddr', );
%SNMP::Info::Layer1::GLOBALS,
'root_ip' => 'actualIPAddr',
);
%FUNCS = (%SNMP::Info::Layer1::FUNCS, %FUNCS = (
'ati_p_name' => 'portName', %SNMP::Info::Layer1::FUNCS,
'ati_up' => 'linkTestLED', 'ati_p_name' => 'portName',
); 'ati_up' => 'linkTestLED',
);
%MIBS = ( %MIBS = ( %SNMP::Info::Layer1::MIBS, 'ATI-MIB' => 'atiPortGroupIndex' );
%SNMP::Info::Layer1::MIBS,
'ATI-MIB' => 'atiPortGroupIndex'
);
%MUNGE = (%SNMP::Info::Layer1::MUNGE, %MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
);
sub vendor { sub vendor {
return 'allied'; return 'allied';
@@ -72,9 +66,9 @@ sub os {
sub os_ver { sub os_ver {
my $allied = shift; my $allied = shift;
my $descr = $allied->description(); my $descr = $allied->description();
if ($descr =~ m/version (\d+\.\d+)/){ if ( $descr =~ m/version (\d+\.\d+)/ ) {
return $1; return $1;
} }
} }
@@ -84,38 +78,38 @@ sub model {
my $desc = $allied->description(); my $desc = $allied->description();
if ($desc =~ /(AT-\d{4}\S{1}?)/){ if ( $desc =~ /(AT-\d{4}\S{1}?)/ ) {
return $1; return $1;
} }
return; return;
} }
sub i_name{ sub i_name {
my $allied = shift; my $allied = shift;
my $partial = shift; my $partial = shift;
my $i_name = $allied->orig_i_name($partial) || {}; my $i_name = $allied->orig_i_name($partial) || {};
my $ati_p_name = $allied->ati_p_name($partial) || {}; my $ati_p_name = $allied->ati_p_name($partial) || {};
foreach my $port (keys %$ati_p_name){ foreach my $port ( keys %$ati_p_name ) {
my $name = $ati_p_name->{$port}; my $name = $ati_p_name->{$port};
$i_name->{$port} = $name if (defined $name and $name !~ /^\s*$/); $i_name->{$port} = $name if ( defined $name and $name !~ /^\s*$/ );
} }
return $i_name; return $i_name;
} }
sub i_up { sub i_up {
my $allied = shift; my $allied = shift;
my $partial = shift; my $partial = shift;
my $i_up = SNMP::Info::Layer1::i_up($allied, $partial); my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial );
my $ati_up = $allied->ati_up($partial) || {}; my $ati_up = $allied->ati_up($partial) || {};
foreach my $port (keys %$ati_up){ foreach my $port ( keys %$ati_up ) {
my $up = $ati_up->{$port}; my $up = $ati_up->{$port};
$i_up->{$port} = 'down' if $up eq 'linktesterror'; $i_up->{$port} = 'down' if $up eq 'linktesterror';
$i_up->{$port} = 'up' if $up eq 'nolinktesterror'; $i_up->{$port} = 'up' if $up eq 'nolinktesterror';
} }
return $i_up; return $i_up;

View File

@@ -36,7 +36,7 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer1; use SNMP::Info::Layer1;
@SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/; @SNMP::Info::Layer1::Asante::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Asante::EXPORT_OK = qw//; @SNMP::Info::Layer1::Asante::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -44,35 +44,29 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
# Set for No CDP # Set for No CDP
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer1::GLOBALS, );
%SNMP::Info::Layer1::GLOBALS,
);
%FUNCS = (%SNMP::Info::Layer1::FUNCS, %FUNCS = (
'asante_port' => 'ePortIndex', %SNMP::Info::Layer1::FUNCS,
'asante_group' => 'ePortGrpIndex', 'asante_port' => 'ePortIndex',
'i_type' => 'ePortStateType', 'asante_group' => 'ePortGrpIndex',
'asante_up' => 'ePortStateLinkStatus', 'i_type' => 'ePortStateType',
); 'asante_up' => 'ePortStateLinkStatus',
);
%MIBS = ( %MIBS = ( %SNMP::Info::Layer1::MIBS, 'ASANTE-HUB1012-MIB' => 'asante' );
%SNMP::Info::Layer1::MIBS,
'ASANTE-HUB1012-MIB' => 'asante'
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer1::MUNGE, );
%SNMP::Info::Layer1::MUNGE,
);
sub interfaces { sub interfaces {
my $asante = shift; my $asante = shift;
my $partial = shift; my $partial = shift;
my $rptr_port = $asante->rptr_port($partial) || {}; my $rptr_port = $asante->rptr_port($partial) || {};
my %interfaces; my %interfaces;
foreach my $port (keys %$rptr_port){ foreach my $port ( keys %$rptr_port ) {
$interfaces{$port} = $port; $interfaces{$port} = $port;
} }
@@ -85,9 +79,9 @@ sub os {
sub os_ver { sub os_ver {
my $asante = shift; my $asante = shift;
my $descr = $asante->description(); my $descr = $asante->description();
if ($descr =~ /software v(\d+\.\d+)/){ if ( $descr =~ /software v(\d+\.\d+)/ ) {
return $1; return $1;
} }
} }
@@ -99,30 +93,30 @@ sub vendor {
sub model { sub model {
my $asante = shift; my $asante = shift;
my $id = $asante->id(); my $id = $asante->id();
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $model; return $model;
} }
sub i_up { sub i_up {
my $asante = shift; my $asante = shift;
my $partial = shift; my $partial = shift;
my $asante_up = $asante->asante_up($partial) || {}; my $asante_up = $asante->asante_up($partial) || {};
my $i_up = {}; my $i_up = {};
foreach my $port (keys %$asante_up){ foreach my $port ( keys %$asante_up ) {
my $up = $asante_up->{$port}; my $up = $asante_up->{$port};
$i_up->{$port} = 'down' if $up =~ /on/; $i_up->{$port} = 'down' if $up =~ /on/;
$i_up->{$port} = 'up' if $up =~ /off/; $i_up->{$port} = 'up' if $up =~ /off/;
} }
return $i_up; return $i_up;
} }
sub i_speed { sub i_speed {
my $asante = shift; my $asante = shift;
my $partial = shift; my $partial = shift;
my $i_speed = $asante->orig_i_speed($partial) || {}; my $i_speed = $asante->orig_i_speed($partial) || {};
@@ -135,7 +129,7 @@ sub i_speed {
} }
sub i_mac { sub i_mac {
my $asante = shift; my $asante = shift;
my $partial = shift; my $partial = shift;
my $i_mac = $asante->orig_i_mac($partial) || {}; my $i_mac = $asante->orig_i_mac($partial) || {};
@@ -152,7 +146,7 @@ sub i_description {
} }
sub i_name { sub i_name {
my $asante = shift; my $asante = shift;
my $partial = shift; my $partial = shift;
my $i_name = $asante->orig_i_descr($partial) || {}; my $i_name = $asante->orig_i_descr($partial) || {};

View File

@@ -36,51 +36,53 @@ use SNMP::Info::SONMP;
use SNMP::Info::NortelStack; use SNMP::Info::NortelStack;
use SNMP::Info::Layer2; 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//; @SNMP::Info::Layer1::Bayhub::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
%SNMP::Info::NortelStack::MIBS, %SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS, %SNMP::Info::SONMP::MIBS,
'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable', 'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable',
'S5-COMMON-STATS-MIB' => 's5CmStat', 'S5-COMMON-STATS-MIB' => 's5CmStat',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS, %SNMP::Info::SONMP::GLOBALS,
%SNMP::Info::SONMP::GLOBALS, );
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
%SNMP::Info::NortelStack::FUNCS, %SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::SONMP::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 = ( # S5-ETHERNET-COMMON-MIB::s5EnPortTable
%SNMP::Info::Layer2::MUNGE, 'bayhub_pb_index' => 's5EnPortBrdIndx',
%SNMP::Info::NortelStack::MUNGE, 'bayhub_pp_index' => 's5EnPortIndx',
%SNMP::Info::SONMP::MUNGE, '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 { sub layers {
return '00000011'; return '00000011';
@@ -96,15 +98,15 @@ sub vendor {
sub model { sub model {
my $bayhub = shift; my $bayhub = shift;
my $id = $bayhub->id(); my $id = $bayhub->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
$model =~ s/^sreg-//i; $model =~ s/^sreg-//i;
return 'Baystack Hub' if ($model =~ /BayStack/); return 'Baystack Hub' if ( $model =~ /BayStack/ );
return '5000' if ($model =~ /5000/); return '5000' if ( $model =~ /5000/ );
return '5005' if ($model =~ /5005/); return '5005' if ( $model =~ /5005/ );
return $model; return $model;
} }
@@ -112,33 +114,35 @@ sub model {
# and port status # and port status
sub i_index { sub i_index {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $b_index = $bayhub->bayhub_pb_index($partial) || {}; my $b_index = $bayhub->bayhub_pb_index($partial) || {};
my $p_index = $bayhub->bayhub_pp_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; my %i_index;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid}; my $board = $b_index->{$iid};
next unless defined $board; 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; my $comidx = $board;
if (! ($comidx % 5)) { if ( !( $comidx % 5 ) ) {
$board = ($board / 5); $board = ( $board / 5 );
} elsif ($comidx =~ /[16]$/) { }
$board = int($board/5); elsif ( $comidx =~ /[16]$/ ) {
$port = 25; $board = int( $board / 5 );
} elsif ($comidx =~ /[27]$/) { $port = 25;
$board = int($board/5); }
$port = 26; elsif ( $comidx =~ /[27]$/ ) {
} $board = int( $board / 5 );
} $port = 26;
}
}
my $index = ($board*256)+$port; my $index = ( $board * 256 ) + $port;
$i_index{$iid} = $index; $i_index{$iid} = $index;
} }
@@ -149,20 +153,20 @@ sub i_index {
# for consistency # for consistency
sub interfaces { sub interfaces {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $i_index = $bayhub->i_index() || {}; my $i_index = $bayhub->i_index() || {};
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; 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 # Index numbers are deterministic slot * 256 + port
my $port = $index % 256; my $port = $index % 256;
my $slot = int($index / 256); my $slot = int( $index / 256 );
my $slotport = "$slot.$port"; my $slotport = "$slot.$port";
@@ -173,113 +177,114 @@ sub interfaces {
} }
sub i_duplex { sub i_duplex {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $port_index = $bayhub->i_index() || {}; my $port_index = $bayhub->i_index() || {};
my %i_duplex; my %i_duplex;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $duplex = 'half'; my $duplex = 'half';
$i_duplex{$index}=$duplex; $i_duplex{$index} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
sub i_duplex_admin { sub i_duplex_admin {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $port_index = $bayhub->i_index() || {}; my $port_index = $bayhub->i_index() || {};
my %i_duplex_admin; my %i_duplex_admin;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $duplex = 'half'; my $duplex = 'half';
$i_duplex_admin{$index}=$duplex; $i_duplex_admin{$index} = $duplex;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
sub i_speed { sub i_speed {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $port_index = $bayhub->i_index() || {}; my $port_index = $bayhub->i_index() || {};
my $port_speed = $bayhub->bayhub_p_speed() || {}; my $port_speed = $bayhub->bayhub_p_speed() || {};
my %i_speed; my %i_speed;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; 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'; 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; $speed = '100 Mbps' if $speed =~ /bps100M/i;
$i_speed{$index}=$speed; $i_speed{$index} = $speed;
} }
return \%i_speed; return \%i_speed;
} }
sub i_up { sub i_up {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $port_index = $bayhub->i_index() || {}; my $port_index = $bayhub->i_index() || {};
my $link_stat = $bayhub->bayhub_up() || {}; my $link_stat = $bayhub->bayhub_up() || {};
my %i_up; my %i_up;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid}; my $link_stat = $link_stat->{$iid};
next unless defined $link_stat; 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; $link_stat = 'down' if $link_stat =~ /off/i;
$i_up{$index}=$link_stat; $i_up{$index} = $link_stat;
} }
return \%i_up; return \%i_up;
} }
sub i_up_admin { sub i_up_admin {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $i_index = $bayhub->i_index() || {}; my $i_index = $bayhub->i_index() || {};
my $link_stat = $bayhub->bayhub_up_admin() || {}; my $link_stat = $bayhub->bayhub_up_admin() || {};
my %i_up_admin; my %i_up_admin;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid}; my $link_stat = $link_stat->{$iid};
next unless defined $link_stat; next unless defined $link_stat;
$i_up_admin{$index}=$link_stat; $i_up_admin{$index} = $link_stat;
} }
return \%i_up_admin; return \%i_up_admin;
} }
sub set_i_up_admin { sub set_i_up_admin {
# map setting to those the hub will understand # map setting to those the hub will understand
my %setting = qw/up 2 down 3/; my %setting = qw/up 2 down 3/;
my $bayhub = shift; 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; my %reverse_i_index = reverse %$i_index;
$setting = lc($setting); $setting = lc($setting);
@@ -288,39 +293,41 @@ sub set_i_up_admin {
$iid = $reverse_i_index{$iid}; $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 # Hubs do not support the standard Bridge MIB
sub bp_index { sub bp_index {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $b_index = $bayhub->bayhub_nb_index() || {}; my $b_index = $bayhub->bayhub_nb_index() || {};
my $p_index = $bayhub->bayhub_np_index() || {}; my $p_index = $bayhub->bayhub_np_index() || {};
my $model = $bayhub->model() || 'Baystack Hub'; my $model = $bayhub->model() || 'Baystack Hub';
my %bp_index; my %bp_index;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid}; my $board = $b_index->{$iid};
next unless defined $board; 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; my $comidx = $board;
if (! ($comidx % 5)) { if ( !( $comidx % 5 ) ) {
$board = ($board / 5); $board = ( $board / 5 );
} elsif ($comidx =~ /[16]$/) { }
$board = int($board/5); elsif ( $comidx =~ /[16]$/ ) {
$port = 25; $board = int( $board / 5 );
} elsif ($comidx =~ /[27]$/) { $port = 25;
$board = int($board/5); }
$port = 26; elsif ( $comidx =~ /[27]$/ ) {
} $board = int( $board / 5 );
} $port = 26;
}
}
my $index = ($board*256)+$port; my $index = ( $board * 256 ) + $port;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
$bp_index{$index} = $index; $bp_index{$index} = $index;
} }
@@ -328,35 +335,37 @@ sub bp_index {
} }
sub fw_port { sub fw_port {
my $bayhub = shift; my $bayhub = shift;
my $partial = shift; my $partial = shift;
my $b_index = $bayhub->bayhub_nb_index($partial) || {}; my $b_index = $bayhub->bayhub_nb_index($partial) || {};
my $p_index = $bayhub->bayhub_np_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; my %fw_port;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid}; my $board = $b_index->{$iid};
next unless defined $board; 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; my $comidx = $board;
if (! ($comidx % 5)) { if ( !( $comidx % 5 ) ) {
$board = ($board / 5); $board = ( $board / 5 );
} elsif ($comidx =~ /[16]$/) { }
$board = int($board/5); elsif ( $comidx =~ /[16]$/ ) {
$port = 25; $board = int( $board / 5 );
} elsif ($comidx =~ /[27]$/) { $port = 25;
$board = int($board/5); }
$port = 26; elsif ( $comidx =~ /[27]$/ ) {
} $board = int( $board / 5 );
} $port = 26;
}
}
my $index = ($board*256)+$port; my $index = ( $board * 256 ) + $port;
$fw_port{$iid} = $index; $fw_port{$iid} = $index;
} }
return \%fw_port; return \%fw_port;
} }
@@ -369,7 +378,6 @@ sub slot_offset {
return 0; return 0;
} }
# Devices do not support ENTITY-MIB use proprietary methods. # Devices do not support ENTITY-MIB use proprietary methods.
sub e_index { sub e_index {

View File

@@ -34,45 +34,46 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer1; use SNMP::Info::Layer1;
@SNMP::Info::Layer1::Cyclades::ISA = qw/SNMP::Info::Layer1 Exporter/; @SNMP::Info::Layer1::Cyclades::ISA = qw/SNMP::Info::Layer1 Exporter/;
@SNMP::Info::Layer1::Cyclades::EXPORT_OK = qw//; @SNMP::Info::Layer1::Cyclades::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer1::MIBS, %SNMP::Info::Layer1::MIBS,
'CYCLADES-ACS-SYS-MIB' => 'cyACSversion', 'CYCLADES-ACS-SYS-MIB' => 'cyACSversion',
'CYCLADES-ACS-CONF-MIB' => 'cyEthIPaddr', 'CYCLADES-ACS-CONF-MIB' => 'cyEthIPaddr',
'CYCLADES-ACS-INFO-MIB' => 'cyISPortTty', 'CYCLADES-ACS-INFO-MIB' => 'cyISPortTty',
); );
%GLOBALS = ( %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 = ( # CYCLADES-ACS-SYS-MIB
%SNMP::Info::Layer1::FUNCS, %SNMP::Info::Layer1::GLOBALS,
# CYCLADES-ACS-INFO-MIB::cyInfoSerialTable 'os_ver' => 'cyACSversion',
'cy_port_tty' => 'cyISPortTty', 'cy_model' => 'cyACSpname',
'cy_port_name' => 'cyISPortName', 'serial' => 'cyACSDevId',
'cy_port_speed' => 'cyISPortSpeed', 'root_ip' => 'cyEthIPaddr',
'cy_port_cd' => 'cyISPortSigCD', 'ps1_status' => 'cyACSPw1',
# CYCLADES-ACS-CONF-MIB::cySerialPortTable 'ps2_status' => 'cyACSPw2',
'cy_port_socket' => 'cySPortSocketPort', );
);
%MUNGE = ( %FUNCS = (
%SNMP::Info::Layer1::MUNGE, %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 # These devices don't have a FDB and we probably don't want to poll for ARP
# cache so turn off reported L2/L3. # cache so turn off reported L2/L3.
@@ -108,10 +109,10 @@ sub i_index {
my $partial = shift; my $partial = shift;
my $orig_index = $cyclades->orig_i_index($partial) || {}; my $orig_index = $cyclades->orig_i_index($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {}; my $cy_index = $cyclades->cy_port_socket() || {};
my %i_index; my %i_index;
foreach my $iid (keys %$orig_index){ foreach my $iid ( keys %$orig_index ) {
my $index = $orig_index->{$iid}; my $index = $orig_index->{$iid};
next unless defined $index; next unless defined $index;
@@ -120,10 +121,10 @@ sub i_index {
# Use alternative labeling system for the serial port, listening socket # Use alternative labeling system for the serial port, listening socket
# to avoid conflicts with ifIndex. # to avoid conflicts with ifIndex.
foreach my $iid (keys %$cy_index){ foreach my $iid ( keys %$cy_index ) {
my $index = $cy_index->{$iid}; my $index = $cy_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
$i_index{$index} = $index; $i_index{$index} = $index;
} }
@@ -135,22 +136,22 @@ sub interfaces {
my $cyclades = shift; my $cyclades = shift;
my $partial = shift; my $partial = shift;
my $i_descr = $cyclades->orig_i_description($partial) || {}; my $i_descr = $cyclades->orig_i_description($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {}; my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_tty = $cyclades->cy_port_tty() || {}; my $cy_p_tty = $cyclades->cy_port_tty() || {};
my %if; my %if;
foreach my $iid (keys %$i_descr){ foreach my $iid ( keys %$i_descr ) {
my $descr = $i_descr->{$iid}; my $descr = $i_descr->{$iid};
next unless defined $descr; next unless defined $descr;
$if{$iid} = $descr; $if{$iid} = $descr;
} }
foreach my $iid (keys %$cy_p_tty){ foreach my $iid ( keys %$cy_p_tty ) {
my $index = $cy_index->{$iid}; my $index = $cy_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $name = $cy_p_tty->{$iid}; my $name = $cy_p_tty->{$iid};
next unless defined $name; next unless defined $name;
@@ -164,22 +165,22 @@ sub i_speed {
my $cyclades = shift; my $cyclades = shift;
my $partial = shift; my $partial = shift;
my $i_speed = $cyclades->orig_i_speed($partial) || {}; my $i_speed = $cyclades->orig_i_speed($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {}; my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_speed = $cyclades->cy_port_speed() || {}; my $cy_p_speed = $cyclades->cy_port_speed() || {};
my %i_speed; my %i_speed;
foreach my $iid (keys %$i_speed){ foreach my $iid ( keys %$i_speed ) {
my $speed = $i_speed->{$iid}; my $speed = $i_speed->{$iid};
next unless defined $speed; next unless defined $speed;
$i_speed{$iid} = $speed; $i_speed{$iid} = $speed;
} }
foreach my $iid (keys %$cy_p_speed){ foreach my $iid ( keys %$cy_p_speed ) {
my $index = $cy_index->{$iid}; my $index = $cy_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $speed = $cy_p_speed->{$iid}; my $speed = $cy_p_speed->{$iid};
next unless defined $speed; next unless defined $speed;
@@ -194,21 +195,21 @@ sub i_up {
my $partial = shift; my $partial = shift;
my $i_up = $cyclades->orig_i_up($partial) || {}; my $i_up = $cyclades->orig_i_up($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {}; my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_up = $cyclades->cy_port_cd() || {}; my $cy_p_up = $cyclades->cy_port_cd() || {};
my %i_up; my %i_up;
foreach my $iid (keys %$i_up){ foreach my $iid ( keys %$i_up ) {
my $up = $i_up->{$iid}; my $up = $i_up->{$iid};
next unless defined $up; next unless defined $up;
$i_up{$iid} = $up; $i_up{$iid} = $up;
} }
foreach my $iid (keys %$cy_p_up){ foreach my $iid ( keys %$cy_p_up ) {
my $index = $cy_index->{$iid}; my $index = $cy_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $up = $cy_p_up->{$iid}; my $up = $cy_p_up->{$iid};
next unless defined $up; next unless defined $up;
@@ -223,21 +224,21 @@ sub i_description {
my $partial = shift; my $partial = shift;
my $i_desc = $cyclades->orig_i_description($partial) || {}; my $i_desc = $cyclades->orig_i_description($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {}; my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_desc = $cyclades->cy_port_name() || {}; my $cy_p_desc = $cyclades->cy_port_name() || {};
my %descr; my %descr;
foreach my $iid (keys %$i_desc){ foreach my $iid ( keys %$i_desc ) {
my $desc = $i_desc->{$iid}; my $desc = $i_desc->{$iid};
next unless defined $desc; next unless defined $desc;
$descr{$iid} = $desc; $descr{$iid} = $desc;
} }
foreach my $iid (keys %$cy_p_desc){ foreach my $iid ( keys %$cy_p_desc ) {
my $index = $cy_index->{$iid}; my $index = $cy_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $desc = $cy_p_desc->{$iid}; my $desc = $cy_p_desc->{$iid};
next unless defined $desc; next unless defined $desc;
@@ -252,21 +253,21 @@ sub i_name {
my $partial = shift; my $partial = shift;
my $i_name = $cyclades->orig_i_name($partial) || {}; my $i_name = $cyclades->orig_i_name($partial) || {};
my $cy_index = $cyclades->cy_port_socket() || {}; my $cy_index = $cyclades->cy_port_socket() || {};
my $cy_p_desc = $cyclades->cy_port_name() || {}; my $cy_p_desc = $cyclades->cy_port_name() || {};
my %i_name; my %i_name;
foreach my $iid (keys %$i_name){ foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid}; my $name = $i_name->{$iid};
next unless defined $name; next unless defined $name;
$i_name{$iid} = $name; $i_name{$iid} = $name;
} }
foreach my $iid (keys %$cy_p_desc){ foreach my $iid ( keys %$cy_p_desc ) {
my $index = $cy_index->{$iid}; my $index = $cy_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $name = $cy_p_desc->{$iid}; my $name = $cy_p_desc->{$iid};
next unless defined $name; next unless defined $name;
@@ -373,8 +374,8 @@ These are methods that return scalar value from SNMP
=item $cyclades->layers() =item $cyclades->layers()
Returns 01000001. These devices don't have a FDB and we probably don't want to Returns 01000001. These devices don't have a FDB and we probably don't want
poll for an ARP cache so turn off reported Layer 2 and Layer 3. to poll for an ARP cache so turn off reported Layer 2 and Layer 3.
=item $cyclades->vendor() =item $cyclades->vendor()

View File

@@ -34,48 +34,51 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer2; 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//; @SNMP::Info::Layer1::S3000::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable', 'SYNOPTICS-ETHERNET-MIB' => 's3EnetPortTable',
'SYNOPTICS-COMMON-MIB' => 's3AgentType', 'SYNOPTICS-COMMON-MIB' => 's3AgentType',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::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 = ( # From SYNOPTICS-COMMON-MIB
%SNMP::Info::Layer2::FUNCS, 'os_bin' => 's3AgentFwVer',
# SYNOPTICS-ETHERNET-MIB::s3EnetPortTable 's3000_major_ver' => 's3AgentSwMajorVer',
's3000_pb_index' => 's3EnetPortBoardIndex', 's3000_minor_ver' => 's3AgentSwMinorVer',
's3000_pp_index' => 's3EnetPortIndex', 's3000_maint_ver' => 's3AgentSwMaintVer',
'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 = ( %FUNCS = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::FUNCS,
's3000_topo_mac' => \&SNMP::Info::munge_mac
); # 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 { sub layers {
return '00000011'; return '00000011';
@@ -91,37 +94,38 @@ sub vendor {
sub model { sub model {
my $s3000 = shift; my $s3000 = shift;
my $id = $s3000->id(); my $id = $s3000->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
$model =~ s/^s3reg-//i; $model =~ s/^s3reg-//i;
return $1 if ($model =~ /((\d+){3}[\dX])/); return $1 if ( $model =~ /((\d+){3}[\dX])/ );
return $model; return $model;
} }
sub os_ver { sub os_ver {
my $s3000 = shift; my $s3000 = shift;
my $major_ver = $s3000->s3000_major_ver() || 0; my $major_ver = $s3000->s3000_major_ver() || 0;
my $minor_ver = $s3000->s3000_minor_ver() || 0; my $minor_ver = $s3000->s3000_minor_ver() || 0;
my $maint_ver = $s3000->s3000_maint_ver() || 0; my $maint_ver = $s3000->s3000_maint_ver() || 0;
my $ver = "$major_ver.$minor_ver.$maint_ver"; my $ver = "$major_ver.$minor_ver.$maint_ver";
return $ver; return $ver;
} }
sub mac { sub mac {
my $s3000 = shift; my $s3000 = shift;
my $topo_port = $s3000->s3000_topo_port(); my $topo_port = $s3000->s3000_topo_port();
my $topo_mac = $s3000->s3000_topo_mac(); my $topo_mac = $s3000->s3000_topo_mac();
foreach my $entry (keys %$topo_port){ foreach my $entry ( keys %$topo_port ) {
my $port = $topo_port->{$entry}; my $port = $topo_port->{$entry};
next unless $port == 0; next unless $port == 0;
my $mac = $topo_mac->{$entry}; my $mac = $topo_mac->{$entry};
return $mac; return $mac;
} }
# Topology turned off, not supported. # Topology turned off, not supported.
return; return;
} }
@@ -130,20 +134,20 @@ sub mac {
# and port status # and port status
sub i_index { sub i_index {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $b_index = $s3000->s3000_pb_index($partial) || {}; my $b_index = $s3000->s3000_pb_index($partial) || {};
my $p_index = $s3000->s3000_pp_index($partial) || {}; my $p_index = $s3000->s3000_pp_index($partial) || {};
my %i_index; my %i_index;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid}; my $board = $b_index->{$iid};
next unless defined $board; 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. # 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; $i_index{$iid} = $index;
} }
@@ -154,20 +158,20 @@ sub i_index {
# for consistency # for consistency
sub interfaces { sub interfaces {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $i_index = $s3000->i_index() || {}; my $i_index = $s3000->i_index() || {};
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; 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() # Index numbers are deterministic slot * 256 + port - see i_index()
my $port = $index % 256; my $port = $index % 256;
my $slot = int($index / 256); my $slot = int( $index / 256 );
my $slotport = "$slot.$port"; my $slotport = "$slot.$port";
@@ -178,113 +182,114 @@ sub interfaces {
} }
sub i_duplex { sub i_duplex {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $port_index = $s3000->i_index() || {}; my $port_index = $s3000->i_index() || {};
my %i_duplex; my %i_duplex;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; 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'; my $duplex = 'half';
$i_duplex{$index}=$duplex; $i_duplex{$index} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
sub i_duplex_admin { sub i_duplex_admin {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $port_index = $s3000->i_index() || {}; my $port_index = $s3000->i_index() || {};
my %i_duplex_admin; my %i_duplex_admin;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; 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'; my $duplex = 'half';
$i_duplex_admin{$index}=$duplex; $i_duplex_admin{$index} = $duplex;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
sub i_speed { sub i_speed {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $port_index = $s3000->i_index() || {}; my $port_index = $s3000->i_index() || {};
my %i_speed; my %i_speed;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; 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'; my $speed = '10000000';
$i_speed{$index}=$speed; $i_speed{$index} = $speed;
} }
return \%i_speed; return \%i_speed;
} }
sub i_up { sub i_up {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $port_index = $s3000->i_index() || {}; my $port_index = $s3000->i_index() || {};
my $link_stat = $s3000->s3000_up() || {}; my $link_stat = $s3000->s3000_up() || {};
my %i_up; my %i_up;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid}; my $link_stat = $link_stat->{$iid};
next unless defined $link_stat; 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; $link_stat = 'down' if $link_stat =~ /off/i;
$i_up{$index}=$link_stat; $i_up{$index} = $link_stat;
} }
return \%i_up; return \%i_up;
} }
sub i_up_admin { sub i_up_admin {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $i_index = $s3000->i_index() || {}; my $i_index = $s3000->i_index() || {};
my $link_stat = $s3000->s3000_up_admin() || {}; my $link_stat = $s3000->s3000_up_admin() || {};
my %i_up_admin; my %i_up_admin;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
my $link_stat = $link_stat->{$iid}; my $link_stat = $link_stat->{$iid};
next unless defined $link_stat; next unless defined $link_stat;
$i_up_admin{$index}=$link_stat; $i_up_admin{$index} = $link_stat;
} }
return \%i_up_admin; return \%i_up_admin;
} }
sub set_i_up_admin { sub set_i_up_admin {
# map setting to those the hub will understand # map setting to those the hub will understand
my %setting = qw/up 2 down 3/; my %setting = qw/up 2 down 3/;
my $s3000 = shift; 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; my %reverse_i_index = reverse %$i_index;
$setting = lc($setting); $setting = lc($setting);
@@ -293,26 +298,26 @@ sub set_i_up_admin {
$iid = $reverse_i_index{$iid}; $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 # Hubs do not support the standard Bridge MIB
sub bp_index { sub bp_index {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $b_index = $s3000->s3000_nb_index() || {}; my $b_index = $s3000->s3000_nb_index() || {};
my $p_index = $s3000->s3000_np_index() || {}; my $p_index = $s3000->s3000_np_index() || {};
my $model = $s3000->model(); my $model = $s3000->model();
my %bp_index; my %bp_index;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid}; my $board = $b_index->{$iid};
next unless defined $board; 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;
next if (defined $partial and $index !~ /^$partial$/); next if ( defined $partial and $index !~ /^$partial$/ );
$bp_index{$index} = $index; $bp_index{$index} = $index;
} }
@@ -320,22 +325,22 @@ sub bp_index {
} }
sub fw_port { sub fw_port {
my $s3000 = shift; my $s3000 = shift;
my $partial = shift; my $partial = shift;
my $b_index = $s3000->s3000_nb_index($partial) || {}; my $b_index = $s3000->s3000_nb_index($partial) || {};
my $p_index = $s3000->s3000_np_index($partial) || {}; my $p_index = $s3000->s3000_np_index($partial) || {};
my $model = $s3000->model(); my $model = $s3000->model();
my %fw_port; my %fw_port;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $board = $b_index->{$iid}; my $board = $b_index->{$iid};
next unless defined $board; 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; return \%fw_port;
} }
@@ -489,7 +494,8 @@ Returns 10000000. The hubs only support 10 Mbs Ethernet.
=item $s3000->i_up() =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() =item $s3000->i_up_admin()
@@ -522,7 +528,8 @@ C<SYNOPTICS-ETHERNET-MIB::s3EnetShowNodesTable> to the Interface index.
=item $s3000->s3000_topo_port() =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>) (C<s3EnetTopNmmPort>)

View File

@@ -39,49 +39,49 @@ use SNMP::Info::Bridge;
use SNMP::Info::Entity; use SNMP::Info::Entity;
use SNMP::Info::PowerEthernet; use SNMP::Info::PowerEthernet;
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity SNMP::Info::PowerEthernet Exporter/; @SNMP::Info::Layer2::ISA
= qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::Entity SNMP::Info::PowerEthernet Exporter/;
@SNMP::Info::Layer2::EXPORT_OK = qw//; @SNMP::Info::Layer2::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::MIBS, %MIBS = (
%SNMP::Info::Bridge::MIBS, %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::Entity::MIBS, %SNMP::Info::Entity::MIBS, %SNMP::Info::PowerEthernet::MIBS,
%SNMP::Info::PowerEthernet::MIBS, );
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Entity::GLOBALS, %SNMP::Info::Entity::GLOBALS,
%SNMP::Info::PowerEthernet::GLOBALS, %SNMP::Info::PowerEthernet::GLOBALS,
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0 'serial1' =>
); '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Bridge::FUNCS, %SNMP::Info::Entity::FUNCS, %SNMP::Info::PowerEthernet::FUNCS,
%SNMP::Info::Entity::FUNCS, );
%SNMP::Info::PowerEthernet::FUNCS,
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE, # Inherit all the built in munging
%SNMP::Info::Bridge::MUNGE, %SNMP::Info::MUNGE,
%SNMP::Info::Entity::MUNGE, %SNMP::Info::Bridge::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE, %SNMP::Info::Entity::MUNGE,
); %SNMP::Info::PowerEthernet::MUNGE,
);
# Method OverRides # Method OverRides
# $l2->model() - Looks at sysObjectID which gives the oid of the system # $l2->model() - Looks at sysObjectID which gives the oid of the system
# name, contained in a propriatry MIB. # name, contained in a propriatry MIB.
sub model { sub model {
my $l2 = shift; my $l2 = shift;
my $id = $l2->id(); my $id = $l2->id();
my $model = &SNMP::translateObj($id) || $id || ''; my $model = &SNMP::translateObj($id) || $id || '';
# HP # HP
@@ -96,15 +96,15 @@ sub model {
} }
sub vendor { sub vendor {
my $l2 = shift; my $l2 = shift;
my $model = $l2->model(); my $model = $l2->model();
my $descr = $l2->description(); my $descr = $l2->description();
if ($model =~ /hp/i or $descr =~ /\bhp\b/i) { if ( $model =~ /hp/i or $descr =~ /\bhp\b/i ) {
return 'hp'; return 'hp';
} }
if ($model =~ /catalyst/i or $descr =~ /(catalyst|cisco)/i) { if ( $model =~ /catalyst/i or $descr =~ /(catalyst|cisco)/i ) {
return 'cisco'; return 'cisco';
} }
@@ -113,31 +113,32 @@ sub vendor {
sub serial { sub serial {
my $l2 = shift; my $l2 = shift;
my $serial1 = $l2->serial1(); my $serial1 = $l2->serial1();
my $e_descr = $l2->e_descr() || {}; my $e_descr = $l2->e_descr() || {};
my $e_serial = $l2->e_serial() || {}; my $e_serial = $l2->e_serial() || {};
my $serial2 = $e_serial->{1} || undef; my $serial2 = $e_serial->{1} || undef;
my $chassis = $e_descr->{1} || undef; my $chassis = $e_descr->{1} || undef;
# precedence # precedence
# serial2,chassis parse,serial1 # serial2,chassis parse,serial1
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/); return $serial2 if ( defined $serial2 and $serial2 !~ /^\s*$/ );
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i); return $1
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/); if ( defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i );
return $serial1 if ( defined $serial1 and $serial1 !~ /^\s*$/ );
return; return;
} }
sub i_ignore { sub i_ignore {
my $l2 = shift; my $l2 = shift;
my $partial = shift; my $partial = shift;
my $i_type = $l2->i_type($partial) || {}; my $i_type = $l2->i_type($partial) || {};
my %i_ignore = (); my %i_ignore = ();
foreach my $if (keys %$i_type){ foreach my $if ( keys %$i_type ) {
my $type = $i_type->{$if}; my $type = $i_type->{$if};
$i_ignore{$if}++ $i_ignore{$if}++
if $type =~ /(loopback|other|cpu)/i; if $type =~ /(loopback|other|cpu)/i;
@@ -147,14 +148,14 @@ sub i_ignore {
} }
sub interfaces { sub interfaces {
my $l2 = shift; my $l2 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l2->i_index($partial) || {}; my $interfaces = $l2->i_index($partial) || {};
my $i_descr = $l2->i_description($partial) || {}; my $i_descr = $l2->i_description($partial) || {};
# Replace the Index with the ifDescr field. # Replace the Index with the ifDescr field.
foreach my $iid (keys %$i_descr){ foreach my $iid ( keys %$i_descr ) {
my $port = $i_descr->{$iid}; my $port = $i_descr->{$iid};
next unless defined $port; next unless defined $port;
$interfaces->{$iid} = $port; $interfaces->{$iid} = $port;
@@ -287,7 +288,8 @@ to a hash.
=item $l2->interfaces() =item $l2->interfaces()
Creates a map between the interface identifier (iid) and the physical port name. Creates a map between the interface identifier (iid) and the physical port
name.
Defaults to C<ifDescr> but checks and overrides with C<ifName> Defaults to C<ifDescr> but checks and overrides with C<ifName>

View File

@@ -35,40 +35,33 @@ use SNMP::Info::Bridge;
use SNMP::Info::CDP; use SNMP::Info::CDP;
use SNMP::Info::Airespace; use SNMP::Info::Airespace;
@SNMP::Info::Layer2::Airespace::ISA = qw/SNMP::Info::Airespace SNMP::Info::CDP SNMP::Info::Bridge Exporter/; @SNMP::Info::Layer2::Airespace::ISA
= qw/SNMP::Info::Airespace SNMP::Info::CDP SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer2::Airespace::EXPORT_OK = qw//; @SNMP::Info::Layer2::Airespace::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::Bridge::MIBS, %SNMP::Info::CDP::MIBS, %SNMP::Info::Airespace::MIBS,
%SNMP::Info::CDP::MIBS, );
%SNMP::Info::Airespace::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Bridge::GLOBALS, %SNMP::Info::CDP::GLOBALS, %SNMP::Info::Airespace::GLOBALS,
%SNMP::Info::CDP::GLOBALS, );
%SNMP::Info::Airespace::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Bridge::FUNCS, %SNMP::Info::CDP::FUNCS, %SNMP::Info::Airespace::FUNCS,
%SNMP::Info::CDP::FUNCS, );
%SNMP::Info::Airespace::FUNCS,
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::MUNGE, %SNMP::Info::MUNGE, %SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Bridge::MUNGE, %SNMP::Info::CDP::MUNGE, %SNMP::Info::Airespace::MUNGE,
%SNMP::Info::CDP::MUNGE, );
%SNMP::Info::Airespace::MUNGE,
);
sub os { sub os {
return 'cisco'; return 'cisco';
@@ -80,7 +73,7 @@ sub vendor {
sub model { sub model {
my $airespace = shift; my $airespace = shift;
my $model = $airespace->airespace_model(); my $model = $airespace->airespace_model();
return unless defined $model; return unless defined $model;
return $model; return $model;

View File

@@ -41,8 +41,9 @@ use SNMP::Info::CiscoStats;
use SNMP::Info::CDP; use SNMP::Info::CDP;
use SNMP::Info::IEEE802dot11; use SNMP::Info::IEEE802dot11;
@SNMP::Info::Layer2::Aironet::ISA = qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike @SNMP::Info::Layer2::Aironet::ISA
SNMP::Info::CiscoStats SNMP::Info::CDP Exporter/; = qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike
SNMP::Info::CiscoStats SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::Aironet::EXPORT_OK = qw//; @SNMP::Info::Layer2::Aironet::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -50,68 +51,69 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::IEEE802dot11::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS,
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::Entity::GLOBALS, %SNMP::Info::Entity::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS, %SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
'serial' => 'entPhysicalSerialNum.1', 'serial' => 'entPhysicalSerialNum.1',
'descr' => 'sysDescr' 'descr' => 'sysDescr'
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::IEEE802dot11::FUNCS, %SNMP::Info::IEEE802dot11::FUNCS,
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
%SNMP::Info::Entity::FUNCS, %SNMP::Info::Entity::FUNCS,
%SNMP::Info::EtherLike::FUNCS, %SNMP::Info::EtherLike::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CDP::FUNCS,
'i_ssidlist' => 'cd11IfAuxSsid', 'i_ssidlist' => 'cd11IfAuxSsid',
'i_ssidbcast' => 'cd11IfAuxSsidBroadcastSsid', 'i_ssidbcast' => 'cd11IfAuxSsidBroadcastSsid',
'i_80211channel' => 'cd11IfPhyDsssCurrentChannel', 'i_80211channel' => 'cd11IfPhyDsssCurrentChannel',
'c_dot11subif' => 'cDot11ClientSubIfIndex', 'c_dot11subif' => 'cDot11ClientSubIfIndex',
'cd11_txrate' => 'cDot11ClientCurrentTxRateSet', 'cd11_txrate' => 'cDot11ClientCurrentTxRateSet',
'cd11_uptime' => 'cDot11ClientUpTime', 'cd11_uptime' => 'cDot11ClientUpTime',
'cd11_sigstrength' => 'cDot11ClientSignalStrength', 'cd11_sigstrength' => 'cDot11ClientSignalStrength',
'cd11_sigqual' => 'cDot11ClientSigQuality', 'cd11_sigqual' => 'cDot11ClientSigQuality',
'cd11_rxpkt' => 'cDot11ClientPacketsReceived', 'cd11_rxpkt' => 'cDot11ClientPacketsReceived',
'cd11_txpkt' => 'cDot11ClientPacketsSent', 'cd11_txpkt' => 'cDot11ClientPacketsSent',
'cd11_rxbyte' => 'cDot11ClientBytesReceived', 'cd11_rxbyte' => 'cDot11ClientBytesReceived',
'cd11_txbyte' => 'cDot11ClientBytesSent', 'cd11_txbyte' => 'cDot11ClientBytesSent',
'mbss_mac_addr' => 'cdot11MbssidIfMacAddress', 'mbss_mac_addr' => 'cdot11MbssidIfMacAddress',
); );
%MIBS = ( %MIBS = (
%SNMP::Info::IEEE802dot11::MIBS, %SNMP::Info::IEEE802dot11::MIBS,
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
%SNMP::Info::Entity::MIBS, %SNMP::Info::Entity::MIBS,
%SNMP::Info::EtherLike::MIBS, %SNMP::Info::EtherLike::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::CDP::MIBS,
'CISCO-DOT11-IF-MIB' => 'cd11IfAuxSsid', 'CISCO-DOT11-IF-MIB' => 'cd11IfAuxSsid',
'CISCO-DOT11-ASSOCIATION-MIB' => 'cDot11ClientSubIfIndex', 'CISCO-DOT11-ASSOCIATION-MIB' => 'cDot11ClientSubIfIndex',
'CISCO-DOT11-SSID-SECURITY-MIB' => 'cdot11SecVlanNameId', 'CISCO-DOT11-SSID-SECURITY-MIB' => 'cdot11SecVlanNameId',
'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex', 'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex',
); );
%MUNGE = ( %MUNGE = (
%SNMP::Info::IEEE802dot11::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE,
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::MUNGE,
%SNMP::Info::Entity::MUNGE, %SNMP::Info::Entity::MUNGE,
%SNMP::Info::EtherLike::MUNGE, %SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::CDP::MUNGE,
'cd11_txrate' => \&munge_cd11_txrate, 'cd11_txrate' => \&munge_cd11_txrate,
'mbss_mac_addr' => \&SNMP::Info::munge_mac, 'mbss_mac_addr' => \&SNMP::Info::munge_mac,
); );
# Use 802.11 power level without putting IEEE802dot11 in @ISA # Use 802.11 power level without putting IEEE802dot11 in @ISA
*SNMP::Info::Layer2::Aironet::dot11_cur_tx_pwr_mw = *SNMP::Info::Layer2::Aironet::dot11_cur_tx_pwr_mw
\&SNMP::Info::IEEE802dot11::dot11_cur_tx_pwr_mw; = \&SNMP::Info::IEEE802dot11::dot11_cur_tx_pwr_mw;
sub vendor { sub vendor {
# Sorry, but it's true. # Sorry, but it's true.
return 'cisco'; return 'cisco';
} }
@@ -128,7 +130,7 @@ sub interfaces {
# Tag on e_descr.1 # Tag on e_descr.1
sub description { sub description {
my $aironet = shift; my $aironet = shift;
my $descr = $aironet->descr(); my $descr = $aironet->descr();
my $e_descr = $aironet->e_descr(); my $e_descr = $aironet->e_descr();
$descr = "$e_descr->{1} $descr" if defined $e_descr->{1}; $descr = "$e_descr->{1} $descr" if defined $e_descr->{1};
@@ -144,7 +146,7 @@ sub i_duplex {
my $el_duplex = $aironet->el_duplex($partial); my $el_duplex = $aironet->el_duplex($partial);
my %i_duplex; my %i_duplex;
foreach my $d (keys %$el_duplex){ foreach my $d ( keys %$el_duplex ) {
my $val = $el_duplex->{$d}; my $val = $el_duplex->{$d};
next unless defined $val; next unless defined $val;
$i_duplex{$d} = 'full' if $val =~ /full/i; $i_duplex{$d} = 'full' if $val =~ /full/i;
@@ -162,9 +164,12 @@ sub i_duplex {
# Q-BRIDGE-MIB dot1qTpFdbTable but that was removed in 12.3. # Q-BRIDGE-MIB dot1qTpFdbTable but that was removed in 12.3.
sub _aironet_special { sub _aironet_special {
my $aironet = shift; my $aironet = shift;
my $os_ver = $aironet->os_ver(); my $os_ver = $aironet->os_ver();
if (defined($os_ver) && $os_ver =~ /^(\d+)\.(\d+)(\D|$)/ && (($1 == 12 && $2 >= 3) || $1 > 12)) { if ( defined($os_ver)
return 1; && $os_ver =~ /^(\d+)\.(\d+)(\D|$)/
&& ( ( $1 == 12 && $2 >= 3 ) || $1 > 12 ) )
{
return 1;
} }
} }
@@ -173,12 +178,12 @@ sub _aironet_special {
sub _aironet_breakout_dot11idx { sub _aironet_breakout_dot11idx {
my $oid = shift; my $oid = shift;
my @parts = split(/\./, $oid); my @parts = split( /\./, $oid );
my $ifindex = shift(@parts); my $ifindex = shift(@parts);
my $ssidlen = shift(@parts); my $ssidlen = shift(@parts);
my $ssid = pack("C*", splice(@parts, 0, $ssidlen)); my $ssid = pack( "C*", splice( @parts, 0, $ssidlen ) );
my $mac = join(":", map {sprintf "%02x", $_} @parts); my $mac = join( ":", map { sprintf "%02x", $_ } @parts );
return ($ifindex, $ssid, $mac); return ( $ifindex, $ssid, $mac );
} }
sub fw_mac { sub fw_mac {
@@ -186,11 +191,11 @@ sub fw_mac {
return qb_fw_mac($aironet) unless _aironet_special($aironet); return qb_fw_mac($aironet) unless _aironet_special($aironet);
my $c_dot11subif = $aironet->c_dot11subif(); my $c_dot11subif = $aironet->c_dot11subif();
my $fw_mac = {}; my $fw_mac = {};
foreach my $i (keys %$c_dot11subif) { foreach my $i ( keys %$c_dot11subif ) {
my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($i); my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i);
$fw_mac->{$i} = $mac; $fw_mac->{$i} = $mac;
} }
return $fw_mac; return $fw_mac;
} }
@@ -200,11 +205,11 @@ sub fw_port {
return $aironet->qb_fw_port() unless _aironet_special($aironet); return $aironet->qb_fw_port() unless _aironet_special($aironet);
my $c_dot11subif = $aironet->c_dot11subif(); my $c_dot11subif = $aironet->c_dot11subif();
my $fw_port = {}; my $fw_port = {};
foreach my $i (keys %$c_dot11subif) { foreach my $i ( keys %$c_dot11subif ) {
my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($i); my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i);
$fw_port->{$i} = $c_dot11subif->{$i} || $ifindex; $fw_port->{$i} = $c_dot11subif->{$i} || $ifindex;
} }
return $fw_port; return $fw_port;
} }
@@ -214,12 +219,12 @@ sub bp_index {
return $aironet->orig_bp_index() unless _aironet_special($aironet); return $aironet->orig_bp_index() unless _aironet_special($aironet);
my $c_dot11subif = $aironet->c_dot11subif(); my $c_dot11subif = $aironet->c_dot11subif();
my $bp_index = {}; my $bp_index = {};
foreach my $i (keys %$c_dot11subif) { foreach my $i ( keys %$c_dot11subif ) {
my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($i); my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($i);
my ($i) = $c_dot11subif->{$i} || $ifindex; my ($i) = $c_dot11subif->{$i} || $ifindex;
$bp_index->{$i} = $i; $bp_index->{$i} = $i;
} }
return $bp_index; return $bp_index;
} }
@@ -231,14 +236,14 @@ sub bp_index {
sub v_name { sub v_name {
my $aironet = shift; my $aironet = shift;
my $v_name = {}; my $v_name = {};
my $vlan_nameid = $aironet->cdot11SecVlanNameId(); my $vlan_nameid = $aironet->cdot11SecVlanNameId();
foreach my $i (keys %$vlan_nameid) { foreach my $i ( keys %$vlan_nameid ) {
my @parts = split(/\./, $i); my @parts = split( /\./, $i );
my $namelen = shift(@parts); my $namelen = shift(@parts);
my $name = pack("C*", @parts); my $name = pack( "C*", @parts );
$v_name->{$i} = $name; $v_name->{$i} = $name;
} }
return $v_name; return $v_name;
} }
@@ -254,9 +259,9 @@ sub i_vlan {
my $i_vlan = {}; my $i_vlan = {};
my $idxmap = $aironet->cviRoutedVlanIfIndex(); my $idxmap = $aironet->cviRoutedVlanIfIndex();
foreach my $i (keys %$idxmap) { foreach my $i ( keys %$idxmap ) {
my @parts = split(/\./, $i); my @parts = split( /\./, $i );
$i_vlan->{$idxmap->{$i}} = $parts[0]; $i_vlan->{ $idxmap->{$i} } = $parts[0];
} }
return $i_vlan; return $i_vlan;
} }
@@ -265,46 +270,46 @@ sub i_vlan {
# 5.5Mbps is reported as 11. # 5.5Mbps is reported as 11.
sub munge_cd11_txrate { sub munge_cd11_txrate {
my $txrates = shift; my $txrates = shift;
my @units = unpack("C*", $txrates); my @units = unpack( "C*", $txrates );
my @rates = map { my @rates = map {
my $unit = $_; my $unit = $_;
$unit *= 0.5; $unit *= 0.5;
} @units; } @units;
return \@rates; return \@rates;
} }
# cd11 INDEX # cd11 INDEX
sub cd11_port { sub cd11_port {
my $aironet = shift; my $aironet = shift;
my $cd11_sigstrength = $aironet->cd11_sigstrength(); my $cd11_sigstrength = $aironet->cd11_sigstrength();
my $interfaces = $aironet->interfaces(); my $interfaces = $aironet->interfaces();
my %ret; my %ret;
foreach (keys %$cd11_sigstrength) { foreach ( keys %$cd11_sigstrength ) {
my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($_); my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_);
$ret{$_} = $interfaces->{$ifindex}; $ret{$_} = $interfaces->{$ifindex};
} }
return \%ret; return \%ret;
} }
sub cd11_ssid { sub cd11_ssid {
my $aironet = shift; my $aironet = shift;
my $cd11_sigstrength = $aironet->cd11_sigstrength(); my $cd11_sigstrength = $aironet->cd11_sigstrength();
my %ret; my %ret;
foreach (keys %$cd11_sigstrength) { foreach ( keys %$cd11_sigstrength ) {
my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($_); my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_);
$ret{$_} = $ssid; $ret{$_} = $ssid;
} }
return \%ret; return \%ret;
} }
sub cd11_mac { sub cd11_mac {
my $aironet = shift; my $aironet = shift;
my $cd11_sigstrength = $aironet->cd11_sigstrength(); my $cd11_sigstrength = $aironet->cd11_sigstrength();
my %ret; my %ret;
foreach (keys %$cd11_sigstrength) { foreach ( keys %$cd11_sigstrength ) {
my ($ifindex, $ssid, $mac) = _aironet_breakout_dot11idx($_); my ( $ifindex, $ssid, $mac ) = _aironet_breakout_dot11idx($_);
$ret{$_} = $mac; $ret{$_} = $mac;
} }
return \%ret; return \%ret;
} }
@@ -316,6 +321,7 @@ sub cd11_mac {
# to get the right overrides. # to get the right overrides.
sub i_mac { sub i_mac {
my $aironet = shift; my $aironet = shift;
# no partial is possible due to the levels # no partial is possible due to the levels
# of indirection. # of indirection.
@@ -323,41 +329,40 @@ sub i_mac {
my $mbss_mac = $aironet->orig_i_mac(); my $mbss_mac = $aironet->orig_i_mac();
my $mbss_mac_addr = $aironet->mbss_mac_addr(); my $mbss_mac_addr = $aironet->mbss_mac_addr();
my $ssid_vlan = $aironet->cdot11SecAuxSsidVlan(); my $ssid_vlan = $aironet->cdot11SecAuxSsidVlan();
my $vlan_map = $aironet->cviRoutedVlanIfIndex(); my $vlan_map = $aironet->cviRoutedVlanIfIndex();
my $ifstack = $aironet->ifStackStatus(); my $ifstack = $aironet->ifStackStatus();
my $vlan_list = {}; my $vlan_list = {};
foreach my $idx (keys %$vlan_map) { foreach my $idx ( keys %$vlan_map ) {
my ($vlan, $num) = split(/\./, $idx); my ( $vlan, $num ) = split( /\./, $idx );
push(@{$vlan_list->{$vlan}}, $vlan_map->{$idx}); push( @{ $vlan_list->{$vlan} }, $vlan_map->{$idx} );
} }
my $stack = {}; my $stack = {};
foreach my $idx (keys %$ifstack) { foreach my $idx ( keys %$ifstack ) {
my ($upper, $lower) = split(/\./, $idx); my ( $upper, $lower ) = split( /\./, $idx );
$stack->{$upper}->{$lower} = $ifstack->{$idx}; $stack->{$upper}->{$lower} = $ifstack->{$idx};
} }
# mbss_mac_addr index is (radio, ssid). # mbss_mac_addr index is (radio, ssid).
# ssid_vlan maps ssid->vlan. # ssid_vlan maps ssid->vlan.
# vlan_map maps vlan->[list of interfaces] # vlan_map maps vlan->[list of interfaces]
# ifstack allows us to pick the right interface # ifstack allows us to pick the right interface
foreach my $idx (keys %$mbss_mac_addr) { foreach my $idx ( keys %$mbss_mac_addr ) {
my ($interface, @ssid) = split(/\./, $idx); my ( $interface, @ssid ) = split( /\./, $idx );
my $vlan = $ssid_vlan->{join(".", scalar(@ssid), @ssid)}; my $vlan = $ssid_vlan->{ join( ".", scalar(@ssid), @ssid ) };
next unless defined($vlan); next unless defined($vlan);
foreach my $vlanif (@{$vlan_list->{$vlan}}) { foreach my $vlanif ( @{ $vlan_list->{$vlan} } ) {
if (defined($stack->{$vlanif}->{$interface})) { if ( defined( $stack->{$vlanif}->{$interface} ) ) {
$mbss_mac->{$vlanif} = $mbss_mac_addr->{$idx}; $mbss_mac->{$vlanif} = $mbss_mac_addr->{$idx};
} }
} }
} }
return $mbss_mac; return $mbss_mac;
} }
1; 1;
__END__ __END__

View File

@@ -35,32 +35,28 @@ use Exporter;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
use SNMP::Info::Layer1; use SNMP::Info::Layer1;
@SNMP::Info::Layer2::Allied::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Allied::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Allied::EXPORT_OK = qw//; @SNMP::Info::Layer2::Allied::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS );
%SNMP::Info::Layer2::GLOBALS
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
'ip_adresses'=> 'atNetAddress', 'ip_adresses' => 'atNetAddress',
'ip_mac' => 'atPhysAddress', 'ip_mac' => 'atPhysAddress',
); );
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
'AtiSwitch-MIB' => 'atiswitchProductType', 'AtiSwitch-MIB' => 'atiswitchProductType',
'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking', 'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking',
); );
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer2::MUNGE, );
%SNMP::Info::Layer2::MUNGE,
);
sub vendor { sub vendor {
return 'allied'; return 'allied';
@@ -72,9 +68,9 @@ sub os {
sub os_ver { sub os_ver {
my $allied = shift; my $allied = shift;
my $descr = $allied->description(); my $descr = $allied->description();
if ($descr =~ m/version (\d+\.\d+)/){ if ( $descr =~ m/version (\d+\.\d+)/ ) {
return $1; return $1;
} }
} }
@@ -84,46 +80,46 @@ sub model {
my $desc = $allied->description(); my $desc = $allied->description();
if ($desc =~ /(AT-80\d{2}\S*)/){ if ( $desc =~ /(AT-80\d{2}\S*)/ ) {
return $1; return $1;
} }
return; return;
} }
sub root_ip { sub root_ip {
my $allied = shift; my $allied = shift;
my $ip_hash = $allied->ip_addresses(); my $ip_hash = $allied->ip_addresses();
my $found_ip; my $found_ip;
foreach my $ip (values %{$ip_hash}) { foreach my $ip ( values %{$ip_hash} ) {
$found_ip = SNMP::Info::munge_ip($ip) if (defined $ip); $found_ip = SNMP::Info::munge_ip($ip) if ( defined $ip );
last; # this is only one IP address last; # this is only one IP address
} }
return $found_ip; return $found_ip;
} }
sub mac{ sub mac {
my $allied = shift; my $allied = shift;
my $mac_hash = $allied->ip_mac(); my $mac_hash = $allied->ip_mac();
my $found_mac; my $found_mac;
foreach my $mac (values %{$mac_hash}) { foreach my $mac ( values %{$mac_hash} ) {
$found_mac = SNMP::Info::munge_mac($mac); $found_mac = SNMP::Info::munge_mac($mac);
last; # this is only one MAC address last; # this is only one MAC address
} }
return $found_mac; return $found_mac;
} }
sub i_up { sub i_up {
my $allied = shift; my $allied = shift;
my $partial = shift; my $partial = shift;
my $i_up = SNMP::Info::Layer1::i_up($allied, $partial); my $i_up = SNMP::Info::Layer1::i_up( $allied, $partial );
foreach my $port (keys %$i_up){ foreach my $port ( keys %$i_up ) {
my $up = $i_up->{$port}; my $up = $i_up->{$port};
$i_up->{$port} = 'down' if $up eq 'linktesterror'; $i_up->{$port} = 'down' if $up eq 'linktesterror';
$i_up->{$port} = 'up' if $up eq 'nolinktesterror'; $i_up->{$port} = 'up' if $up eq 'nolinktesterror';
} }
return $i_up; return $i_up;

View File

@@ -34,48 +34,47 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Aruba::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Aruba::EXPORT_OK = qw//; @SNMP::Info::Layer2::Aruba::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
'WLSX-SWITCH-MIB' => 'wlsxHostname', 'WLSX-SWITCH-MIB' => 'wlsxHostname',
'WLSR-AP-MIB' => 'wlsrHideSSID', 'WLSR-AP-MIB' => 'wlsrHideSSID',
); );
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, );
%SNMP::Info::Layer2::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
# WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable
# Table index leafs do not return information
# therefore unable to use apBSSID. We extract
# the information from the IID instead.
'aruba_ap_name' => 'apLocation',
'aruba_ap_ip' => 'apIpAddress',
'aruba_ap_essid' => 'apESSID',
'aruba_ap_ssidbcast' => 'wlsrHideSSID',
# WLSR-AP-MIB::wlsrConfigTable
'aruba_ap_channel' => 'apCurrentChannel',
# WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable
# Table index leafs do not return information
# therefore unable to use staAccessPointBSSID
# or staPhyAddress. We extract the information from
# the IID instead.
#'fw_port' => 'staAccessPointBSSID',
#'fw_mac' => 'staPhyAddress',
'fw_user' => 'staUserName',
);
%MUNGE = ( # WLSX-SWITCH-MIB::wlsxSwitchAccessPointTable
%SNMP::Info::Layer2::MUNGE, # Table index leafs do not return information
); # therefore unable to use apBSSID. We extract
# the information from the IID instead.
'aruba_ap_name' => 'apLocation',
'aruba_ap_ip' => 'apIpAddress',
'aruba_ap_essid' => 'apESSID',
'aruba_ap_ssidbcast' => 'wlsrHideSSID',
# WLSR-AP-MIB::wlsrConfigTable
'aruba_ap_channel' => 'apCurrentChannel',
# WLSX-SWITCH-MIB::wlsxSwitchStationMgmtTable
# Table index leafs do not return information
# therefore unable to use staAccessPointBSSID
# or staPhyAddress. We extract the information from
# the IID instead.
#'fw_port' => 'staAccessPointBSSID',
#'fw_mac' => 'staPhyAddress',
'fw_user' => 'staUserName',
);
%MUNGE = ( %SNMP::Info::Layer2::MUNGE, );
sub layers { sub layers {
return '00000011'; return '00000011';
@@ -94,7 +93,7 @@ sub os_ver {
my $descr = $aruba->description(); my $descr = $aruba->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/){ if ( $descr =~ m/Version\s+(\d+\.\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
@@ -103,7 +102,7 @@ sub os_ver {
sub model { sub model {
my $aruba = shift; my $aruba = shift;
my $id = $aruba->id(); my $id = $aruba->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
@@ -114,14 +113,14 @@ sub model {
# Thin APs do not support ifMIB requirement # Thin APs do not support ifMIB requirement
sub i_index { sub i_index {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->orig_i_index($partial) || {}; my $i_index = $aruba->orig_i_index($partial) || {};
my $ap_index = $aruba->aruba_ap_name($partial) || {}; my $ap_index = $aruba->aruba_ap_name($partial) || {};
my %if_index; my %if_index;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
@@ -129,9 +128,11 @@ sub i_index {
} }
# Get Attached APs as Interfaces # Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){ foreach my $ap_id ( keys %$ap_index ) {
# Convert the 0.254.123.456 index entry to a MAC address. # Convert the 0.254.123.456 index entry to a MAC address.
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$ap_id)); my $mac = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $ap_id ) );
$if_index{$ap_id} = $mac; $if_index{$ap_id} = $mac;
} }
@@ -139,26 +140,27 @@ sub i_index {
} }
sub interfaces { sub interfaces {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->i_index($partial) || {}; my $i_index = $aruba->i_index($partial) || {};
my $i_descr = $aruba->i_description($partial) || {}; my $i_descr = $aruba->i_description($partial) || {};
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
# Replace the Index with the ifDescr field.
my $port = $i_descr->{$iid}; # Replace the Index with the ifDescr field.
next unless defined $port; my $port = $i_descr->{$iid};
$if{$iid} = $port; next unless defined $port;
$if{$iid} = $port;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
$if{$index} = $index; $if{$index} = $index;
} }
else { else {
@@ -169,120 +171,119 @@ sub interfaces {
} }
sub i_name { sub i_name {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->i_index($partial) || {}; my $i_index = $aruba->i_index($partial) || {};
my $i_name2 = $aruba->orig_i_name($partial) || {}; my $i_name2 = $aruba->orig_i_name($partial) || {};
my $ap_name = $aruba->aruba_ap_name($partial) || {}; my $ap_name = $aruba->aruba_ap_name($partial) || {};
my %i_name; my %i_name;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /^\d+$/ ) { if ( $index =~ /^\d+$/ ) {
my $name = $i_name2->{$iid}; my $name = $i_name2->{$iid};
next unless defined $name; next unless defined $name;
$i_name{$index} = $name; $i_name{$index} = $name;
} }
elsif ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { elsif ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $name = $ap_name->{$iid}; my $name = $ap_name->{$iid};
next unless defined $name; next unless defined $name;
$i_name{$index} = $name; $i_name{$index} = $name;
} }
else { else {
next; next;
} }
} }
return \%i_name; return \%i_name;
} }
sub i_ssidlist { sub i_ssidlist {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->i_index($partial) || {}; my $i_index = $aruba->i_index($partial) || {};
my $ap_ssid = $aruba->aruba_ap_essid($partial) || {}; my $ap_ssid = $aruba->aruba_ap_essid($partial) || {};
my %i_ssid; my %i_ssid;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $ssid = $ap_ssid->{$iid}; my $ssid = $ap_ssid->{$iid};
next unless defined $ssid; next unless defined $ssid;
$i_ssid{$index} = $ssid; $i_ssid{$index} = $ssid;
} }
else { else {
next; next;
} }
} }
return \%i_ssid; return \%i_ssid;
} }
sub i_80211channel { sub i_80211channel {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->i_index($partial) || {}; my $i_index = $aruba->i_index($partial) || {};
my $ap_ch = $aruba->aruba_ap_channel($partial) || {}; my $ap_ch = $aruba->aruba_ap_channel($partial) || {};
my %i_ch; my %i_ch;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $ch = $ap_ch->{$iid}; my $ch = $ap_ch->{$iid};
next unless defined $ch; next unless defined $ch;
$i_ch{$index} = $ch; $i_ch{$index} = $ch;
} }
else { else {
next; next;
} }
} }
return \%i_ch; return \%i_ch;
} }
sub i_ssidbcast { sub i_ssidbcast {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->i_index($partial) || {}; my $i_index = $aruba->i_index($partial) || {};
my $ap_bc = $aruba->aruba_ap_ssidbcast($partial) || {}; my $ap_bc = $aruba->aruba_ap_ssidbcast($partial) || {};
my %i_bc; my %i_bc;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
if ($index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/) { if ( $index =~ /(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/ ) {
my $bc = $ap_bc->{$iid}; my $bc = $ap_bc->{$iid};
next unless defined $bc; next unless defined $bc;
$bc = ($bc ? 0 : 1); $bc = ( $bc ? 0 : 1 );
$i_bc{$index} = $bc; $i_bc{$index} = $bc;
} }
else { else {
next; next;
} }
} }
return \%i_bc; return \%i_bc;
} }
# Wireless switches do not support the standard Bridge MIB # Wireless switches do not support the standard Bridge MIB
sub bp_index { sub bp_index {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $i_index = $aruba->orig_i_index($partial) || {}; my $i_index = $aruba->orig_i_index($partial) || {};
my $ap_index = $aruba->aruba_ap_name($partial) || {}; my $ap_index = $aruba->aruba_ap_name($partial) || {};
my %bp_index; my %bp_index;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
@@ -290,9 +291,11 @@ sub bp_index {
} }
# Get Attached APs as Interfaces # Get Attached APs as Interfaces
foreach my $ap_id (keys %$ap_index){ foreach my $ap_id ( keys %$ap_index ) {
# Convert the 0.254.123.456 index entry to a MAC address. # Convert the 0.254.123.456 index entry to a MAC address.
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$ap_id)); my $mac = join( ':',
map { sprintf( "%02x", $_ ) } split( /\./, $ap_id ) );
$bp_index{$mac} = $mac; $bp_index{$mac} = $mac;
} }
@@ -300,39 +303,47 @@ sub bp_index {
} }
sub fw_port { sub fw_port {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $fw_idx = $aruba->fw_user($partial) || {}; my $fw_idx = $aruba->fw_user($partial) || {};
my %fw_port; my %fw_port;
foreach my $iid (keys %$fw_idx){ foreach my $iid ( keys %$fw_idx ) {
if ($iid =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/) { if ( $iid
my $port = join(':',map {sprintf("%02x",$_)} split(/\./,$2)); =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/
$fw_port{$iid} = $port; )
} {
else { my $port = join( ':',
next; map { sprintf( "%02x", $_ ) } split( /\./, $2 ) );
} $fw_port{$iid} = $port;
}
else {
next;
}
} }
return \%fw_port; return \%fw_port;
} }
sub fw_mac { sub fw_mac {
my $aruba = shift; my $aruba = shift;
my $partial = shift; my $partial = shift;
my $fw_idx = $aruba->fw_user($partial) || {}; my $fw_idx = $aruba->fw_user($partial) || {};
my %fw_mac; my %fw_mac;
foreach my $iid (keys %$fw_idx){ foreach my $iid ( keys %$fw_idx ) {
if ($iid =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/) { if ( $iid
my $mac = join(':',map {sprintf("%02x",$_)} split(/\./,$1)); =~ /(\d+\.\d+\.\d+\.\d+\.\d+\.\d+).(\d+\.\d+\.\d+\.\d+\.\d+\.\d+)/
$fw_mac{$iid} = $mac; )
} {
else { my $mac = join( ':',
next; map { sprintf( "%02x", $_ ) } split( /\./, $1 ) );
} $fw_mac{$iid} = $mac;
}
else {
next;
}
} }
return \%fw_mac; return \%fw_mac;
} }
@@ -366,10 +377,10 @@ Eric Miller
=head1 DESCRIPTION =head1 DESCRIPTION
SNMP::Info::Layer2::Aruba is a subclass of SNMP::Info that provides an interface SNMP::Info::Layer2::Aruba is a subclass of SNMP::Info that provides an
to Aruba wireless switches. The Aruba platform utilizes intelligent wireless interface to Aruba wireless switches. The Aruba platform utilizes
switches which control thin access points. The thin access points themselves intelligent wireless switches which control thin access points. The thin
are unable to be polled for end station information. access points themselves are unable to be polled for end station information.
This class emulates bridge functionality for the wireless switch. This enables This class emulates bridge functionality for the wireless switch. This enables
end station MAC addresses collection and correlation to the thin access point end station MAC addresses collection and correlation to the thin access point
@@ -464,8 +475,8 @@ interfaces. The thin AP MAC address is used as the port identifier.
=item $aruba->i_name() =item $aruba->i_name()
Interface name. Returns (C<ifName>) for Ethernet interfaces and (C<apLocation>) Interface name. Returns (C<ifName>) for Ethernet interfaces and
for thin AP interfaces. (C<apLocation>) for thin AP interfaces.
=item $aruba->bp_index() =item $aruba->bp_index()

View File

@@ -37,7 +37,7 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Bay::EXPORT_OK = qw//; @SNMP::Info::Layer2::Bay::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -45,89 +45,92 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
# Set for No CDP # Set for No CDP
%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, %GLOBALS = (
'cdp_id' => 's5EnMsTopIpAddr', %SNMP::Info::Layer2::GLOBALS,
'cdp_run' => 's5EnMsTopStatus', 'cdp_id' => 's5EnMsTopIpAddr',
); 'cdp_run' => 's5EnMsTopStatus',
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS, %FUNCS = (
'imac2' => 'ifPhysAddress', %SNMP::Info::Layer2::FUNCS,
# S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable 'imac2' => 'ifPhysAddress',
'bay_topo_slot' => 's5EnMsTopNmmSlot',
'bay_topo_port' => 's5EnMsTopNmmPort',
'bay_topo_ip' => 's5EnMsTopNmmIpAddr',
'bay_topo_seg' => 's5EnMsTopNmmSegId',
'bay_topo_mac' => 's5EnMsTopNmmMacAddr',
'bay_topo_platform' => 's5EnMsTopNmmChassisType',
'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
%MIBS = ( # S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable
%SNMP::Info::Layer2::MIBS, 'bay_topo_slot' => 's5EnMsTopNmmSlot',
'SYNOPTICS-ROOT-MIB' => 'synoptics', 'bay_topo_port' => 's5EnMsTopNmmPort',
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop' 'bay_topo_ip' => 's5EnMsTopNmmIpAddr',
); 'bay_topo_seg' => 's5EnMsTopNmmSegId',
'bay_topo_mac' => 's5EnMsTopNmmMacAddr',
'bay_topo_platform' => 's5EnMsTopNmmChassisType',
'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
%MIBS = (
%SNMP::Info::Layer2::MIBS,
'SYNOPTICS-ROOT-MIB' => 'synoptics',
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop'
);
delete $MIBS{'CISCO-CDP-MIB'}; delete $MIBS{'CISCO-CDP-MIB'};
# 450's report full duplex as speed = 20mbps?! # 450's report full duplex as speed = 20mbps?!
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps'; $SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps'; $SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
%MUNGE = (%SNMP::Info::Layer2::MUNGE, %MUNGE = ( %SNMP::Info::Layer2::MUNGE, 'i_mac2' => \&SNMP::Info::munge_mac, );
'i_mac2' => \&SNMP::Info::munge_mac ,
);
sub os { sub os {
return 'bay'; return 'bay';
} }
sub os_ver { sub os_ver {
my $bay = shift; my $bay = shift;
my $descr = $bay->description(); my $descr = $bay->description();
return unless defined $descr; return unless defined $descr;
# 303 / 304 # 303 / 304
if ($descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/){ if ( $descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
# 450 # 450
if ($descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/){ if ( $descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
return; return;
} }
sub os_bin { sub os_bin {
my $bay = shift; my $bay = shift;
my $descr = $bay->description(); my $descr = $bay->description();
return unless defined $descr; return unless defined $descr;
# 303 / 304 # 303 / 304
if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){ if ( $descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/ ) {
return $1; return $1;
} }
# 450 # 450
if ($descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/){ if ( $descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
return; return;
} }
sub vendor { sub vendor {
# or nortel, or synopsis? # or nortel, or synopsis?
return 'bay'; return 'bay';
} }
sub i_ignore { sub i_ignore {
my $bay = shift; my $bay = shift;
my $descr = $bay->description(); my $descr = $bay->description();
my $i_type = $bay->i_type(); my $i_type = $bay->i_type();
my %i_ignore; my %i_ignore;
foreach my $if (keys %$i_type){ foreach my $if ( keys %$i_type ) {
my $type = $i_type->{$if}; my $type = $i_type->{$if};
$i_ignore{$if}++ if $type =~ /(loopback|propvirtual|cpu)/i; $i_ignore{$if}++ if $type =~ /(loopback|propvirtual|cpu)/i;
} }
@@ -136,28 +139,27 @@ sub i_ignore {
} }
sub interfaces { sub interfaces {
my $bay = shift; my $bay = shift;
my $i_index = $bay->i_index(); my $i_index = $bay->i_index();
return $i_index; return $i_index;
} }
sub i_mac { sub i_mac {
my $bay = shift; my $bay = shift;
my $i_mac = $bay->i_mac2(); my $i_mac = $bay->i_mac2();
# Bay 303's with a hw rev < 2.11.4.5 report the mac as all zeros # Bay 303's with a hw rev < 2.11.4.5 report the mac as all zeros
foreach my $iid (keys %$i_mac){ foreach my $iid ( keys %$i_mac ) {
my $mac = $i_mac->{$iid}; my $mac = $i_mac->{$iid};
delete $i_mac->{$iid} if $mac eq '00:00:00:00:00:00'; delete $i_mac->{$iid} if $mac eq '00:00:00:00:00:00';
} }
return $i_mac; return $i_mac;
} }
sub model { sub model {
my $bay = shift; my $bay = shift;
my $id = $bay->id(); my $id = $bay->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
@@ -165,20 +167,20 @@ sub model {
my $descr = $bay->description(); my $descr = $bay->description();
return '303' if ($descr =~ /\D303\D/); return '303' if ( $descr =~ /\D303\D/ );
return '304' if ($descr =~ /\D304\D/); return '304' if ( $descr =~ /\D304\D/ );
return '450' if ($model =~ /BayStack450/); return '450' if ( $model =~ /BayStack450/ );
return $model; return $model;
} }
# Hack in some CDP type stuff # Hack in some CDP type stuff
sub c_if { sub c_if {
my $bay = shift; my $bay = shift;
my $bay_topo_port = $bay->bay_topo_port(); my $bay_topo_port = $bay->bay_topo_port();
my %c_if; my %c_if;
foreach my $entry (keys %$bay_topo_port){ foreach my $entry ( keys %$bay_topo_port ) {
my $port = $bay_topo_port->{$entry}; my $port = $bay_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if $port == 0; next if $port == 0;
@@ -188,29 +190,30 @@ sub c_if {
} }
sub c_ip { sub c_ip {
my $bay = shift; my $bay = shift;
my $bay_topo_ip = $bay->bay_topo_ip(); my $bay_topo_ip = $bay->bay_topo_ip();
my $bay_topo_port = $bay->bay_topo_port(); my $bay_topo_port = $bay->bay_topo_port();
my $ip = $bay->cdp_ip(); my $ip = $bay->cdp_ip();
# Count the number of devices seen on each port. # Count the number of devices seen on each port.
# more than one device seen means connected to a non-bay # more than one device seen means connected to a non-bay
# device, but other bay devices are squawking further away. # device, but other bay devices are squawking further away.
my %ip_port; my %ip_port;
foreach my $entry (keys %$bay_topo_ip){ foreach my $entry ( keys %$bay_topo_ip ) {
my $port = $bay_topo_port->{$entry}; my $port = $bay_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if ($port =~ /^[\d\.]+$/ and $port == 0); next if ( $port =~ /^[\d\.]+$/ and $port == 0 );
my $ip = $bay_topo_ip->{$entry}; my $ip = $bay_topo_ip->{$entry};
push(@{$ip_port{$port}},$ip); push( @{ $ip_port{$port} }, $ip );
} }
my %c_ip; my %c_ip;
foreach my $port (keys %ip_port){ foreach my $port ( keys %ip_port ) {
my $ips = $ip_port{$port}; my $ips = $ip_port{$port};
if (scalar @$ips == 1) { if ( scalar @$ips == 1 ) {
$c_ip{"$port.1"} = $ips->[0]; $c_ip{"$port.1"} = $ips->[0];
} else { }
else {
$c_ip{"$port.1"} = $ips; $c_ip{"$port.1"} = $ips;
} }
} }
@@ -219,12 +222,12 @@ sub c_ip {
} }
sub c_port { sub c_port {
my $bay = shift; my $bay = shift;
my $bay_topo_port = $bay->bay_topo_port(); my $bay_topo_port = $bay->bay_topo_port();
my $bay_topo_seg = $bay->bay_topo_seg(); my $bay_topo_seg = $bay->bay_topo_seg();
my %c_port; my %c_port;
foreach my $entry (keys %$bay_topo_seg){ foreach my $entry ( keys %$bay_topo_seg ) {
my $port = $bay_topo_port->{$entry}; my $port = $bay_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if $port == 0; next if $port == 0;
@@ -232,7 +235,7 @@ sub c_port {
# For fake remotes (multiple IPs for a c_ip), use first found # For fake remotes (multiple IPs for a c_ip), use first found
next if defined $c_port{"$port.1"}; next if defined $c_port{"$port.1"};
my $seg = $bay_topo_seg->{$entry}; my $seg = $bay_topo_seg->{$entry};
# Segment id is (256 * remote slot_num) + (remote_port) # Segment id is (256 * remote slot_num) + (remote_port)
my $remote_port = $seg % 256; my $remote_port = $seg % 256;
@@ -244,20 +247,19 @@ sub c_port {
} }
sub c_platform { sub c_platform {
my $bay = shift; my $bay = shift;
my $bay_topo_port = $bay->bay_topo_port(); my $bay_topo_port = $bay->bay_topo_port();
my $bay_topo_platform = $bay->bay_topo_platform(); my $bay_topo_platform = $bay->bay_topo_platform();
my %c_platform; my %c_platform;
foreach my $entry (keys %$bay_topo_platform){ foreach my $entry ( keys %$bay_topo_platform ) {
my $port = $bay_topo_port->{$entry} || 0; my $port = $bay_topo_port->{$entry} || 0;
next if $port == 0; next if $port == 0;
# For fake remotes (multiple IPs for a c_ip), use first found # For fake remotes (multiple IPs for a c_ip), use first found
next if defined $c_platform{"$port.1"}; next if defined $c_platform{"$port.1"};
my $platform = $bay_topo_platform->{$entry}; my $platform = $bay_topo_platform->{$entry};
$c_platform{"$port.1"} = $platform; $c_platform{"$port.1"} = $platform;
} }
@@ -446,7 +448,8 @@ Returns reference to hash. Key: Table entry, Value:slot number
=item $bay->bay_topo_port() =item $bay->bay_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<s5EnMsTopNmmPort>) (C<s5EnMsTopNmmPort>)

View File

@@ -38,82 +38,82 @@ use SNMP::Info::RapidCity;
use SNMP::Info::LLDP; use SNMP::Info::LLDP;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer2::Baystack::ISA = qw/SNMP::Info::SONMP SNMP::Info::NortelStack @SNMP::Info::Layer2::Baystack::ISA
SNMP::Info::RapidCity SNMP::Info::LLDP = qw/SNMP::Info::SONMP SNMP::Info::NortelStack
SNMP::Info::Layer3 Exporter/; SNMP::Info::RapidCity SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer2::Baystack::EXPORT_OK = qw//; @SNMP::Info::Layer2::Baystack::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::LLDP::MIBS,
%SNMP::Info::LLDP::MIBS, %SNMP::Info::RapidCity::MIBS, %SNMP::Info::NortelStack::MIBS,
%SNMP::Info::RapidCity::MIBS, %SNMP::Info::SONMP::MIBS,
%SNMP::Info::NortelStack::MIBS, );
%SNMP::Info::SONMP::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::RapidCity::GLOBALS, %SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::RapidCity::GLOBALS, %SNMP::Info::SONMP::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS, );
%SNMP::Info::SONMP::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS, %SNMP::Info::LLDP::FUNCS,
%SNMP::Info::LLDP::FUNCS, %SNMP::Info::RapidCity::FUNCS, %SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::RapidCity::FUNCS, %SNMP::Info::SONMP::FUNCS,
%SNMP::Info::NortelStack::FUNCS, );
%SNMP::Info::SONMP::FUNCS,
);
# 450's report full duplex as speed = 20mbps?! # 450's report full duplex as speed = 20mbps?!
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps'; $SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps'; $SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
$SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps'; $SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps';
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::RapidCity::MUNGE, %SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::RapidCity::MUNGE, %SNMP::Info::SONMP::MUNGE,
%SNMP::Info::NortelStack::MUNGE, );
%SNMP::Info::SONMP::MUNGE,
);
sub os { sub os {
my $baystack = shift; my $baystack = shift;
my $descr = $baystack->description(); my $descr = $baystack->description();
my $model = $baystack->model(); my $model = $baystack->model();
if ((defined $model and $model =~ /(325|420|425|470|460|BPS|2500|3510|4524|4526|4548|4550|5510|5520|5530)/) and (defined $descr and $descr =~ m/SW:v[3-5]/i)) { if (( defined $model
return 'boss'; and $model
=~ /(325|420|425|470|460|BPS|2500|3510|4524|4526|4548|4550|5510|5520|5530)/
)
and ( defined $descr and $descr =~ m/SW:v[3-5]/i )
)
{
return 'boss';
} }
if ((defined $descr and $descr =~ /Business Ethernet Switch.*SW:v/i)) { if ( ( defined $descr and $descr =~ /Business Ethernet Switch.*SW:v/i ) )
return 'bes'; {
return 'bes';
} }
return 'baystack'; return 'baystack';
} }
sub os_bin { sub os_bin {
my $baystack = shift; my $baystack = shift;
my $descr = $baystack->description(); my $descr = $baystack->description();
return unless defined $descr; return unless defined $descr;
# 303 / 304 # 303 / 304
if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){ if ( $descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/ ) {
return $1; return $1;
} }
# 450 # 450
if ($descr =~ m/FW:V(\d+\.\d+)/){ if ( $descr =~ m/FW:V(\d+\.\d+)/ ) {
return $1; return $1;
} }
if ($descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i){ if ( $descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i ) {
return $1; return $1;
} }
return; return;
@@ -125,38 +125,41 @@ sub vendor {
sub model { sub model {
my $baystack = shift; my $baystack = shift;
my $id = $baystack->id(); my $id = $baystack->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
my $descr = $baystack->description(); my $descr = $baystack->description();
return '303' if (defined $descr and $descr =~ /\D303\D/); return '303' if ( defined $descr and $descr =~ /\D303\D/ );
return '304' if (defined $descr and $descr =~ /\D304\D/); return '304' if ( defined $descr and $descr =~ /\D304\D/ );
return 'BPS' if ($model =~ /BPS2000/i); return 'BPS' if ( $model =~ /BPS2000/i );
return $2 if ($model =~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)-?(\d+)/); return $2
if ( $model
=~ /(ES|ERS|BayStack|EthernetRoutingSwitch|EthernetSwitch)-?(\d+)/ );
return $model; return $model;
} }
sub interfaces { sub interfaces {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $i_index = $baystack->i_index($partial) || {}; my $i_index = $baystack->i_index($partial) || {};
my $index_factor = $baystack->index_factor(); my $index_factor = $baystack->index_factor();
my $slot_offset = $baystack->slot_offset(); my $slot_offset = $baystack->slot_offset();
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
# Ignore cascade ports # Ignore cascade ports
next if $index > 513; next if $index > 513;
my $port = ($index % $index_factor); my $port = ( $index % $index_factor );
my $slot = (int($index / $index_factor)) + $slot_offset; my $slot = ( int( $index / $index_factor ) ) + $slot_offset;
my $slotport = "$slot.$port"; my $slotport = "$slot.$port";
$if{$iid} = $slotport; $if{$iid} = $slotport;
@@ -166,51 +169,55 @@ sub interfaces {
sub i_mac { sub i_mac {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $i_mac = $baystack->orig_i_mac($partial) || {}; my $i_mac = $baystack->orig_i_mac($partial) || {};
my %i_mac; my %i_mac;
# Baystack 303's with a hw rev < 2.11.4.5 report the mac as all zeros # Baystack 303's with a hw rev < 2.11.4.5 report the mac as all zeros
foreach my $iid (keys %$i_mac){ foreach my $iid ( keys %$i_mac ) {
my $mac = $i_mac->{$iid}; my $mac = $i_mac->{$iid};
next unless defined $mac; next unless defined $mac;
next if $mac eq '00:00:00:00:00:00'; next if $mac eq '00:00:00:00:00:00';
$i_mac{$iid}=$mac; $i_mac{$iid} = $mac;
} }
return \%i_mac; return \%i_mac;
} }
sub i_name { sub i_name {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $i_index = $baystack->i_index($partial) || {}; my $i_index = $baystack->i_index($partial) || {};
my $i_alias = $baystack->i_alias($partial) || {}; my $i_alias = $baystack->i_alias($partial) || {};
my $i_name2 = $baystack->orig_i_name($partial) || {}; my $i_name2 = $baystack->orig_i_name($partial) || {};
my %i_name; my %i_name;
foreach my $iid (keys %$i_name2){ foreach my $iid ( keys %$i_name2 ) {
my $name = $i_name2->{$iid}; my $name = $i_name2->{$iid};
my $alias = $i_alias->{$iid}; my $alias = $i_alias->{$iid};
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ? $i_name{$iid}
$alias : = ( defined $alias and $alias !~ /^\s*$/ )
$name; ? $alias
: $name;
} }
return \%i_name; return \%i_name;
} }
sub index_factor { sub index_factor {
my $baystack = shift; my $baystack = shift;
my $model = $baystack->model(); my $model = $baystack->model();
my $os = $baystack->os(); my $os = $baystack->os();
my $op_mode = $baystack->ns_op_mode(); my $op_mode = $baystack->ns_op_mode();
$op_mode = 'pure' unless defined $op_mode; $op_mode = 'pure' unless defined $op_mode;
my $index_factor = 32; my $index_factor = 32;
$index_factor = 64 if ((defined $model and $model =~ /(470)/) or ($os =~ m/(boss|bes)/) and ($op_mode eq 'pure')); $index_factor = 64
if ( ( defined $model and $model =~ /(470)/ )
or ( $os =~ m/(boss|bes)/ ) and ( $op_mode eq 'pure' ) );
return $index_factor; return $index_factor;
} }
@@ -225,20 +232,20 @@ sub hasCDP {
sub c_ip { sub c_ip {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $cdp = $baystack->SUPER::c_ip($partial) || {}; my $cdp = $baystack->SUPER::c_ip($partial) || {};
my $lldp = $baystack->lldp_ip($partial) || {}; my $lldp = $baystack->lldp_ip($partial) || {};
my %c_ip; my %c_ip;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid}; my $ip = $cdp->{$iid};
next unless defined $ip; next unless defined $ip;
$c_ip{$iid} = $ip; $c_ip{$iid} = $ip;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid}; my $ip = $lldp->{$iid};
next unless defined $ip; next unless defined $ip;
@@ -249,20 +256,20 @@ sub c_ip {
sub c_if { sub c_if {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $lldp = $baystack->lldp_if($partial) || {};; my $lldp = $baystack->lldp_if($partial) || {};
my $cdp = $baystack->SUPER::c_if($partial) || {}; my $cdp = $baystack->SUPER::c_if($partial) || {};
my %c_if; my %c_if;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid}; my $if = $cdp->{$iid};
next unless defined $if; next unless defined $if;
$c_if{$iid} = $if; $c_if{$iid} = $if;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid}; my $if = $lldp->{$iid};
next unless defined $if; next unless defined $if;
@@ -273,20 +280,20 @@ sub c_if {
sub c_port { sub c_port {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $lldp = $baystack->lldp_port($partial) || {}; my $lldp = $baystack->lldp_port($partial) || {};
my $cdp = $baystack->SUPER::c_port($partial) || {}; my $cdp = $baystack->SUPER::c_port($partial) || {};
my %c_port; my %c_port;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid}; my $port = $cdp->{$iid};
next unless defined $port; next unless defined $port;
$c_port{$iid} = $port; $c_port{$iid} = $port;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid}; my $port = $lldp->{$iid};
next unless defined $port; next unless defined $port;
@@ -297,20 +304,20 @@ sub c_port {
sub c_id { sub c_id {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $lldp = $baystack->lldp_id($partial) || {}; my $lldp = $baystack->lldp_id($partial) || {};
my $cdp = $baystack->SUPER::c_id($partial) || {}; my $cdp = $baystack->SUPER::c_id($partial) || {};
my %c_id; my %c_id;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid}; my $id = $cdp->{$iid};
next unless defined $id; next unless defined $id;
$c_id{$iid} = $id; $c_id{$iid} = $id;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid}; my $id = $lldp->{$iid};
next unless defined $id; next unless defined $id;
@@ -321,20 +328,20 @@ sub c_id {
sub c_platform { sub c_platform {
my $baystack = shift; my $baystack = shift;
my $partial = shift; my $partial = shift;
my $lldp = $baystack->lldp_rem_sysdesc($partial) || {}; my $lldp = $baystack->lldp_rem_sysdesc($partial) || {};
my $cdp = $baystack->SUPER::c_platform($partial) || {}; my $cdp = $baystack->SUPER::c_platform($partial) || {};
my %c_platform; my %c_platform;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid}; my $platform = $cdp->{$iid};
next unless defined $platform; next unless defined $platform;
$c_platform{$iid} = $platform; $c_platform{$iid} = $platform;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid}; my $platform = $lldp->{$iid};
next unless defined $platform; next unless defined $platform;
@@ -582,7 +589,8 @@ to a hash.
Returns reference to the map between IID and physical Port. Returns reference to the map between IID and physical Port.
Slot and port numbers on the Baystack switches are determined by the formula: Slot and port numbers on the Baystack switches are determined by the
formula:
port = (Interface index % Index factor) port = (Interface index % Index factor)
slot = (int(Interface index / Index factor)) + Slot offset slot = (int(Interface index / Index factor)) + Slot offset
@@ -602,7 +610,8 @@ revisions of Baystack firmware report all zeros for each port mac.
=item $baystack->i_name() =item $baystack->i_name()
Crosses C<ifName> with C<ifAlias> and returns the human set port name if exists. Crosses C<ifName> with C<ifAlias> and returns the human set port name if
exists.
=back =back
@@ -701,8 +710,8 @@ Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4 If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry. address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different IPv4 If multiple entries exist with the same local port, c_if(), with different
addresses, c_ip(), there is either a non-SONMP/LLDP device in between two or IPv4 addresses, c_ip(), there is either a non-SONMP/LLDP device in between two or
more devices or multiple devices which are not directly connected. more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper. Use the data from the Layer2 Topology Table below to dig deeper.

View File

@@ -40,8 +40,8 @@ use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::CDP SNMP::Info::CiscoStats @SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoConfig SNMP::Info::Layer2 SNMP::Info::CiscoConfig SNMP::Info::Layer2
Exporter/; Exporter/;
@SNMP::Info::Layer2::C1900::EXPORT_OK = qw//; @SNMP::Info::Layer2::C1900::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -49,44 +49,44 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
'c1900_flash_status' => 'upgradeFlashBankStatus', 'c1900_flash_status' => 'upgradeFlashBankStatus',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CDP::FUNCS,
# ESSWITCH-MIB
'c1900_p_index' => 'swPortIndex', # ESSWITCH-MIB
'c1900_p_ifindex' => 'swPortIfIndex', 'c1900_p_index' => 'swPortIndex',
'c1900_p_duplex' => 'swPortDuplexStatus', 'c1900_p_ifindex' => 'swPortIfIndex',
'c1900_p_duplex_admin' => 'swPortFullDuplex', 'c1900_p_duplex' => 'swPortDuplexStatus',
'c1900_p_name' => 'swPortName', 'c1900_p_duplex_admin' => 'swPortFullDuplex',
'c1900_p_up_admin' => 'swPortAdminStatus', 'c1900_p_name' => 'swPortName',
'c1900_p_type' => 'swPortMediaCapability', 'c1900_p_up_admin' => 'swPortAdminStatus',
'c1900_p_media' => 'swPortConnectorType', 'c1900_p_type' => 'swPortMediaCapability',
); 'c1900_p_media' => 'swPortConnectorType',
);
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::CDP::MIBS,
# Also known as the ESSWITCH-MIB
'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000' # Also known as the ESSWITCH-MIB
); 'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000'
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, );
%SNMP::Info::CDP::MUNGE,
);
sub bulkwalk_no { return 1; } sub bulkwalk_no { return 1; }
sub cisco_comm_indexing { return 1; } sub cisco_comm_indexing { return 1; }
@@ -199,29 +199,30 @@ sub set_i_duplex_admin {
} }
sub i_vlan { sub i_vlan {
my $c1900 = shift; my $c1900 = shift;
my $partial = shift; my $partial = shift;
# Overlap allows more than one VLAN per port. Unable to determine default # Overlap allows more than one VLAN per port. Unable to determine default
my $overlap = $c1900->bridgeGroupAllowMembershipOverlap() || my $overlap = $c1900->bridgeGroupAllowMembershipOverlap()
$c1900->vlanAllowMembershipOverlap() || 'disabled'; || $c1900->vlanAllowMembershipOverlap()
|| 'disabled';
if ($overlap eq 'enabled') { if ( $overlap eq 'enabled' ) {
return; return;
} }
my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup() || my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup()
$c1900->vlanMemberPortOfVlan(); || $c1900->vlanMemberPortOfVlan();
my $i_pvid = {}; my $i_pvid = {};
foreach my $idx (keys %$member_of) { foreach my $idx ( keys %$member_of ) {
my @values = split(/\./, $idx); my @values = split( /\./, $idx );
my ($vlan, $port) = @values; my ( $vlan, $port ) = @values;
next unless $vlan; next unless $vlan;
next unless $port; next unless $port;
next if (defined $partial and $port !~ /^$partial$/); next if ( defined $partial and $port !~ /^$partial$/ );
my $value = $member_of->{$idx}; my $value = $member_of->{$idx};
next if ($value eq 'false'); next if ( $value eq 'false' );
$i_pvid->{$port} = $vlan; $i_pvid->{$port} = $vlan;
} }
@@ -229,23 +230,23 @@ sub i_vlan {
} }
sub i_vlan_membership { sub i_vlan_membership {
my $c1900 = shift; my $c1900 = shift;
my $partial = shift; my $partial = shift;
my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup() || my $member_of = $c1900->bridgeGroupMemberPortOfBridgeGroup()
$c1900->vlanMemberPortOfVlan(); || $c1900->vlanMemberPortOfVlan();
my $i_vlan_membership = {}; my $i_vlan_membership = {};
foreach my $idx (keys %$member_of) { foreach my $idx ( keys %$member_of ) {
my @values = split(/\./, $idx); my @values = split( /\./, $idx );
my ($vlan, $port) = @values; my ( $vlan, $port ) = @values;
next unless $vlan; next unless $vlan;
next unless $port; next unless $port;
next if (defined $partial and $port !~ /^$partial$/); next if ( defined $partial and $port !~ /^$partial$/ );
my $value = $member_of->{$idx}; my $value = $member_of->{$idx};
next if ($value eq 'false'); next if ( $value eq 'false' );
push(@{$i_vlan_membership->{$port}}, $vlan); push( @{ $i_vlan_membership->{$port} }, $vlan );
} }
return $i_vlan_membership; return $i_vlan_membership;
} }
@@ -499,9 +500,10 @@ See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head1 SET METHODS =head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods or These are methods that provide SNMP set functionality for overridden methods
provide a simpler interface to complex set operations. See or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set operations. L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over =over

View File

@@ -41,8 +41,8 @@ use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP @SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoConfig SNMP::Info::CiscoStats SNMP::Info::CiscoConfig
SNMP::Info::Layer2 Exporter/; SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::C2900::EXPORT_OK = qw//; @SNMP::Info::Layer2::C2900::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -50,43 +50,37 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CDP::GLOBALS, );
%SNMP::Info::CiscoVTP::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
'i_name' => 'ifAlias', 'i_name' => 'ifAlias',
# C2900PortEntry
'c2900_p_index' => 'c2900PortIfIndex',
'c2900_p_duplex' => 'c2900PortDuplexStatus',
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
);
%MIBS = ( # C2900PortEntry
%SNMP::Info::Layer2::MIBS, 'c2900_p_index' => 'c2900PortIfIndex',
%SNMP::Info::CiscoConfig::MIBS, 'c2900_p_duplex' => 'c2900PortDuplexStatus',
%SNMP::Info::CiscoStats::MIBS, 'c2900_p_duplex_admin' => 'c2900PortDuplexState',
%SNMP::Info::CDP::MIBS, 'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
%SNMP::Info::CiscoVTP::MIBS, );
'CISCO-C2900-MIB' => 'ciscoC2900MIB',
);
%MUNGE = ( %MIBS = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CiscoVTP::MIBS, 'CISCO-C2900-MIB' => 'ciscoC2900MIB',
%SNMP::Info::CDP::MUNGE, );
%SNMP::Info::CiscoVTP::MUNGE,
); %MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
sub vendor { sub vendor {
return 'cisco'; return 'cisco';
@@ -97,7 +91,7 @@ sub cisco_comm_indexing {
} }
sub i_duplex { sub i_duplex {
my $c2900 = shift; my $c2900 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $c2900->interfaces($partial); my $interfaces = $c2900->interfaces($partial);
@@ -107,7 +101,7 @@ sub i_duplex {
my %reverse_2900 = reverse %$c2900_p_index; my %reverse_2900 = reverse %$c2900_p_index;
my %i_duplex; my %i_duplex;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
my $port_2900 = $reverse_2900{$if}; my $port_2900 = $reverse_2900{$if};
next unless defined $port_2900; next unless defined $port_2900;
my $duplex = $c2900_p_duplex->{$port_2900}; my $duplex = $c2900_p_duplex->{$port_2900};
@@ -115,23 +109,23 @@ sub i_duplex {
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if}=$duplex; $i_duplex{$if} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
sub i_duplex_admin { sub i_duplex_admin {
my $c2900 = shift; my $c2900 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $c2900->interfaces($partial); my $interfaces = $c2900->interfaces($partial);
my $c2900_p_index = $c2900->c2900_p_index(); my $c2900_p_index = $c2900->c2900_p_index();
my $c2900_p_admin = $c2900->c2900_p_duplex_admin(); my $c2900_p_admin = $c2900->c2900_p_duplex_admin();
my %reverse_2900 = reverse %$c2900_p_index; my %reverse_2900 = reverse %$c2900_p_index;
my %i_duplex_admin; my %i_duplex_admin;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
my $port_2900 = $reverse_2900{$if}; my $port_2900 = $reverse_2900{$if};
next unless defined $port_2900; next unless defined $port_2900;
my $duplex = $c2900_p_admin->{$port_2900}; my $duplex = $c2900_p_admin->{$port_2900};
@@ -140,20 +134,20 @@ sub i_duplex_admin {
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i; $duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex_admin{$if}=$duplex; $i_duplex_admin{$if} = $duplex;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
sub set_i_speed_admin { sub set_i_speed_admin {
my $c2900 = shift; my $c2900 = shift;
my ($speed, $iid) = @_; my ( $speed, $iid ) = @_;
# map speeds to those the switch will understand # map speeds to those the switch will understand
my %speeds = qw/auto 1 10 10000000 100 100000000/; my %speeds = qw/auto 1 10 10000000 100 100000000/;
my $c2900_p_index = $c2900->c2900_p_index(); my $c2900_p_index = $c2900->c2900_p_index();
my %reverse_2900 = reverse %$c2900_p_index; my %reverse_2900 = reverse %$c2900_p_index;
$speed = lc($speed); $speed = lc($speed);
@@ -162,18 +156,18 @@ sub set_i_speed_admin {
# account for weirdness of c2900 mib # account for weirdness of c2900 mib
$iid = $reverse_2900{$iid}; $iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_speed_admin($speeds{$speed}, $iid); return $c2900->set_c2900_p_speed_admin( $speeds{$speed}, $iid );
} }
sub set_i_duplex_admin { sub set_i_duplex_admin {
my $c2900 = shift; my $c2900 = shift;
my ($duplex, $iid) = @_; my ( $duplex, $iid ) = @_;
# map a textual duplex to an integer one the switch understands # map a textual duplex to an integer one the switch understands
my %duplexes = qw/full 1 half 2 auto 3/; my %duplexes = qw/full 1 half 2 auto 3/;
my $c2900_p_index = $c2900->c2900_p_index(); my $c2900_p_index = $c2900->c2900_p_index();
my %reverse_2900 = reverse %$c2900_p_index; my %reverse_2900 = reverse %$c2900_p_index;
$duplex = lc($duplex); $duplex = lc($duplex);
@@ -182,29 +176,29 @@ sub set_i_duplex_admin {
# account for weirdness of c2900 mib # account for weirdness of c2900 mib
$iid = $reverse_2900{$iid}; $iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_duplex_admin($duplexes{$duplex}, $iid); return $c2900->set_c2900_p_duplex_admin( $duplexes{$duplex}, $iid );
} }
# Use i_descritption for port key, cuz i_name can be manually entered. # Use i_descritption for port key, cuz i_name can be manually entered.
sub interfaces { sub interfaces {
my $c2900 = shift; my $c2900 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $c2900->i_index($partial) || {}; my $interfaces = $c2900->i_index($partial) || {};
my $i_descr = $c2900->i_description($partial) || {}; my $i_descr = $c2900->i_description($partial) || {};
my %if; my %if;
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $port = $i_descr->{$iid}; my $port = $i_descr->{$iid};
next unless defined $port; next unless defined $port;
$port =~ s/\./\//g if( $port =~ /\d+\.\d+$/); $port =~ s/\./\//g if ( $port =~ /\d+\.\d+$/ );
$port =~ s/[^\d\/,()\w]+//gi; $port =~ s/[^\d\/,()\w]+//gi;
$if{$iid} = $port; $if{$iid} = $port;
} }
return \%if return \%if;
} }
1; 1;
@@ -409,9 +403,10 @@ See L<SNMP::Info::Layer2/"TABLE METHODS"> for details.
=head1 SET METHODS =head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods or These are methods that provide SNMP set functionality for overridden methods
provide a simpler interface to complex set operations. See or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set operations. L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over =over

View File

@@ -40,51 +40,43 @@ use SNMP::Info::CiscoStats;
use SNMP::Info::CiscoPortSecurity; use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::CiscoStack SNMP::Info::CiscoVTP @SNMP::Info::Layer2::Catalyst::ISA
SNMP::Info::CDP SNMP::Info::CiscoStats = qw/SNMP::Info::CiscoStack SNMP::Info::CiscoVTP
SNMP::Info::CiscoPortSecurity SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::Layer2 Exporter/; SNMP::Info::CiscoPortSecurity
SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//; @SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoPortSecurity::MIBS, %SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CDP::MIBS, );
%SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS, %SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS, %SNMP::Info::CiscoStack::GLOBALS,
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS, %SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CiscoVTP::FUNCS, %SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CDP::FUNCS, );
%SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoPortSecurity::MUNGE, %SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CiscoVTP::MUNGE, %SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CDP::MUNGE, );
%SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
);
# Overidden Methods # Overidden Methods
@@ -95,7 +87,7 @@ sub i_physical {
my $p_port = $cat->p_port(); my $p_port = $cat->p_port();
my %i_physical; my %i_physical;
foreach my $port (keys %$p_port) { foreach my $port ( keys %$p_port ) {
my $iid = $p_port->{$port}; my $iid = $p_port->{$port};
$i_physical{$iid} = 1; $i_physical{$iid} = 1;
} }
@@ -111,7 +103,7 @@ sub os {
} }
sub os_ver { sub os_ver {
my $cat = shift; my $cat = shift;
my $os_ver = $cat->SUPER::os_ver(); my $os_ver = $cat->SUPER::os_ver();
return $os_ver if defined $os_ver; return $os_ver if defined $os_ver;
@@ -125,15 +117,15 @@ sub os_ver {
# Workaround for incomplete bp_index # Workaround for incomplete bp_index
sub bp_index { sub bp_index {
my $cat = shift; my $cat = shift;
my $p_index = $cat->p_port(); my $p_index = $cat->p_port();
my $b_index = $cat->p_oidx(); my $b_index = $cat->p_oidx();
my %bp_index; my %bp_index;
foreach my $iid (keys %$p_index){ foreach my $iid ( keys %$p_index ) {
my $ifidx = $p_index->{$iid}; my $ifidx = $p_index->{$iid};
next unless defined $ifidx; next unless defined $ifidx;
my $bpidx = $b_index->{$iid}||0; my $bpidx = $b_index->{$iid} || 0;
$bp_index{$bpidx} = $ifidx; $bp_index{$bpidx} = $ifidx;
} }
@@ -145,15 +137,15 @@ sub cisco_comm_indexing {
} }
sub interfaces { sub interfaces {
my $cat = shift; my $cat = shift;
my $partial = shift; my $partial = shift;
my $i_index = $cat->i_index($partial); my $i_index = $cat->i_index($partial);
my $portnames = $cat->p_port() || {}; my $portnames = $cat->p_port() || {};
my %portmap = reverse %$portnames; my %portmap = reverse %$portnames;
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$i_index) { foreach my $iid ( keys %$i_index ) {
next unless defined $iid; next unless defined $iid;
my $if = $i_index->{$iid}; my $if = $i_index->{$iid};
my $port = $portmap{$iid}; my $port = $portmap{$iid};
@@ -163,17 +155,17 @@ sub interfaces {
} }
sub i_name { sub i_name {
my $cat = shift; my $cat = shift;
my $partial = shift; my $partial = shift;
my $p_port = $cat->p_port() || {}; my $p_port = $cat->p_port() || {};
my $p_name = $cat->p_name() || {}; my $p_name = $cat->p_name() || {};
my %i_name; my %i_name;
foreach my $port (keys %$p_name) { foreach my $port ( keys %$p_name ) {
my $iid = $p_port->{$port}; my $iid = $p_port->{$port};
next unless defined $iid; next unless defined $iid;
next if (defined $partial and $iid !~ /^$partial$/); next if ( defined $partial and $iid !~ /^$partial$/ );
$i_name{$iid} = $p_name->{$port}; $i_name{$iid} = $p_name->{$port};
} }
return \%i_name; return \%i_name;
@@ -211,7 +203,8 @@ Max Baker
SNMP::Info subclass to provide information for Cisco Catalyst series switches SNMP::Info subclass to provide information for Cisco Catalyst series switches
running CatOS. running CatOS.
This class includes the Catalyst 2920, 4000, 5000, 6000 (hybrid mode) families. This class includes the Catalyst 2920, 4000, 5000, 6000 (hybrid mode)
families.
This subclass is not for all devices that have the name Catalyst. Note that This subclass is not for all devices that have the name Catalyst. Note that
some Catalyst switches run IOS, like the 2900 and 3550 families. Cisco some Catalyst switches run IOS, like the 2900 and 3550 families. Cisco
@@ -330,7 +323,8 @@ to a hash.
=item $cat->interfaces() =item $cat->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port name. Returns the map between SNMP Interface Identifier (iid) and physical port
name.
=item $cat->i_name() =item $cat->i_name()
@@ -347,8 +341,8 @@ Returns a map to IID for ports that are physical ports, not vlans, etc.
Returns reference to hash of bridge port table entries map back to interface Returns reference to hash of bridge port table entries map back to interface
identifier (iid) identifier (iid)
Crosses (C<portCrossIndex>) to (C<portIfIndex>) since some devices seem to have Crosses (C<portCrossIndex>) to (C<portIfIndex>) since some devices seem to
problems with F<BRIDGE-MIB> have problems with F<BRIDGE-MIB>
=back =back

View File

@@ -37,61 +37,66 @@ use SNMP::Info::Bridge;
use SNMP::Info::NortelStack; use SNMP::Info::NortelStack;
use SNMP::Info::SONMP; use SNMP::Info::SONMP;
@SNMP::Info::Layer2::Centillion::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/; @SNMP::Info::Layer2::Centillion::ISA
= qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/;
@SNMP::Info::Layer2::Centillion::EXPORT_OK = qw//; @SNMP::Info::Layer2::Centillion::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::NortelStack::MIBS, %SNMP::Info::NortelStack::MIBS,
%SNMP::Info::SONMP::MIBS, %SNMP::Info::SONMP::MIBS,
'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable', 'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable',
'S5-COMMON-STATS-MIB' => 's5CmStat', 'S5-COMMON-STATS-MIB' => 's5CmStat',
'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt', 'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt',
'CENTILLION-CONFIG-MIB' => 'sysTFTPStart', 'CENTILLION-CONFIG-MIB' => 'sysTFTPStart',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::NortelStack::GLOBALS, %SNMP::Info::NortelStack::GLOBALS,
%SNMP::Info::SONMP::GLOBALS, %SNMP::Info::SONMP::GLOBALS,
'tftp_action' => 'sysTFTPStart', 'tftp_action' => 'sysTFTPStart',
'tftp_host' => 'sysTFTPIpAddress', 'tftp_host' => 'sysTFTPIpAddress',
'tftp_file' => 'sysTFTPFileName', 'tftp_file' => 'sysTFTPFileName',
'tftp_type' => 'sysTFTPFileType', 'tftp_type' => 'sysTFTPFileType',
'tftp_result' => 'sysTFTPResult', 'tftp_result' => 'sysTFTPResult',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::NortelStack::FUNCS, %SNMP::Info::NortelStack::FUNCS,
%SNMP::Info::SONMP::FUNCS, %SNMP::Info::SONMP::FUNCS,
# CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable
'centillion_p_index' => 'cnDot3ExtnIfIndex',
'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType',
'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType',
# S5-COMMON-STATS-MIB::s5CmSNodeTable
'fw_mac' => 's5CmSNodeMacAddr',
'fw_port' => 's5CmSNodeIfIndx',
# CENTILLION-VLAN-MIB::cnVlanPortMemberTable
'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex',
'centillion_i_vlan' => 'cnVlanPortMemberVID',
'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType',
);
%MUNGE = ( # CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable
# Inherit all the built in munging 'centillion_p_index' => 'cnDot3ExtnIfIndex',
%SNMP::Info::MUNGE, 'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType',
%SNMP::Info::Bridge::MUNGE, 'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType',
%SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::SONMP::MUNGE, # S5-COMMON-STATS-MIB::s5CmSNodeTable
); 'fw_mac' => 's5CmSNodeMacAddr',
'fw_port' => 's5CmSNodeIfIndx',
# CENTILLION-VLAN-MIB::cnVlanPortMemberTable
'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex',
'centillion_i_vlan' => 'cnVlanPortMemberVID',
'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType',
);
%MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::NortelStack::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
sub os { sub os {
return 'centillion'; return 'centillion';
@@ -103,12 +108,13 @@ sub vendor {
sub i_ignore { sub i_ignore {
my $centillion = shift; my $centillion = shift;
my $descr = $centillion->i_description(); my $descr = $centillion->i_description();
my %i_ignore; my %i_ignore;
foreach my $if (keys %$descr){ foreach my $if ( keys %$descr ) {
my $type = $descr->{$if}; my $type = $descr->{$if};
# Skip virtual interfaces
# Skip virtual interfaces
$i_ignore{$if}++ if $type =~ /(VE|VID|vc|lp)/i; $i_ignore{$if}++ if $type =~ /(VE|VID|vc|lp)/i;
} }
return \%i_ignore; return \%i_ignore;
@@ -116,23 +122,24 @@ sub i_ignore {
sub interfaces { sub interfaces {
my $centillion = shift; my $centillion = shift;
my $i_index = $centillion->i_index(); my $i_index = $centillion->i_index();
my $i_descr = $centillion->i_description(); my $i_descr = $centillion->i_description();
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
my $descr = $i_descr->{$iid}; my $descr = $i_descr->{$iid};
# Skip ATM and virtual interfaces
next if $descr =~ /(VE|VID|vc|lp)/i;
# Index numbers are deterministic slot * 256 + port # Skip ATM and virtual interfaces
my $port = $index % 256; next if $descr =~ /(VE|VID|vc|lp)/i;
my $slot = int($index / 256);
# Index numbers are deterministic slot * 256 + port
my $port = $index % 256;
my $slot = int( $index / 256 );
my $slotport = "$slot.$port"; my $slotport = "$slot.$port";
$slotport = "$descr" if $descr =~ /(mcp)/i; $slotport = "$descr" if $descr =~ /(mcp)/i;
$if{$index} = $slotport; $if{$index} = $slotport;
} }
@@ -147,7 +154,7 @@ sub i_duplex {
my $port_duplex = $centillion->centillion_p_duplex(); my $port_duplex = $centillion->centillion_p_duplex();
my %i_duplex; my %i_duplex;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; next unless defined $index;
my $duplex = $port_duplex->{$iid}; my $duplex = $port_duplex->{$iid};
@@ -155,7 +162,7 @@ sub i_duplex {
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$index}=$duplex; $i_duplex{$index} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
@@ -167,7 +174,7 @@ sub i_duplex_admin {
my $port_admin = $centillion->centillion_p_duplex_admin(); my $port_admin = $centillion->centillion_p_duplex_admin();
my %i_duplex_admin; my %i_duplex_admin;
foreach my $iid (keys %$port_index){ foreach my $iid ( keys %$port_index ) {
my $index = $port_index->{$iid}; my $index = $port_index->{$iid};
next unless defined $index; next unless defined $index;
my $duplex = $port_admin->{$iid}; my $duplex = $port_admin->{$iid};
@@ -176,7 +183,7 @@ sub i_duplex_admin {
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i; $duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex_admin{$index}=$duplex; $i_duplex_admin{$index} = $duplex;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
@@ -185,46 +192,46 @@ sub i_vlan {
my $centillion = shift; my $centillion = shift;
my $cn_vlan_index = $centillion->centillion_i_vlan_index(); my $cn_vlan_index = $centillion->centillion_i_vlan_index();
my $cn_vlan = $centillion->centillion_i_vlan(); my $cn_vlan = $centillion->centillion_i_vlan();
my %i_vlan; my %i_vlan;
foreach my $iid (keys %$cn_vlan_index){ foreach my $iid ( keys %$cn_vlan_index ) {
my $index = $cn_vlan_index->{$iid}; my $index = $cn_vlan_index->{$iid};
next unless defined $index; next unless defined $index;
my $vlan = $cn_vlan->{$iid}; my $vlan = $cn_vlan->{$iid};
next unless defined $vlan; next unless defined $vlan;
$i_vlan{$index}=$vlan; $i_vlan{$index} = $vlan;
} }
return \%i_vlan; return \%i_vlan;
} }
sub model { sub model {
my $centillion = shift; my $centillion = shift;
my $id = $centillion->id(); my $id = $centillion->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
$model =~ s/^sreg-//i; $model =~ s/^sreg-//i;
return '5000BH' if ($model =~ /5000BH/); return '5000BH' if ( $model =~ /5000BH/ );
return '5005BH' if ($model =~ /5005BH/); return '5005BH' if ( $model =~ /5005BH/ );
return 'C100' if ($model =~ /Centillion100/); return 'C100' if ( $model =~ /Centillion100/ );
return 'C50N' if ($model =~ /Centillion50N/); return 'C50N' if ( $model =~ /Centillion50N/ );
return 'C50T' if ($model =~ /Centillion50T/); return 'C50T' if ( $model =~ /Centillion50T/ );
return $model; return $model;
} }
sub bp_index { sub bp_index {
my $centillion = shift; my $centillion = shift;
my $index = $centillion->fw_port(); my $index = $centillion->fw_port();
my %bp_index; my %bp_index;
foreach my $iid (keys %$index){ foreach my $iid ( keys %$index ) {
my $b_index = $index->{$iid}; my $b_index = $index->{$iid};
next unless defined $b_index; next unless defined $b_index;
#Index value is the same as ifIndex #Index value is the same as ifIndex
$bp_index{$b_index} = $b_index; $bp_index{$b_index} = $b_index;
} }
@@ -239,7 +246,6 @@ sub slot_offset {
return 0; return 0;
} }
1; 1;
__END__ __END__
@@ -411,7 +417,8 @@ to a hash.
Returns reference to the map between IID and physical Port. Returns reference to the map between IID and physical Port.
Slot and port numbers on the Passport switches are determined by the formula: Slot and port numbers on the Passport switches are determined by the
formula:
port = index % 256 port = index % 256
slot = int(index / 256) slot = int(index / 256)

View File

@@ -42,59 +42,43 @@ use SNMP::Info::CiscoConfig;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP @SNMP::Info::Layer2::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoImage SNMP::Info::CiscoStats SNMP::Info::CiscoImage
SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS
SNMP::Info::CiscoConfig SNMP::Info::Layer2 SNMP::Info::CiscoConfig SNMP::Info::Layer2
Exporter/; Exporter/;
@SNMP::Info::Layer2::Cisco::EXPORT_OK = qw//; @SNMP::Info::Layer2::Cisco::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoQOS::MIBS, %SNMP::Info::CiscoRTT::MIBS,
%SNMP::Info::CiscoQOS::MIBS, %SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoRTT::MIBS, %SNMP::Info::CDP::MIBS, %SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoImage::MIBS, );
%SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoQOS::GLOBALS, %SNMP::Info::CiscoRTT::GLOBALS,
%SNMP::Info::CiscoQOS::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CiscoRTT::GLOBALS, %SNMP::Info::CDP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS, );
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS, %SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoQOS::FUNCS, %SNMP::Info::CiscoRTT::FUNCS,
%SNMP::Info::CiscoQOS::FUNCS, %SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoRTT::FUNCS, %SNMP::Info::CDP::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, );
%SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoQOS::MUNGE, %SNMP::Info::CiscoRTT::MUNGE,
%SNMP::Info::CiscoQOS::MUNGE, %SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoRTT::MUNGE, %SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, );
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
1; 1;
__END__ __END__

View File

@@ -37,51 +37,45 @@ use SNMP::Info::FDP;
use SNMP::Info::EtherLike; use SNMP::Info::EtherLike;
use SNMP::Info::MAU; use SNMP::Info::MAU;
@SNMP::Info::Layer2::Foundry::ISA = qw/SNMP::Info::Layer2 SNMP::Info::FDP SNMP::Info::EtherLike @SNMP::Info::Layer2::Foundry::ISA
SNMP::Info::MAU Exporter/; = qw/SNMP::Info::Layer2 SNMP::Info::FDP SNMP::Info::EtherLike
SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer2::Foundry::EXPORT_OK = qw//; @SNMP::Info::Layer2::Foundry::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer2::MIBS, %MIBS = (
%SNMP::Info::FDP::MIBS, %SNMP::Info::Layer2::MIBS, %SNMP::Info::FDP::MIBS,
%SNMP::Info::EtherLike::MIBS, %SNMP::Info::EtherLike::MIBS, %SNMP::Info::MAU::MIBS,
%SNMP::Info::MAU::MIBS, 'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-ROOT-MIB' => 'foundry', );
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::FDP::GLOBALS,
%SNMP::Info::FDP::GLOBALS, %SNMP::Info::EtherLike::GLOBALS, %SNMP::Info::MAU::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS, );
%SNMP::Info::MAU::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS, %SNMP::Info::FDP::FUNCS,
%SNMP::Info::FDP::FUNCS, %SNMP::Info::EtherLike::FUNCS, %SNMP::Info::MAU::FUNCS,
%SNMP::Info::EtherLike::FUNCS, 'test' => 'dot1dStpPortState',
%SNMP::Info::MAU::FUNCS, );
'test' => 'dot1dStpPortState',
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::MUNGE, %SNMP::Info::FDP::MUNGE,
%SNMP::Info::FDP::MUNGE, %SNMP::Info::EtherLike::MUNGE, %SNMP::Info::MAU::MUNGE,
%SNMP::Info::EtherLike::MUNGE, );
%SNMP::Info::MAU::MUNGE,
);
# Method OverRides # Method OverRides
#sub bulkwalk_no { 1;} #sub bulkwalk_no { 1;}
*SNMP::Info::Layer2::Foundry::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; *SNMP::Info::Layer2::Foundry::i_duplex = \&SNMP::Info::MAU::mau_i_duplex;
*SNMP::Info::Layer2::Foundry::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin; *SNMP::Info::Layer2::Foundry::i_duplex_admin
*SNMP::Info::Layer2::Foundry::i_vlan = \&SNMP::Info::Bridge::qb_i_vlan_t; = \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer2::Foundry::i_vlan = \&SNMP::Info::Bridge::qb_i_vlan_t;
# todo doc these # todo doc these
@@ -92,19 +86,19 @@ sub os_ver {
# find entity table entry for "stackmanaget.1" # find entity table entry for "stackmanaget.1"
my $unit_iid = undef; my $unit_iid = undef;
foreach my $e (keys %$e_name){ foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || ''; my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'stackmanaget.1'; $unit_iid = $e if $name eq 'stackmanaget.1';
} }
# Default to OID method if no dice. # Default to OID method if no dice.
unless (defined $unit_iid){ unless ( defined $unit_iid ) {
return $foundry->SUPER::model(); return $foundry->SUPER::model();
} }
# Find Model Name # Find Model Name
my $e_fwver = $foundry->e_fwver(); my $e_fwver = $foundry->e_fwver();
if (defined $e_fwver->{$unit_iid}){ if ( defined $e_fwver->{$unit_iid} ) {
return $e_fwver->{$unit_iid}; return $e_fwver->{$unit_iid};
} }
@@ -119,19 +113,19 @@ sub model {
# find entity table entry for "unit.1" # find entity table entry for "unit.1"
my $unit_iid = undef; my $unit_iid = undef;
foreach my $e (keys %$e_name){ foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || ''; my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1'; $unit_iid = $e if $name eq 'unit.1';
} }
# Default to OID method if no dice. # Default to OID method if no dice.
unless (defined $unit_iid){ unless ( defined $unit_iid ) {
return $foundry->SUPER::model(); return $foundry->SUPER::model();
} }
# Find Model Name # Find Model Name
my $e_model = $foundry->e_model(); my $e_model = $foundry->e_model();
if (defined $e_model->{$unit_iid}){ if ( defined $e_model->{$unit_iid} ) {
return $e_model->{$unit_iid}; return $e_model->{$unit_iid};
} }
@@ -147,7 +141,7 @@ sub serial {
# find entity table entry for "unit.1" # find entity table entry for "unit.1"
my $unit_iid = undef; my $unit_iid = undef;
foreach my $e (keys %$e_name){ foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || ''; my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1'; $unit_iid = $e if $name eq 'unit.1';
} }
@@ -168,7 +162,7 @@ sub interfaces {
# use ifName only if it is in portn # use ifName only if it is in portn
# format. For EdgeIrons # format. For EdgeIrons
# else use ifDescr # else use ifDescr
foreach my $iid (keys %$i_name){ foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid}; my $name = $i_name->{$iid};
next unless defined $name; next unless defined $name;
$i_descr->{$iid} = $name $i_descr->{$iid} = $name
@@ -180,20 +174,20 @@ sub interfaces {
sub i_ignore { sub i_ignore {
my $foundry = shift; my $foundry = shift;
my $i_type = $foundry->i_type(); my $i_type = $foundry->i_type();
my %i_ignore = (); my %i_ignore = ();
foreach my $iid (keys %$i_type){ foreach my $iid ( keys %$i_type ) {
my $type = $i_type->{$iid} || ''; my $type = $i_type->{$iid} || '';
$i_ignore{$iid}++ $i_ignore{$iid}++
# 33 is the console port # 33 is the console port
if $type =~ /(loopback|propvirtual|other|cpu|33)/i; if $type =~ /(loopback|propvirtual|other|cpu|33)/i;
} }
return \%i_ignore; return \%i_ignore;
} }
sub os { sub os {
return 'foundry'; return 'foundry';
} }
@@ -211,7 +205,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry FastIron Network Devices SNMP::Info::Layer2::Foundry - SNMP Interface to Foundry FastIron Network
Devices
=head1 AUTHOR =head1 AUTHOR

View File

@@ -39,140 +39,147 @@ use SNMP::Info::MAU;
use SNMP::Info::LLDP; use SNMP::Info::LLDP;
use SNMP::Info::CDP; use SNMP::Info::CDP;
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer3 SNMP::Info::MAU SNMP::Info::LLDP @SNMP::Info::Layer2::HP::ISA
SNMP::Info::CDP Exporter/; = qw/SNMP::Info::Layer3 SNMP::Info::MAU SNMP::Info::LLDP
SNMP::Info::CDP Exporter/;
@SNMP::Info::Layer2::HP::EXPORT_OK = qw//; @SNMP::Info::Layer2::HP::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer3::MIBS, %MIBS = (
%SNMP::Info::MAU::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::LLDP::MIBS, %SNMP::Info::MAU::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::LLDP::MIBS,
'RFC1271-MIB' => 'logDescription', %SNMP::Info::CDP::MIBS,
'HP-ICF-OID' => 'hpSwitch4000', 'RFC1271-MIB' => 'logDescription',
'HP-VLAN' => 'hpVlanMemberIndex', 'HP-ICF-OID' => 'hpSwitch4000',
'STATISTICS-MIB' => 'hpSwitchCpuStat', 'HP-VLAN' => 'hpVlanMemberIndex',
'NETSWITCH-MIB' => 'hpMsgBufFree', 'STATISTICS-MIB' => 'hpSwitchCpuStat',
'CONFIG-MIB' => 'hpSwitchConfig', 'NETSWITCH-MIB' => 'hpMsgBufFree',
'SEMI-MIB' => 'hpHttpMgSerialNumber', 'CONFIG-MIB' => 'hpSwitchConfig',
'HP-ICF-CHASSIS' => 'hpicfSensorObjectId', 'SEMI-MIB' => 'hpHttpMgSerialNumber',
); 'HP-ICF-CHASSIS' => 'hpicfSensorObjectId',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS, %SNMP::Info::MAU::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
'serial1' => 'entPhysicalSerialNum.1', 'serial1' => 'entPhysicalSerialNum.1',
'serial2' => 'hpHttpMgSerialNumber.0', 'serial2' => 'hpHttpMgSerialNumber.0',
'hp_cpu' => 'hpSwitchCpuStat.0', 'hp_cpu' => 'hpSwitchCpuStat.0',
'hp_mem_total' => 'hpGlobalMemTotalBytes.1', 'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
'mem_free' => 'hpGlobalMemFreeBytes.1', 'mem_free' => 'hpGlobalMemFreeBytes.1',
'mem_used' => 'hpGlobalMemAllocBytes.1', 'mem_used' => 'hpGlobalMemAllocBytes.1',
'os_version' => 'hpSwitchOsVersion.0', 'os_version' => 'hpSwitchOsVersion.0',
'os_bin' => 'hpSwitchRomVersion.0', 'os_bin' => 'hpSwitchRomVersion.0',
'mac' => 'hpSwitchBaseMACAddress.0', 'mac' => 'hpSwitchBaseMACAddress.0',
'hp_vlans' => 'hpVlanNumber', 'hp_vlans' => 'hpVlanNumber',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS, %SNMP::Info::MAU::FUNCS,
%SNMP::Info::LLDP::FUNCS, %SNMP::Info::LLDP::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CDP::FUNCS,
'bp_index2' => 'dot1dBasePortIfIndex', 'bp_index2' => 'dot1dBasePortIfIndex',
'i_type2' => 'ifType', 'i_type2' => 'ifType',
# RFC1271
'l_descr' => 'logDescription', # RFC1271
# HP-VLAN-MIB 'l_descr' => 'logDescription',
'hp_v_index' => 'hpVlanDot1QID',
'hp_v_name' => 'hpVlanIdentName', # HP-VLAN-MIB
'hp_v_state' => 'hpVlanIdentState', 'hp_v_index' => 'hpVlanDot1QID',
'hp_v_type' => 'hpVlanIdentType', 'hp_v_name' => 'hpVlanIdentName',
'hp_v_status' => 'hpVlanIdentStatus', 'hp_v_state' => 'hpVlanIdentState',
'hp_v_mac' => 'hpVlanAddrPhysAddress', 'hp_v_type' => 'hpVlanIdentType',
'hp_v_if_index'=> 'hpVlanMemberIndex', 'hp_v_status' => 'hpVlanIdentStatus',
'hp_v_if_tag' => 'hpVlanMemberTagged2', 'hp_v_mac' => 'hpVlanAddrPhysAddress',
# CONFIG-MIB::hpSwitchPortTable 'hp_v_if_index' => 'hpVlanMemberIndex',
'hp_duplex' => 'hpSwitchPortEtherMode', 'hp_v_if_tag' => 'hpVlanMemberTagged2',
'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
# HP-ICF-CHASSIS # CONFIG-MIB::hpSwitchPortTable
'hp_s_oid' => 'hpicfSensorObjectId', 'hp_duplex' => 'hpSwitchPortEtherMode',
'hp_s_name' => 'hpicfSensorDescr', 'hp_duplex_admin' => 'hpSwitchPortFastEtherMode',
'hp_s_status' => 'hpicfSensorStatus',
); # HP-ICF-CHASSIS
'hp_s_oid' => 'hpicfSensorObjectId',
'hp_s_name' => 'hpicfSensorDescr',
'hp_s_status' => 'hpicfSensorStatus',
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE, # Inherit all the built in munging
%SNMP::Info::MAU::MUNGE, %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::MAU::MUNGE,
%SNMP::Info::CDP::MUNGE %SNMP::Info::LLDP::MUNGE,
); %SNMP::Info::CDP::MUNGE
);
%MODEL_MAP = ( %MODEL_MAP = (
'J4093A' => '2424M', 'J4093A' => '2424M',
'J4110A' => '8000M', 'J4110A' => '8000M',
'J4120A' => '1600M', 'J4120A' => '1600M',
'J4121A' => '4000M', 'J4121A' => '4000M',
'J4122A' => '2400M', 'J4122A' => '2400M',
'J4122B' => '2424M', 'J4122B' => '2424M',
'J4138A' => '9308M', 'J4138A' => '9308M',
'J4139A' => '9304M', 'J4139A' => '9304M',
'J4812A' => '2512', 'J4812A' => '2512',
'J4813A' => '2524', 'J4813A' => '2524',
'J4815A' => '3324XL', 'J4815A' => '3324XL',
'J4819A' => '5308XL', 'J4819A' => '5308XL',
'J4840A' => '6308M-SX', 'J4840A' => '6308M-SX',
'J4841A' => '6208M-SX', 'J4841A' => '6208M-SX',
'J4850A' => '5304XL', 'J4850A' => '5304XL',
'J4851A' => '3124', 'J4851A' => '3124',
'J4865A' => '4108GL', 'J4865A' => '4108GL',
'J4874A' => '9315M', 'J4874A' => '9315M',
'J4887A' => '4104GL', 'J4887A' => '4104GL',
'J4899A' => '2650', 'J4899A' => '2650',
'J4899B' => '2650-CR', 'J4899B' => '2650-CR',
'J4900A' => '2626', 'J4900A' => '2626',
'J4900B' => '2626-CR', 'J4900B' => '2626-CR',
'J4902A' => '6108', 'J4902A' => '6108',
'J4903A' => '2824', 'J4903A' => '2824',
'J4904A' => '2848', 'J4904A' => '2848',
'J4905A' => '3400cl-24G', 'J4905A' => '3400cl-24G',
'J4906A' => '3400cl-48G', 'J4906A' => '3400cl-48G',
'J8130A' => 'WAP-420-NA', 'J8130A' => 'WAP-420-NA',
'J8131A' => 'WAP-420-WW', 'J8131A' => 'WAP-420-WW',
'J8133A' => 'AP520WL', 'J8133A' => 'AP520WL',
'J8164A' => '2626-PWR', 'J8164A' => '2626-PWR',
'J8165A' => '2650-PWR', 'J8165A' => '2650-PWR',
'J8433A' => 'CX4-6400cl-6XG', 'J8433A' => 'CX4-6400cl-6XG',
'J8474A' => 'MF-6400cl-6XG', 'J8474A' => 'MF-6400cl-6XG',
'J8680A' => '9608sl', 'J8680A' => '9608sl',
'J8692A' => '3500yl-24G-PWR', 'J8692A' => '3500yl-24G-PWR',
'J8693A' => '3500yl-48G-PWR', 'J8693A' => '3500yl-48G-PWR',
'J8697A' => '5406zl', 'J8697A' => '5406zl',
'J8698A' => '5412zl', 'J8698A' => '5412zl',
'J8718A' => '5404yl', 'J8718A' => '5404yl',
'J8719A' => '5408yl', 'J8719A' => '5408yl',
'J8770A' => '4204vl', 'J8770A' => '4204vl',
'J8771A' => '4202vl-48G', 'J8771A' => '4202vl-48G',
'J8772A' => '4202vl-72', 'J8772A' => '4202vl-72',
'J8773A' => '4208vl', 'J8773A' => '4208vl',
'J8762A' => '2600-8-PWR', 'J8762A' => '2600-8-PWR',
'J8992A' => '6200yl-24G', 'J8992A' => '6200yl-24G',
'J9019A' => '2510-24A', 'J9019A' => '2510-24A',
'J9020A' => '2510-48A', 'J9020A' => '2510-48A',
'J9021A' => '2810-24G', 'J9021A' => '2810-24G',
'J9022A' => '2810-48G', 'J9022A' => '2810-48G',
'J9028A' => '1800-24G', 'J9028A' => '1800-24G',
'J9029A' => '1800-8G', 'J9029A' => '1800-8G',
'J9050A' => '2900-48G', 'J9050A' => '2900-48G',
'J9049A' => '2900-24G', 'J9049A' => '2900-24G',
'J9032A' => '4202vl-68G', 'J9032A' => '4202vl-68G',
'J9091A' => '8212zl', 'J9091A' => '8212zl',
); );
# Method Overrides # Method Overrides
@@ -189,13 +196,15 @@ sub mem_total {
sub os { sub os {
return 'hp'; return 'hp';
} }
sub os_ver { sub os_ver {
my $hp = shift; my $hp = shift;
my $os_version = $hp->os_version(); my $os_version = $hp->os_version();
return $os_version if defined $os_version; return $os_version if defined $os_version;
# Some older ones don't have this value,so we cull it from the description # Some older ones don't have this value,so we cull it from the description
my $descr = $hp->description(); my $descr = $hp->description();
if ($descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/) { if ( $descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/ ) {
return $1; return $1;
} }
return; return;
@@ -224,15 +233,15 @@ sub serial {
} }
sub interfaces { sub interfaces {
my $hp = shift; my $hp = shift;
my $interfaces = $hp->i_index(); my $interfaces = $hp->i_index();
my $i_descr = $hp->i_description(); my $i_descr = $hp->i_description();
my %if; my %if;
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $descr = $i_descr->{$iid}; my $descr = $i_descr->{$iid};
next unless defined $descr; next unless defined $descr;
$if{$iid} = $descr if (defined $descr and length $descr); $if{$iid} = $descr if ( defined $descr and length $descr );
} }
return \%if return \%if
@@ -240,14 +249,14 @@ sub interfaces {
} }
sub i_name { sub i_name {
my $hp = shift; my $hp = shift;
my $i_alias = $hp->i_alias(); my $i_alias = $hp->i_alias();
my $e_name = $hp->e_name(); my $e_name = $hp->e_name();
my $e_port = $hp->e_port(); my $e_port = $hp->e_port();
my %i_name; my %i_name;
foreach my $port (keys %$e_name){ foreach my $port ( keys %$e_name ) {
my $iid = $e_port->{$port}; my $iid = $e_port->{$port};
next unless defined $iid; next unless defined $iid;
my $alias = $i_alias->{$iid}; my $alias = $i_alias->{$iid};
@@ -255,7 +264,7 @@ sub i_name {
$i_name{$iid} = $e_name->{$port}; $i_name{$iid} = $e_name->{$port};
# Check for alias # Check for alias
$i_name{$iid} = $alias if (defined $alias and length($alias)); $i_name{$iid} = $alias if ( defined $alias and length($alias) );
} }
return \%i_name; return \%i_name;
@@ -268,22 +277,22 @@ sub i_duplex {
} }
sub i_duplex_admin { sub i_duplex_admin {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
# Try HP MIB first # Try HP MIB first
my $hp_duplex = $hp->hp_duplex_admin($partial); my $hp_duplex = $hp->hp_duplex_admin($partial);
if (defined $hp_duplex and scalar(keys %$hp_duplex)){ if ( defined $hp_duplex and scalar( keys %$hp_duplex ) ) {
my %i_duplex; my %i_duplex;
foreach my $if (keys %$hp_duplex){ foreach my $if ( keys %$hp_duplex ) {
my $duplex = $hp_duplex->{$if}; my $duplex = $hp_duplex->{$if};
next unless defined $duplex; next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$duplex = 'auto' if $duplex =~ /auto/i; $duplex = 'auto' if $duplex =~ /auto/i;
$i_duplex{$if}=$duplex; $i_duplex{$if} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
@@ -297,13 +306,13 @@ sub vendor {
} }
sub log { sub log {
my $hp=shift; my $hp = shift;
my $log = $hp->l_descr(); my $log = $hp->l_descr();
my $logstring = undef; my $logstring = undef;
foreach my $val (values %$log){ foreach my $val ( values %$log ) {
next if $val =~ /^Link\s+(Up|Down)/; next if $val =~ /^Link\s+(Up|Down)/;
$logstring .= "$val\n"; $logstring .= "$val\n";
} }
@@ -312,14 +321,14 @@ sub log {
} }
sub slots { sub slots {
my $hp=shift; my $hp = shift;
my $e_name = $hp->e_name(); my $e_name = $hp->e_name();
return unless defined $e_name; return unless defined $e_name;
my $slots; my $slots;
foreach my $slot (keys %$e_name) { foreach my $slot ( keys %$e_name ) {
$slots++ if $e_name->{$slot} =~ /slot/i; $slots++ if $e_name->{$slot} =~ /slot/i;
} }
@@ -328,31 +337,33 @@ sub slots {
sub fan { sub fan {
my $hp = shift; my $hp = shift;
return &_sensor($hp, 'fan'); return &_sensor( $hp, 'fan' );
} }
sub ps1_status { sub ps1_status {
my $hp = shift; my $hp = shift;
return &_sensor($hp, 'power', '^power supply 1') || &_sensor($hp, 'power', '^power supply sensor'); return &_sensor( $hp, 'power', '^power supply 1' )
|| &_sensor( $hp, 'power', '^power supply sensor' );
} }
sub ps2_status { sub ps2_status {
my $hp = shift; my $hp = shift;
return &_sensor($hp, 'power', '^power supply 2') || &_sensor($hp, 'power', '^redundant'); return &_sensor( $hp, 'power', '^power supply 2' )
|| &_sensor( $hp, 'power', '^redundant' );
} }
sub _sensor { sub _sensor {
my $hp = shift; my $hp = shift;
my $search_type = shift || 'fan'; my $search_type = shift || 'fan';
my $search_name = shift || ''; my $search_name = shift || '';
my $hp_s_oid = $hp->hp_s_oid(); my $hp_s_oid = $hp->hp_s_oid();
my $result; my $result;
foreach my $sensor (keys %$hp_s_oid) { foreach my $sensor ( keys %$hp_s_oid ) {
my $sensortype = &SNMP::translateObj($hp_s_oid->{$sensor}); my $sensortype = &SNMP::translateObj( $hp_s_oid->{$sensor} );
if ($sensortype =~ /$search_type/i) { if ( $sensortype =~ /$search_type/i ) {
my $sensorname = $hp->hp_s_name()->{$sensor}; my $sensorname = $hp->hp_s_name()->{$sensor};
my $sensorstatus = $hp->hp_s_status()->{$sensor}; my $sensorstatus = $hp->hp_s_status()->{$sensor};
if ($sensorname =~ /$search_name/i) { if ( $sensorname =~ /$search_name/i ) {
$result = $sensorstatus; $result = $sensorstatus;
} }
} }
@@ -362,19 +373,19 @@ sub _sensor {
# Bridge MIB does not map Bridge Port to ifIndex correctly on all models # Bridge MIB does not map Bridge Port to ifIndex correctly on all models
sub bp_index { sub bp_index {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
my $if_index = $hp->i_index($partial); my $if_index = $hp->i_index($partial);
my $model = $hp->model(); my $model = $hp->model();
my $bp_index = $hp->bp_index2($partial); my $bp_index = $hp->bp_index2($partial);
unless (defined $model and $model =~ /(1600|2424|4000|8000)/) { unless ( defined $model and $model =~ /(1600|2424|4000|8000)/ ) {
return $bp_index; return $bp_index;
} }
my %mod_bp_index; my %mod_bp_index;
foreach my $iid (keys %$if_index){ foreach my $iid ( keys %$if_index ) {
$mod_bp_index{$iid} = $iid; $mod_bp_index{$iid} = $iid;
} }
return \%mod_bp_index; return \%mod_bp_index;
@@ -384,12 +395,12 @@ sub bp_index {
# Q-BRIDGE if available. # Q-BRIDGE if available.
sub v_index { sub v_index {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
# Newer devices # Newer devices
my $q_index = $hp->SUPER::v_index($partial); my $q_index = $hp->SUPER::v_index($partial);
if (defined $q_index and scalar(keys %$q_index)){ if ( defined $q_index and scalar( keys %$q_index ) ) {
return $q_index; return $q_index;
} }
@@ -398,12 +409,12 @@ sub v_index {
} }
sub v_name { sub v_name {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
# Newer devices # Newer devices
my $q_name = $hp->SUPER::v_name($partial); my $q_name = $hp->SUPER::v_name($partial);
if (defined $q_name and scalar(keys %$q_name)){ if ( defined $q_name and scalar( keys %$q_name ) ) {
return $q_name; return $q_name;
} }
@@ -416,7 +427,7 @@ sub i_vlan {
# Newer devices use Q-BRIDGE-MIB # Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->SUPER::i_vlan(); my $qb_i_vlan = $hp->SUPER::i_vlan();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ if ( defined $qb_i_vlan and scalar( keys %$qb_i_vlan ) ) {
return $qb_i_vlan; return $qb_i_vlan;
} }
@@ -426,13 +437,13 @@ sub i_vlan {
my $i_vlan = {}; my $i_vlan = {};
my $hp_v_index = $hp->hp_v_index(); my $hp_v_index = $hp->hp_v_index();
my $hp_v_if_tag = $hp->hp_v_if_tag(); my $hp_v_if_tag = $hp->hp_v_if_tag();
foreach my $row (keys %$hp_v_if_tag){ foreach my $row ( keys %$hp_v_if_tag ) {
my ($index,$if) = split(/\./,$row); my ( $index, $if ) = split( /\./, $row );
my $tag = $hp_v_if_tag->{$row}; my $tag = $hp_v_if_tag->{$row};
my $vlan = $hp_v_index->{$index}; my $vlan = $hp_v_index->{$index};
next unless (defined $tag and $tag =~ /untagged/); next unless ( defined $tag and $tag =~ /untagged/ );
$i_vlan->{$if} = $vlan if defined $vlan; $i_vlan->{$if} = $vlan if defined $vlan;
} }
@@ -445,24 +456,24 @@ sub i_vlan_membership {
# Newer devices use Q-BRIDGE-MIB # Newer devices use Q-BRIDGE-MIB
my $qb_i_vlan = $hp->SUPER::i_vlan_membership(); my $qb_i_vlan = $hp->SUPER::i_vlan_membership();
if (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){ if ( defined $qb_i_vlan and scalar( keys %$qb_i_vlan ) ) {
return $qb_i_vlan; return $qb_i_vlan;
} }
# Older get it from HP-VLAN # Older get it from HP-VLAN
my $i_vlan_membership = {}; my $i_vlan_membership = {};
my $hp_v_index = $hp->hp_v_index(); my $hp_v_index = $hp->hp_v_index();
my $hp_v_if_tag = $hp->hp_v_if_tag(); my $hp_v_if_tag = $hp->hp_v_if_tag();
foreach my $row (keys %$hp_v_if_tag){ foreach my $row ( keys %$hp_v_if_tag ) {
my ($index,$if) = split(/\./,$row); my ( $index, $if ) = split( /\./, $row );
my $tag = $hp_v_if_tag->{$row}; my $tag = $hp_v_if_tag->{$row};
my $vlan = $hp_v_index->{$index}; my $vlan = $hp_v_index->{$index};
next unless (defined $tag); next unless ( defined $tag );
next if ($tag eq 'no'); next if ( $tag eq 'no' );
push(@{$i_vlan_membership->{$if}}, $vlan); push( @{ $i_vlan_membership->{$if} }, $vlan );
} }
return $i_vlan_membership; return $i_vlan_membership;
@@ -477,21 +488,21 @@ sub hasCDP {
} }
sub c_ip { sub c_ip {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
my $cdp = $hp->SUPER::c_ip($partial) || {}; my $cdp = $hp->SUPER::c_ip($partial) || {};
my $lldp = $hp->lldp_ip($partial) || {}; my $lldp = $hp->lldp_ip($partial) || {};
my %c_ip; my %c_ip;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid}; my $ip = $cdp->{$iid};
next unless defined $ip; next unless defined $ip;
$c_ip{$iid} = $ip; $c_ip{$iid} = $ip;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid}; my $ip = $lldp->{$iid};
next unless defined $ip; next unless defined $ip;
@@ -501,21 +512,21 @@ sub c_ip {
} }
sub c_if { sub c_if {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp->lldp_if($partial) || {};; my $lldp = $hp->lldp_if($partial) || {};
my $cdp = $hp->SUPER::c_if($partial) || {}; my $cdp = $hp->SUPER::c_if($partial) || {};
my %c_if; my %c_if;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid}; my $if = $cdp->{$iid};
next unless defined $if; next unless defined $if;
$c_if{$iid} = $if; $c_if{$iid} = $if;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid}; my $if = $lldp->{$iid};
next unless defined $if; next unless defined $if;
@@ -525,21 +536,21 @@ sub c_if {
} }
sub c_port { sub c_port {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp->lldp_port($partial) || {}; my $lldp = $hp->lldp_port($partial) || {};
my $cdp = $hp->SUPER::c_port($partial) || {}; my $cdp = $hp->SUPER::c_port($partial) || {};
my %c_port; my %c_port;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid}; my $port = $cdp->{$iid};
next unless defined $port; next unless defined $port;
$c_port{$iid} = $port; $c_port{$iid} = $port;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid}; my $port = $lldp->{$iid};
next unless defined $port; next unless defined $port;
@@ -549,21 +560,21 @@ sub c_port {
} }
sub c_id { sub c_id {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp->lldp_id($partial) || {}; my $lldp = $hp->lldp_id($partial) || {};
my $cdp = $hp->SUPER::c_id($partial) || {}; my $cdp = $hp->SUPER::c_id($partial) || {};
my %c_id; my %c_id;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid}; my $id = $cdp->{$iid};
next unless defined $id; next unless defined $id;
$c_id{$iid} = $id; $c_id{$iid} = $id;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid}; my $id = $lldp->{$iid};
next unless defined $id; next unless defined $id;
@@ -573,21 +584,21 @@ sub c_id {
} }
sub c_platform { sub c_platform {
my $hp = shift; my $hp = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp->lldp_rem_sysdesc($partial) || {}; my $lldp = $hp->lldp_rem_sysdesc($partial) || {};
my $cdp = $hp->SUPER::c_platform($partial) || {}; my $cdp = $hp->SUPER::c_platform($partial) || {};
my %c_platform; my %c_platform;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid}; my $platform = $cdp->{$iid};
next unless defined $platform; next unless defined $platform;
$c_platform{$iid} = $platform; $c_platform{$iid} = $platform;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid}; my $platform = $lldp->{$iid};
next unless defined $platform; next unless defined $platform;
@@ -923,9 +934,9 @@ Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4 If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry. address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different IPv4 If multiple entries exist with the same local port, c_if(), with different
addresses, c_ip(), there is either a non-CDP/LLDP device in between two or IPv4 addresses, c_ip(), there is either a non-CDP/LLDP device in between two
more devices or multiple devices which are not directly connected. or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper. Use the data from the Layer2 Topology Table below to dig deeper.

View File

@@ -37,40 +37,33 @@ use SNMP::Info::Bridge;
use SNMP::Info::SONMP; use SNMP::Info::SONMP;
use SNMP::Info::Airespace; use SNMP::Info::Airespace;
@SNMP::Info::Layer2::N2270::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::Airespace Exporter/; @SNMP::Info::Layer2::N2270::ISA
= qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::Airespace Exporter/;
@SNMP::Info::Layer2::N2270::EXPORT_OK = qw//; @SNMP::Info::Layer2::N2270::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::Bridge::MIBS, %SNMP::Info::SONMP::MIBS, %SNMP::Info::Airespace::MIBS,
%SNMP::Info::SONMP::MIBS, );
%SNMP::Info::Airespace::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::Bridge::GLOBALS, %SNMP::Info::SONMP::GLOBALS, %SNMP::Info::Airespace::GLOBALS,
%SNMP::Info::SONMP::GLOBALS, );
%SNMP::Info::Airespace::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS, %SNMP::Info::Bridge::FUNCS,
%SNMP::Info::Bridge::FUNCS, %SNMP::Info::SONMP::FUNCS, %SNMP::Info::Airespace::FUNCS,
%SNMP::Info::SONMP::FUNCS, );
%SNMP::Info::Airespace::FUNCS,
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::MUNGE, %SNMP::Info::MUNGE, %SNMP::Info::Bridge::MUNGE,
%SNMP::Info::Bridge::MUNGE, %SNMP::Info::SONMP::MUNGE, %SNMP::Info::Airespace::MUNGE,
%SNMP::Info::SONMP::MUNGE, );
%SNMP::Info::Airespace::MUNGE,
);
sub os { sub os {
return 'nortel'; return 'nortel';
@@ -82,7 +75,7 @@ sub vendor {
sub model { sub model {
my $n2270 = shift; my $n2270 = shift;
my $id = $n2270->id(); my $id = $n2270->id();
return unless defined $id; return unless defined $id;
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
@@ -104,7 +97,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::Layer2::N2270 - SNMP Interface to Nortel 2270 Series Wireless Switch SNMP::Info::Layer2::N2270 - SNMP Interface to Nortel 2270 Series Wireless
Switch
=head1 AUTHOR =head1 AUTHOR

View File

@@ -36,59 +36,60 @@ use SNMP::Info::SONMP;
use SNMP::Info::IEEE802dot11; use SNMP::Info::IEEE802dot11;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::NAP222x::ISA = qw/SNMP::Info::SONMP SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::NAP222x::ISA
= qw/SNMP::Info::SONMP SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::NAP222x::EXPORT_OK = qw//; @SNMP::Info::Layer2::NAP222x::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS, %SNMP::Info::IEEE802dot11::MIBS,
%SNMP::Info::IEEE802dot11::MIBS, %SNMP::Info::SONMP::MIBS, 'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer',
%SNMP::Info::SONMP::MIBS, );
'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer2::GLOBALS, %SNMP::Info::Layer2::GLOBALS,
%SNMP::Info::IEEE802dot11::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS,
%SNMP::Info::SONMP::GLOBALS, %SNMP::Info::SONMP::GLOBALS,
'nt_hw_ver' => 'ntWlanSwHardwareVer', 'nt_hw_ver' => 'ntWlanSwHardwareVer',
'nt_fw_ver' => 'ntWlanSwBootRomVer', 'nt_fw_ver' => 'ntWlanSwBootRomVer',
'nt_sw_ver' => 'ntWlanSwOpCodeVer', 'nt_sw_ver' => 'ntWlanSwOpCodeVer',
'nt_cc' => 'ntWlanSwCountryCode', 'nt_cc' => 'ntWlanSwCountryCode',
'tftp_action' => 'ntWlanTransferStart', 'tftp_action' => 'ntWlanTransferStart',
'tftp_host' => 'ntWlanFileServer', 'tftp_host' => 'ntWlanFileServer',
'tftp_file' => 'ntWlanDestFile', 'tftp_file' => 'ntWlanDestFile',
'tftp_type' => 'ntWlanFileType', 'tftp_type' => 'ntWlanFileType',
'tftp_result' => 'ntWlanFileTransferStatus', 'tftp_result' => 'ntWlanFileTransferStatus',
'tftp_xtype' => 'ntWlanTransferType', 'tftp_xtype' => 'ntWlanTransferType',
'tftp_src_file' => 'ntWlanSrcFile', 'tftp_src_file' => 'ntWlanSrcFile',
'ftp_user' => 'ntWlanUserName', 'ftp_user' => 'ntWlanUserName',
'ftp_pass' => 'ntWlanPassword', 'ftp_pass' => 'ntWlanPassword',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer2::FUNCS, %SNMP::Info::Layer2::FUNCS,
%SNMP::Info::IEEE802dot11::FUNCS, %SNMP::Info::IEEE802dot11::FUNCS,
%SNMP::Info::SONMP::FUNCS, %SNMP::Info::SONMP::FUNCS,
# From ntWlanPortTable
'nt_prt_name' => 'ntWlanPortName',
'nt_dpx_admin' => 'ntWlanPortCapabilities',
'nt_auto' => 'ntWlanPortAutonegotiation',
'nt_dpx' => 'ntWlanPortSpeedDpxStatus',
# From ntWlanDot11PhyOperationTable
'nt_i_broadcast' => 'ntWlanDot11ClosedSystem',
# From ntWlanApVlanTable
'nt_i_vlan' => 'ntWlanApVlanDefaultVid',
);
%MUNGE = ( # From ntWlanPortTable
%SNMP::Info::Layer2::MUNGE, 'nt_prt_name' => 'ntWlanPortName',
%SNMP::Info::IEEE802dot11::MUNGE, 'nt_dpx_admin' => 'ntWlanPortCapabilities',
%SNMP::Info::SONMP::MUNGE, 'nt_auto' => 'ntWlanPortAutonegotiation',
); 'nt_dpx' => 'ntWlanPortSpeedDpxStatus',
# From ntWlanDot11PhyOperationTable
'nt_i_broadcast' => 'ntWlanDot11ClosedSystem',
# From ntWlanApVlanTable
'nt_i_vlan' => 'ntWlanApVlanDefaultVid',
);
%MUNGE = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE,
%SNMP::Info::SONMP::MUNGE,
);
sub os { sub os {
return 'nortel'; return 'nortel';
@@ -96,31 +97,31 @@ sub os {
sub os_bin { sub os_bin {
my $nap222x = shift; my $nap222x = shift;
my $bin = $nap222x->nt_fw_ver(); my $bin = $nap222x->nt_fw_ver();
return unless defined $bin; return unless defined $bin;
if ($bin =~ m/(\d+\.\d+\.\d+)/){ if ( $bin =~ m/(\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
return; return;
} }
sub model { sub model {
my $nap222x = shift; my $nap222x = shift;
my $descr = $nap222x->description(); my $descr = $nap222x->description();
return unless defined $descr; return unless defined $descr;
return 'AP-2220' if ($descr =~ /2220/); return 'AP-2220' if ( $descr =~ /2220/ );
return 'AP-2221' if ($descr =~ /2221/); return 'AP-2221' if ( $descr =~ /2221/ );
return; return;
} }
sub mac { sub mac {
my $nap222x = shift; my $nap222x = shift;
my $i_mac = $nap222x->i_mac(); my $i_mac = $nap222x->i_mac();
# Return Interface MAC # Return Interface MAC
foreach my $entry (keys %$i_mac){ foreach my $entry ( keys %$i_mac ) {
my $sn = $i_mac->{$entry}; my $sn = $i_mac->{$entry};
next unless $sn; next unless $sn;
return $sn; return $sn;
@@ -130,10 +131,10 @@ sub mac {
sub serial { sub serial {
my $nap222x = shift; my $nap222x = shift;
my $i_mac = $nap222x->i_mac(); my $i_mac = $nap222x->i_mac();
# Return Interface MAC # Return Interface MAC
foreach my $entry (keys %$i_mac){ foreach my $entry ( keys %$i_mac ) {
my $sn = $i_mac->{$entry}; my $sn = $i_mac->{$entry};
next unless $sn; next unless $sn;
return $sn; return $sn;
@@ -145,11 +146,11 @@ sub interfaces {
my $nap222x = shift; my $nap222x = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $nap222x->i_index($partial) || {}; my $interfaces = $nap222x->i_index($partial) || {};
my $description = $nap222x->i_description($partial) || {}; my $description = $nap222x->i_description($partial) || {};
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $desc = $description->{$iid}; my $desc = $description->{$iid};
next unless defined $desc; next unless defined $desc;
next if $desc =~ /lo/i; next if $desc =~ /lo/i;
@@ -163,16 +164,16 @@ sub i_duplex {
my $nap222x = shift; my $nap222x = shift;
my $partial = shift; my $partial = shift;
my $mode = $nap222x->nt_dpx($partial) || {}; my $mode = $nap222x->nt_dpx($partial) || {};
my $port_name = $nap222x->nt_prt_name($partial) || {}; my $port_name = $nap222x->nt_prt_name($partial) || {};
my $interfaces = $nap222x->interfaces($partial) || {}; my $interfaces = $nap222x->interfaces($partial) || {};
my %i_duplex; my %i_duplex;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
my $port = $interfaces->{$if}; my $port = $interfaces->{$if};
next unless $port =~ /dp/i; next unless $port =~ /dp/i;
foreach my $idx (keys %$mode) { foreach my $idx ( keys %$mode ) {
my $name = $port_name->{$idx}||'unknown'; my $name = $port_name->{$idx} || 'unknown';
next unless $name eq $port; next unless $name eq $port;
my $duplex = $mode->{$idx}; my $duplex = $mode->{$idx};
@@ -180,7 +181,7 @@ sub i_duplex {
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if}=$duplex; $i_duplex{$if} = $duplex;
} }
} }
return \%i_duplex; return \%i_duplex;
@@ -190,27 +191,29 @@ sub i_duplex_admin {
my $nap222x = shift; my $nap222x = shift;
my $partial = shift; my $partial = shift;
my $dpx_admin = $nap222x->nt_dpx_admin($partial) || {}; my $dpx_admin = $nap222x->nt_dpx_admin($partial) || {};
my $nt_auto = $nap222x->nt_auto($partial) || {}; my $nt_auto = $nap222x->nt_auto($partial) || {};
my $interfaces = $nap222x->interfaces($partial) || {}; my $interfaces = $nap222x->interfaces($partial) || {};
my $port_name = $nap222x->nt_prt_name($partial) || {}; my $port_name = $nap222x->nt_prt_name($partial) || {};
my %i_duplex_admin; my %i_duplex_admin;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
my $port = $interfaces->{$if}; my $port = $interfaces->{$if};
next unless $port =~ /dp/i; next unless $port =~ /dp/i;
foreach my $idx (keys %$dpx_admin) { foreach my $idx ( keys %$dpx_admin ) {
my $name = $port_name->{$idx}||'unknown'; my $name = $port_name->{$idx} || 'unknown';
next unless $name eq $port; next unless $name eq $port;
my $duplex = $dpx_admin->{$idx}; my $duplex = $dpx_admin->{$idx};
my $auto = $nt_auto->{$idx}; my $auto = $nt_auto->{$idx};
$duplex = 'other' unless defined $duplex; $duplex = 'other' unless defined $duplex;
$duplex = 'half' if ($duplex =~ /half/i and $auto =~ /disabled/i); $duplex = 'half'
$duplex = 'full' if ($duplex =~ /full/i and $auto =~ /disabled/i); if ( $duplex =~ /half/i and $auto =~ /disabled/i );
$duplex = 'full'
if ( $duplex =~ /full/i and $auto =~ /disabled/i );
$duplex = 'auto' if $auto =~ /enabled/i; $duplex = 'auto' if $auto =~ /enabled/i;
$i_duplex_admin{$if}=$duplex; $i_duplex_admin{$if} = $duplex;
} }
} }
return \%i_duplex_admin; return \%i_duplex_admin;
@@ -223,12 +226,12 @@ sub i_name {
my $interfaces = $nap222x->interfaces($partial) || {}; my $interfaces = $nap222x->interfaces($partial) || {};
my %i_name; my %i_name;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
my $desc = $interfaces->{$if}; my $desc = $interfaces->{$if};
next unless defined $desc; next unless defined $desc;
my $name = 'unknown'; my $name = 'unknown';
$name = 'Ethernet Interface' if $desc =~ /dp/i; $name = 'Ethernet Interface' if $desc =~ /dp/i;
$name = 'Wireless Interface B' if $desc =~ /ndc/i; $name = 'Wireless Interface B' if $desc =~ /ndc/i;
$name = 'Wireless Interface A' if $desc =~ /ar/i; $name = 'Wireless Interface A' if $desc =~ /ar/i;
@@ -245,7 +248,7 @@ sub bp_index {
my $interfaces = $nap222x->interfaces($partial) || {}; my $interfaces = $nap222x->interfaces($partial) || {};
my %bp_index; my %bp_index;
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $desc = $interfaces->{$iid}; my $desc = $interfaces->{$iid};
next unless defined $desc; next unless defined $desc;
next unless $desc =~ /(ndc|ar)/i; next unless $desc =~ /(ndc|ar)/i;
@@ -253,7 +256,7 @@ sub bp_index {
my $port = 1; my $port = 1;
$port = 2 if $desc =~ /ndc/i; $port = 2 if $desc =~ /ndc/i;
$bp_index{$port} = $iid; $bp_index{$port} = $iid;
} }
return \%bp_index; return \%bp_index;
} }
@@ -265,13 +268,13 @@ sub i_ssidlist {
my $partial = shift; my $partial = shift;
# modify partial to match index # modify partial to match index
if (defined $partial) { if ( defined $partial ) {
$partial = $partial - 2; $partial = $partial - 2;
} }
my $ssids = $nap222x->orig_i_ssidlist($partial) || {}; my $ssids = $nap222x->orig_i_ssidlist($partial) || {};
my %i_ssidlist; my %i_ssidlist;
foreach my $iid (keys %$ssids){ foreach my $iid ( keys %$ssids ) {
my $port = $iid + 2; my $port = $iid + 2;
my $ssid = $ssids->{$iid}; my $ssid = $ssids->{$iid};
next unless defined $ssid; next unless defined $ssid;
@@ -286,13 +289,13 @@ sub i_ssidbcast {
my $partial = shift; my $partial = shift;
# modify partial to match index # modify partial to match index
if (defined $partial) { if ( defined $partial ) {
$partial = $partial - 2; $partial = $partial - 2;
} }
my $bcast = $nap222x->nt_i_broadcast($partial) || {}; my $bcast = $nap222x->nt_i_broadcast($partial) || {};
my %i_ssidbcast; my %i_ssidbcast;
foreach my $iid (keys %$bcast){ foreach my $iid ( keys %$bcast ) {
my $port = $iid + 2; my $port = $iid + 2;
my $bc = $bcast->{$iid}; my $bc = $bcast->{$iid};
next unless defined $bc; next unless defined $bc;
@@ -307,24 +310,24 @@ sub i_80211channel {
my $partial = shift; my $partial = shift;
# modify partial to match index # modify partial to match index
if (defined $partial) { if ( defined $partial ) {
$partial = $partial - 2; $partial = $partial - 2;
} }
my $phy_type = $nap222x->dot11_phy_type($partial) || {}; my $phy_type = $nap222x->dot11_phy_type($partial) || {};
my $cur_freq = $nap222x->dot11_cur_freq() || {}; my $cur_freq = $nap222x->dot11_cur_freq() || {};
my $cur_ch = $nap222x->dot11_cur_ch() || {}; my $cur_ch = $nap222x->dot11_cur_ch() || {};
my %i_80211channel; my %i_80211channel;
foreach my $iid (keys %$phy_type){ foreach my $iid ( keys %$phy_type ) {
my $port = $iid + 2; my $port = $iid + 2;
my $type = $phy_type->{$iid}; my $type = $phy_type->{$iid};
next unless defined $type; next unless defined $type;
if ($type =~ /dsss/) { if ( $type =~ /dsss/ ) {
my $ch = $cur_ch->{1}; my $ch = $cur_ch->{1};
next unless defined $ch; next unless defined $ch;
$i_80211channel{$port} = $ch; $i_80211channel{$port} = $ch;
} }
elsif ($type =~ /ofdm/) { elsif ( $type =~ /ofdm/ ) {
my $ch = $cur_freq->{0}; my $ch = $cur_freq->{0};
next unless defined $ch; next unless defined $ch;
$i_80211channel{$port} = $ch; $i_80211channel{$port} = $ch;
@@ -342,13 +345,13 @@ sub i_vlan {
my $partial = shift; my $partial = shift;
# modify partial to match index # modify partial to match index
if (defined $partial) { if ( defined $partial ) {
$partial = $partial - 2; $partial = $partial - 2;
} }
my $vlans = $nap222x->nt_i_vlan($partial) || {}; my $vlans = $nap222x->nt_i_vlan($partial) || {};
my %i_vlan; my %i_vlan;
foreach my $iid (keys %$vlans){ foreach my $iid ( keys %$vlans ) {
my $port = $iid + 2; my $port = $iid + 2;
my $vlan = $vlans->{$iid}; my $vlan = $vlans->{$iid};
next unless defined $vlan; next unless defined $vlan;
@@ -363,7 +366,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::Layer2::NAP222x - SNMP Interface to Nortel 2220 Series Access Points SNMP::Info::Layer2::NAP222x - SNMP Interface to Nortel 2220 Series Access
Points
=head1 AUTHOR =head1 AUTHOR

View File

@@ -34,28 +34,20 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Netgear::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Netgear::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Netgear::EXPORT_OK = qw//; @SNMP::Info::Layer2::Netgear::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( %SNMP::Info::Layer2::MIBS, );
%SNMP::Info::Layer2::MIBS,
);
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS, );
%SNMP::Info::Layer2::GLOBALS,
);
%FUNCS = ( %FUNCS = ( %SNMP::Info::Layer2::FUNCS, );
%SNMP::Info::Layer2::FUNCS,
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer2::MUNGE, );
%SNMP::Info::Layer2::MUNGE,
);
sub vendor { sub vendor {
return 'netgear'; return 'netgear';
@@ -82,15 +74,15 @@ sub model {
# return anything. # return anything.
sub fw_mac { sub fw_mac {
my $netgear = shift; my $netgear = shift;
my $ret = $netgear->qb_fw_mac(); my $ret = $netgear->qb_fw_mac();
$ret = $netgear->orig_fw_mac() if (!defined($ret)); $ret = $netgear->orig_fw_mac() if ( !defined($ret) );
return $ret; return $ret;
} }
sub fw_port { sub fw_port {
my $netgear = shift; my $netgear = shift;
my $ret = $netgear->qb_fw_port(); my $ret = $netgear->qb_fw_port();
$ret = $netgear->orig_fw_port() if (!defined($ret)); $ret = $netgear->orig_fw_port() if ( !defined($ret) );
return $ret; return $ret;
} }
@@ -141,7 +133,8 @@ inherited methods.
=item Inherited Classes' MIBs =item Inherited Classes' MIBs
MIBs listed in L<SNMP::Info::Layer2/"Required MIBs"> and its inherited classes. MIBs listed in L<SNMP::Info::Layer2/"Required MIBs"> and its inherited
classes.
=back =back

View File

@@ -35,38 +35,36 @@ use Exporter;
use SNMP::Info::IEEE802dot11; use SNMP::Info::IEEE802dot11;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::Orinoco::ISA = qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Orinoco::ISA
= qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//; @SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer2::MIBS, %SNMP::Info::Layer2::MIBS,
%SNMP::Info::IEEE802dot11::MIBS, %SNMP::Info::IEEE802dot11::MIBS,
#'ORiNOCO-MIB' => 'orinoco',
);
%GLOBALS = ( #'ORiNOCO-MIB' => 'orinoco',
%SNMP::Info::Layer2::GLOBALS, );
%SNMP::Info::IEEE802dot11::GLOBALS,
);
%FUNCS = ( %GLOBALS
%SNMP::Info::Layer2::FUNCS, = ( %SNMP::Info::Layer2::GLOBALS, %SNMP::Info::IEEE802dot11::GLOBALS, );
%SNMP::Info::IEEE802dot11::FUNCS,
# ORiNOCO-MIB:oriWirelessIfPropertiesTable
#'ori_ssid' => 'oriWirelessIfNetworkName',
#'ori_channel' => 'oriWirelessIfChannel',
#'ori_closed_sys' => 'oriWirelessIfClosedSystem',
# ORiNOCO-MIB:oriSystemInvMgmtComponentTable
);
%MUNGE = ( %FUNCS = (
%SNMP::Info::Layer2::MUNGE, %SNMP::Info::Layer2::FUNCS,
%SNMP::Info::IEEE802dot11::MUNGE, %SNMP::Info::IEEE802dot11::FUNCS,
);
# ORiNOCO-MIB:oriWirelessIfPropertiesTable
#'ori_ssid' => 'oriWirelessIfNetworkName',
#'ori_channel' => 'oriWirelessIfChannel',
#'ori_closed_sys' => 'oriWirelessIfClosedSystem',
# ORiNOCO-MIB:oriSystemInvMgmtComponentTable
);
%MUNGE = ( %SNMP::Info::Layer2::MUNGE, %SNMP::Info::IEEE802dot11::MUNGE, );
sub os { sub os {
return 'orinoco'; return 'orinoco';
@@ -78,10 +76,10 @@ sub os_ver {
my $descr = $orinoco->description(); my $descr = $orinoco->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/V(\d+\.\d+)/){ if ( $descr =~ m/V(\d+\.\d+)/ ) {
return $1; return $1;
} }
if ($descr =~ m/v(\d+\.\d+\.\d+)/){ if ( $descr =~ m/v(\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
@@ -94,10 +92,10 @@ sub os_bin {
my $descr = $orinoco->description(); my $descr = $orinoco->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/V(\d+\.\d+)$/){ if ( $descr =~ m/V(\d+\.\d+)$/ ) {
return $1; return $1;
} }
if ($descr =~ m/v(\d+\.\d+\.\d+)$/){ if ( $descr =~ m/v(\d+\.\d+\.\d+)$/ ) {
return $1; return $1;
} }
@@ -114,8 +112,8 @@ sub model {
my $descr = $orinoco->description(); my $descr = $orinoco->description();
return unless defined $descr; return unless defined $descr;
return $1 if ($descr =~ /(AP-\d+)/); return $1 if ( $descr =~ /(AP-\d+)/ );
return 'WavePOINT-II' if ($descr =~ /WavePOINT-II/); return 'WavePOINT-II' if ( $descr =~ /WavePOINT-II/ );
return; return;
} }
@@ -125,7 +123,7 @@ sub serial {
my $descr = $orinoco->description(); my $descr = $orinoco->description();
return unless defined $descr; return unless defined $descr;
$descr = $1 if $descr =~ /SN-(\S+)/; $descr = $1 if $descr =~ /SN-(\S+)/;
return $descr; return $descr;
} }
@@ -136,9 +134,10 @@ sub i_ignore {
my $descr = $orinoco->i_description($partial) || {}; my $descr = $orinoco->i_description($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$descr){ foreach my $if ( keys %$descr ) {
my $type = $descr->{$if}; my $type = $descr->{$if};
# Skip virtual interfaces
# Skip virtual interfaces
$i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i; $i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i;
} }
return \%i_ignore; return \%i_ignore;
@@ -148,16 +147,16 @@ sub interfaces {
my $orinoco = shift; my $orinoco = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $orinoco->i_index($partial) || {}; my $interfaces = $orinoco->i_index($partial) || {};
my $descriptions = $orinoco->i_description($partial) || {}; my $descriptions = $orinoco->i_description($partial) || {};
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid}; my $desc = $descriptions->{$iid};
next unless defined $desc; next unless defined $desc;
next if $desc =~ /(lo|empty|PCMCIA)/i; next if $desc =~ /(lo|empty|PCMCIA)/i;
$desc = 'AMD' if $desc =~ /AMD/; $desc = 'AMD' if $desc =~ /AMD/;
$interfaces{$iid} = $desc; $interfaces{$iid} = $desc;
} }
@@ -208,9 +207,9 @@ Eric Miller
=head1 DESCRIPTION =head1 DESCRIPTION
Provides abstraction to the configuration information obtainable from a Orinoco Provides abstraction to the configuration information obtainable from
Access Point through SNMP. Orinoco devices have been manufactured by Proxim, Orinoco Access Point through SNMP. Orinoco devices have been manufactured
Agere, and Lucent. by Proxim, Agere, and Lucent.
For speed or debugging purposes you can call the subclass directly, but not For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above. after determining a more specific class using the method above.

View File

@@ -34,7 +34,7 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer2; use SNMP::Info::Layer2;
@SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/;
@SNMP::Info::Layer2::ZyXEL_DSLAM::EXPORT_OK = qw//; @SNMP::Info::Layer2::ZyXEL_DSLAM::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
@@ -42,27 +42,22 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
# Set for No CDP # Set for No CDP
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer2::GLOBALS );
%SNMP::Info::Layer2::GLOBALS
);
%FUNCS = (%SNMP::Info::Layer2::FUNCS, %FUNCS = (
'ip_adresses' => 'ipAdEntAddr', %SNMP::Info::Layer2::FUNCS,
'i_name' => 'ifDescr', 'ip_adresses' => 'ipAdEntAddr',
'i_description' => 'adslLineConfProfile', 'i_name' => 'ifDescr',
); 'i_description' => 'adslLineConfProfile',
);
%MIBS = ( %MIBS
%SNMP::Info::Layer2::MIBS, = ( %SNMP::Info::Layer2::MIBS, 'ADSL-LINE-MIB' => 'adslLineConfProfile' );
'ADSL-LINE-MIB' => 'adslLineConfProfile'
);
%MUNGE = (%SNMP::Info::Layer2::MUNGE
);
%MUNGE = ( %SNMP::Info::Layer2::MUNGE );
sub layers { sub layers {
my $zyxel = shift; my $zyxel = shift;
my $layers = $zyxel->layers(); my $layers = $zyxel->layers();
return $layers if defined $layers; return $layers if defined $layers;
@@ -82,7 +77,7 @@ sub os_ver {
my $zyxel = shift; my $zyxel = shift;
my $descr = $zyxel->description(); my $descr = $zyxel->description();
if ($descr =~ m/version (\S+) /){ if ( $descr =~ m/version (\S+) / ) {
return $1; return $1;
} }
return; return;
@@ -93,21 +88,24 @@ sub model {
my $desc = $zyxel->description(); my $desc = $zyxel->description();
if ($desc =~ /8-port ADSL Module\(Annex A\)/){ if ( $desc =~ /8-port ADSL Module\(Annex A\)/ ) {
return "AAM1008-61"; return "AAM1008-61";
} elsif ($desc =~ /8-port ADSL Module\(Annex B\)/){ }
elsif ( $desc =~ /8-port ADSL Module\(Annex B\)/ ) {
return "AAM1008-63"; return "AAM1008-63";
} }
return; return;
} }
sub ip{ sub ip {
my $zyxel = shift; my $zyxel = shift;
my $ip_hash = $zyxel->ip_addresses(); my $ip_hash = $zyxel->ip_addresses();
my $found_ip; my $found_ip;
foreach my $ip (keys %{$ip_hash}) { foreach my $ip ( keys %{$ip_hash} ) {
$found_ip = $ip if (defined $ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/); $found_ip = $ip
if ( defined $ip
and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ );
} }
return $found_ip; return $found_ip;
} }

View File

@@ -41,102 +41,110 @@ use SNMP::Info::Entity;
use SNMP::Info::PowerEthernet; use SNMP::Info::PowerEthernet;
@SNMP::Info::Layer3::ISA = qw/SNMP::Info::PowerEthernet @SNMP::Info::Layer3::ISA = qw/SNMP::Info::PowerEthernet
SNMP::Info::Entity SNMP::Info::EtherLike SNMP::Info::Entity SNMP::Info::EtherLike
SNMP::Info::Bridge SNMP::Info Exporter/; SNMP::Info::Bridge SNMP::Info Exporter/;
@SNMP::Info::Layer3::EXPORT_OK = qw//; @SNMP::Info::Layer3::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::MIBS, %MIBS = (
%SNMP::Info::Bridge::MIBS, %SNMP::Info::MIBS,
%SNMP::Info::EtherLike::MIBS, %SNMP::Info::Bridge::MIBS,
%SNMP::Info::Entity::MIBS, %SNMP::Info::EtherLike::MIBS,
%SNMP::Info::PowerEthernet::MIBS, %SNMP::Info::Entity::MIBS,
'IP-MIB' => 'ipNetToMediaIfIndex', %SNMP::Info::PowerEthernet::MIBS,
'OSPF-MIB' => 'ospfRouterId', 'IP-MIB' => 'ipNetToMediaIfIndex',
'BGP4-MIB' => 'bgpIdentifier', 'OSPF-MIB' => 'ospfRouterId',
); 'BGP4-MIB' => 'bgpIdentifier',
);
%GLOBALS = ( %GLOBALS = (
# Inherit the super class ones
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
%SNMP::Info::PowerEthernet::GLOBALS,
'mac' => 'ifPhysAddress.1',
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
'router_ip' => 'ospfRouterId.0',
'bgp_id' => 'bgpIdentifier.0',
'bgp_local_as' => 'bgpLocalAs.0',
);
%FUNCS = ( # Inherit the super class ones
%SNMP::Info::FUNCS, %SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::FUNCS, %SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::EtherLike::FUNCS, %SNMP::Info::EtherLike::GLOBALS,
%SNMP::Info::Entity::FUNCS, %SNMP::Info::Entity::GLOBALS,
%SNMP::Info::PowerEthernet::FUNCS, %SNMP::Info::PowerEthernet::GLOBALS,
# Obsolete Address Translation Table (ARP Cache) 'mac' => 'ifPhysAddress.1',
'old_at_index' => 'atIfIndex', 'serial1' =>
'old_at_paddr' => 'atPhysAddress', '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
'old_at_netaddr' => 'atNetAddress', 'router_ip' => 'ospfRouterId.0',
# IP-MIB IP Net to Media Table (ARP Cache) 'bgp_id' => 'bgpIdentifier.0',
'at_index' => 'ipNetToMediaIfIndex', 'bgp_local_as' => 'bgpLocalAs.0',
'at_paddr' => 'ipNetToMediaPhysAddress', );
'at_netaddr' => 'ipNetToMediaNetAddress',
# OSPF-MIB::ospfIfTable %FUNCS = (
'ospf_if_ip' => 'ospfIfIpAddress', %SNMP::Info::FUNCS,
'ospf_if_area' => 'ospfIfAreaId', %SNMP::Info::Bridge::FUNCS,
'ospf_if_type' => 'ospfIfType', %SNMP::Info::EtherLike::FUNCS,
'ospf_if_hello' => 'ospfIfHelloInterval', %SNMP::Info::Entity::FUNCS,
'ospf_if_dead' => 'ospfIfRtrDeadInterval', %SNMP::Info::PowerEthernet::FUNCS,
'ospf_if_admin' => 'ospfIfAdminStat',
'ospf_if_state' => 'ospfIfState', # Obsolete Address Translation Table (ARP Cache)
# OSPF-MIB::ospfNbrTable 'old_at_index' => 'atIfIndex',
'ospf_ip' => 'ospfHostIpAddress', 'old_at_paddr' => 'atPhysAddress',
'ospf_peers' => 'ospfNbrIpAddr', 'old_at_netaddr' => 'atNetAddress',
'ospf_peer_id' => 'ospfNbrRtrId',
'ospf_peer_state' => 'ospfNbrState', # IP-MIB IP Net to Media Table (ARP Cache)
# BGP4-MIB::bgpPeerTable 'at_index' => 'ipNetToMediaIfIndex',
'bgp_peers' => 'bgpPeerLocalAddr', 'at_paddr' => 'ipNetToMediaPhysAddress',
'bgp_peer_id' => 'bgpPeerIdentifier', 'at_netaddr' => 'ipNetToMediaNetAddress',
'bgp_peer_state' => 'bgpPeerState',
'bgp_peer_as' => 'bgpPeerRemoteAs', # OSPF-MIB::ospfIfTable
'bgp_peer_addr' => 'bgpPeerRemoteAddr', 'ospf_if_ip' => 'ospfIfIpAddress',
'bgp_peer_fsm_est_trans' => 'bgpPeerFsmEstablishedTransitions', 'ospf_if_area' => 'ospfIfAreaId',
'bgp_peer_in_tot_msgs' => 'bgpPeerInTotalMessages', 'ospf_if_type' => 'ospfIfType',
'bgp_peer_in_upd_el_time' => 'bgpPeerInUpdateElapsedTime', 'ospf_if_hello' => 'ospfIfHelloInterval',
'bgp_peer_in_upd' => 'bgpPeerInUpdates', 'ospf_if_dead' => 'ospfIfRtrDeadInterval',
'bgp_peer_out_tot_msgs' => 'bgpPeerOutTotalMessages', 'ospf_if_admin' => 'ospfIfAdminStat',
'bgp_peer_out_upd' => 'bgpPeerOutUpdates', 'ospf_if_state' => 'ospfIfState',
);
# OSPF-MIB::ospfNbrTable
'ospf_ip' => 'ospfHostIpAddress',
'ospf_peers' => 'ospfNbrIpAddr',
'ospf_peer_id' => 'ospfNbrRtrId',
'ospf_peer_state' => 'ospfNbrState',
# BGP4-MIB::bgpPeerTable
'bgp_peers' => 'bgpPeerLocalAddr',
'bgp_peer_id' => 'bgpPeerIdentifier',
'bgp_peer_state' => 'bgpPeerState',
'bgp_peer_as' => 'bgpPeerRemoteAs',
'bgp_peer_addr' => 'bgpPeerRemoteAddr',
'bgp_peer_fsm_est_trans' => 'bgpPeerFsmEstablishedTransitions',
'bgp_peer_in_tot_msgs' => 'bgpPeerInTotalMessages',
'bgp_peer_in_upd_el_time' => 'bgpPeerInUpdateElapsedTime',
'bgp_peer_in_upd' => 'bgpPeerInUpdates',
'bgp_peer_out_tot_msgs' => 'bgpPeerOutTotalMessages',
'bgp_peer_out_upd' => 'bgpPeerOutUpdates',
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE,
'old_at_paddr' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
);
# Inherit all the built in munging
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::EtherLike::MUNGE,
%SNMP::Info::Entity::MUNGE,
%SNMP::Info::PowerEthernet::MUNGE,
'old_at_paddr' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
);
# Method OverRides # Method OverRides
sub root_ip { sub root_ip {
my $l3 = shift; my $l3 = shift;
my $router_ip = $l3->router_ip(); my $router_ip = $l3->router_ip();
my $ospf_ip = $l3->ospf_ip(); my $ospf_ip = $l3->ospf_ip();
# return the first one found here (should be only one) # return the first one found here (should be only one)
if (defined $ospf_ip and scalar(keys %$ospf_ip)){ if ( defined $ospf_ip and scalar( keys %$ospf_ip ) ) {
foreach my $key (keys %$ospf_ip){ foreach my $key ( keys %$ospf_ip ) {
my $ip = $ospf_ip->{$key}; my $ip = $ospf_ip->{$key};
next if $ip eq '0.0.0.0'; next if $ip eq '0.0.0.0';
next unless $l3->snmp_connect_ip($ip); next unless $l3->snmp_connect_ip($ip);
@@ -145,20 +153,24 @@ sub root_ip {
} }
} }
return $router_ip if ( (defined $router_ip) and ($router_ip ne '0.0.0.0') and ($l3->snmp_connect_ip($router_ip)) ); return $router_ip
if (( defined $router_ip )
and ( $router_ip ne '0.0.0.0' )
and ( $l3->snmp_connect_ip($router_ip) ) );
return; return;
} }
sub i_ignore { sub i_ignore {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {}; my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces) { foreach my $if ( keys %$interfaces ) {
# lo -> cisco aironet 350 loopback # lo -> cisco aironet 350 loopback
if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|null)/i){ if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|null)/i ) {
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }
@@ -168,18 +180,19 @@ sub i_ignore {
sub serial { sub serial {
my $l3 = shift; my $l3 = shift;
my $serial1 = $l3->serial1(); my $serial1 = $l3->serial1();
my $e_descr = $l3->e_descr() || {}; my $e_descr = $l3->e_descr() || {};
my $e_serial = $l3->e_serial() || {}; my $e_serial = $l3->e_serial() || {};
my $serial2 = $e_serial->{1} || undef; my $serial2 = $e_serial->{1} || undef;
my $chassis = $e_descr->{1} || undef; my $chassis = $e_descr->{1} || undef;
# precedence # precedence
# serial2,chassis parse,serial1 # serial2,chassis parse,serial1
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/); return $serial2 if ( defined $serial2 and $serial2 !~ /^\s*$/ );
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i); return $1
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/); if ( defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i );
return $serial1 if ( defined $serial1 and $serial1 !~ /^\s*$/ );
return; return;
} }
@@ -190,8 +203,10 @@ sub model {
my $l3 = shift; my $l3 = shift;
my $id = $l3->id(); my $id = $l3->id();
unless (defined $id){ unless ( defined $id ) {
print " SNMP::Info::Layer3::model() - Device does not support sysObjectID\n" if $l3->debug(); print
" SNMP::Info::Layer3::model() - Device does not support sysObjectID\n"
if $l3->debug();
return; return;
} }
@@ -206,34 +221,35 @@ sub model {
} }
sub i_name { sub i_name {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $i_index = $l3->i_index($partial); my $i_index = $l3->i_index($partial);
my $i_alias = $l3->i_alias($partial); my $i_alias = $l3->i_alias($partial);
my $i_name2 = $l3->orig_i_name($partial); my $i_name2 = $l3->orig_i_name($partial);
my %i_name; my %i_name;
foreach my $iid (keys %$i_name2){ foreach my $iid ( keys %$i_name2 ) {
my $name = $i_name2->{$iid}; my $name = $i_name2->{$iid};
my $alias = $i_alias->{$iid}; my $alias = $i_alias->{$iid};
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ? $i_name{$iid}
$alias : = ( defined $alias and $alias !~ /^\s*$/ )
$name; ? $alias
: $name;
} }
return \%i_name; return \%i_name;
} }
sub i_duplex { sub i_duplex {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $el_index = $l3->el_index($partial); my $el_index = $l3->el_index($partial);
my $el_duplex = $l3->el_duplex($partial); my $el_duplex = $l3->el_duplex($partial);
my %i_index; my %i_index;
foreach my $el_port (keys %$el_duplex){ foreach my $el_port ( keys %$el_duplex ) {
my $iid = $el_index->{$el_port}; my $iid = $el_index->{$el_port};
next unless defined $iid; next unless defined $iid;
my $duplex = $el_duplex->{$el_port}; my $duplex = $el_duplex->{$el_port};
@@ -249,14 +265,14 @@ sub i_duplex {
# $l3->interfaces() - Map the Interfaces to their physical names # $l3->interfaces() - Map the Interfaces to their physical names
sub interfaces { sub interfaces {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l3->i_index($partial); my $interfaces = $l3->i_index($partial);
my $descriptions = $l3->i_description($partial); my $descriptions = $l3->i_description($partial);
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid}; my $desc = $descriptions->{$iid};
next unless defined $desc; next unless defined $desc;
@@ -271,29 +287,29 @@ sub vendor {
my $descr = $l3->description(); my $descr = $l3->description();
return 'cisco' if ($descr =~ /(cisco|\bios\b)/i); return 'cisco' if ( $descr =~ /(cisco|\bios\b)/i );
return 'foundry' if ($descr =~ /foundry/i); return 'foundry' if ( $descr =~ /foundry/i );
return 'unknown'; return 'unknown';
} }
sub at_index { sub at_index {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
return $l3->orig_at_index($partial) || $l3->old_at_index($partial); return $l3->orig_at_index($partial) || $l3->old_at_index($partial);
} }
sub at_paddr { sub at_paddr {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
return $l3->orig_at_paddr($partial) || $l3->old_at_paddr($partial); return $l3->orig_at_paddr($partial) || $l3->old_at_paddr($partial);
} }
sub at_netaddr { sub at_netaddr {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
return $l3->orig_at_netaddr($partial) || $l3->old_at_netaddr($partial); return $l3->orig_at_netaddr($partial) || $l3->old_at_netaddr($partial);
@@ -472,7 +488,8 @@ to a hash.
=item $l3->interfaces() =item $l3->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port name. Returns the map between SNMP Interface Identifier (iid) and physical port
name.
Only returns those iids that have a description listed in $l3->i_description() Only returns those iids that have a description listed in $l3->i_description()
@@ -623,8 +640,8 @@ received on this connection
=item $l3->bgp_peer_out_tot_msgs() =item $l3->bgp_peer_out_tot_msgs()
Returns reference to hash of BGP peer to the total number of messages transmitted Returns reference to hash of BGP peer to the total number of messages
to the remote peer on this connection transmitted to the remote peer on this connection
(C<bgpPeerOutTotalMessages>) (C<bgpPeerOutTotalMessages>)

View File

@@ -36,50 +36,54 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Aironet::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Aironet::EXPORT_OK = qw//; @SNMP::Info::Layer3::Aironet::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
'AWCVX-MIB' => 'awcIfTable', 'AWCVX-MIB' => 'awcIfTable',
'IEEE802dot11-MIB' => 'dot11StationID', 'IEEE802dot11-MIB' => 'dot11StationID',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
'mac' => 'dot11StationID.2', 'mac' => 'dot11StationID.2',
# AWC Ethernet Table
'awc_duplex' => 'awcEtherDuplex.0', # AWC Ethernet Table
); 'awc_duplex' => 'awcEtherDuplex.0',
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
'i_mac2' => 'ifPhysAddress', 'i_mac2' => 'ifPhysAddress',
'i_mtu2' => 'ifMtu', 'i_mtu2' => 'ifMtu',
'i_ssid' => 'dot11DesiredSSID', 'i_ssid' => 'dot11DesiredSSID',
# Bridge-mib overrides
'fw_mac2' => 'dot1dTpFdbAddress', # Bridge-mib overrides
'fw_port2' => 'dot1dTpFdbPort', 'fw_mac2' => 'dot1dTpFdbAddress',
'bp_index2' => 'dot1dBasePortIfIndex', 'fw_port2' => 'dot1dTpFdbPort',
# AWC Interface Table (awcIfTable) 'bp_index2' => 'dot1dBasePortIfIndex',
'awc_default_mac' => 'awcIfDefaultPhyAddress',
'awc_mac' => 'awcIfPhyAddress', # AWC Interface Table (awcIfTable)
'awc_ip' => 'awcIfIpAddress', 'awc_default_mac' => 'awcIfDefaultPhyAddress',
'awc_netmask' => 'awcIfIpNetMask', 'awc_mac' => 'awcIfPhyAddress',
'awc_msdu' => 'awcIfMSDUMaxLength', 'awc_ip' => 'awcIfIpAddress',
); 'awc_netmask' => 'awcIfIpNetMask',
'awc_msdu' => 'awcIfMSDUMaxLength',
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE, # Inherit all the built in munging
'i_mac2' => \&SNMP::Info::munge_mac, %SNMP::Info::Layer3::MUNGE,
'awc_mac' => \&SNMP::Info::munge_mac, 'i_mac2' => \&SNMP::Info::munge_mac,
'fw_mac2' => \&SNMP::Info::munge_mac, 'awc_mac' => \&SNMP::Info::munge_mac,
); 'fw_mac2' => \&SNMP::Info::munge_mac,
);
sub os { sub os {
return 'aironet'; return 'aironet';
@@ -90,11 +94,11 @@ sub os_ver {
my $descr = $aironet->description() || ''; my $descr = $aironet->description() || '';
# CAP340 11.21, AP4800-E 11.21 # CAP340 11.21, AP4800-E 11.21
if ($descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/){ if ( $descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/ ) {
return $2; return $2;
} }
if ($descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/){ if ( $descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/ ) {
return $1; return $1;
} }
@@ -103,16 +107,16 @@ sub os_ver {
# Override wireless port with static info # Override wireless port with static info
sub bp_index { sub bp_index {
my $aironet = shift; my $aironet = shift;
my $interfaces = $aironet->interfaces(); my $interfaces = $aironet->interfaces();
my $bp_index = $aironet->bp_index2(); my $bp_index = $aironet->bp_index2();
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $port = $interfaces->{$iid}; my $port = $interfaces->{$iid};
# Hardwire the wireless port to the transparent bridge port # Hardwire the wireless port to the transparent bridge port
if ($port =~ /awc/){ if ( $port =~ /awc/ ) {
$bp_index->{0}=$iid; $bp_index->{0} = $iid;
} }
} }
@@ -127,13 +131,13 @@ sub fw_mac {
my $bs_mac = $aironet->bs_mac(); my $bs_mac = $aironet->bs_mac();
# remove port 0 forwarding table entries, only port 0 static entries # remove port 0 forwarding table entries, only port 0 static entries
foreach my $fw (keys %$fw_mac){ foreach my $fw ( keys %$fw_mac ) {
my $port = $fw_port->{$fw}; my $port = $fw_port->{$fw};
next unless defined $port; next unless defined $port;
delete $fw_mac->{$fw} if $port == 0; delete $fw_mac->{$fw} if $port == 0;
} }
foreach my $bs (keys %$bs_mac){ foreach my $bs ( keys %$bs_mac ) {
my $entry = $bs; my $entry = $bs;
$entry =~ s/\.0$//; $entry =~ s/\.0$//;
$fw_mac->{$entry} = $bs_mac->{$bs}; $fw_mac->{$entry} = $bs_mac->{$bs};
@@ -148,8 +152,7 @@ sub fw_port {
my $fw_port = $aironet->fw_port2(); my $fw_port = $aironet->fw_port2();
my $bs_port = $aironet->bs_port(); my $bs_port = $aironet->bs_port();
foreach my $bs ( keys %$bs_port ) {
foreach my $bs (keys %$bs_port){
my $entry = $bs; my $entry = $bs;
$entry =~ s/\.0$//; $entry =~ s/\.0$//;
$fw_port->{$entry} = $bs_port->{$bs}; $fw_port->{$entry} = $bs_port->{$bs};
@@ -158,18 +161,17 @@ sub fw_port {
return $fw_port; return $fw_port;
} }
sub i_duplex { sub i_duplex {
my $aironet = shift; my $aironet = shift;
my $interfaces = $aironet->interfaces(); my $interfaces = $aironet->interfaces();
my $awc_duplex = $aironet->awc_duplex(); my $awc_duplex = $aironet->awc_duplex();
my %i_duplex; my %i_duplex;
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $name = $interfaces->{$iid}; my $name = $interfaces->{$iid};
if ($name =~ /fec/){ if ( $name =~ /fec/ ) {
$i_duplex{$iid} = $awc_duplex; $i_duplex{$iid} = $awc_duplex;
} }
} }
@@ -183,7 +185,7 @@ sub i_mac {
my $i_mac = $aironet->i_mac2(); my $i_mac = $aironet->i_mac2();
my $awc_mac = $aironet->awc_mac(); my $awc_mac = $aironet->awc_mac();
foreach my $iid (keys %$awc_mac){ foreach my $iid ( keys %$awc_mac ) {
next unless defined $i_mac->{$iid}; next unless defined $i_mac->{$iid};
$i_mac->{$iid} = $awc_mac->{$iid}; $i_mac->{$iid} = $awc_mac->{$iid};
} }
@@ -192,12 +194,12 @@ sub i_mac {
} }
sub i_ignore { sub i_ignore {
my $aironet = shift; my $aironet = shift;
my $interfaces = $aironet->interfaces(); my $interfaces = $aironet->interfaces();
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
$i_ignore{$if}++ if ($interfaces->{$if} =~ /(rptr|lo)/); $i_ignore{$if}++ if ( $interfaces->{$if} =~ /(rptr|lo)/ );
} }
return \%i_ignore; return \%i_ignore;
@@ -213,8 +215,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless
running Aironet software, not IOS Devices running Aironet software, not IOS
=head1 AUTHOR =head1 AUTHOR

View File

@@ -34,7 +34,7 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//; @SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
@@ -42,79 +42,89 @@ use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
'ALTEON-ROOT-MIB' => 'aceswitch184', 'ALTEON-ROOT-MIB' => 'aceswitch184',
'ALTEON-TIGON-SWITCH-MIB' => 'hwPowerSupplyStatus', 'ALTEON-TIGON-SWITCH-MIB' => 'hwPowerSupplyStatus',
'ALTEON-CHEETAH-SWITCH-MIB' => 'hwFanStatus', 'ALTEON-CHEETAH-SWITCH-MIB' => 'hwFanStatus',
'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt', 'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt',
'ALTEON-CS-PHYSICAL-MIB' => 'vlanCurCfgLearn', 'ALTEON-CS-PHYSICAL-MIB' => 'vlanCurCfgLearn',
'ALTEON-TS-NETWORK-MIB' => 'ripCurCfgSupply', 'ALTEON-TS-NETWORK-MIB' => 'ripCurCfgSupply',
'ALTEON-CHEETAH-NETWORK-MIB' => 'ripCurCfgIntfSupply', 'ALTEON-CHEETAH-NETWORK-MIB' => 'ripCurCfgIntfSupply',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
'old_sw_ver' => 'ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion', 'old_sw_ver' => 'ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion',
'new_sw_ver' => 'ALTEON_CHEETAH_SWITCH_MIB__agSoftwareVersion', 'new_sw_ver' => 'ALTEON_CHEETAH_SWITCH_MIB__agSoftwareVersion',
'old_tftp_action' => 'ALTEON_TIGON_SWITCH_MIB__agTftpAction', 'old_tftp_action' => 'ALTEON_TIGON_SWITCH_MIB__agTftpAction',
'new_tftp_action' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpAction', 'new_tftp_action' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpAction',
'old_tftp_host' => 'ALTEON_TIGON_SWITCH_MIB__agTftpServer', 'old_tftp_host' => 'ALTEON_TIGON_SWITCH_MIB__agTftpServer',
'new_tftp_host' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpServer', 'new_tftp_host' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpServer',
'old_tftp_file' => 'ALTEON_TIGON_SWITCH_MIB__agTftpCfgFileName', 'old_tftp_file' => 'ALTEON_TIGON_SWITCH_MIB__agTftpCfgFileName',
'new_tftp_file' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpCfgFileName', 'new_tftp_file' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpCfgFileName',
'old_tftp_result' => 'ALTEON_TIGON_SWITCH_MIB__agTftpLastActionStatus', 'old_tftp_result' => 'ALTEON_TIGON_SWITCH_MIB__agTftpLastActionStatus',
'new_tftp_result' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpLastActionStatus', 'new_tftp_result' => 'ALTEON_CHEETAH_SWITCH_MIB__agTftpLastActionStatus',
'old_ip_max' => 'ALTEON_TS_NETWORK_MIB__ipInterfaceTableMax', 'old_ip_max' => 'ALTEON_TS_NETWORK_MIB__ipInterfaceTableMax',
'new_ip_max' => 'ALTEON_CHEETAH_NETWORK_MIB__ipInterfaceTableMax', 'new_ip_max' => 'ALTEON_CHEETAH_NETWORK_MIB__ipInterfaceTableMax',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
# From agPortCurCfgTable
'old_ag_p_cfg_idx' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgIndx',
'new_ag_p_cfg_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgIndx',
'old_ag_p_cfg_pref' => 'agPortCurCfgPrefLink',
'new_ag_p_cfg_pref' => 'agPortCurCfgPreferred',
'old_ag_p_cfg_pvid' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPVID',
'new_ag_p_cfg_pvid' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPVID',
'old_ag_p_cfg_fe_auto' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthAutoNeg',
'new_ag_p_cfg_fe_auto' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthAutoNeg',
'old_ag_p_cfg_fe_mode' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthMode',
'new_ag_p_cfg_fe_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthMode',
'old_ag_p_cfg_ge_auto' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgGigEthAutoNeg',
'new_ag_p_cfg_ge_auto' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgGigEthAutoNeg',
'old_ag_p_cfg_name' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName',
'new_ag_p_cfg_name' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPortName',
# From portInfoTable
'old_p_info_idx' => 'ALTEON_TS_PHYSICAL_MIB__portInfoIndx',
'new_p_info_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoIndx',
'old_p_info_mode' => 'ALTEON_TS_PHYSICAL_MIB__portInfoMode',
'new_p_info_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoMode',
# From ipCurCfgIntfTable
'old_ip_cfg_vlan' => 'ALTEON_TS_NETWORK_MIB__ipCurCfgIntfVlan',
'new_ip_cfg_vlan' => 'ALTEON_CHEETAH_NETWORK_MIB__ipCurCfgIntfVlan',
# From vlanCurCfgTable
'old_vlan_id' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanId',
'new_vlan_id' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanId',
'old_vlan_state' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgState',
'new_vlan_state' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgState',
'old_vlan_name' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanName',
'new_vlan_name' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanName',
'old_vlan_ports' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgPorts',
'new_vlan_ports' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgPorts',
);
%MUNGE = ( # From agPortCurCfgTable
%SNMP::Info::Layer3::MUNGE, 'old_ag_p_cfg_idx' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgIndx',
); 'new_ag_p_cfg_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgIndx',
'old_ag_p_cfg_pref' => 'agPortCurCfgPrefLink',
'new_ag_p_cfg_pref' => 'agPortCurCfgPreferred',
'old_ag_p_cfg_pvid' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPVID',
'new_ag_p_cfg_pvid' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPVID',
'old_ag_p_cfg_fe_auto' =>
'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthAutoNeg',
'new_ag_p_cfg_fe_auto' =>
'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthAutoNeg',
'old_ag_p_cfg_fe_mode' =>
'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgFastEthMode',
'new_ag_p_cfg_fe_mode' =>
'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgFastEthMode',
'old_ag_p_cfg_ge_auto' =>
'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgGigEthAutoNeg',
'new_ag_p_cfg_ge_auto' =>
'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgGigEthAutoNeg',
'old_ag_p_cfg_name' => 'ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName',
'new_ag_p_cfg_name' => 'ALTEON_CHEETAH_SWITCH_MIB__agPortCurCfgPortName',
# From portInfoTable
'old_p_info_idx' => 'ALTEON_TS_PHYSICAL_MIB__portInfoIndx',
'new_p_info_idx' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoIndx',
'old_p_info_mode' => 'ALTEON_TS_PHYSICAL_MIB__portInfoMode',
'new_p_info_mode' => 'ALTEON_CHEETAH_SWITCH_MIB__portInfoMode',
# From ipCurCfgIntfTable
'old_ip_cfg_vlan' => 'ALTEON_TS_NETWORK_MIB__ipCurCfgIntfVlan',
'new_ip_cfg_vlan' => 'ALTEON_CHEETAH_NETWORK_MIB__ipCurCfgIntfVlan',
# From vlanCurCfgTable
'old_vlan_id' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanId',
'new_vlan_id' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanId',
'old_vlan_state' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgState',
'new_vlan_state' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgState',
'old_vlan_name' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgVlanName',
'new_vlan_name' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgVlanName',
'old_vlan_ports' => 'ALTEON_TS_PHYSICAL_MIB__vlanCurCfgPorts',
'new_vlan_ports' => 'ALTEON_CS_PHYSICAL_MIB__vlanCurCfgPorts',
);
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
sub model { sub model {
my $alteon = shift; my $alteon = shift;
my $id = $alteon->id(); my $id = $alteon->id();
unless (defined $id){ unless ( defined $id ) {
print " SNMP::Info::Layer3::AlteonAD::model() - Device does not support sysObjectID\n" if $alteon->debug(); print
" SNMP::Info::Layer3::AlteonAD::model() - Device does not support sysObjectID\n"
if $alteon->debug();
return; return;
} }
@@ -146,23 +156,24 @@ sub os_ver {
} }
sub interfaces { sub interfaces {
my $alteon = shift; my $alteon = shift;
my $interfaces = $alteon->i_index(); my $interfaces = $alteon->i_index();
my $descriptions = $alteon->i_description(); my $descriptions = $alteon->i_description();
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid}; my $desc = $descriptions->{$iid};
next unless defined $desc; next unless defined $desc;
if ($desc =~ /(^net\d+)/) { if ( $desc =~ /(^net\d+)/ ) {
$desc = $1; $desc = $1;
} }
# IP interfaces are first followed by physical, number possible # IP interfaces are first followed by physical, number possible
# varies by switch model # varies by switch model
elsif (defined $ip_max and $iid > $ip_max ) { elsif ( defined $ip_max and $iid > $ip_max ) {
$desc = ($iid % $ip_max); $desc = ( $iid % $ip_max );
} }
$interfaces{$iid} = $desc; $interfaces{$iid} = $desc;
} }
@@ -172,11 +183,13 @@ sub interfaces {
sub i_duplex { sub i_duplex {
my $alteon = shift; my $alteon = shift;
my $p_mode = $alteon->new_p_info_mode() || $alteon->old_p_info_mode() || {}; my $p_mode = $alteon->new_p_info_mode()
|| $alteon->old_p_info_mode()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_duplex; my %i_duplex;
foreach my $if (keys %$p_mode){ foreach my $if ( keys %$p_mode ) {
my $duplex = $p_mode->{$if}; my $duplex = $p_mode->{$if};
next unless defined $duplex; next unless defined $duplex;
@@ -184,9 +197,9 @@ sub i_duplex {
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
my $idx; my $idx;
$idx = $if + $ip_max if (defined $ip_max); $idx = $if + $ip_max if ( defined $ip_max );
$i_duplex{$idx}=$duplex; $i_duplex{$idx} = $duplex;
} }
return \%i_duplex; return \%i_duplex;
} }
@@ -194,35 +207,45 @@ sub i_duplex {
sub i_duplex_admin { sub i_duplex_admin {
my $alteon = shift; my $alteon = shift;
my $ag_pref = $alteon->new_ag_p_cfg_pref() || $alteon->old_ag_p_cfg_pref() || {}; my $ag_pref = $alteon->new_ag_p_cfg_pref()
my $ag_fe_auto = $alteon->new_ag_p_cfg_fe_auto() || $alteon->old_ag_p_cfg_fe_auto() || {}; || $alteon->old_ag_p_cfg_pref()
my $ag_fe_mode = $alteon->new_ag_p_cfg_fe_mode() || $alteon->old_ag_p_cfg_fe_mode() || {}; || {};
my $ag_ge_auto = $alteon->new_ag_p_cfg_ge_auto() || $alteon->old_ag_p_cfg_ge_auto() || {}; my $ag_fe_auto = $alteon->new_ag_p_cfg_fe_auto()
|| $alteon->old_ag_p_cfg_fe_auto()
|| {};
my $ag_fe_mode = $alteon->new_ag_p_cfg_fe_mode()
|| $alteon->old_ag_p_cfg_fe_mode()
|| {};
my $ag_ge_auto = $alteon->new_ag_p_cfg_ge_auto()
|| $alteon->old_ag_p_cfg_ge_auto()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_duplex_admin; my %i_duplex_admin;
foreach my $if (keys %$ag_pref){ foreach my $if ( keys %$ag_pref ) {
my $pref = $ag_pref->{$if}; my $pref = $ag_pref->{$if};
next unless defined $pref; next unless defined $pref;
my $string = 'other'; my $string = 'other';
if ($pref =~ /gigabit/i) { if ( $pref =~ /gigabit/i ) {
my $ge_auto = $ag_ge_auto->{$if}; my $ge_auto = $ag_ge_auto->{$if};
$string = 'full' if ($ge_auto =~ /off/i); $string = 'full' if ( $ge_auto =~ /off/i );
$string = 'auto' if ($ge_auto =~ /on/i); $string = 'auto' if ( $ge_auto =~ /on/i );
} }
elsif ($pref =~ /fast/i) { elsif ( $pref =~ /fast/i ) {
my $fe_auto = $ag_fe_auto->{$if}; my $fe_auto = $ag_fe_auto->{$if};
my $fe_mode = $ag_fe_mode->{$if}; my $fe_mode = $ag_fe_mode->{$if};
$string = 'half' if ($fe_mode =~ /half/i and $fe_auto =~ /off/i); $string = 'half'
$string = 'full' if ($fe_mode =~ /full/i and $fe_auto =~ /off/i); if ( $fe_mode =~ /half/i and $fe_auto =~ /off/i );
$string = 'full'
if ( $fe_mode =~ /full/i and $fe_auto =~ /off/i );
$string = 'auto' if $fe_auto =~ /on/i; $string = 'auto' if $fe_auto =~ /on/i;
} }
my $idx; my $idx;
$idx = $if + $ip_max if (defined $ip_max); $idx = $if + $ip_max if ( defined $ip_max );
$i_duplex_admin{$idx}=$string; $i_duplex_admin{$idx} = $string;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
@@ -230,55 +253,62 @@ sub i_duplex_admin {
sub i_name { sub i_name {
my $alteon = shift; my $alteon = shift;
my $p_name = $alteon->new_ag_p_cfg_name() || $alteon->old_ag_p_cfg_name() || {}; my $p_name = $alteon->new_ag_p_cfg_name()
|| $alteon->old_ag_p_cfg_name()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_name; my %i_name;
foreach my $iid (keys %$p_name){ foreach my $iid ( keys %$p_name ) {
my $name = $p_name->{$iid}; my $name = $p_name->{$iid};
next unless defined $name; next unless defined $name;
my $idx; my $idx;
$idx = $iid + $ip_max if (defined $ip_max); $idx = $iid + $ip_max if ( defined $ip_max );
$i_name{$idx} = $name; $i_name{$idx} = $name;
} }
return \%i_name; return \%i_name;
} }
sub v_index { sub v_index {
my $alteon = shift; my $alteon = shift;
my $partial = shift; my $partial = shift;
return $alteon->new_vlan_id($partial) || $alteon->old_vlan_id($partial); return $alteon->new_vlan_id($partial) || $alteon->old_vlan_id($partial);
} }
sub v_name { sub v_name {
my $alteon = shift; my $alteon = shift;
my $partial = shift; my $partial = shift;
return $alteon->new_vlan_name($partial) || $alteon->old_vlan_name($partial); return $alteon->new_vlan_name($partial)
|| $alteon->old_vlan_name($partial);
} }
sub i_vlan { sub i_vlan {
my $alteon = shift; my $alteon = shift;
my $ag_vlans = $alteon->new_ag_p_cfg_pvid() || $alteon->old_ag_p_cfg_pvid() || {}; my $ag_vlans = $alteon->new_ag_p_cfg_pvid()
my $ip_vlans = $alteon->new_ip_cfg_vlan() || $alteon->old_ip_cfg_vlan() || {}; || $alteon->old_ag_p_cfg_pvid()
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); || {};
my $ip_vlans = $alteon->new_ip_cfg_vlan()
|| $alteon->old_ip_cfg_vlan()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %i_vlan; my %i_vlan;
foreach my $if (keys %$ip_vlans){ foreach my $if ( keys %$ip_vlans ) {
my $ip_vlanid = $ip_vlans->{$if}; my $ip_vlanid = $ip_vlans->{$if};
next unless defined $ip_vlanid; next unless defined $ip_vlanid;
$i_vlan{$if}=$ip_vlanid; $i_vlan{$if} = $ip_vlanid;
} }
foreach my $if (keys %$ag_vlans){ foreach my $if ( keys %$ag_vlans ) {
my $ag_vlanid = $ag_vlans->{$if}; my $ag_vlanid = $ag_vlans->{$if};
next unless defined $ag_vlanid; next unless defined $ag_vlanid;
my $idx; my $idx;
$idx = $if + $ip_max if (defined $ip_max); $idx = $if + $ip_max if ( defined $ip_max );
$i_vlan{$idx}=$ag_vlanid; $i_vlan{$idx} = $ag_vlanid;
} }
return \%i_vlan; return \%i_vlan;
} }
@@ -286,24 +316,26 @@ sub i_vlan {
sub i_vlan_membership { sub i_vlan_membership {
my $alteon = shift; my $alteon = shift;
my $v_ports = $alteon->old_vlan_ports() || $alteon->new_vlan_ports() || {}; my $v_ports = $alteon->old_vlan_ports()
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); || $alteon->new_vlan_ports()
|| {};
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my $i_vlan_membership = {}; my $i_vlan_membership = {};
foreach my $vlan (keys %$v_ports) { foreach my $vlan ( keys %$v_ports ) {
my $portlist = [split(//, unpack("B*", $v_ports->{$vlan}))]; my $portlist = [ split( //, unpack( "B*", $v_ports->{$vlan} ) ) ];
my $ret = []; my $ret = [];
# Convert portlist bit array to ifIndex array # Convert portlist bit array to ifIndex array
for (my $i = 0; $i <= scalar(@$portlist); $i++) { for ( my $i = 0; $i <= scalar(@$portlist); $i++ ) {
my $idx; my $idx;
$idx = $i + $ip_max if (defined $ip_max); $idx = $i + $ip_max if ( defined $ip_max );
push(@{$ret}, $idx) if (@$portlist[$i]); push( @{$ret}, $idx ) if ( @$portlist[$i] );
} }
#Create HoA ifIndex -> VLAN array #Create HoA ifIndex -> VLAN array
foreach my $port (@{$ret}) { foreach my $port ( @{$ret} ) {
push(@{$i_vlan_membership->{$port}}, $vlan); push( @{ $i_vlan_membership->{$port} }, $vlan );
} }
} }
return $i_vlan_membership; return $i_vlan_membership;
@@ -315,13 +347,13 @@ sub bp_index {
my $alteon = shift; my $alteon = shift;
my $b_index = $alteon->orig_bp_index(); my $b_index = $alteon->orig_bp_index();
my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max(); my $ip_max = $alteon->new_ip_max() || $alteon->old_ip_max();
my %bp_index; my %bp_index;
foreach my $iid (keys %$b_index){ foreach my $iid ( keys %$b_index ) {
my $port = $b_index->{$iid}; my $port = $b_index->{$iid};
next unless defined $port; next unless defined $port;
$port = $port + $ip_max if (defined $ip_max and $iid == $ip_max); $port = $port + $ip_max if ( defined $ip_max and $iid == $ip_max );
$bp_index{$iid} = $port; $bp_index{$iid} = $port;
} }
@@ -357,8 +389,8 @@ Eric Miller
=head1 DESCRIPTION =head1 DESCRIPTION
Abstraction subclass for Nortel Alteon Series Layer 2-7 load balancing switches Abstraction subclass for Nortel Alteon Series Layer 2-7 load balancing
and Nortel BladeCenter Layer2-3 GbE Switch Modules. switches and Nortel BladeCenter Layer2-3 GbE Switch Modules.
For speed or debugging purposes you can call the subclass directly, but not For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above. after determining a more specific class using the method above.

File diff suppressed because it is too large Load Diff

View File

@@ -42,63 +42,57 @@ use SNMP::Info::CiscoPortSecurity;
use SNMP::Info::CiscoPower; use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::C3550::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack @SNMP::Info::Layer3::C3550::ISA
SNMP::Info::CDP SNMP::Info::CiscoStats = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack
SNMP::Info::CiscoPortSecurity SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoImage SNMP::Info::CiscoPower SNMP::Info::CiscoPortSecurity
SNMP::Info::Layer3 SNMP::Info::CiscoImage SNMP::Info::CiscoPower
Exporter/; SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::C3550::EXPORT_OK = qw//; @SNMP::Info::Layer3::C3550::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoPower::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS, %SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoPortSecurity::MIBS, %SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStack::MIBS, %SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStats::MIBS, );
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoPower::GLOBALS, %SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS, %SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS, %SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
'ports2' => 'ifNumber', 'ports2' => 'ifNumber',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoPower::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS, %SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS, %SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStack::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, );
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE, # Inherit all the built in munging
%SNMP::Info::CiscoPower::MUNGE, %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::CiscoPortSecurity::MUNGE, %SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CiscoImage::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoStack::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE, %SNMP::Info::CiscoStack::MUNGE,
); %SNMP::Info::CiscoVTP::MUNGE,
);
sub vendor { sub vendor {
return 'cisco'; return 'cisco';
@@ -106,12 +100,12 @@ sub vendor {
sub model { sub model {
my $c3550 = shift; my $c3550 = shift;
my $id = $c3550->id(); my $id = $c3550->id();
my $model = &SNMP::translateObj($id) || $id; my $model = &SNMP::translateObj($id) || $id;
$model =~ s/^catalyst//; $model =~ s/^catalyst//;
# turn 355048 into 3550-48 # turn 355048 into 3550-48
if ($model =~ /^(35\d\d)(\d\d(T|G)?)$/) { if ( $model =~ /^(35\d\d)(\d\d(T|G)?)$/ ) {
$model = "$1-$2"; $model = "$1-$2";
} }
return $model; return $model;
@@ -123,9 +117,9 @@ sub ports {
my $ports2 = $c3550->ports2(); my $ports2 = $c3550->ports2();
my $id = $c3550->id(); my $id = $c3550->id();
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
if ($model =~ /(12|24|48)(C|T|TS|G|TS-E|TS-S|T-E)?$/) { if ( $model =~ /(12|24|48)(C|T|TS|G|TS-E|TS-S|T-E)?$/ ) {
return $1; return $1;
} }
return $ports2; return $ports2;
@@ -136,15 +130,15 @@ sub ports {
# See http://www.ciscosystems.com/en/US/products/hw/switches/ps646/prod_release_note09186a00802a08ee.html # See http://www.ciscosystems.com/en/US/products/hw/switches/ps646/prod_release_note09186a00802a08ee.html
sub i_duplex { sub i_duplex {
my $c3550 = shift; my $c3550 = shift;
my $partial = shift; my $partial = shift;
my $el_duplex = $c3550->el_duplex($partial); my $el_duplex = $c3550->el_duplex($partial);
# Newer software # Newer software
if (defined $el_duplex and scalar(keys %$el_duplex)){ if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my %i_duplex; my %i_duplex;
foreach my $el_port (keys %$el_duplex){ foreach my $el_port ( keys %$el_duplex ) {
my $duplex = $el_duplex->{$el_port}; my $duplex = $el_duplex->{$el_port};
next unless defined $duplex; next unless defined $duplex;
@@ -153,6 +147,7 @@ sub i_duplex {
} }
return \%i_duplex; return \%i_duplex;
} }
# Fall back to CiscoStack method # Fall back to CiscoStack method
else { else {
return $c3550->SUPER::i_duplex($partial); return $c3550->SUPER::i_duplex($partial);
@@ -162,26 +157,27 @@ sub i_duplex {
# Software >= 12.1(22)EA1a uses portDuplex as admin setting # Software >= 12.1(22)EA1a uses portDuplex as admin setting
sub i_duplex_admin { sub i_duplex_admin {
my $c3550 = shift; my $c3550 = shift;
my $partial = shift; my $partial = shift;
my $el_duplex = $c3550->el_duplex($partial); my $el_duplex = $c3550->el_duplex($partial);
# Newer software # Newer software
if (defined $el_duplex and scalar(keys %$el_duplex)){ if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c3550->p_port() || {}; my $p_port = $c3550->p_port() || {};
my $p_duplex = $c3550->p_duplex() || {}; my $p_duplex = $c3550->p_duplex() || {};
my $i_duplex_admin = {}; my $i_duplex_admin = {};
foreach my $port (keys %$p_duplex) { foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port}; my $iid = $p_port->{$port};
next unless defined $iid; next unless defined $iid;
next if (defined $partial and $iid !~ /^$partial$/); next if ( defined $partial and $iid !~ /^$partial$/ );
$i_duplex_admin->{$iid} = $p_duplex->{$port}; $i_duplex_admin->{$iid} = $p_duplex->{$port};
} }
return $i_duplex_admin; return $i_duplex_admin;
} }
# Fall back to CiscoStack method # Fall back to CiscoStack method
else { else {
return $c3550->SUPER::i_duplex_admin($partial); return $c3550->SUPER::i_duplex_admin($partial);
@@ -189,26 +185,27 @@ sub i_duplex_admin {
} }
sub set_i_duplex_admin { sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands # map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/; my %duplexes = qw/half 1 full 2 auto 4/;
my $c3550 = shift; my $c3550 = shift;
my ($duplex, $iid) = @_; my ( $duplex, $iid ) = @_;
my $el_duplex = $c3550->el_duplex($iid); my $el_duplex = $c3550->el_duplex($iid);
# Auto duplex only supported on newer software # Auto duplex only supported on newer software
if (defined $el_duplex and scalar(keys %$el_duplex)){ if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c3550->p_port() || {}; my $p_port = $c3550->p_port() || {};
my %reverse_p_port = reverse %$p_port; my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex); $duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex}; return 0 unless defined $duplexes{$duplex};
$iid = $reverse_p_port{$iid}; $iid = $reverse_p_port{$iid};
return $c3550->set_p_duplex($duplexes{$duplex}, $iid); return $c3550->set_p_duplex( $duplexes{$duplex}, $iid );
} }
else { else {
return $c3550->SUPER::set_i_duplex_admin; return $c3550->SUPER::set_i_duplex_admin;
@@ -315,7 +312,7 @@ These are methods that return scalar value from SNMP
=item $c3550->vendor() =item $c3550->vendor()
Returns 'cisco' Returns 'cisco'
=item $c3550->model() =item $c3550->model()

View File

@@ -42,83 +42,81 @@ use SNMP::Info::MAU;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::C4000::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP @SNMP::Info::Layer3::C4000::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoImage SNMP::Info::CiscoStats SNMP::Info::CiscoImage
SNMP::Info::CiscoPortSecurity SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoConfig SNMP::Info::MAU SNMP::Info::CiscoConfig SNMP::Info::MAU
SNMP::Info::Layer3 Exporter/; SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::C4000::EXPORT_OK = qw//; @SNMP::Info::Layer3::C4000::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::MAU::MIBS, %SNMP::Info::MAU::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoPortSecurity::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoVTP::MIBS,
'CISCO-ENVMON-MIB' => 'ciscoEnvMonMIB', 'CISCO-ENVMON-MIB' => 'ciscoEnvMonMIB',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS, %SNMP::Info::MAU::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS, %SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
'ps1_type' => 'ciscoEnvMonSupplyStatusDescr.1', 'ps1_type' => 'ciscoEnvMonSupplyStatusDescr.1',
'ps1_status' => 'ciscoEnvMonSupplyState.1', 'ps1_status' => 'ciscoEnvMonSupplyState.1',
'ps2_type' => 'ciscoEnvMonSupplyStatusDescr.2', 'ps2_type' => 'ciscoEnvMonSupplyStatusDescr.2',
'ps2_status' => 'ciscoEnvMonSupplyState.2', 'ps2_status' => 'ciscoEnvMonSupplyState.2',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS, %SNMP::Info::MAU::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
'fan_state' => 'ciscoEnvMonFanState', 'fan_state' => 'ciscoEnvMonFanState',
'fan_descr' => 'ciscoEnvMonFanStatusDescr', 'fan_descr' => 'ciscoEnvMonFanStatusDescr',
); );
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE, %SNMP::Info::MAU::MUNGE,
%SNMP::Info::MAU::MUNGE, %SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoPortSecurity::MUNGE, %SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, );
%SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
# Override Inheritance for these specific methods # Override Inheritance for these specific methods
# use MAU-MIB for admin. duplex and admin. speed # use MAU-MIB for admin. duplex and admin. speed
*SNMP::Info::Layer3::C4000::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin; *SNMP::Info::Layer3::C4000::i_duplex_admin
*SNMP::Info::Layer3::C4000::i_speed_admin = \&SNMP::Info::MAU::mau_i_speed_admin; = \&SNMP::Info::MAU::mau_i_duplex_admin;
*SNMP::Info::Layer3::C4000::i_speed_admin
= \&SNMP::Info::MAU::mau_i_speed_admin;
sub fan { sub fan {
my $c4000 = shift; my $c4000 = shift;
my $fan_state = $c4000->fan_state(); my $fan_state = $c4000->fan_state();
my $fan_descr = $c4000->fan_descr(); my $fan_descr = $c4000->fan_descr();
my $ret = ""; my $ret = "";
my $s = ""; my $s = "";
foreach my $i (sort {$a <=> $b} keys %$fan_state) { foreach my $i ( sort { $a <=> $b } keys %$fan_state ) {
$ret .= $s . $fan_descr->{$i} . ": " . $fan_state->{$i}; $ret .= $s . $fan_descr->{$i} . ": " . $fan_state->{$i};
$s = ", "; $s = ", ";
} }
return if ($s eq ""); return if ( $s eq "" );
return $ret; return $ret;
} }

View File

@@ -42,67 +42,56 @@ use SNMP::Info::CiscoConfig;
use SNMP::Info::CiscoPower; use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::C6500::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack @SNMP::Info::Layer3::C6500::ISA
SNMP::Info::CDP SNMP::Info::CiscoStats = qw/SNMP::Info::CiscoVTP SNMP::Info::CiscoStack
SNMP::Info::CiscoImage SNMP::Info::CDP SNMP::Info::CiscoStats
SNMP::Info::CiscoPortSecurity SNMP::Info::CiscoImage
SNMP::Info::CiscoConfig SNMP::Info::CiscoPortSecurity
SNMP::Info::CiscoPower SNMP::Info::CiscoConfig
SNMP::Info::Layer3 SNMP::Info::CiscoPower
Exporter/; SNMP::Info::Layer3
Exporter/;
@SNMP::Info::Layer3::C6500::EXPORT_OK = qw//; @SNMP::Info::Layer3::C6500::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoPower::MIBS, %SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoPortSecurity::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CiscoPortSecurity::MIBS, %SNMP::Info::CDP::MIBS, %SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoVTP::MIBS,
%SNMP::Info::CiscoStats::MIBS, );
%SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoStack::MIBS,
%SNMP::Info::CiscoVTP::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::CiscoPower::GLOBALS, %SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS,
%SNMP::Info::CiscoPortSecurity::GLOBALS, %SNMP::Info::CiscoPortSecurity::GLOBALS,
%SNMP::Info::CiscoImage::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoStack::GLOBALS, %SNMP::Info::CiscoStack::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS,
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoPower::FUNCS, %SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoPortSecurity::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CiscoPortSecurity::FUNCS, %SNMP::Info::CDP::FUNCS, %SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, );
%SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoStack::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS,
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE, %SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoPower::MUNGE, %SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoPortSecurity::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CiscoPortSecurity::MUNGE, %SNMP::Info::CDP::MUNGE, %SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, );
%SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoStack::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE,
);
sub vendor { sub vendor {
return 'cisco'; return 'cisco';
@@ -113,15 +102,15 @@ sub cisco_comm_indexing { return 1; }
# Newer versions use the ETHERLIKE-MIB to report operational duplex. # Newer versions use the ETHERLIKE-MIB to report operational duplex.
sub i_duplex { sub i_duplex {
my $c6500 = shift; my $c6500 = shift;
my $partial = shift; my $partial = shift;
my $el_duplex = $c6500->el_duplex($partial); my $el_duplex = $c6500->el_duplex($partial);
# Newer software # Newer software
if (defined $el_duplex and scalar(keys %$el_duplex)){ if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my %i_duplex; my %i_duplex;
foreach my $el_port (keys %$el_duplex){ foreach my $el_port ( keys %$el_duplex ) {
my $duplex = $el_duplex->{$el_port}; my $duplex = $el_duplex->{$el_port};
next unless defined $duplex; next unless defined $duplex;
@@ -130,6 +119,7 @@ sub i_duplex {
} }
return \%i_duplex; return \%i_duplex;
} }
# Fall back to CiscoStack method # Fall back to CiscoStack method
else { else {
return $c6500->SUPER::i_duplex($partial); return $c6500->SUPER::i_duplex($partial);
@@ -139,26 +129,27 @@ sub i_duplex {
# Newer software uses portDuplex as admin setting # Newer software uses portDuplex as admin setting
sub i_duplex_admin { sub i_duplex_admin {
my $c6500 = shift; my $c6500 = shift;
my $partial = shift; my $partial = shift;
my $el_duplex = $c6500->el_duplex($partial); my $el_duplex = $c6500->el_duplex($partial);
# Newer software # Newer software
if (defined $el_duplex and scalar(keys %$el_duplex)){ if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c6500->p_port() || {}; my $p_port = $c6500->p_port() || {};
my $p_duplex = $c6500->p_duplex() || {}; my $p_duplex = $c6500->p_duplex() || {};
my $i_duplex_admin = {}; my $i_duplex_admin = {};
foreach my $port (keys %$p_duplex) { foreach my $port ( keys %$p_duplex ) {
my $iid = $p_port->{$port}; my $iid = $p_port->{$port};
next unless defined $iid; next unless defined $iid;
next if (defined $partial and $iid !~ /^$partial$/); next if ( defined $partial and $iid !~ /^$partial$/ );
$i_duplex_admin->{$iid} = $p_duplex->{$port}; $i_duplex_admin->{$iid} = $p_duplex->{$port};
} }
return $i_duplex_admin; return $i_duplex_admin;
} }
# Fall back to CiscoStack method # Fall back to CiscoStack method
else { else {
return $c6500->SUPER::i_duplex_admin($partial); return $c6500->SUPER::i_duplex_admin($partial);
@@ -166,26 +157,27 @@ sub i_duplex_admin {
} }
sub set_i_duplex_admin { sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands # map a textual duplex to an integer one the switch understands
my %duplexes = qw/half 1 full 2 auto 4/; my %duplexes = qw/half 1 full 2 auto 4/;
my $c6500 = shift; my $c6500 = shift;
my ($duplex, $iid) = @_; my ( $duplex, $iid ) = @_;
my $el_duplex = $c6500->el_duplex($iid); my $el_duplex = $c6500->el_duplex($iid);
# Auto duplex only supported on newer software # Auto duplex only supported on newer software
if (defined $el_duplex and scalar(keys %$el_duplex)){ if ( defined $el_duplex and scalar( keys %$el_duplex ) ) {
my $p_port = $c6500->p_port() || {}; my $p_port = $c6500->p_port() || {};
my %reverse_p_port = reverse %$p_port; my %reverse_p_port = reverse %$p_port;
$duplex = lc($duplex); $duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex}; return 0 unless defined $duplexes{$duplex};
$iid = $reverse_p_port{$iid}; $iid = $reverse_p_port{$iid};
return $c6500->set_p_duplex($duplexes{$duplex}, $iid); return $c6500->set_p_duplex( $duplexes{$duplex}, $iid );
} }
else { else {
return $c6500->SUPER::set_i_duplex_admin; return $c6500->SUPER::set_i_duplex_admin;
@@ -224,9 +216,9 @@ Max Baker
Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches. Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches.
These devices run IOS but have some of the same characteristics as the Catalyst These devices run IOS but have some of the same characteristics as the
WS-C family (5xxx). For example, forwarding tables are held in VLANs, and Catalyst WS-C family (5xxx). For example, forwarding tables are held in
extended interface information is gleaned from F<CISCO-SWITCH-MIB>. VLANs, and extended interface information is gleaned from F<CISCO-SWITCH-MIB>.
For speed or debugging purposes you can call the subclass directly, but not For speed or debugging purposes you can call the subclass directly, but not
after determining a more specific class using the method above. after determining a more specific class using the method above.

View File

@@ -43,11 +43,11 @@ use SNMP::Info::CiscoPower;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP @SNMP::Info::Layer3::Cisco::ISA = qw/SNMP::Info::CiscoVTP SNMP::Info::CDP
SNMP::Info::CiscoStats SNMP::Info::CiscoImage SNMP::Info::CiscoStats SNMP::Info::CiscoImage
SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS SNMP::Info::CiscoRTT SNMP::Info::CiscoQOS
SNMP::Info::CiscoConfig SNMP::Info::CiscoPower SNMP::Info::CiscoConfig SNMP::Info::CiscoPower
SNMP::Info::Layer3 SNMP::Info::Layer3
Exporter/; Exporter/;
@SNMP::Info::Layer3::Cisco::EXPORT_OK = qw//; @SNMP::Info::Layer3::Cisco::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
@@ -55,74 +55,70 @@ use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::CiscoPower::MIBS, %SNMP::Info::CiscoPower::MIBS,
%SNMP::Info::CiscoConfig::MIBS, %SNMP::Info::CiscoConfig::MIBS,
%SNMP::Info::CiscoQOS::MIBS, %SNMP::Info::CiscoQOS::MIBS,
%SNMP::Info::CiscoRTT::MIBS, %SNMP::Info::CiscoRTT::MIBS,
%SNMP::Info::CiscoImage::MIBS, %SNMP::Info::CiscoImage::MIBS,
%SNMP::Info::CiscoStats::MIBS, %SNMP::Info::CiscoStats::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CiscoVTP::MIBS, %SNMP::Info::CiscoVTP::MIBS,
'CISCO-EIGRP-MIB' => 'cEigrpAsRouterId', 'CISCO-EIGRP-MIB' => 'cEigrpAsRouterId',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CiscoPower::GLOBALS,
%SNMP::Info::CiscoPower::GLOBALS, %SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoQOS::GLOBALS,
%SNMP::Info::CiscoConfig::GLOBALS, %SNMP::Info::CiscoRTT::GLOBALS, %SNMP::Info::CiscoImage::GLOBALS,
%SNMP::Info::CiscoQOS::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoRTT::GLOBALS, %SNMP::Info::CiscoVTP::GLOBALS, 'eigrp_id' => 'cEigrpAsRouterId',
%SNMP::Info::CiscoImage::GLOBALS, );
%SNMP::Info::CiscoStats::GLOBALS,
%SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CiscoVTP::GLOBALS,
'eigrp_id' => 'cEigrpAsRouterId',
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::CiscoPower::FUNCS, %SNMP::Info::CiscoPower::FUNCS,
%SNMP::Info::CiscoConfig::FUNCS, %SNMP::Info::CiscoConfig::FUNCS,
%SNMP::Info::CiscoQOS::FUNCS, %SNMP::Info::CiscoQOS::FUNCS,
%SNMP::Info::CiscoRTT::FUNCS, %SNMP::Info::CiscoRTT::FUNCS,
%SNMP::Info::CiscoImage::FUNCS, %SNMP::Info::CiscoImage::FUNCS,
%SNMP::Info::CiscoStats::FUNCS, %SNMP::Info::CiscoStats::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CiscoVTP::FUNCS, %SNMP::Info::CiscoVTP::FUNCS,
# EIGRP
'eigrp_peers' => 'cEigrpPeerAddr', # EIGRP
); 'eigrp_peers' => 'cEigrpPeerAddr',
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::CiscoPower::MUNGE, %SNMP::Info::CiscoPower::MUNGE,
%SNMP::Info::CiscoConfig::MUNGE, %SNMP::Info::CiscoConfig::MUNGE,
%SNMP::Info::CiscoQOS::MUNGE, %SNMP::Info::CiscoQOS::MUNGE,
%SNMP::Info::CiscoRTT::MUNGE, %SNMP::Info::CiscoRTT::MUNGE,
%SNMP::Info::CiscoImage::MUNGE, %SNMP::Info::CiscoImage::MUNGE,
%SNMP::Info::CiscoStats::MUNGE, %SNMP::Info::CiscoStats::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CiscoVTP::MUNGE, %SNMP::Info::CiscoVTP::MUNGE,
'eigrp_peers' => \&SNMP::Info::munge_ip, 'eigrp_peers' => \&SNMP::Info::munge_ip,
); );
sub i_vlan { sub i_vlan {
my ($cisco) = shift; my ($cisco) = shift;
my ($partial) = shift; my ($partial) = shift;
my ($i_type) = $cisco->i_type($partial); my ($i_type) = $cisco->i_type($partial);
my ($i_descr) = $cisco->i_description($partial); my ($i_descr) = $cisco->i_description($partial);
my %i_vlan; my %i_vlan;
foreach my $idx (keys %$i_descr) { foreach my $idx ( keys %$i_descr ) {
if ($i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135) { if ( $i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135 ) {
if ($i_descr->{$idx} =~ /\.(\d+)$/) { if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) {
$i_vlan{$idx} = $1; $i_vlan{$idx} = $1;
} }
} }
} }
return \%i_vlan; return \%i_vlan;
} }
1; 1;

View File

@@ -36,7 +36,8 @@ use SNMP::Info;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
use SNMP::Info::Entity; use SNMP::Info::Entity;
@SNMP::Info::Layer3::Contivity::ISA = qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Entity Exporter/; @SNMP::Info::Layer3::Contivity::ISA
= qw/SNMP::Info SNMP::Info::Layer3 SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//; @SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
@@ -44,28 +45,23 @@ use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::MIBS, %SNMP::Info::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::Entity::MIBS,
%SNMP::Info::Layer3::MIBS, );
%SNMP::Info::Entity::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::GLOBALS, %SNMP::Info::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Entity::GLOBALS,
%SNMP::Info::Entity::GLOBALS, );
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::FUNCS, %SNMP::Info::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Entity::FUNCS,
%SNMP::Info::Entity::FUNCS, );
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::MUNGE, %SNMP::Info::MUNGE, %SNMP::Info::Layer3::MUNGE,
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Entity::MUNGE,
%SNMP::Info::Entity::MUNGE, );
);
sub layers { sub layers {
return '00000100'; return '00000100';
@@ -81,7 +77,7 @@ sub model {
my $model = $e_model->{1} || undef; my $model = $e_model->{1} || undef;
return $1 if (defined $model and $model =~ /(CES\d+)/i); return $1 if ( defined $model and $model =~ /(CES\d+)/i );
return; return;
} }
@@ -91,10 +87,10 @@ sub os {
sub os_ver { sub os_ver {
my $contivity = shift; my $contivity = shift;
my $descr = $contivity->description(); my $descr = $contivity->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/V(\d+_\d+\.\d+)/i){ if ( $descr =~ m/V(\d+_\d+\.\d+)/i ) {
return $1; return $1;
} }
return; return;
@@ -102,10 +98,10 @@ sub os_ver {
sub mac { sub mac {
my $contivity = shift; my $contivity = shift;
my $i_mac = $contivity->i_mac(); my $i_mac = $contivity->i_mac();
# Return Interface MAC # Return Interface MAC
foreach my $entry (keys %$i_mac){ foreach my $entry ( keys %$i_mac ) {
my $sn = $i_mac->{$entry}; my $sn = $i_mac->{$entry};
next unless $sn; next unless $sn;
return $sn; return $sn;
@@ -119,22 +115,22 @@ sub serial {
my $serial = $e_serial->{1} || undef; my $serial = $e_serial->{1} || undef;
return $1 if (defined $serial and $serial =~ /(\d+)/); return $1 if ( defined $serial and $serial =~ /(\d+)/ );
return; return;
} }
sub interfaces { sub interfaces {
my $contivity = shift; my $contivity = shift;
my $partial = shift; my $partial = shift;
my $description = $contivity->i_description($partial) || {}; my $description = $contivity->i_description($partial) || {};
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$description){ foreach my $iid ( keys %$description ) {
my $desc = $description->{$iid}; my $desc = $description->{$iid};
# Skip everything except Ethernet interfaces # Skip everything except Ethernet interfaces
next unless (defined $desc and $desc =~ /fe/i); next unless ( defined $desc and $desc =~ /fe/i );
$interfaces{$iid} = $desc; $interfaces{$iid} = $desc;
} }
@@ -143,21 +139,22 @@ sub interfaces {
sub i_name { sub i_name {
my $contivity = shift; my $contivity = shift;
my $partial = shift; my $partial = shift;
my $i_name2 = $contivity->orig_i_name($partial) || {}; my $i_name2 = $contivity->orig_i_name($partial) || {};
my %i_name; my %i_name;
foreach my $iid (keys %$i_name2){ foreach my $iid ( keys %$i_name2 ) {
my $name = $i_name2->{$iid}; my $name = $i_name2->{$iid};
#Skip everything except Ethernet interfaces #Skip everything except Ethernet interfaces
next unless (defined $name and $name =~ /fe/i); next unless ( defined $name and $name =~ /fe/i );
$name = $1 if $name =~ /(fei\.\d+\.\d+)/; $name = $1 if $name =~ /(fei\.\d+\.\d+)/;
$i_name{$iid} = $name; $i_name{$iid} = $name;
} }
return \%i_name; return \%i_name;
} }
1; 1;
@@ -165,8 +162,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::Layer3::Contivity - SNMP Interface to Nortel VPN Routers (Contivity SNMP::Info::Layer3::Contivity - SNMP Interface to Nortel VPN Routers
Extranet Switches). (Contivity Extranet Switches).
=head1 AUTHOR =head1 AUTHOR

View File

@@ -34,84 +34,88 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Dell::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Dell::EXPORT_OK = qw//; @SNMP::Info::Layer3::Dell::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer3::MIBS, %MIBS = (
'RADLAN-Physicaldescription-MIB' => 'rlPhdStackReorder', %SNMP::Info::Layer3::MIBS,
'RADLAN-rlInterfaces' => 'rlIfNumOfLoopbackPorts', 'RADLAN-Physicaldescription-MIB' => 'rlPhdStackReorder',
'RADLAN-HWENVIROMENT' => 'rlEnvPhysicalDescription', 'RADLAN-rlInterfaces' => 'rlIfNumOfLoopbackPorts',
'Dell-Vendor-MIB' => 'productIdentificationVersion', 'RADLAN-HWENVIROMENT' => 'rlEnvPhysicalDescription',
); 'Dell-Vendor-MIB' => 'productIdentificationVersion',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
'os_ver' => 'productIdentificationVersion', 'os_ver' => 'productIdentificationVersion',
'dell_id_name' => 'productIdentificationDisplayName', 'dell_id_name' => 'productIdentificationDisplayName',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
# RADLAN-rlInterfaces:swIfTable
'dell_duplex_admin' => 'swIfDuplexAdminMode',
'dell_duplex' => 'swIfDuplexOperMode',
'dell_tag_mode' => 'swIfTaggedMode',
'dell_i_type' => 'swIfType',
'dell_fc_admin' => 'swIfFlowControlMode',
'dell_speed_admin' => 'swIfSpeedAdminMode',
'dell_auto' => 'swIfSpeedDuplexAutoNegotiation',
'dell_fc' => 'swIfOperFlowControlMode',
# RADLAN-Physicaldescription-MIB:rlPhdUnitGenParamTable
'dell_unit' => 'rlPhdUnitGenParamStackUnit',
'dell_sw_ver' => 'rlPhdUnitGenParamSoftwareVersion',
'dell_fw_ver' => 'rlPhdUnitGenParamFirmwareVersion',
'dell_hw_ver' => 'rlPhdUnitGenParamHardwareVersion',
'dell_serial_no' => 'rlPhdUnitGenParamSerialNum',
'dell_asset_no' => 'rlPhdUnitGenParamAssetTag',
# RADLAN-COPY-MIB:rlCopyTable
'dell_cp_idx' => 'rlCopyIndex',
'dell_cp_sloc' => 'rlCopySourceLocation',
'dell_cp_sip' => 'rlCopySourceIpAddress',
'dell_cp_sunit' => 'rlCopySourceUnitNumber',
'dell_cp_sfile' => 'rlCopySourceFileName',
'dell_cp_stype' => 'rlCopySourceFileType',
'dell_cp_dloc' => 'rlCopyDestinationLocation',
'dell_cp_dip' => 'rlCopyDestinationIpAddress',
'dell_cp_dunit' => 'rlCopyDestinationUnitNumber',
'dell_cp_dfile' => 'rlCopyDestinationFileName',
'dell_cp_dtype' => 'rlCopyDestinationFileType',
'dell_cp_state' => 'rlCopyOperationState',
'dell_cp_bkgnd' => 'rlCopyInBackground',
'dell_cp_rstatus' => 'rlCopyRowStatus',
# RADLAN-HWENVIROMENT:rlEnvMonSupplyStatusTable
'dell_pwr_src' => 'rlEnvMonSupplySource',
'dell_pwr_state' => 'rlEnvMonSupplyState',
'dell_pwr_desc' => 'rlEnvMonSupplyStatusDescr',
# RADLAN-HWENVIROMENT:rlEnvMonFanStatusTable
'dell_fan_state' => 'rlEnvMonFanState',
'dell_fan_desc' => 'rlEnvMonFanStatusDescr',
);
# RADLAN-rlInterfaces:swIfTable
'dell_duplex_admin' => 'swIfDuplexAdminMode',
'dell_duplex' => 'swIfDuplexOperMode',
'dell_tag_mode' => 'swIfTaggedMode',
'dell_i_type' => 'swIfType',
'dell_fc_admin' => 'swIfFlowControlMode',
'dell_speed_admin' => 'swIfSpeedAdminMode',
'dell_auto' => 'swIfSpeedDuplexAutoNegotiation',
'dell_fc' => 'swIfOperFlowControlMode',
%MUNGE = ( # RADLAN-Physicaldescription-MIB:rlPhdUnitGenParamTable
%SNMP::Info::Layer3::MUNGE, 'dell_unit' => 'rlPhdUnitGenParamStackUnit',
); 'dell_sw_ver' => 'rlPhdUnitGenParamSoftwareVersion',
'dell_fw_ver' => 'rlPhdUnitGenParamFirmwareVersion',
'dell_hw_ver' => 'rlPhdUnitGenParamHardwareVersion',
'dell_serial_no' => 'rlPhdUnitGenParamSerialNum',
'dell_asset_no' => 'rlPhdUnitGenParamAssetTag',
# RADLAN-COPY-MIB:rlCopyTable
'dell_cp_idx' => 'rlCopyIndex',
'dell_cp_sloc' => 'rlCopySourceLocation',
'dell_cp_sip' => 'rlCopySourceIpAddress',
'dell_cp_sunit' => 'rlCopySourceUnitNumber',
'dell_cp_sfile' => 'rlCopySourceFileName',
'dell_cp_stype' => 'rlCopySourceFileType',
'dell_cp_dloc' => 'rlCopyDestinationLocation',
'dell_cp_dip' => 'rlCopyDestinationIpAddress',
'dell_cp_dunit' => 'rlCopyDestinationUnitNumber',
'dell_cp_dfile' => 'rlCopyDestinationFileName',
'dell_cp_dtype' => 'rlCopyDestinationFileType',
'dell_cp_state' => 'rlCopyOperationState',
'dell_cp_bkgnd' => 'rlCopyInBackground',
'dell_cp_rstatus' => 'rlCopyRowStatus',
# RADLAN-HWENVIROMENT:rlEnvMonSupplyStatusTable
'dell_pwr_src' => 'rlEnvMonSupplySource',
'dell_pwr_state' => 'rlEnvMonSupplyState',
'dell_pwr_desc' => 'rlEnvMonSupplyStatusDescr',
# RADLAN-HWENVIROMENT:rlEnvMonFanStatusTable
'dell_fan_state' => 'rlEnvMonFanState',
'dell_fan_desc' => 'rlEnvMonFanStatusDescr',
);
%MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
# Method OverRides # Method OverRides
sub model { sub model {
my $dell = shift; my $dell = shift;
my $name = $dell->dell_id_name(); my $name = $dell->dell_id_name();
my $descr = $dell->description(); my $descr = $dell->description();
if (defined $name and $name =~ m/(\d+)/){ if ( defined $name and $name =~ m/(\d+)/ ) {
return $1; return $1;
} }
# Don't have a vendor MIB for D-Link # Don't have a vendor MIB for D-Link
else { else {
return $descr; return $descr;
@@ -131,13 +135,13 @@ sub os {
} }
sub serial { sub serial {
my $dell = shift; my $dell = shift;
my $numbers = $dell->dell_serial_no(); my $numbers = $dell->dell_serial_no();
foreach my $key (keys %$numbers){ foreach my $key ( keys %$numbers ) {
my $serial = $numbers->{$key}; my $serial = $numbers->{$key};
return $serial if (defined $serial and $serial !~ /^\s*$/); return $serial if ( defined $serial and $serial !~ /^\s*$/ );
next; next;
} }
@@ -146,15 +150,15 @@ sub serial {
} }
sub interfaces { sub interfaces {
my $dell = shift; my $dell = shift;
my $partial = shift; my $partial = shift;
my $i_descr = $dell->i_description($partial) || {}; my $i_descr = $dell->i_description($partial) || {};
my $i_name = $dell->i_name($partial) || {}; my $i_name = $dell->i_name($partial) || {};
# Descriptions are all the same on some Dells, so use name instead if # Descriptions are all the same on some Dells, so use name instead if
# available # available
foreach my $iid (keys %$i_name){ foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid}; my $name = $i_name->{$iid};
next unless defined $name; next unless defined $name;
$i_descr->{$iid} = $name; $i_descr->{$iid} = $name;
@@ -164,23 +168,23 @@ sub interfaces {
} }
sub i_duplex_admin { sub i_duplex_admin {
my $dell = shift; my $dell = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $dell->interfaces($partial) || {}; my $interfaces = $dell->interfaces($partial) || {};
my $dell_duplex = $dell->dell_duplex_admin($partial) || {}; my $dell_duplex = $dell->dell_duplex_admin($partial) || {};
my $dell_auto = $dell->dell_auto($partial) || {}; my $dell_auto = $dell->dell_auto($partial) || {};
my %i_duplex_admin; my %i_duplex_admin;
foreach my $if (keys %$interfaces){ foreach my $if ( keys %$interfaces ) {
my $duplex = $dell_duplex->{$if}; my $duplex = $dell_duplex->{$if};
next unless defined $duplex; next unless defined $duplex;
my $auto = $dell_auto->{$if}||'false'; my $auto = $dell_auto->{$if} || 'false';
$duplex = 'half' if ($duplex =~ /half/i and $auto =~ /false/i); $duplex = 'half' if ( $duplex =~ /half/i and $auto =~ /false/i );
$duplex = 'full' if ($duplex =~ /half/i and $auto =~ /false/i); $duplex = 'full' if ( $duplex =~ /half/i and $auto =~ /false/i );
$duplex = 'auto' if $auto =~ /true/i; $duplex = 'auto' if $auto =~ /true/i;
$i_duplex_admin{$if}=$duplex; $i_duplex_admin{$if} = $duplex;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
} }
@@ -192,31 +196,31 @@ sub i_duplex_admin {
# return anything. # return anything.
sub fw_mac { sub fw_mac {
my $dell = shift; my $dell = shift;
my $ret = $dell->qb_fw_mac(); my $ret = $dell->qb_fw_mac();
$ret = $dell->orig_fw_mac() if (!defined($ret)); $ret = $dell->orig_fw_mac() if ( !defined($ret) );
return $ret; return $ret;
} }
sub fw_port { sub fw_port {
my $dell = shift; my $dell = shift;
my $ret = $dell->qb_fw_port(); my $ret = $dell->qb_fw_port();
$ret = $dell->orig_fw_port() if (!defined($ret)); $ret = $dell->orig_fw_port() if ( !defined($ret) );
return $ret; return $ret;
} }
sub _vendor { sub _vendor {
my $dell = shift; my $dell = shift;
my $id = $dell->id() || 'undef'; my $id = $dell->id() || 'undef';
my %oidmap = ( my %oidmap = (
2 => 'ibm', 2 => 'ibm',
171 => 'dlink', 171 => 'dlink',
674 => 'dell', 674 => 'dell',
3955 => 'linksys', 3955 => 'linksys',
); );
$id = $1 if (defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/); $id = $1 if ( defined($id) && $id =~ /^\.1\.3\.6\.1\.4\.1\.(\d+)/ );
if (defined($id) and exists($oidmap{$id})) { if ( defined($id) and exists( $oidmap{$id} ) ) {
return $oidmap{$id}; return $oidmap{$id};
} }
else { else {
@@ -229,7 +233,8 @@ __END__
=head1 NAME =head1 NAME
SNMP::Info::Layer3::Dell - SNMP Interface to Dell Power Connect Network Devices SNMP::Info::Layer3::Dell - SNMP Interface to Dell Power Connect Network
Devices
=head1 AUTHOR =head1 AUTHOR
@@ -304,8 +309,9 @@ These are methods that return scalar value from SNMP
=item $dell->model() =item $dell->model()
Returns model type. Returns numeric from (C<productIdentificationDisplayName>) Returns model type. Returns numeric from
if available, otherwise if returns description(). (C<productIdentificationDisplayName>) if available, otherwise if returns
description().
=item $dell->vendor() =item $dell->vendor()
@@ -383,13 +389,14 @@ to a hash.
=item $dell->interfaces() =item $dell->interfaces()
Returns the map between SNMP Interface Identifier (iid) and physical port name. Returns the map between SNMP Interface Identifier (iid) and physical port
Uses name if available instead of description since descriptions are name. Uses name if available instead of description since descriptions are
sometimes not unique. sometimes not unique.
=item $dell->i_duplex_admin() =item $dell->i_duplex_admin()
Returns reference to hash of iid to current link administrative duplex setting. Returns reference to hash of iid to current link administrative duplex
setting.
=item $dell->fw_mac() =item $dell->fw_mac()

View File

@@ -38,8 +38,8 @@ use SNMP::Info::CDP;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Enterasys::ISA = qw/SNMP::Info::MAU SNMP::Info::LLDP @SNMP::Info::Layer3::Enterasys::ISA = qw/SNMP::Info::MAU SNMP::Info::LLDP
SNMP::Info::CDP SNMP::Info::Layer3 SNMP::Info::CDP SNMP::Info::Layer3
Exporter/; Exporter/;
@SNMP::Info::Layer3::Enterasys::EXPORT_OK = qw//; @SNMP::Info::Layer3::Enterasys::EXPORT_OK = qw//;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/; use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@@ -47,41 +47,35 @@ use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS, %SNMP::Info::CDP::MIBS,
%SNMP::Info::CDP::MIBS, %SNMP::Info::LLDP::MIBS, %SNMP::Info::MAU::MIBS,
%SNMP::Info::LLDP::MIBS, 'ENTERASYS-OIDS-MIB' => 'etsysOidDevice',
%SNMP::Info::MAU::MIBS, );
'ENTERASYS-OIDS-MIB' => 'etsysOidDevice',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CDP::GLOBALS,
%SNMP::Info::CDP::GLOBALS, %SNMP::Info::LLDP::GLOBALS, %SNMP::Info::MAU::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, 'mac' => 'dot1dBaseBridgeAddress',
%SNMP::Info::MAU::GLOBALS, );
'mac' => 'dot1dBaseBridgeAddress',
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS, %SNMP::Info::CDP::FUNCS,
%SNMP::Info::CDP::FUNCS, %SNMP::Info::LLDP::FUNCS, %SNMP::Info::MAU::FUNCS,
%SNMP::Info::LLDP::FUNCS, );
%SNMP::Info::MAU::FUNCS,
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE, %SNMP::Info::CDP::MUNGE,
%SNMP::Info::CDP::MUNGE, %SNMP::Info::LLDP::MUNGE, %SNMP::Info::MAU::MUNGE,
%SNMP::Info::LLDP::MUNGE, );
%SNMP::Info::MAU::MUNGE,
);
sub model { sub model {
my $enterasys = shift; my $enterasys = shift;
my $id = $enterasys->id(); my $id = $enterasys->id();
unless (defined $id){ unless ( defined $id ) {
print " SNMP::Info::Layer3::Enterasys::model() - Device does not support sysObjectID\n" if $enterasys->debug(); print
" SNMP::Info::Layer3::Enterasys::model() - Device does not support sysObjectID\n"
if $enterasys->debug();
return; return;
} }
@@ -104,10 +98,10 @@ sub os {
sub os_ver { sub os_ver {
my $enterasys = shift; my $enterasys = shift;
my $descr = $enterasys->description(); my $descr = $enterasys->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/\bRev ([\d.]*)/){ if ( $descr =~ m/\bRev ([\d.]*)/ ) {
return $1; return $1;
} }
@@ -117,23 +111,24 @@ sub os_ver {
# Use ifName as it is used for CDP and LLDP. # Use ifName as it is used for CDP and LLDP.
sub interfaces { sub interfaces {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
# We need the original ifName, SUPER:: would give us a method definition # We need the original ifName, SUPER:: would give us a method definition
# in a higher class, we could use orig_ but just call the MIB leaf since # in a higher class, we could use orig_ but just call the MIB leaf since
# that's what we really want anyway. # that's what we really want anyway.
return $enterasys->ifName($partial) || $enterasys->i_description($partial); return $enterasys->ifName($partial)
|| $enterasys->i_description($partial);
} }
sub i_ignore { sub i_ignore {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $enterasys->i_type($partial) || {}; my $interfaces = $enterasys->i_type($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces) { foreach my $if ( keys %$interfaces ) {
if ($interfaces->{$if} =~ /(rs232|tunnel|loopback|\blo\b|null)/i){ if ( $interfaces->{$if} =~ /(rs232|tunnel|loopback|\blo\b|null)/i ) {
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }
@@ -142,14 +137,14 @@ sub i_ignore {
sub i_duplex { sub i_duplex {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
return $enterasys->mau_i_duplex($partial); return $enterasys->mau_i_duplex($partial);
} }
sub i_duplex_admin { sub i_duplex_admin {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
return $enterasys->mau_i_duplex_admin($partial); return $enterasys->mau_i_duplex_admin($partial);
} }
@@ -158,24 +153,25 @@ sub i_duplex_admin {
# non-increasing oids, Use Q-BRIDGE-MIB for macsuck # non-increasing oids, Use Q-BRIDGE-MIB for macsuck
sub fw_mac { sub fw_mac {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
return $enterasys->qb_fw_mac($partial); return $enterasys->qb_fw_mac($partial);
} }
sub fw_port { sub fw_port {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
return $enterasys->qb_fw_port($partial); return $enterasys->qb_fw_port($partial);
} }
# Use CDP and/or LLDP # Use CDP and/or LLDP
# #
# LLDP table timefilter implementation continuously increments when walked and # LLDP table timefilter implementation continuously increments when walked
# we may never reach the end of the table. This behavior can be modified with # and we may never reach the end of the table. This behavior can be
# the "set snmp timefilter break disable" command, unfortunately it is not # modified with the "set snmp timefilter break disable" command,
# the default. Query with a partial value of zero which means no time filter. # unfortunately it is not the default. Query with a partial value of zero
# which means no time filter.
sub hasCDP { sub hasCDP {
my $enterasys = shift; my $enterasys = shift;
@@ -185,20 +181,20 @@ sub hasCDP {
sub c_ip { sub c_ip {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
my $cdp = $enterasys->SUPER::c_ip($partial) || {}; my $cdp = $enterasys->SUPER::c_ip($partial) || {};
my $lldp = $enterasys->lldp_ip(0) || {}; my $lldp = $enterasys->lldp_ip(0) || {};
my %c_ip; my %c_ip;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid}; my $ip = $cdp->{$iid};
next unless defined $ip; next unless defined $ip;
$c_ip{$iid} = $ip; $c_ip{$iid} = $ip;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid}; my $ip = $lldp->{$iid};
next unless defined $ip; next unless defined $ip;
@@ -209,20 +205,20 @@ sub c_ip {
sub c_if { sub c_if {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
my $lldp = $enterasys->lldp_if(0) || {};; my $lldp = $enterasys->lldp_if(0) || {};
my $cdp = $enterasys->SUPER::c_if($partial) || {}; my $cdp = $enterasys->SUPER::c_if($partial) || {};
my %c_if; my %c_if;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid}; my $if = $cdp->{$iid};
next unless defined $if; next unless defined $if;
$c_if{$iid} = $if; $c_if{$iid} = $if;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid}; my $if = $lldp->{$iid};
next unless defined $if; next unless defined $if;
@@ -233,20 +229,20 @@ sub c_if {
sub c_port { sub c_port {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
my $lldp = $enterasys->lldp_port(0) || {}; my $lldp = $enterasys->lldp_port(0) || {};
my $cdp = $enterasys->SUPER::c_port($partial) || {}; my $cdp = $enterasys->SUPER::c_port($partial) || {};
my %c_port; my %c_port;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid}; my $port = $cdp->{$iid};
next unless defined $port; next unless defined $port;
$c_port{$iid} = $port; $c_port{$iid} = $port;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid}; my $port = $lldp->{$iid};
next unless defined $port; next unless defined $port;
@@ -257,20 +253,20 @@ sub c_port {
sub c_id { sub c_id {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
my $lldp = $enterasys->lldp_id(0) || {}; my $lldp = $enterasys->lldp_id(0) || {};
my $cdp = $enterasys->SUPER::c_id($partial) || {}; my $cdp = $enterasys->SUPER::c_id($partial) || {};
my %c_id; my %c_id;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid}; my $id = $cdp->{$iid};
next unless defined $id; next unless defined $id;
$c_id{$iid} = $id; $c_id{$iid} = $id;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid}; my $id = $lldp->{$iid};
next unless defined $id; next unless defined $id;
@@ -281,20 +277,20 @@ sub c_id {
sub c_platform { sub c_platform {
my $enterasys = shift; my $enterasys = shift;
my $partial = shift; my $partial = shift;
my $lldp = $enterasys->lldp_rem_sysdesc(0) || {}; my $lldp = $enterasys->lldp_rem_sysdesc(0) || {};
my $cdp = $enterasys->SUPER::c_platform($partial) || {}; my $cdp = $enterasys->SUPER::c_platform($partial) || {};
my %c_platform; my %c_platform;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid}; my $platform = $cdp->{$iid};
next unless defined $platform; next unless defined $platform;
$c_platform{$iid} = $platform; $c_platform{$iid} = $platform;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid}; my $platform = $lldp->{$iid};
next unless defined $platform; next unless defined $platform;
@@ -380,7 +376,8 @@ These are methods that return scalar value from SNMP
=item $enterasys->model() =item $enterasys->model()
Returns model type. Checks $enterasys->id() against the F<ENTERASYS-OIDS-MIB>. Returns model type. Checks $enterasys->id() against the
F<ENTERASYS-OIDS-MIB>.
=item $enterasys->vendor() =item $enterasys->vendor()

View File

@@ -37,71 +37,80 @@ use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
use SNMP::Info::MAU; use SNMP::Info::MAU;
@SNMP::Info::Layer3::Extreme::ISA = qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/; @SNMP::Info::Layer3::Extreme::ISA
= qw/SNMP::Info::Layer3 SNMP::Info::MAU Exporter/;
@SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//; @SNMP::Info::Layer3::Extreme::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer3::MIBS, %MIBS = (
%SNMP::Info::MAU::MIBS, %SNMP::Info::Layer3::MIBS,
'EXTREME-BASE-MIB' => 'extremeAgent', %SNMP::Info::MAU::MIBS,
'EXTREME-SYSTEM-MIB' => 'extremeSystem', 'EXTREME-BASE-MIB' => 'extremeAgent',
'EXTREME-FDB-MIB' => 'extremeSystem', 'EXTREME-SYSTEM-MIB' => 'extremeSystem',
'EXTREME-VLAN-MIB' => 'extremeVlan', 'EXTREME-FDB-MIB' => 'extremeSystem',
); 'EXTREME-VLAN-MIB' => 'extremeVlan',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::MAU::GLOBALS, %SNMP::Info::MAU::GLOBALS,
'serial1' => 'extremeSystemID.0', 'serial1' => 'extremeSystemID.0',
'temp' => 'extremeCurrentTemperature', 'temp' => 'extremeCurrentTemperature',
'ps1_status_old' => 'extremePrimaryPowerOperational.0', 'ps1_status_old' => 'extremePrimaryPowerOperational.0',
'ps1_status_new' => 'extremePowerSupplyStatus.1', 'ps1_status_new' => 'extremePowerSupplyStatus.1',
'ps2_status_old' => 'extremeRedundantPowerStatus.0', 'ps2_status_old' => 'extremeRedundantPowerStatus.0',
'ps2_status_new' => 'extremePowerSupplyStatus.2', 'ps2_status_new' => 'extremePowerSupplyStatus.2',
'mac' => 'dot1dBaseBridgeAddress', 'mac' => 'dot1dBaseBridgeAddress',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::MAU::FUNCS, %SNMP::Info::MAU::FUNCS,
'fan_state' => 'extremeFanOperational', 'fan_state' => 'extremeFanOperational',
# EXTREME-FDB-MIB:extremeFdbMacFdbTable
'ex_fw_mac' => 'extremeFdbMacFdbMacAddress', # EXTREME-FDB-MIB:extremeFdbMacFdbTable
'ex_fw_port' => 'extremeFdbMacFdbPortIfIndex', 'ex_fw_mac' => 'extremeFdbMacFdbMacAddress',
'ex_fw_status' => 'extremeFdbMacFdbStatus', 'ex_fw_port' => 'extremeFdbMacFdbPortIfIndex',
# EXTREME-VLAN-MIB:extremeVlanIfTable 'ex_fw_status' => 'extremeFdbMacFdbStatus',
'ex_vlan_descr' => 'extremeVlanIfDescr',
'ex_vlan_global_id' => 'extremeVlanIfGlobalIdentifier', # EXTREME-VLAN-MIB:extremeVlanIfTable
# EXTREME-VLAN-MIB:extremeVlanEncapsIfTable 'ex_vlan_descr' => 'extremeVlanIfDescr',
'ex_vlan_encap_tag' => 'extremeVlanEncapsIfTag', 'ex_vlan_global_id' => 'extremeVlanIfGlobalIdentifier',
);
# EXTREME-VLAN-MIB:extremeVlanEncapsIfTable
'ex_vlan_encap_tag' => 'extremeVlanEncapsIfTag',
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE, # Inherit all the built in munging
%SNMP::Info::MAU::MUNGE, %SNMP::Info::Layer3::MUNGE,
'ex_fw_mac' => \&SNMP::Info::munge_mac, %SNMP::Info::MAU::MUNGE,
'ps1_status_old' => \&munge_true_ok, 'ex_fw_mac' => \&SNMP::Info::munge_mac,
'ps1_status_new' => \&munge_power_stat, 'ps1_status_old' => \&munge_true_ok,
'ps2_status_old' => \&munge_power_stat, 'ps1_status_new' => \&munge_power_stat,
'ps2_status_new' => \&munge_power_stat, 'ps2_status_old' => \&munge_power_stat,
'fan_state' => \&munge_true_ok, 'ps2_status_new' => \&munge_power_stat,
); 'fan_state' => \&munge_true_ok,
);
# Method OverRides # Method OverRides
*SNMP::Info::Layer3::Extreme::i_duplex = \&SNMP::Info::MAU::mau_i_duplex; *SNMP::Info::Layer3::Extreme::i_duplex = \&SNMP::Info::MAU::mau_i_duplex;
*SNMP::Info::Layer3::Extreme::i_duplex_admin = \&SNMP::Info::MAU::mau_i_duplex_admin; *SNMP::Info::Layer3::Extreme::i_duplex_admin
= \&SNMP::Info::MAU::mau_i_duplex_admin;
sub model { sub model {
my $extreme = shift; my $extreme = shift;
my $id = $extreme->id(); my $id = $extreme->id();
unless (defined $id){ unless ( defined $id ) {
print " SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n" if $extreme->debug(); print
" SNMP::Info::Layer3::Extreme::model() - Device does not support sysObjectID\n"
if $extreme->debug();
return; return;
} }
@@ -122,10 +131,10 @@ sub os {
sub os_ver { sub os_ver {
my $extreme = shift; my $extreme = shift;
my $descr = $extreme->description(); my $descr = $extreme->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/Version ([\d.]*)/){ if ( $descr =~ m/Version ([\d.]*)/ ) {
return $1; return $1;
} }
@@ -139,15 +148,16 @@ sub os_ver {
# assigned for router interfaces, so we use ifDescr # assigned for router interfaces, so we use ifDescr
# for those. # for those.
sub interfaces { sub interfaces {
my $extreme = shift; my $extreme = shift;
my $partial = shift; my $partial = shift;
my $i_name = $extreme->orig_i_name($partial); my $i_name = $extreme->orig_i_name($partial);
my $i_description = $extreme->orig_i_description($partial); my $i_description = $extreme->orig_i_description($partial);
my $interfaces = {}; my $interfaces = {};
foreach my $idx (keys %$i_name) { foreach my $idx ( keys %$i_name ) {
if ($i_name->{$idx} =~ /\([0-9.]+\)/) { if ( $i_name->{$idx} =~ /\([0-9.]+\)/ ) {
$interfaces->{$idx} = $i_description->{$idx}; $interfaces->{$idx} = $i_description->{$idx};
} else { }
else {
$interfaces->{$idx} = $i_name->{$idx}; $interfaces->{$idx} = $i_name->{$idx};
} }
} }
@@ -163,8 +173,10 @@ sub i_ignore {
my $i_description = $extreme->i_description($partial) || {}; my $i_description = $extreme->i_description($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$i_description) { foreach my $if ( keys %$i_description ) {
if ($i_description->{$if} =~ /^(802.1Q Encapsulation Tag \d+|VLAN \d+|lo\d+)/i){ if ( $i_description->{$if}
=~ /^(802.1Q Encapsulation Tag \d+|VLAN \d+|lo\d+)/i )
{
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }
@@ -175,11 +187,11 @@ sub i_ignore {
# Either way, Extreme uses a 1:1 mapping of bridge interface ID to # Either way, Extreme uses a 1:1 mapping of bridge interface ID to
# ifIndex. # ifIndex.
sub bp_index { sub bp_index {
my $extreme = shift; my $extreme = shift;
my $if_index = $extreme->i_index(); my $if_index = $extreme->i_index();
my %bp_index; my %bp_index;
foreach my $iid (keys %$if_index){ foreach my $iid ( keys %$if_index ) {
$bp_index{$iid} = $iid; $bp_index{$iid} = $iid;
} }
return \%bp_index; return \%bp_index;
@@ -188,8 +200,8 @@ sub bp_index {
sub munge_true_ok { sub munge_true_ok {
my $val = shift; my $val = shift;
return unless defined($val); return unless defined($val);
return "OK" if ($val eq 'true'); return "OK" if ( $val eq 'true' );
return "Not OK" if ($val eq 'false'); return "Not OK" if ( $val eq 'false' );
return $val; return $val;
} }
@@ -202,27 +214,27 @@ sub munge_power_stat {
} }
sub ps1_status { sub ps1_status {
my $extreme = shift; my $extreme = shift;
my $ps1_status = $extreme->ps1_status_new(); my $ps1_status = $extreme->ps1_status_new();
return $ps1_status || $extreme->ps1_status_old(); return $ps1_status || $extreme->ps1_status_old();
} }
sub ps2_status { sub ps2_status {
my $extreme = shift; my $extreme = shift;
my $ps2_status = $extreme->ps2_status_new(); my $ps2_status = $extreme->ps2_status_new();
return $ps2_status || $extreme->ps2_status_old(); return $ps2_status || $extreme->ps2_status_old();
} }
sub fan { sub fan {
my $extreme = shift; my $extreme = shift;
my $fan_state = $extreme->fan_state(); my $fan_state = $extreme->fan_state();
my $ret = ""; my $ret = "";
my $s = ""; my $s = "";
foreach my $i (sort {$a <=> $b} keys %$fan_state) { foreach my $i ( sort { $a <=> $b } keys %$fan_state ) {
$ret .= $s . $i . ": " . $fan_state->{$i}; $ret .= $s . $i . ": " . $fan_state->{$i};
$s = ", "; $s = ", ";
} }
return if ($s eq ""); return if ( $s eq "" );
return $ret; return $ret;
} }
@@ -231,7 +243,7 @@ sub fan {
# these tables, so we use the BRIDGE-MIB tables. # these tables, so we use the BRIDGE-MIB tables.
sub fw_mac { sub fw_mac {
my $extreme = shift; my $extreme = shift;
my $fw_mac = $extreme->ex_fw_mac; my $fw_mac = $extreme->ex_fw_mac;
return $fw_mac if defined($fw_mac); return $fw_mac if defined($fw_mac);
return $extreme->orig_fw_mac(); return $extreme->orig_fw_mac();
} }
@@ -244,7 +256,7 @@ sub fw_port {
} }
sub fw_status { sub fw_status {
my $extreme = shift; my $extreme = shift;
my $fw_status = $extreme->ex_fw_status; my $fw_status = $extreme->ex_fw_status;
return $fw_status if defined($fw_status); return $fw_status if defined($fw_status);
return $extreme->orig_fw_status(); return $extreme->orig_fw_status();
@@ -260,35 +272,38 @@ sub fw_status {
# To represent this, we use a negative version of the # To represent this, we use a negative version of the
# internal VLAN ID (the deprecated extremeVlanIfGlobalIdentifier) # internal VLAN ID (the deprecated extremeVlanIfGlobalIdentifier)
sub _if2tag { sub _if2tag {
my $extreme = shift; my $extreme = shift;
my $partial = shift; my $partial = shift;
my $stack = shift || $extreme->ifStackStatus($partial); my $stack = shift || $extreme->ifStackStatus($partial);
my $encap_tag = $extreme->ex_vlan_encap_tag(); my $encap_tag = $extreme->ex_vlan_encap_tag();
my $vlan_descr = $extreme->ex_vlan_descr(); my $vlan_descr = $extreme->ex_vlan_descr();
my $stackmap = {}; my $stackmap = {};
foreach my $idx (keys %$stack) { foreach my $idx ( keys %$stack ) {
my ($higher, $lower) = split(/\./, $idx); my ( $higher, $lower ) = split( /\./, $idx );
$stackmap->{$higher}->{$lower} = $stack->{$idx}; $stackmap->{$higher}->{$lower} = $stack->{$idx};
} }
my %if2tag = (); my %if2tag = ();
my $missed = 0; my $missed = 0;
foreach my $if (keys %$vlan_descr) { foreach my $if ( keys %$vlan_descr ) {
$if2tag{$if} = -1; $if2tag{$if} = -1;
foreach my $tagif (keys %$encap_tag) { foreach my $tagif ( keys %$encap_tag ) {
if (defined($stackmap->{$if}->{$tagif}) && $stackmap->{$if}->{$tagif} eq 'active') { if ( defined( $stackmap->{$if}->{$tagif} )
&& $stackmap->{$if}->{$tagif} eq 'active' )
{
$if2tag{$if} = $encap_tag->{$tagif}; $if2tag{$if} = $encap_tag->{$tagif};
} }
} }
if ($if2tag{$if} == -1) { if ( $if2tag{$if} == -1 ) {
$missed++; $missed++;
} }
} }
if ($missed) { if ($missed) {
my $global_id = $extreme->ex_vlan_global_id(); my $global_id = $extreme->ex_vlan_global_id();
foreach my $if (keys %if2tag) { foreach my $if ( keys %if2tag ) {
$if2tag{$if} = -$global_id->{$if} if ($if2tag{$if} == -1 && defined($global_id->{$if})); $if2tag{$if} = -$global_id->{$if}
if ( $if2tag{$if} == -1 && defined( $global_id->{$if} ) );
} }
} }
return \%if2tag; return \%if2tag;
@@ -308,23 +323,24 @@ sub v_index {
} }
sub i_vlan { sub i_vlan {
my $extreme = shift; my $extreme = shift;
my $partial = shift; my $partial = shift;
my $stack = $extreme->ifStackStatus($partial); my $stack = $extreme->ifStackStatus($partial);
my $encap_tag = $extreme->ex_vlan_encap_tag(); my $encap_tag = $extreme->ex_vlan_encap_tag();
my $vlan_descr = $extreme->ex_vlan_descr(); my $vlan_descr = $extreme->ex_vlan_descr();
my $stackmap = {}; my $stackmap = {};
foreach my $idx (keys %$stack) { foreach my $idx ( keys %$stack ) {
my ($higher, $lower) = split(/\./, $idx); my ( $higher, $lower ) = split( /\./, $idx );
$stackmap->{$higher}->{$lower} = $stack->{$idx}; $stackmap->{$higher}->{$lower} = $stack->{$idx};
} }
my $if2tag = $extreme->_if2tag($partial, $stack); my $if2tag = $extreme->_if2tag( $partial, $stack );
# #
# Now that we've done all that mapping work, we can map the # Now that we've done all that mapping work, we can map the
# ifStack indexes. # ifStack indexes.
my %i_vlan = (); my %i_vlan = ();
foreach my $if (keys %$if2tag) { foreach my $if ( keys %$if2tag ) {
foreach my $lowif (keys %{$stackmap->{$if}}) { foreach my $lowif ( keys %{ $stackmap->{$if} } ) {
$i_vlan{$lowif} = $if2tag->{$if}; $i_vlan{$lowif} = $if2tag->{$if};
} }
} }
@@ -332,31 +348,33 @@ sub i_vlan {
} }
sub i_vlan_membership { sub i_vlan_membership {
my $extreme = shift; my $extreme = shift;
my $partial = shift; my $partial = shift;
my $stack = $extreme->ifStackStatus($partial); my $stack = $extreme->ifStackStatus($partial);
my $encap_tag = $extreme->ex_vlan_encap_tag(); my $encap_tag = $extreme->ex_vlan_encap_tag();
my $vlan_descr = $extreme->ex_vlan_descr(); my $vlan_descr = $extreme->ex_vlan_descr();
my $stackmap = {}; my $stackmap = {};
foreach my $idx (keys %$stack) { foreach my $idx ( keys %$stack ) {
my ($higher, $lower) = split(/\./, $idx); my ( $higher, $lower ) = split( /\./, $idx );
$stackmap->{$higher}->{$lower} = $stack->{$idx}; $stackmap->{$higher}->{$lower} = $stack->{$idx};
} }
my $if2tag = $extreme->_if2tag($partial, $stack); my $if2tag = $extreme->_if2tag( $partial, $stack );
# #
# Now that we've done all that mapping work, we can map the # Now that we've done all that mapping work, we can map the
# ifStack indexes. # ifStack indexes.
my %i_vlan_membership = (); my %i_vlan_membership = ();
foreach my $if (keys %$if2tag) { foreach my $if ( keys %$if2tag ) {
foreach my $lowif (keys %{$stackmap->{$if}}) { foreach my $lowif ( keys %{ $stackmap->{$if} } ) {
push(@{$i_vlan_membership{$lowif}}, $if2tag->{$if}); push( @{ $i_vlan_membership{$lowif} }, $if2tag->{$if} );
} }
} }
# #
# Now add all the tagged ports. # Now add all the tagged ports.
foreach my $if (keys %$encap_tag) { foreach my $if ( keys %$encap_tag ) {
foreach my $lowif (keys %{$stackmap->{$if}}) { foreach my $lowif ( keys %{ $stackmap->{$if} } ) {
push(@{$i_vlan_membership{$lowif}}, $encap_tag->{$if}); push( @{ $i_vlan_membership{$lowif} }, $encap_tag->{$if} );
} }
} }
return \%i_vlan_membership; return \%i_vlan_membership;
@@ -368,12 +386,12 @@ sub i_vlan_membership {
sub set_i_vlan { sub set_i_vlan {
my $extreme = shift; my $extreme = shift;
return $extreme->_extreme_set_i_vlan(0, @_); return $extreme->_extreme_set_i_vlan( 0, @_ );
} }
sub set_i_pvid { sub set_i_pvid {
my $extreme = shift; my $extreme = shift;
return $extreme->_extreme_set_i_vlan(1, @_); return $extreme->_extreme_set_i_vlan( 1, @_ );
} }
# set_i_vlan implicitly turns off any encapsulation # set_i_vlan implicitly turns off any encapsulation
@@ -384,98 +402,127 @@ sub set_i_pvid {
# off any encapsulation. # off any encapsulation.
sub _extreme_set_i_vlan { sub _extreme_set_i_vlan {
my $extreme = shift; my $extreme = shift;
my ($is_pvid, $vlan_id, $ifindex) = @_; my ( $is_pvid, $vlan_id, $ifindex ) = @_;
my $encap_tag = $extreme->ex_vlan_encap_tag(); my $encap_tag = $extreme->ex_vlan_encap_tag();
# The inverted stack MIB would make this easier, since # The inverted stack MIB would make this easier, since
# we need to find the vlan interface # we need to find the vlan interface
# that's stacked above $ifindex. # that's stacked above $ifindex.
my $cur_stack = $extreme->ifStackStatus(); my $cur_stack = $extreme->ifStackStatus();
# #
# create inverted stack # create inverted stack
my $invstack; my $invstack;
foreach my $idx (keys %$cur_stack) { foreach my $idx ( keys %$cur_stack ) {
my ($higher, $lower) = split(/\./, $idx); my ( $higher, $lower ) = split( /\./, $idx );
$invstack->{$lower}->{$higher} = $cur_stack->{$idx}; $invstack->{$lower}->{$higher} = $cur_stack->{$idx};
} }
# create vlan tag -> encap interface map # create vlan tag -> encap interface map
my %encapif = reverse %$encap_tag; my %encapif = reverse %$encap_tag;
# now find encap interface from tag # now find encap interface from tag
my $encapidx = $encapif{$vlan_id}; my $encapidx = $encapif{$vlan_id};
if (!defined($encapidx)) { if ( !defined($encapidx) ) {
$extreme->error_throw("can't map $vlan_id to encapsulation interface"); $extreme->error_throw(
"can't map $vlan_id to encapsulation interface");
return; return;
} }
# now find vlan interface stacked above encap # now find vlan interface stacked above encap
my @abovevlan = keys %{$invstack->{$encapidx}}; my @abovevlan = keys %{ $invstack->{$encapidx} };
if (@abovevlan != 1) { if ( @abovevlan != 1 ) {
$extreme->error_throw("can't map encap interface $encapidx for $vlan_id to encapsulation interface"); $extreme->error_throw(
"can't map encap interface $encapidx for $vlan_id to encapsulation interface"
);
return; return;
} }
my $vlanidx = $abovevlan[0]; my $vlanidx = $abovevlan[0];
my $rv; my $rv;
# Delete old VLAN mapping # Delete old VLAN mapping
foreach my $oldidx (keys %{$invstack->{$ifindex}}) { foreach my $oldidx ( keys %{ $invstack->{$ifindex} } ) {
if ($is_pvid && defined($encap_tag->{$oldidx})) { if ( $is_pvid && defined( $encap_tag->{$oldidx} ) ) {
next; # Don't delete tagged mappings next; # Don't delete tagged mappings
} }
$rv = $extreme->set_ifStackStatus("destroy", $oldidx . "." . $ifindex); $rv = $extreme->set_ifStackStatus( "destroy",
$oldidx . "." . $ifindex );
unless ($rv) { unless ($rv) {
$extreme->error_throw("Unable to remove $ifindex from old VLAN index $oldidx"); $extreme->error_throw(
"Unable to remove $ifindex from old VLAN index $oldidx");
return; return;
} }
} }
# Add new VLAN mapping # Add new VLAN mapping
$rv = $extreme->set_ifStackStatus("createAndGo", $vlanidx . "." . $ifindex); $rv = $extreme->set_ifStackStatus( "createAndGo",
$vlanidx . "." . $ifindex );
unless ($rv) { unless ($rv) {
$extreme->error_throw("Unable to add new VLAN index $vlanidx to ifIndex $ifindex"); $extreme->error_throw(
"Unable to add new VLAN index $vlanidx to ifIndex $ifindex");
return; return;
} }
# XXX invalidate cache of ifstack?
# XXX Info.pm library function for this? # XXX invalidate cache of ifstack?
# XXX set_ should do invalidation? # XXX Info.pm library function for this?
# $store = $extreme->store(); delete $store->{ifStackStatus}; $extreme->store($store); # XXX set_ should do invalidation?
# $extreme->{_ifStackStatus} = 0; # $store = $extreme->store(); delete $store->{ifStackStatus}; $extreme->store($store);
# $extreme->{_ifStackStatus} = 0;
return $rv; return $rv;
} }
sub set_remove_i_vlan_tagged { sub set_remove_i_vlan_tagged {
my $extreme = shift; my $extreme = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
my $encap_tag = $extreme->ex_vlan_encap_tag(); my $encap_tag = $extreme->ex_vlan_encap_tag();
# create vlan tag -> encap interface map # create vlan tag -> encap interface map
my %encapif = reverse %$encap_tag; my %encapif = reverse %$encap_tag;
# now find encap interface from tag # now find encap interface from tag
my $encapidx = $encapif{$vlan_id}; my $encapidx = $encapif{$vlan_id};
if (!defined($encapidx)) { if ( !defined($encapidx) ) {
$extreme->error_throw("can't map $vlan_id to encapsulation interface"); $extreme->error_throw(
"can't map $vlan_id to encapsulation interface");
return; return;
} }
my $rv = $extreme->set_ifStackStatus("destroy", $encapidx . "." . $ifindex); my $rv = $extreme->set_ifStackStatus( "destroy",
$encapidx . "." . $ifindex );
unless ($rv) { unless ($rv) {
$extreme->error_throw("Unable to delete VLAN encap ifIndex $encapidx for VLAN $vlan_id from ifIndex $ifindex"); $extreme->error_throw(
"Unable to delete VLAN encap ifIndex $encapidx for VLAN $vlan_id from ifIndex $ifindex"
);
return; return;
} }
# invalidate cache of ifstack? # invalidate cache of ifstack?
return $rv; return $rv;
} }
sub set_add_i_vlan_tagged { sub set_add_i_vlan_tagged {
my $extreme = shift; my $extreme = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
my $encap_tag = $extreme->ex_vlan_encap_tag(); my $encap_tag = $extreme->ex_vlan_encap_tag();
# create vlan tag -> encap interface map # create vlan tag -> encap interface map
my %encapif = reverse %$encap_tag; my %encapif = reverse %$encap_tag;
# now find encap interface from tag # now find encap interface from tag
my $encapidx = $encapif{$vlan_id}; my $encapidx = $encapif{$vlan_id};
if (!defined($encapidx)) { if ( !defined($encapidx) ) {
$extreme->error_throw("can't map $vlan_id to encapsulation interface"); $extreme->error_throw(
"can't map $vlan_id to encapsulation interface");
return; return;
} }
my $rv = $extreme->set_ifStackStatus("createAndGo", $encapidx . "." . $ifindex); my $rv = $extreme->set_ifStackStatus( "createAndGo",
$encapidx . "." . $ifindex );
unless ($rv) { unless ($rv) {
$extreme->error_throw("Unable to add VLAN encap ifIndex $encapidx for VLAN $vlan_id to ifIndex $ifindex"); $extreme->error_throw(
"Unable to add VLAN encap ifIndex $encapidx for VLAN $vlan_id to ifIndex $ifindex"
);
return; return;
} }
# invalidate cache of ifstack? # invalidate cache of ifstack?
return $rv; return $rv;
} }
@@ -698,8 +745,8 @@ Returns VLAN names
Returns reference to hash of bridge port table entries map back to interface Returns reference to hash of bridge port table entries map back to interface
identifier (iid) identifier (iid)
Returns (C<ifIndex>) for both key and value since we're using F<EXTREME-FDB-MIB> Returns (C<ifIndex>) for both key and value since we're using
rather than F<BRIDGE-MIB>. F<EXTREME-FDB-MIB> rather than F<BRIDGE-MIB>.
=back =back

View File

@@ -39,51 +39,52 @@ use SNMP::Info::FDP;
use SNMP::Info::LLDP; use SNMP::Info::LLDP;
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP @SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/; SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//; @SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer3::MIBS, %MIBS = (
%SNMP::Info::LLDP::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::FDP::MIBS, %SNMP::Info::LLDP::MIBS,
'FOUNDRY-SN-ROOT-MIB' => 'foundry', %SNMP::Info::FDP::MIBS,
'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', 'FOUNDRY-SN-ROOT-MIB' => 'foundry',
'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', 'FOUNDRY-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
); 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::FDP::GLOBALS, %SNMP::Info::FDP::GLOBALS,
'mac' => 'ifPhysAddress.1', 'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1', 'chassis' => 'entPhysicalDescr.1',
'temp' => 'snChasActualTemperature', 'temp' => 'snChasActualTemperature',
'ps1_type' => 'snChasPwrSupplyDescription.1', 'ps1_type' => 'snChasPwrSupplyDescription.1',
'ps1_status' => 'snChasPwrSupplyOperStatus.1', 'ps1_status' => 'snChasPwrSupplyOperStatus.1',
'fan' => 'snChasFanOperStatus.1', 'fan' => 'snChasFanOperStatus.1',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS, %SNMP::Info::LLDP::FUNCS,
%SNMP::Info::FDP::FUNCS, %SNMP::Info::FDP::FUNCS,
# FOUNDRY-SN-SWITCH-GROUP-MIB
# snSwPortInfoTable - Switch Port Information Group # FOUNDRY-SN-SWITCH-GROUP-MIB
'sw_index' => 'snSwPortIfIndex', # snSwPortInfoTable - Switch Port Information Group
'sw_duplex' => 'snSwPortInfoChnMode', 'sw_index' => 'snSwPortIfIndex',
'sw_type' => 'snSwPortInfoMediaType', 'sw_duplex' => 'snSwPortInfoChnMode',
'sw_speed' => 'snSwPortInfoSpeed', 'sw_type' => 'snSwPortInfoMediaType',
); 'sw_speed' => 'snSwPortInfoSpeed',
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::FDP::MUNGE,
%SNMP::Info::FDP::MUNGE, );
);
sub i_ignore { sub i_ignore {
my $foundry = shift; my $foundry = shift;
@@ -92,8 +93,8 @@ sub i_ignore {
my $interfaces = $foundry->interfaces($partial) || {}; my $interfaces = $foundry->interfaces($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces) { foreach my $if ( keys %$interfaces ) {
if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i){ if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) {
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }
@@ -104,16 +105,16 @@ sub i_duplex {
my $foundry = shift; my $foundry = shift;
my $partial = shift; my $partial = shift;
my $sw_index = $foundry->sw_index($partial); my $sw_index = $foundry->sw_index($partial);
my $sw_duplex= $foundry->sw_duplex($partial); my $sw_duplex = $foundry->sw_duplex($partial);
unless (defined $sw_index and defined $sw_duplex){ unless ( defined $sw_index and defined $sw_duplex ) {
return $foundry->SUPER::i_duplex(); return $foundry->SUPER::i_duplex();
} }
my %i_duplex; my %i_duplex;
foreach my $sw_port (keys %$sw_duplex){ foreach my $sw_port ( keys %$sw_duplex ) {
my $iid = $sw_index->{$sw_port}; my $iid = $sw_index->{$sw_port};
my $duplex = $sw_duplex->{$sw_port}; my $duplex = $sw_duplex->{$sw_port};
next if $duplex =~ /none/i; next if $duplex =~ /none/i;
$i_duplex{$iid} = 'half' if $duplex =~ /half/i; $i_duplex{$iid} = 'half' if $duplex =~ /half/i;
@@ -124,24 +125,24 @@ sub i_duplex {
sub model { sub model {
my $foundry = shift; my $foundry = shift;
my $id = $foundry->id(); my $id = $foundry->id();
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
# EdgeIron # EdgeIron
if ($id =~ /\.1991\.1\.[45]\./) { if ( $id =~ /\.1991\.1\.[45]\./ ) {
my $e_name = $foundry->e_name(); my $e_name = $foundry->e_name();
# Find entity table entry for "unit.1" # Find entity table entry for "unit.1"
my $unit_iid = undef; my $unit_iid = undef;
foreach my $e (keys %$e_name){ foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || ''; my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1'; $unit_iid = $e if $name eq 'unit.1';
} }
# Find Model Name # Find Model Name
my $e_model = $foundry->e_model(); my $e_model = $foundry->e_model();
if (defined $e_model->{$unit_iid}){ if ( defined $e_model->{$unit_iid} ) {
return $e_model->{$unit_iid}; return $e_model->{$unit_iid};
} }
} }
@@ -168,7 +169,7 @@ sub os_ver {
# Some older ones don't have this value,so we cull it from the description # Some older ones don't have this value,so we cull it from the description
my $descr = $foundry->description(); my $descr = $foundry->description();
if ($descr =~ m/Version (\d\S*)/) { if ( $descr =~ m/Version (\d\S*)/ ) {
return $1; return $1;
} }
@@ -177,16 +178,16 @@ sub os_ver {
# find entity table entry for "stackmanaget.1" # find entity table entry for "stackmanaget.1"
my $unit_iid = undef; my $unit_iid = undef;
foreach my $e (keys %$e_name){ foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || ''; my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'stackmanaget.1'; $unit_iid = $e if $name eq 'stackmanaget.1';
} }
if (defined $unit_iid){ if ( defined $unit_iid ) {
# Find Model Name # Find Model Name
my $e_fwver = $foundry->e_fwver(); my $e_fwver = $foundry->e_fwver();
if (defined $e_fwver->{$unit_iid}){ if ( defined $e_fwver->{$unit_iid} ) {
return $e_fwver->{$unit_iid}; return $e_fwver->{$unit_iid};
} }
} }
@@ -205,7 +206,7 @@ sub serial {
# If no chassis serial use first module serial # If no chassis serial use first module serial
my $mod_serials = $foundry->snAgentConfigModuleSerialNumber(); my $mod_serials = $foundry->snAgentConfigModuleSerialNumber();
foreach my $mod (sort keys %$mod_serials){ foreach my $mod ( sort keys %$mod_serials ) {
my $serial = $mod_serials->{$mod} || ''; my $serial = $mod_serials->{$mod} || '';
next unless defined $serial; next unless defined $serial;
return $serial; return $serial;
@@ -216,12 +217,13 @@ sub serial {
# find entity table entry for "unit.1" # find entity table entry for "unit.1"
my $unit_iid = undef; my $unit_iid = undef;
foreach my $e (keys %$e_name){ foreach my $e ( keys %$e_name ) {
my $name = $e_name->{$e} || ''; my $name = $e_name->{$e} || '';
$unit_iid = $e if $name eq 'unit.1'; $unit_iid = $e if $name eq 'unit.1';
} }
if (defined $unit_iid) { if ( defined $unit_iid ) {
# Look up serial of found entry. # Look up serial of found entry.
my $e_serial = $foundry->e_serial(); my $e_serial = $foundry->e_serial();
return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid}; return $e_serial->{$unit_iid} if defined $e_serial->{$unit_iid};
@@ -236,10 +238,10 @@ sub interfaces {
my $partial = shift; my $partial = shift;
my $i_descr = $foundry->i_description($partial) || {}; my $i_descr = $foundry->i_description($partial) || {};
my $i_name = $foundry->i_name($partial) || {}; my $i_name = $foundry->i_name($partial) || {};
# Use ifName for EdgeIrons else use ifDescr # Use ifName for EdgeIrons else use ifDescr
foreach my $iid (keys %$i_name){ foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid}; my $name = $i_name->{$iid};
next unless defined $name; next unless defined $name;
$i_descr->{$iid} = $name $i_descr->{$iid} = $name
@@ -255,7 +257,7 @@ sub stp_p_state {
my $partial = shift; my $partial = shift;
my $descr = $foundry->description(); my $descr = $foundry->description();
if ($descr =~ m/\bEdgeIron 24G\b/) { if ( $descr =~ m/\bEdgeIron 24G\b/ ) {
return; return;
} }
@@ -276,17 +278,17 @@ sub c_ip {
my $partial = shift; my $partial = shift;
my $cdp = $foundry->SUPER::c_ip($partial) || {}; my $cdp = $foundry->SUPER::c_ip($partial) || {};
my $lldp = $foundry->lldp_ip($partial) || {}; my $lldp = $foundry->lldp_ip($partial) || {};
my %c_ip; my %c_ip;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid}; my $ip = $cdp->{$iid};
next unless defined $ip; next unless defined $ip;
$c_ip{$iid} = $ip; $c_ip{$iid} = $ip;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid}; my $ip = $lldp->{$iid};
next unless defined $ip; next unless defined $ip;
@@ -299,18 +301,18 @@ sub c_if {
my $foundry = shift; my $foundry = shift;
my $partial = shift; my $partial = shift;
my $lldp = $foundry->lldp_if($partial) || {};; my $lldp = $foundry->lldp_if($partial) || {};
my $cdp = $foundry->SUPER::c_if($partial) || {}; my $cdp = $foundry->SUPER::c_if($partial) || {};
my %c_if; my %c_if;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid}; my $if = $cdp->{$iid};
next unless defined $if; next unless defined $if;
$c_if{$iid} = $if; $c_if{$iid} = $if;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid}; my $if = $lldp->{$iid};
next unless defined $if; next unless defined $if;
@@ -323,18 +325,18 @@ sub c_port {
my $foundry = shift; my $foundry = shift;
my $partial = shift; my $partial = shift;
my $lldp = $foundry->lldp_port($partial) || {}; my $lldp = $foundry->lldp_port($partial) || {};
my $cdp = $foundry->SUPER::c_port($partial) || {}; my $cdp = $foundry->SUPER::c_port($partial) || {};
my %c_port; my %c_port;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid}; my $port = $cdp->{$iid};
next unless defined $port; next unless defined $port;
$c_port{$iid} = $port; $c_port{$iid} = $port;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid}; my $port = $lldp->{$iid};
next unless defined $port; next unless defined $port;
@@ -347,18 +349,18 @@ sub c_id {
my $foundry = shift; my $foundry = shift;
my $partial = shift; my $partial = shift;
my $lldp = $foundry->lldp_id($partial) || {}; my $lldp = $foundry->lldp_id($partial) || {};
my $cdp = $foundry->SUPER::c_id($partial) || {}; my $cdp = $foundry->SUPER::c_id($partial) || {};
my %c_id; my %c_id;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid}; my $id = $cdp->{$iid};
next unless defined $id; next unless defined $id;
$c_id{$iid} = $id; $c_id{$iid} = $id;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid}; my $id = $lldp->{$iid};
next unless defined $id; next unless defined $id;
@@ -371,18 +373,18 @@ sub c_platform {
my $foundry = shift; my $foundry = shift;
my $partial = shift; my $partial = shift;
my $lldp = $foundry->lldp_rem_sysdesc($partial) || {}; my $lldp = $foundry->lldp_rem_sysdesc($partial) || {};
my $cdp = $foundry->SUPER::c_platform($partial) || {}; my $cdp = $foundry->SUPER::c_platform($partial) || {};
my %c_platform; my %c_platform;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid}; my $platform = $cdp->{$iid};
next unless defined $platform; next unless defined $platform;
$c_platform{$iid} = $platform; $c_platform{$iid} = $platform;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid}; my $platform = $lldp->{$iid};
next unless defined $platform; next unless defined $platform;
@@ -629,9 +631,9 @@ Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4 If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry. address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different IPv4 If multiple entries exist with the same local port, c_if(), with different
addresses, c_ip(), there is either a non-FDP/LLDP device in between two or IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two
more devices or multiple devices which are not directly connected. or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper. Use the data from the Layer2 Topology Table below to dig deeper.

View File

@@ -37,63 +37,64 @@ use SNMP::Info::FDP;
use SNMP::Info::LLDP; use SNMP::Info::LLDP;
@SNMP::Info::Layer3::HP9300::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP @SNMP::Info::Layer3::HP9300::ISA = qw/SNMP::Info::FDP SNMP::Info::LLDP
SNMP::Info::Layer3 Exporter/; SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::HP9300::EXPORT_OK = qw//; @SNMP::Info::Layer3::HP9300::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer3::MIBS, %MIBS = (
%SNMP::Info::LLDP::MIBS, %SNMP::Info::Layer3::MIBS,
%SNMP::Info::FDP::MIBS, %SNMP::Info::LLDP::MIBS,
'HP-SN-ROOT-MIB' => 'hp', %SNMP::Info::FDP::MIBS,
'HP-SN-AGENT-MIB' => 'snChasPwrSupplyDescription', 'HP-SN-ROOT-MIB' => 'hp',
'HP-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode', 'HP-SN-AGENT-MIB' => 'snChasPwrSupplyDescription',
); 'HP-SN-SWITCH-GROUP-MIB' => 'snSwGroupOperMode',
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::LLDP::GLOBALS, %SNMP::Info::LLDP::GLOBALS,
%SNMP::Info::FDP::GLOBALS, %SNMP::Info::FDP::GLOBALS,
'mac' => 'ifPhysAddress.1', 'mac' => 'ifPhysAddress.1',
'chassis' => 'entPhysicalDescr.1', 'chassis' => 'entPhysicalDescr.1',
'temp' => 'snChasActualTemperature', 'temp' => 'snChasActualTemperature',
'ps1_type' => 'snChasPwrSupplyDescription.1', 'ps1_type' => 'snChasPwrSupplyDescription.1',
'ps1_status' => 'snChasPwrSupplyOperStatus.1', 'ps1_status' => 'snChasPwrSupplyOperStatus.1',
'fan' => 'snChasFanOperStatus.1', 'fan' => 'snChasFanOperStatus.1',
); );
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::LLDP::FUNCS, %SNMP::Info::LLDP::FUNCS,
%SNMP::Info::FDP::FUNCS, %SNMP::Info::FDP::FUNCS,
# HP-SN-SWITCH-GROUP-MIB
# snSwPortInfoTable - Switch Port Information Group # HP-SN-SWITCH-GROUP-MIB
# Fully qualify these since FDP class will load # snSwPortInfoTable - Switch Port Information Group
# FOUNDRY-SN-SWITCH-GROUP-MIB which contains the same leaf names # Fully qualify these since FDP class will load
'sw_index' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortIfIndex', # FOUNDRY-SN-SWITCH-GROUP-MIB which contains the same leaf names
'sw_duplex' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoChnMode', 'sw_index' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortIfIndex',
'sw_type' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoMediaType', 'sw_duplex' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoChnMode',
'sw_speed' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoSpeed', 'sw_type' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoMediaType',
); 'sw_speed' => 'HP_SN_SWITCH_GROUP_MIB__snSwPortInfoSpeed',
);
%MUNGE = ( %MUNGE = (
%SNMP::Info::Layer3::MUNGE, %SNMP::Info::Layer3::MUNGE, %SNMP::Info::LLDP::MUNGE,
%SNMP::Info::LLDP::MUNGE, %SNMP::Info::FDP::MUNGE,
%SNMP::Info::FDP::MUNGE, );
);
sub i_ignore { sub i_ignore {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $hp9300->interfaces($partial) || {}; my $interfaces = $hp9300->interfaces($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces) { foreach my $if ( keys %$interfaces ) {
if ($interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i){ if ( $interfaces->{$if} =~ /(tunnel|loopback|\blo\b|lb|null)/i ) {
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }
@@ -101,19 +102,19 @@ sub i_ignore {
} }
sub i_duplex { sub i_duplex {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $sw_index = $hp9300->sw_index($partial); my $sw_index = $hp9300->sw_index($partial);
my $sw_duplex= $hp9300->sw_duplex($partial); my $sw_duplex = $hp9300->sw_duplex($partial);
unless (defined $sw_index and defined $sw_duplex){ unless ( defined $sw_index and defined $sw_duplex ) {
return $hp9300->SUPER::i_duplex(); return $hp9300->SUPER::i_duplex();
} }
my %i_duplex; my %i_duplex;
foreach my $sw_port (keys %$sw_duplex){ foreach my $sw_port ( keys %$sw_duplex ) {
my $iid = $sw_index->{$sw_port}; my $iid = $sw_index->{$sw_port};
my $duplex = $sw_duplex->{$sw_port}; my $duplex = $sw_duplex->{$sw_port};
next if $duplex =~ /none/i; next if $duplex =~ /none/i;
$i_duplex{$iid} = 'half' if $duplex =~ /half/i; $i_duplex{$iid} = 'half' if $duplex =~ /half/i;
@@ -124,8 +125,8 @@ sub i_duplex {
sub model { sub model {
my $hp9300 = shift; my $hp9300 = shift;
my $id = $hp9300->id(); my $id = $hp9300->id();
my $model = &SNMP::translateObj($id); my $model = &SNMP::translateObj($id);
return $id unless defined $model; return $id unless defined $model;
@@ -149,7 +150,7 @@ sub os_ver {
# Some older ones don't have this value,so we cull it from the description # Some older ones don't have this value,so we cull it from the description
my $descr = $hp9300->description(); my $descr = $hp9300->description();
if ($descr =~ m/Version (\d\S*)/) { if ( $descr =~ m/Version (\d\S*)/ ) {
return $1; return $1;
} }
@@ -167,7 +168,7 @@ sub serial {
# If no chassis serial use first module serial # If no chassis serial use first module serial
my $mod_serials = $hp9300->snAgentConfigModuleSerialNumber(); my $mod_serials = $hp9300->snAgentConfigModuleSerialNumber();
foreach my $mod (sort keys %$mod_serials){ foreach my $mod ( sort keys %$mod_serials ) {
my $serial = $mod_serials->{$mod} || ''; my $serial = $mod_serials->{$mod} || '';
next unless defined $serial; next unless defined $serial;
return $serial; return $serial;
@@ -178,14 +179,14 @@ sub serial {
} }
sub interfaces { sub interfaces {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $i_descr = $hp9300->i_description($partial) || {}; my $i_descr = $hp9300->i_description($partial) || {};
my $i_name = $hp9300->i_name($partial) || {}; my $i_name = $hp9300->i_name($partial) || {};
# Use ifName for EdgeIrons else use ifDescr # Use ifName for EdgeIrons else use ifDescr
foreach my $iid (keys %$i_name){ foreach my $iid ( keys %$i_name ) {
my $name = $i_name->{$iid}; my $name = $i_name->{$iid};
next unless defined $name; next unless defined $name;
$i_descr->{$iid} = $name $i_descr->{$iid} = $name
@@ -204,21 +205,21 @@ sub hasCDP {
} }
sub c_ip { sub c_ip {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $cdp = $hp9300->SUPER::c_ip($partial) || {}; my $cdp = $hp9300->SUPER::c_ip($partial) || {};
my $lldp = $hp9300->lldp_ip($partial) || {}; my $lldp = $hp9300->lldp_ip($partial) || {};
my %c_ip; my %c_ip;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $ip = $cdp->{$iid}; my $ip = $cdp->{$iid};
next unless defined $ip; next unless defined $ip;
$c_ip{$iid} = $ip; $c_ip{$iid} = $ip;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $ip = $lldp->{$iid}; my $ip = $lldp->{$iid};
next unless defined $ip; next unless defined $ip;
@@ -228,21 +229,21 @@ sub c_ip {
} }
sub c_if { sub c_if {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp9300->lldp_if($partial) || {};; my $lldp = $hp9300->lldp_if($partial) || {};
my $cdp = $hp9300->SUPER::c_if($partial) || {}; my $cdp = $hp9300->SUPER::c_if($partial) || {};
my %c_if; my %c_if;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $if = $cdp->{$iid}; my $if = $cdp->{$iid};
next unless defined $if; next unless defined $if;
$c_if{$iid} = $if; $c_if{$iid} = $if;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $if = $lldp->{$iid}; my $if = $lldp->{$iid};
next unless defined $if; next unless defined $if;
@@ -252,21 +253,21 @@ sub c_if {
} }
sub c_port { sub c_port {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp9300->lldp_port($partial) || {}; my $lldp = $hp9300->lldp_port($partial) || {};
my $cdp = $hp9300->SUPER::c_port($partial) || {}; my $cdp = $hp9300->SUPER::c_port($partial) || {};
my %c_port; my %c_port;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $port = $cdp->{$iid}; my $port = $cdp->{$iid};
next unless defined $port; next unless defined $port;
$c_port{$iid} = $port; $c_port{$iid} = $port;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $port = $lldp->{$iid}; my $port = $lldp->{$iid};
next unless defined $port; next unless defined $port;
@@ -276,21 +277,21 @@ sub c_port {
} }
sub c_id { sub c_id {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp9300->lldp_id($partial) || {}; my $lldp = $hp9300->lldp_id($partial) || {};
my $cdp = $hp9300->SUPER::c_id($partial) || {}; my $cdp = $hp9300->SUPER::c_id($partial) || {};
my %c_id; my %c_id;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $id = $cdp->{$iid}; my $id = $cdp->{$iid};
next unless defined $id; next unless defined $id;
$c_id{$iid} = $id; $c_id{$iid} = $id;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $id = $lldp->{$iid}; my $id = $lldp->{$iid};
next unless defined $id; next unless defined $id;
@@ -300,21 +301,21 @@ sub c_id {
} }
sub c_platform { sub c_platform {
my $hp9300 = shift; my $hp9300 = shift;
my $partial = shift; my $partial = shift;
my $lldp = $hp9300->lldp_rem_sysdesc($partial) || {}; my $lldp = $hp9300->lldp_rem_sysdesc($partial) || {};
my $cdp = $hp9300->SUPER::c_platform($partial) || {}; my $cdp = $hp9300->SUPER::c_platform($partial) || {};
my %c_platform; my %c_platform;
foreach my $iid (keys %$cdp){ foreach my $iid ( keys %$cdp ) {
my $platform = $cdp->{$iid}; my $platform = $cdp->{$iid};
next unless defined $platform; next unless defined $platform;
$c_platform{$iid} = $platform; $c_platform{$iid} = $platform;
} }
foreach my $iid (keys %$lldp){ foreach my $iid ( keys %$lldp ) {
my $platform = $lldp->{$iid}; my $platform = $lldp->{$iid};
next unless defined $platform; next unless defined $platform;
@@ -553,9 +554,9 @@ Returns reference to hash. Key: iid Value: remote IPv4 address
If multiple entries exist with the same local port, c_if(), with the same IPv4 If multiple entries exist with the same local port, c_if(), with the same IPv4
address, c_ip(), it may be a duplicate entry. address, c_ip(), it may be a duplicate entry.
If multiple entries exist with the same local port, c_if(), with different IPv4 If multiple entries exist with the same local port, c_if(), with different
addresses, c_ip(), there is either a non-FDP/LLDP device in between two or IPv4 addresses, c_ip(), there is either a non-FDP/LLDP device in between two
more devices or multiple devices which are not directly connected. or more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper. Use the data from the Layer2 Topology Table below to dig deeper.

View File

@@ -34,47 +34,40 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Juniper::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Juniper::EXPORT_OK = qw//; @SNMP::Info::Layer3::Juniper::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
'JUNIPER-CHASSIS-DEFINES-MIB' => 'jnxChassisDefines', 'JUNIPER-CHASSIS-DEFINES-MIB' => 'jnxChassisDefines',
'JUNIPER-MIB' => 'jnxBoxAnatomy', 'JUNIPER-MIB' => 'jnxBoxAnatomy',
); );
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, 'serial' => 'jnxBoxSerialNo.0', );
%SNMP::Info::Layer3::GLOBALS,
'serial' => 'jnxBoxSerialNo.0',
);
%FUNCS = ( %FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%SNMP::Info::Layer3::FUNCS,
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
%SNMP::Info::Layer3::MUNGE,
);
sub vendor { sub vendor {
return 'juniper'; return 'juniper';
} }
sub os { sub os {
return 'junos'; return 'junos';
} }
sub os_ver { sub os_ver {
my $juniper = shift; my $juniper = shift;
my $descr = $juniper->description(); my $descr = $juniper->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/kernel JUNOS (\S+)/) { if ( $descr =~ m/kernel JUNOS (\S+)/ ) {
return $1; return $1;
} }
return; return;
} }
@@ -83,8 +76,10 @@ sub model {
my $l3 = shift; my $l3 = shift;
my $id = $l3->id(); my $id = $l3->id();
unless (defined $id){ unless ( defined $id ) {
print " SNMP::Info::Layer3::Juniper::model() - Device does not support sysObjectID\n" if $l3->debug(); print
" SNMP::Info::Layer3::Juniper::model() - Device does not support sysObjectID\n"
if $l3->debug();
return; return;
} }
@@ -103,21 +98,21 @@ sub serial {
} }
sub i_vlan { sub i_vlan {
my ($juniper) = shift; my ($juniper) = shift;
my ($partial) = shift; my ($partial) = shift;
my ($i_type) = $juniper->i_type($partial); my ($i_type) = $juniper->i_type($partial);
my ($i_descr) = $juniper->i_description($partial); my ($i_descr) = $juniper->i_description($partial);
my %i_vlan; my %i_vlan;
foreach my $idx (keys %$i_descr) { foreach my $idx ( keys %$i_descr ) {
if ($i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135) { if ( $i_type->{$idx} eq 'l2vlan' || $i_type->{$idx} eq 135 ) {
if ($i_descr->{$idx} =~ /\.(\d+)$/) { if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) {
$i_vlan{$idx} = $1; $i_vlan{$idx} = $1;
} }
} }
} }
return \%i_vlan; return \%i_vlan;
} }
1; 1;

View File

@@ -34,35 +34,27 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Microsoft::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Microsoft::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Microsoft::EXPORT_OK = qw//; @SNMP::Info::Layer3::Microsoft::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( %SNMP::Info::Layer3::MIBS, );
%SNMP::Info::Layer3::MIBS,
);
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, );
%SNMP::Info::Layer3::GLOBALS,
);
%FUNCS = ( %FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%SNMP::Info::Layer3::FUNCS,
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
%SNMP::Info::Layer3::MUNGE,
);
sub vendor { sub vendor {
return 'microsoft'; return 'microsoft';
} }
sub os { sub os {
return 'windows'; return 'windows';
} }
sub os_ver { sub os_ver {
@@ -70,28 +62,30 @@ sub os_ver {
} }
sub model { sub model {
return 'Windows Router' return 'Windows Router';
} }
sub serial { sub serial {
return ''; return '';
} }
# $l3->interfaces() - Map the Interfaces to their physical names # $l3->interfaces() - Map the Interfaces to their physical names
# Add interface number to interface name because if MS Win # Add interface number to interface name because if MS Win
# have identical interface cards ("HP NC7782 Gigabit Server Adapter" # have identical interface cards ("HP NC7782 Gigabit Server Adapter"
# for example), than MS Win return identical ifDescr # for example), than MS Win return identical ifDescr
sub interfaces { sub interfaces {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l3->i_index($partial); my $interfaces = $l3->i_index($partial);
my $descriptions = $l3->i_description($partial); my $descriptions = $l3->i_description($partial);
my %interfaces = (); my %interfaces = ();
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid}; my $desc = $descriptions->{$iid};
next unless defined $desc; next unless defined $desc;
$interfaces{$iid} = sprintf("(%U) %s", $iid, $desc); $interfaces{$iid} = sprintf( "(%U) %s", $iid, $desc );
} }
return \%interfaces; return \%interfaces;

View File

@@ -35,48 +35,52 @@ use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
use SNMP::Info::SONMP; use SNMP::Info::SONMP;
@SNMP::Info::Layer3::N1600::ISA = qw/SNMP::Info::Layer3 SNMP::Info::SONMP Exporter/; @SNMP::Info::Layer3::N1600::ISA
= qw/SNMP::Info::Layer3 SNMP::Info::SONMP Exporter/;
@SNMP::Info::Layer3::N1600::EXPORT_OK = qw//; @SNMP::Info::Layer3::N1600::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/; use vars qw/$VERSION %GLOBALS %FUNCS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %SNMP::Info::Layer3::MIBS, %MIBS = (
%SNMP::Info::SONMP::MIBS, %SNMP::Info::Layer3::MIBS,
'SWL2MGMT-MIB' => 'swL2MgmtMIB', %SNMP::Info::SONMP::MIBS,
'RAPID-CITY' => 'rapidCity', 'SWL2MGMT-MIB' => 'swL2MgmtMIB',
); 'RAPID-CITY' => 'rapidCity',
);
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::SONMP::GLOBALS, );
%SNMP::Info::Layer3::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
);
%FUNCS = ( %FUNCS = (
%SNMP::Info::Layer3::FUNCS, %SNMP::Info::Layer3::FUNCS,
%SNMP::Info::SONMP::FUNCS, %SNMP::Info::SONMP::FUNCS,
# SWL2MGMT-MIB
# swL2PortInfoTable # SWL2MGMT-MIB
'n1600_nway_status' => 'swL2PortInfoNwayStatus', # swL2PortInfoTable
# swL2PortCtrlTable 'n1600_nway_status' => 'swL2PortInfoNwayStatus',
'n1600_nway_state' => 'swL2PortCtrlNwayState',
); # swL2PortCtrlTable
'n1600_nway_state' => 'swL2PortCtrlNwayState',
);
%MUNGE = ( %MUNGE = (
# Inherit all the built in munging
%SNMP::Info::Layer3::MUNGE, # Inherit all the built in munging
%SNMP::Info::SONMP::MUNGE, %SNMP::Info::Layer3::MUNGE,
); %SNMP::Info::SONMP::MUNGE,
);
# Method OverRides # Method OverRides
sub model { sub model {
my $n1600 = shift; my $n1600 = shift;
my $id = $n1600->id(); my $id = $n1600->id();
unless (defined $id){ unless ( defined $id ) {
print " SNMP::Info::Layer3::N1600::model() - Device does not support sysObjectID\n" if $n1600->debug(); print
" SNMP::Info::Layer3::N1600::model() - Device does not support sysObjectID\n"
if $n1600->debug();
return; return;
} }
@@ -101,7 +105,7 @@ sub os_ver {
my $descr = $n1600->description(); my $descr = $n1600->description();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/(\d+\.\d+\.\d+\.\d+)/){ if ( $descr =~ m/(\d+\.\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
@@ -109,13 +113,13 @@ sub os_ver {
} }
sub interfaces { sub interfaces {
my $n1600 = shift; my $n1600 = shift;
my $partial = shift; my $partial = shift;
my $i_index = $n1600->i_index($partial) || {}; my $i_index = $n1600->i_index($partial) || {};
my %if; my %if;
foreach my $iid (keys %$i_index){ foreach my $iid ( keys %$i_index ) {
my $index = $i_index->{$iid}; my $index = $i_index->{$iid};
next unless defined $index; next unless defined $index;
@@ -126,13 +130,13 @@ sub interfaces {
} }
sub i_duplex { sub i_duplex {
my $n1600 = shift; my $n1600 = shift;
my $partial = shift; my $partial = shift;
my $nway_status = $n1600->n1600_nway_status($partial) || {}; my $nway_status = $n1600->n1600_nway_status($partial) || {};
my %i_duplex; my %i_duplex;
foreach my $iid (keys %$nway_status){ foreach my $iid ( keys %$nway_status ) {
my $duplex = $nway_status->{$iid}; my $duplex = $nway_status->{$iid};
next unless defined $duplex; next unless defined $duplex;
next if $duplex =~ /other/i; next if $duplex =~ /other/i;
@@ -143,13 +147,13 @@ sub i_duplex {
} }
sub i_duplex_admin { sub i_duplex_admin {
my $n1600 = shift; my $n1600 = shift;
my $partial = shift; my $partial = shift;
my $nway_state = $n1600->n1600_nway_state($partial) || {}; my $nway_state = $n1600->n1600_nway_state($partial) || {};
my %i_duplex; my %i_duplex;
foreach my $iid (keys %$nway_state){ foreach my $iid ( keys %$nway_state ) {
my $duplex = $nway_state->{$iid}; my $duplex = $nway_state->{$iid};
next unless defined $duplex; next unless defined $duplex;
next if $duplex =~ /other/i; next if $duplex =~ /other/i;

View File

@@ -34,33 +34,29 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::NetSNMP::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::NetSNMP::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::NetSNMP::EXPORT_OK = qw//; @SNMP::Info::Layer3::NetSNMP::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
'UCD-SNMP-MIB' => 'versionTag', 'UCD-SNMP-MIB' => 'versionTag',
'NET-SNMP-TC' => 'netSnmpAgentOIDs', 'NET-SNMP-TC' => 'netSnmpAgentOIDs',
'HOST-RESOURCES-MIB' => 'hrSystem', 'HOST-RESOURCES-MIB' => 'hrSystem',
); );
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
'netsnmp_vers' => 'versionTag', 'netsnmp_vers' => 'versionTag',
'hrSystemUptime' => 'hrSystemUptime', 'hrSystemUptime' => 'hrSystemUptime',
); );
%FUNCS = ( %FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%SNMP::Info::Layer3::FUNCS,
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
%SNMP::Info::Layer3::MUNGE,
);
sub vendor { sub vendor {
return 'Net-SNMP'; return 'Net-SNMP';
@@ -68,19 +64,19 @@ sub vendor {
sub os { sub os {
my $netsnmp = shift; my $netsnmp = shift;
my $descr = $netsnmp->description(); my $descr = $netsnmp->description();
return $1 if ($descr =~ /^(\S+)\s+/); return $1 if ( $descr =~ /^(\S+)\s+/ );
return; return;
} }
sub os_ver { sub os_ver {
my $netsnmp = shift; my $netsnmp = shift;
my $descr = $netsnmp->description(); my $descr = $netsnmp->description();
my $vers = $netsnmp->netsnmp_vers(); my $vers = $netsnmp->netsnmp_vers();
my $os_ver = undef; my $os_ver = undef;
$os_ver = $1 if ($descr =~ /^\S+\s+\S+\s+(\S+)\s+/); $os_ver = $1 if ( $descr =~ /^\S+\s+\S+\s+(\S+)\s+/ );
if ($vers) { if ($vers) {
$os_ver = "???" unless defined($os_ver); $os_ver = "???" unless defined($os_ver);
$os_ver .= " / Net-SNMP " . $vers; $os_ver .= " / Net-SNMP " . $vers;
@@ -109,15 +105,16 @@ sub uptime {
} }
sub i_ignore { sub i_ignore {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {}; my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces) { foreach my $if ( keys %$interfaces ) {
# lo0 etc # lo0 etc
if ($interfaces->{$if} =~ /\blo\d*\b/i){ if ( $interfaces->{$if} =~ /\blo\d*\b/i ) {
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }

View File

@@ -34,36 +34,29 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Netscreen::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Netscreen::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Netscreen::EXPORT_OK = qw//; @SNMP::Info::Layer3::Netscreen::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
%SNMP::Info::Layer3::MIBS, %SNMP::Info::Layer3::MIBS,
'NETSCREEN-SMI' => 'netscreenSetting', 'NETSCREEN-SMI' => 'netscreenSetting',
'NETSCREEN-PRODUCTS-MIB' => 'netscreenGeneric', 'NETSCREEN-PRODUCTS-MIB' => 'netscreenGeneric',
'NETSCREEN-INTERFACE-MIB' => 'nsIfIndex', 'NETSCREEN-INTERFACE-MIB' => 'nsIfIndex',
'NETSCREEN-SET-GEN-MIB' => 'nsSetGenSwVer', 'NETSCREEN-SET-GEN-MIB' => 'nsSetGenSwVer',
); );
%GLOBALS = ( %GLOBALS = ( %SNMP::Info::Layer3::GLOBALS, 'os_version' => 'nsSetGenSwVer', );
%SNMP::Info::Layer3::GLOBALS,
'os_version' => 'nsSetGenSwVer',
);
%FUNCS = ( %FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%SNMP::Info::Layer3::FUNCS,
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
%SNMP::Info::Layer3::MUNGE,
);
sub layers { sub layers {
return '01001100'; return '01001100';
} }
sub vendor { sub vendor {
@@ -78,8 +71,8 @@ sub os_ver {
my $netscreen = shift; my $netscreen = shift;
my $descr = $netscreen->description(); my $descr = $netscreen->description();
if ( $descr =~ m/version (\d\S*) \(SN: /) { if ( $descr =~ m/version (\d\S*) \(SN: / ) {
return $1; return $1;
} }
return; return;
} }
@@ -91,9 +84,9 @@ sub serial {
my $serial = $e_serial->{1} || undef; my $serial = $e_serial->{1} || undef;
return $1 if (defined $serial and $serial =~ /(\d+)/); return $1 if ( defined $serial and $serial =~ /(\d+)/ );
my $descr = $netscreen->description(); my $descr = $netscreen->description();
if ( $descr =~ m/version .*\(SN: (\d\S*),/) { if ( $descr =~ m/version .*\(SN: (\d\S*),/ ) {
return $1; return $1;
} }
return; return;

File diff suppressed because it is too large Load Diff

View File

@@ -34,69 +34,65 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info::Layer3; use SNMP::Info::Layer3;
@SNMP::Info::Layer3::Sun::ISA = qw/SNMP::Info::Layer3 Exporter/; @SNMP::Info::Layer3::Sun::ISA = qw/SNMP::Info::Layer3 Exporter/;
@SNMP::Info::Layer3::Sun::EXPORT_OK = qw//; @SNMP::Info::Layer3::Sun::EXPORT_OK = qw//;
use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/ ; use vars qw/$VERSION %GLOBALS %MIBS %FUNCS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( %SNMP::Info::Layer3::MIBS, );
%SNMP::Info::Layer3::MIBS,
);
%GLOBALS = ( %GLOBALS = (
%SNMP::Info::Layer3::GLOBALS, %SNMP::Info::Layer3::GLOBALS,
'sun_hostid' => '.1.3.6.1.4.1.42.3.1.2.0', 'sun_hostid' => '.1.3.6.1.4.1.42.3.1.2.0',
'motd' => '.1.3.6.1.4.1.42.3.1.3.0', 'motd' => '.1.3.6.1.4.1.42.3.1.3.0',
); );
%FUNCS = ( %FUNCS = ( %SNMP::Info::Layer3::FUNCS, );
%SNMP::Info::Layer3::FUNCS,
);
%MUNGE = ( %MUNGE = ( %SNMP::Info::Layer3::MUNGE, );
%SNMP::Info::Layer3::MUNGE,
);
sub vendor { sub vendor {
return 'sun'; return 'sun';
} }
sub os { sub os {
return 'sun'; return 'sun';
} }
sub os_ver { sub os_ver {
my $sun = shift; my $sun = shift;
my $descr = $sun->motd(); my $descr = $sun->motd();
return unless defined $descr; return unless defined $descr;
if ($descr =~ m/SunOS (\S+)/) { if ( $descr =~ m/SunOS (\S+)/ ) {
return $1; return $1;
} }
return; return;
} }
sub model { sub model {
return 'Solaris Router' return 'Solaris Router';
} }
sub serial { sub serial {
my $sun = shift; my $sun = shift;
my $serial = unpack("H*", $sun->sun_hostid()); my $serial = unpack( "H*", $sun->sun_hostid() );
return $serial; return $serial;
} }
sub i_ignore { sub i_ignore {
my $l3 = shift; my $l3 = shift;
my $partial = shift; my $partial = shift;
my $interfaces = $l3->interfaces($partial) || {}; my $interfaces = $l3->interfaces($partial) || {};
my %i_ignore; my %i_ignore;
foreach my $if (keys %$interfaces) { foreach my $if ( keys %$interfaces ) {
# lo0 # lo0
if ($interfaces->{$if} =~ /\blo0\b/i){ if ( $interfaces->{$if} =~ /\blo0\b/i ) {
$i_ignore{$if}++; $i_ignore{$if}++;
} }
} }

View File

@@ -36,98 +36,103 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; 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//; @SNMP::Info::MAU::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ('MAU-MIB' => 'mauMod'); %MIBS = ( 'MAU-MIB' => 'mauMod' );
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = (
# Interface MAU Table
'mau_index' => 'ifMauIfIndex', # Interface MAU Table
'mau_link' => 'ifMauType', 'mau_index' => 'ifMauIfIndex',
'mau_status' => 'ifMauStatus', 'mau_link' => 'ifMauType',
'mau_up' => 'ifMauMediaAvailable', 'mau_status' => 'ifMauStatus',
'mau_type' => 'ifMauTypeList', 'mau_up' => 'ifMauMediaAvailable',
'mau_type_admin' => 'ifMauDefaultType', 'mau_type' => 'ifMauTypeList',
# Interface Auto-Negotiation Table 'mau_type_admin' => 'ifMauDefaultType',
'mau_auto' => 'ifMauAutoNegSupported',
'mau_autostat' => 'ifMauAutoNegAdminStatus', # Interface Auto-Negotiation Table
'mau_autosent' => 'ifMauAutoNegCapAdvertised', 'mau_auto' => 'ifMauAutoNegSupported',
'mau_autorec' => 'ifMauAutoNegCapReceived', 'mau_autostat' => 'ifMauAutoNegAdminStatus',
); 'mau_autosent' => 'ifMauAutoNegCapAdvertised',
'mau_autorec' => 'ifMauAutoNegCapReceived',
);
%MUNGE = ( %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 { sub munge_int2bin {
my $int = shift; my $int = shift;
return unless defined $int; return unless defined $int;
return unpack("B32", pack("N", $int)); return unpack( "B32", pack( "N", $int ) );
} }
sub _isfullduplex{ sub _isfullduplex {
my $mau = shift; my $mau = shift;
my $mautype = shift; my $mautype = shift;
my @full_types = qw/11 13 16 18 20/; my @full_types = qw/11 13 16 18 20/;
foreach my $type ( @full_types ) { foreach my $type (@full_types) {
return 1 if (substr($mautype,32-$type,1) eq '1') return 1 if ( substr( $mautype, 32 - $type, 1 ) eq '1' );
} }
return 0; return 0;
} }
sub _ishalfduplex{ sub _ishalfduplex {
my $mau = shift; my $mau = shift;
my $mautype = shift; my $mautype = shift;
my @half_types = qw/10 12 15 17 19/; my @half_types = qw/10 12 15 17 19/;
foreach my $type ( @half_types ) { foreach my $type (@half_types) {
return 1 if (substr($mautype,32-$type,1) eq '1') return 1 if ( substr( $mautype, 32 - $type, 1 ) eq '1' );
} }
return 0; return 0;
} }
my %_mau_i_speed_map = ( my %_mau_i_speed_map = (
'10' => '10 Mbps', '10' => '10 Mbps',
'100' => '100 Mbps', '100' => '100 Mbps',
'1000' => '1.0 Gbps', '1000' => '1.0 Gbps',
'10Gig' => '10 Gbps', '10Gig' => '10 Gbps',
); );
sub mau_i_speed_admin { sub mau_i_speed_admin {
my $mau = shift; my $mau = shift;
my $mau_index = $mau->mau_index(); my $mau_index = $mau->mau_index();
my $mau_type_admin = $mau->mau_type_admin(); my $mau_type_admin = $mau->mau_type_admin();
my %i_speed_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}; my $iid = $mau_index->{$mau_port};
next unless defined $iid; next unless defined $iid;
my $type_adminoid = $mau_type_admin->{$mau_port}; 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; next unless defined $type_admin;
if ($type_adminoid eq '.0.0') { if ( $type_adminoid eq '.0.0' ) {
$i_speed_admin{$iid} = 'auto'; $i_speed_admin{$iid} = 'auto';
} elsif ($type_admin =~ /^dot3MauType(.*)Base/ && $_mau_i_speed_map{$1}) { }
$i_speed_admin{$iid} = $_mau_i_speed_map{$1}; elsif ($type_admin =~ /^dot3MauType(.*)Base/
} && $_mau_i_speed_map{$1} )
{
$i_speed_admin{$iid} = $_mau_i_speed_map{$1};
}
} }
return \%i_speed_admin; return \%i_speed_admin;
} }
@@ -136,22 +141,23 @@ sub mau_i_duplex {
my $mau = shift; my $mau = shift;
my $mau_index = $mau->mau_index(); my $mau_index = $mau->mau_index();
my $mau_link = $mau->mau_link(); my $mau_link = $mau->mau_link();
my %i_duplex; my %i_duplex;
foreach my $mau_port (keys %$mau_link){ foreach my $mau_port ( keys %$mau_link ) {
my $iid = $mau_index->{$mau_port}; my $iid = $mau_index->{$mau_port};
next unless defined $iid; next unless defined $iid;
my $linkoid = $mau_link->{$mau_port}; my $linkoid = $mau_link->{$mau_port};
my $link = &SNMP::translateObj($linkoid); my $link = &SNMP::translateObj($linkoid);
next unless defined $link; next unless defined $link;
my $duplex = undef; my $duplex = undef;
if ($link =~ /fd$/i) { if ( $link =~ /fd$/i ) {
$duplex = 'full'; $duplex = 'full';
} elsif ($link =~ /hd$/i){ }
elsif ( $link =~ /hd$/i ) {
$duplex = 'half'; $duplex = 'half';
} }
@@ -161,46 +167,55 @@ sub mau_i_duplex {
} }
sub mau_i_duplex_admin { sub mau_i_duplex_admin {
my $mau = shift; my $mau = shift;
my $partial = shift; my $partial = shift;
my $mau_index = $mau->mau_index(); my $mau_index = $mau->mau_index();
my %rev_mau_index = reverse %$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_autostat
my $mau_type_admin = defined $partial ? $mau->mau_type_admin($rev_mau_index{$partial}) : $mau->mau_type_admin(); = 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 # Older HP4000's don't implement ifMauDefaultType, but we can
# figure out from ifMauAutoNegCapAdvertised what we'd like. # figure out from ifMauAutoNegCapAdvertised what we'd like.
if (!defined($mau_type_admin)) { if ( !defined($mau_type_admin) ) {
if (defined($mau_index)) { if ( defined($mau_index) ) {
return mau_i_duplex_admin_old($mau,$mau_index,$mau_autostat); return mau_i_duplex_admin_old( $mau, $mau_index, $mau_autostat );
} else { }
else {
return; return;
} }
} }
my %i_duplex_admin; 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}; my $iid = $mau_index->{$mau_port};
next unless defined $iid; next unless defined $iid;
my $autostat = $mau_autostat->{$mau_port}; 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'; $i_duplex_admin{$iid} = 'auto';
next; next;
} }
my $type_adminoid = $mau_type_admin->{$mau_port}; 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; next unless defined $type_admin;
my $duplex = undef; my $duplex = undef;
if ($type_admin =~ /fd$/i) { if ( $type_admin =~ /fd$/i ) {
$duplex = 'full'; $duplex = 'full';
} elsif ($type_admin =~ /hd$/i){ }
elsif ( $type_admin =~ /hd$/i ) {
$duplex = 'half'; $duplex = 'half';
} elsif ($type_admin eq 'zeroDotZero') { }
elsif ( $type_admin eq 'zeroDotZero' ) {
$duplex = 'auto'; $duplex = 'auto';
} }
@@ -210,8 +225,8 @@ sub mau_i_duplex_admin {
} }
sub mau_i_duplex_admin_old { sub mau_i_duplex_admin_old {
my $mau = shift; my $mau = shift;
my $mau_index = shift; my $mau_index = shift;
my $mau_autostat = shift; my $mau_autostat = shift;
my $interfaces = $mau->interfaces(); my $interfaces = $mau->interfaces();
@@ -220,14 +235,14 @@ sub mau_i_duplex_admin_old {
my %mau_reverse = reverse %$mau_index; my %mau_reverse = reverse %$mau_index;
my %i_duplex_admin; my %i_duplex_admin;
foreach my $iid (keys %$interfaces){ foreach my $iid ( keys %$interfaces ) {
my $mau_index = $mau_reverse{$iid}; my $mau_index = $mau_reverse{$iid};
next unless defined $mau_index; next unless defined $mau_index;
my $autostat = $mau_autostat->{$mau_index}; my $autostat = $mau_autostat->{$mau_index};
# HP25xx has this value # HP25xx has this value
if (defined $autostat and $autostat =~ /enabled/i){ if ( defined $autostat and $autostat =~ /enabled/i ) {
$i_duplex_admin{$iid} = 'auto'; $i_duplex_admin{$iid} = 'auto';
next; next;
} }
@@ -236,7 +251,7 @@ sub mau_i_duplex_admin_old {
next unless defined $type; next unless defined $type;
if ($type == 0) { if ( $type == 0 ) {
$i_duplex_admin{$iid} = 'none'; $i_duplex_admin{$iid} = 'none';
next; next;
} }
@@ -244,9 +259,10 @@ sub mau_i_duplex_admin_old {
my $full = $mau->_isfullduplex($type); my $full = $mau->_isfullduplex($type);
my $half = $mau->_ishalfduplex($type); my $half = $mau->_ishalfduplex($type);
if ($full and !$half){ if ( $full and !$half ) {
$i_duplex_admin{$iid} = 'full'; $i_duplex_admin{$iid} = 'full';
} elsif ($half) { }
elsif ($half) {
$i_duplex_admin{$iid} = 'half'; $i_duplex_admin{$iid} = 'half';
} }
} }
@@ -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 The MAU table contains link and duplex info for the port itself and the device
connected to that port. connected to that port.
Normally you use or create a subclass of SNMP::Info that inherits this one. Do Normally you use or create a subclass of SNMP::Info that inherits this one.
not use directly. Do not use directly.
For debugging purposes call the class directly as you would SNMP::Info 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) =item $mau->_isfullduplex(bitstring)
Boolean. Checks to see if any of the full_duplex types from mau_type() are Boolean. Checks to see if any of the full_duplex types from mau_type()
high. Currently bits 11,13,16,18,20. are high. Currently bits 11,13,16,18,20.
=item $mau->_ishalfduplex(bitstring) =item $mau->_ishalfduplex(bitstring)
Boolean. Checks to see if any of the half_duplex types from mau_type() are Boolean. Checks to see if any of the half_duplex types from mau_type()
high. Currently bits 10,12,15,17,19. are high. Currently bits 10,12,15,17,19.
=back =back

View File

@@ -34,67 +34,74 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::NortelStack::EXPORT_OK = qw//; @SNMP::Info::NortelStack::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
# S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below
'S5-AGENT-MIB' => 's5AgMyGrpIndx', # S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below
'S5-CHASSIS-MIB' => 's5ChasType', 'S5-AGENT-MIB' => 's5AgMyGrpIndx',
'S5-REG-MIB' => 's5ChasTypeVal', 'S5-CHASSIS-MIB' => 's5ChasType',
); 'S5-REG-MIB' => 's5ChasTypeVal',
);
%GLOBALS = ( %GLOBALS = (
# From S5-AGENT-MIB
'ns_ag_ver' => 's5AgInfoVer',
'ns_op_mode' => 's5AgSysCurrentOperationalMode',
'ns_auto_pvid' => 's5AgSysAutoPvid',
'tftp_host' => 's5AgSysTftpServerAddress',
'tftp_file' => 's5AgSysBinaryConfigFilename',
'tftp_action' => 's5AgInfoFileAction',
'tftp_result' => 's5AgInfoFileStatus',
'vlan' => 's5AgSysManagementVlanId',
# From S5-CHASSIS-MIB
'ns_serial' => 's5ChasSerNum',
'ns_ch_type' => 's5ChasType',
'ns_cfg_chg' => 's5ChasGblConfChngs',
'ns_cfg_time' => 's5ChasGblConfLstChng',
);
%FUNCS = ( # From S5-AGENT-MIB
# From S5-AGENT-MIB::s5AgMyIfTable 'ns_ag_ver' => 's5AgInfoVer',
'i_cfg_file' => 's5AgMyIfCfgFname', 'ns_op_mode' => 's5AgSysCurrentOperationalMode',
'i_cfg_host' => 's5AgMyIfLdSvrAddr', 'ns_auto_pvid' => 's5AgSysAutoPvid',
# From S5-CHASSIS-MIB::s5ChasGrpTable 'tftp_host' => 's5AgSysTftpServerAddress',
'ns_grp_type' => 's5ChasGrpType', 'tftp_file' => 's5AgSysBinaryConfigFilename',
# From S5-CHASSIS-MIB::s5ChasComTable 'tftp_action' => 's5AgInfoFileAction',
'ns_com_grp_idx' => 's5ChasComGrpIndx', 'tftp_result' => 's5AgInfoFileStatus',
'ns_com_idx' => 's5ChasComIndx', 'vlan' => 's5AgSysManagementVlanId',
'ns_com_sub_idx' => 's5ChasComSubIndx',
'ns_com_type' => 's5ChasComType', # From S5-CHASSIS-MIB
'ns_com_descr' => 's5ChasComDescr', 'ns_serial' => 's5ChasSerNum',
'ns_com_ver' => 's5ChasComVer', 'ns_ch_type' => 's5ChasType',
'ns_com_serial' => 's5ChasComSerNum', 'ns_cfg_chg' => 's5ChasGblConfChngs',
# From S5-CHASSIS-MIB::s5ChasStoreTable 'ns_cfg_time' => 's5ChasGblConfLstChng',
'ns_store_grp_idx' => 's5ChasStoreGrpIndx', );
'ns_store_com_idx' => 's5ChasStoreComIndx',
'ns_store_sub_idx' => 's5ChasStoreSubIndx', %FUNCS = (
'ns_store_idx' => 's5ChasStoreIndx',
'ns_store_type' => 's5ChasStoreType', # From S5-AGENT-MIB::s5AgMyIfTable
'ns_store_size' => 's5ChasStoreCurSize', 'i_cfg_file' => 's5AgMyIfCfgFname',
'ns_store_ver' => 's5ChasStoreCntntVer', 'i_cfg_host' => 's5AgMyIfLdSvrAddr',
);
# From S5-CHASSIS-MIB::s5ChasGrpTable
'ns_grp_type' => 's5ChasGrpType',
# From S5-CHASSIS-MIB::s5ChasComTable
'ns_com_grp_idx' => 's5ChasComGrpIndx',
'ns_com_idx' => 's5ChasComIndx',
'ns_com_sub_idx' => 's5ChasComSubIndx',
'ns_com_type' => 's5ChasComType',
'ns_com_descr' => 's5ChasComDescr',
'ns_com_ver' => 's5ChasComVer',
'ns_com_serial' => 's5ChasComSerNum',
# From S5-CHASSIS-MIB::s5ChasStoreTable
'ns_store_grp_idx' => 's5ChasStoreGrpIndx',
'ns_store_com_idx' => 's5ChasStoreComIndx',
'ns_store_sub_idx' => 's5ChasStoreSubIndx',
'ns_store_idx' => 's5ChasStoreIndx',
'ns_store_type' => 's5ChasStoreType',
'ns_store_size' => 's5ChasStoreCurSize',
'ns_store_ver' => 's5ChasStoreCntntVer',
);
%MUNGE = ( %MUNGE = (
'ns_ch_type' => \&SNMP::Info::munge_e_type, 'ns_ch_type' => \&SNMP::Info::munge_e_type,
'ns_grp_type' => \&munge_ns_grp_type, 'ns_grp_type' => \&munge_ns_grp_type,
'ns_com_type' => \&SNMP::Info::munge_e_type, 'ns_com_type' => \&SNMP::Info::munge_e_type,
'ns_store_type' => \&SNMP::Info::munge_e_type, 'ns_store_type' => \&SNMP::Info::munge_e_type,
); );
sub os_ver { sub os_ver {
my $stack = shift; my $stack = shift;
@@ -102,13 +109,13 @@ sub os_ver {
my $ver = $stack->ns_ag_ver(); my $ver = $stack->ns_ag_ver();
return unless defined $ver; return unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){ if ( $ver =~ m/(\d+\.\d+\.\d+\.\d+)/ ) {
return $1; return $1;
} }
if ($ver =~ m/V(\d+\.\d+\.\d+)/i){ if ( $ver =~ m/V(\d+\.\d+\.\d+)/i ) {
return $1; return $1;
} }
return; return;
} }
sub os_bin { sub os_bin {
@@ -117,13 +124,13 @@ sub os_bin {
my $ver = $stack->ns_ag_ver(); my $ver = $stack->ns_ag_ver();
return unless defined $ver; return unless defined $ver;
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/i){ if ( $ver =~ m/(\d+\.\d+\.\d+\.\d+)/i ) {
return $1; return $1;
} }
if ($ver =~ m/V(\d+\.\d+.\d+)/i){ if ( $ver =~ m/V(\d+\.\d+.\d+)/i ) {
return $1; return $1;
} }
return; return;
} }
# Need to override here since overridden in Layer2 and Layer3 classes # Need to override here since overridden in Layer2 and Layer3 classes
@@ -141,24 +148,24 @@ sub serial {
# This class supports both stackable and chassis based switches, identify if # This class supports both stackable and chassis based switches, identify if
# we have a stackable so that we return appropriate entPhysicalClass # we have a stackable so that we return appropriate entPhysicalClass
sub _ns_e_is_virtual { sub _ns_e_is_virtual {
my $stack = shift; my $stack = shift;
# We really only need one value, but we want this cached since most methods # We really only need one value, but we want this cached since most
# call it at least via ns_e_index() # methods call it at least via ns_e_index()
my $v_test = $stack->s5ChasComRelPos() || {}; my $v_test = $stack->s5ChasComRelPos() || {};
return $v_test->{'8.1.0'}; return $v_test->{'8.1.0'};
} }
# Identify is the stackable is actually a stack vs. single switch # Identify is the stackable is actually a stack vs. single switch
sub _ns_e_is_stack { sub _ns_e_is_stack {
my $stack = shift; my $stack = shift;
my $s_test = $stack->ns_e_class() || {}; my $s_test = $stack->ns_e_class() || {};
foreach my $iid (keys %$s_test){ foreach my $iid ( keys %$s_test ) {
my $class = $s_test->{$iid}; my $class = $s_test->{$iid};
next unless defined $class; next unless defined $class;
return 1 if ($class eq 'stack'); return 1 if ( $class eq 'stack' );
} }
return 0; return 0;
} }
@@ -171,20 +178,22 @@ sub ns_e_index {
my $is_virtual = $stack->_ns_e_is_virtual(); my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_index; my %ns_e_index;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
# Skip backplane, power, sensor, fan, clock - these aren't in the # Skip backplane, power, sensor, fan, clock - these aren't in the
# newer devices ENTITY-MIB we're emulating # newer devices ENTITY-MIB we're emulating
next if ($iid =~ /^[24567]/); next if ( $iid =~ /^[24567]/ );
next if (($is_virtual) and ($iid =~ /^8/ or $iid eq '1.0.0')); next if ( ($is_virtual) and ( $iid =~ /^8/ or $iid eq '1.0.0' ) );
# Format into consistent integer format so that numeric sorting works # Format into consistent integer format so that numeric sorting works
my $index = join('',map { sprintf "%02d",$_ } split /\./, $iid); my $index = join( '', map { sprintf "%02d", $_ } split /\./, $iid );
$ns_e_index{$iid} = $index; $ns_e_index{$iid} = $index;
} }
return \%ns_e_index; return \%ns_e_index;
} }
sub ns_e_class { sub ns_e_class {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
@@ -193,18 +202,18 @@ sub ns_e_class {
my $is_virtual = $stack->_ns_e_is_virtual(); my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_class; my %ns_e_class;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my ($grp, $idx, $sub) = split (/\./,$iid); my ( $grp, $idx, $sub ) = split( /\./, $iid );
next unless defined $grp; next unless defined $grp;
my $class = $classes->{$grp}; my $class = $classes->{$grp};
next unless defined $class; next unless defined $class;
my $enc = $ns_grp_enc->{$grp}; my $enc = $ns_grp_enc->{$grp};
# Handle quirks of dealing with both stacks and chassis # Handle quirks of dealing with both stacks and chassis
if ((!$is_virtual) and ($grp == 1)) { if ( ( !$is_virtual ) and ( $grp == 1 ) ) {
$class = 'module'; $class = 'module';
} }
if (($is_virtual) and ($grp == 3) and !($idx % $enc)) { if ( ($is_virtual) and ( $grp == 3 ) and !( $idx % $enc ) ) {
$class = 'chassis'; $class = 'chassis';
} }
@@ -217,11 +226,11 @@ sub ns_e_descr {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_descr = $stack->ns_com_descr($partial) || {}; my $ns_e_descr = $stack->ns_com_descr($partial) || {};
my %ns_e_descr; my %ns_e_descr;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my $descr = $ns_e_descr->{$iid}; my $descr = $ns_e_descr->{$iid};
next unless defined $descr; next unless defined $descr;
@@ -231,29 +240,29 @@ sub ns_e_descr {
} }
sub ns_e_name { sub ns_e_name {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_class = $stack->ns_e_class() || {}; my $ns_class = $stack->ns_e_class() || {};
my $ns_e_idx = $stack->ns_e_index() || {}; my $ns_e_idx = $stack->ns_e_index() || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virtual = $stack->_ns_e_is_virtual(); my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_name; my %ns_e_name;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my ($grp, $idx, $sub) = split (/\./,$iid); my ( $grp, $idx, $sub ) = split( /\./, $iid );
my $class = $ns_class->{$iid}; my $class = $ns_class->{$iid};
next unless defined $class; next unless defined $class;
my $enc = $ns_grp_enc->{$grp}; my $enc = $ns_grp_enc->{$grp};
if ((!$is_virtual) and ($grp == 1)) { if ( ( !$is_virtual ) and ( $grp == 1 ) ) {
$ns_e_name{$iid} = 'Supervisory Module'; $ns_e_name{$iid} = 'Supervisory Module';
} }
elsif ($class eq 'stack') { elsif ( $class eq 'stack' ) {
$ns_e_name{$iid} = 'Stack Master Unit'; $ns_e_name{$iid} = 'Stack Master Unit';
} }
elsif ($class eq 'chassis') { elsif ( $class eq 'chassis' ) {
if ($is_virtual) { if ($is_virtual) {
my $unit = $idx / $enc; my $unit = $idx / $enc;
$ns_e_name{$iid} = "Switch Unit $unit"; $ns_e_name{$iid} = "Switch Unit $unit";
@@ -262,13 +271,13 @@ sub ns_e_name {
$ns_e_name{$iid} = "Chassis"; $ns_e_name{$iid} = "Chassis";
} }
} }
elsif ($class eq 'module') { elsif ( $class eq 'module' ) {
if ($is_virtual) { if ($is_virtual) {
my $unit = int ($idx / $enc); my $unit = int( $idx / $enc );
my $mda = $idx % $enc; my $mda = $idx % $enc;
$ns_e_name{$iid} = "Switch Unit $unit, MDA $mda"; $ns_e_name{$iid} = "Switch Unit $unit, MDA $mda";
} }
elsif ($sub != 0) { elsif ( $sub != 0 ) {
$ns_e_name{$iid} = "Module Slot $idx, Subcomponent $sub"; $ns_e_name{$iid} = "Module Slot $idx, Subcomponent $sub";
} }
else { else {
@@ -287,7 +296,7 @@ sub ns_e_hwver {
my $ns_e_ver = $stack->ns_com_ver($partial) || {}; my $ns_e_ver = $stack->ns_com_ver($partial) || {};
my %ns_e_hwver; my %ns_e_hwver;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my $ver = $ns_e_ver->{$iid}; my $ver = $ns_e_ver->{$iid};
next unless defined $ver; next unless defined $ver;
@@ -303,7 +312,7 @@ sub ns_e_vendor {
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my %ns_e_vendor; my %ns_e_vendor;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my $vendor = 'nortel'; my $vendor = 'nortel';
$ns_e_vendor{$iid} = $vendor; $ns_e_vendor{$iid} = $vendor;
@@ -315,11 +324,11 @@ sub ns_e_serial {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_serial = $stack->ns_com_serial($partial) || {}; my $ns_e_serial = $stack->ns_com_serial($partial) || {};
my %ns_e_serial; my %ns_e_serial;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my $serial = $ns_e_serial->{$iid}; my $serial = $ns_e_serial->{$iid};
next unless defined $serial; next unless defined $serial;
@@ -332,17 +341,17 @@ sub ns_e_type {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_type = $stack->ns_com_type($partial) || {}; my $ns_e_type = $stack->ns_com_type($partial) || {};
my $is_stack = $stack->_ns_e_is_stack(); my $is_stack = $stack->_ns_e_is_stack();
my $ch_type = $stack->ns_ch_type(); my $ch_type = $stack->ns_ch_type();
my %ns_e_type; my %ns_e_type;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my $type = $ns_e_type->{$iid}; my $type = $ns_e_type->{$iid};
next unless defined $type; next unless defined $type;
if ($is_stack and $iid =~ /^1/) { if ( $is_stack and $iid =~ /^1/ ) {
$type = $ch_type; $type = $ch_type;
} }
$ns_e_type{$iid} = $type; $ns_e_type{$iid} = $type;
@@ -354,18 +363,18 @@ sub ns_e_pos {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_stack = $stack->_ns_e_is_stack(); my $is_stack = $stack->_ns_e_is_stack();
my $is_virtual = $stack->_ns_e_is_virtual(); my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_pos; my %ns_e_pos;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my ($grp, $pos, $idx) = split (/\./,$iid); my ( $grp, $pos, $idx ) = split( /\./, $iid );
next unless defined $grp; next unless defined $grp;
next unless defined $pos; next unless defined $pos;
if ($grp == 1) { if ( $grp == 1 ) {
if ($is_stack) { if ($is_stack) {
$pos = -1; $pos = -1;
} }
@@ -373,22 +382,22 @@ sub ns_e_pos {
$pos = 99; $pos = 99;
} }
} }
elsif ($grp == 3 and $idx == 0 ) { elsif ( $grp == 3 and $idx == 0 ) {
my $enc = $ns_grp_enc->{$grp}; my $enc = $ns_grp_enc->{$grp};
if ($is_virtual and ($pos % $enc)) { if ( $is_virtual and ( $pos % $enc ) ) {
$pos = int ($pos % $enc); $pos = int( $pos % $enc );
} }
elsif ($is_virtual and !$is_stack and !($pos % $enc)) { elsif ( $is_virtual and !$is_stack and !( $pos % $enc ) ) {
$pos = -1; $pos = -1;
} }
elsif ($is_virtual and !($pos % $enc)) { elsif ( $is_virtual and !( $pos % $enc ) ) {
$pos = ($pos / $enc); $pos = ( $pos / $enc );
} }
} }
elsif (!$is_stack and $grp == 3) { elsif ( !$is_stack and $grp == 3 ) {
$pos = $idx; $pos = $idx;
} }
elsif ($grp == 8) { elsif ( $grp == 8 ) {
$pos = -1; $pos = -1;
} }
$ns_e_pos{$iid} = $pos; $ns_e_pos{$iid} = $pos;
@@ -400,23 +409,23 @@ sub ns_e_fwver {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_ver = $stack->ns_store_ver($partial) || {}; my $ns_e_ver = $stack->ns_store_ver($partial) || {};
my $ns_e_type = $stack->ns_store_type($partial) || {}; my $ns_e_type = $stack->ns_store_type($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virt = $stack->_ns_e_is_virtual(); my $is_virt = $stack->_ns_e_is_virtual();
my %ns_e_fwver; my %ns_e_fwver;
foreach my $iid (keys %$ns_e_type){ foreach my $iid ( keys %$ns_e_type ) {
my $type = $ns_e_type->{$iid}; my $type = $ns_e_type->{$iid};
next unless defined $type; next unless defined $type;
next unless $type =~ /(rom|boot|fw)/i; next unless $type =~ /(rom|boot|fw)/i;
my $ver = $ns_e_ver->{$iid}; my $ver = $ns_e_ver->{$iid};
next unless defined $ver; next unless defined $ver;
$iid =~ s/\.\d+$//; $iid =~ s/\.\d+$//;
if ($is_virt) { if ($is_virt) {
my ($grp, $idx, $pos) = split (/\./,$iid); my ( $grp, $idx, $pos ) = split( /\./, $iid );
my $enc = $ns_grp_enc->{$grp}; my $enc = $ns_grp_enc->{$grp};
$idx = $idx * $enc; $idx = $idx * $enc;
$iid = "3.$idx.$pos"; $iid = "3.$idx.$pos";
@@ -430,23 +439,23 @@ sub ns_e_swver {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_e_ver = $stack->ns_store_ver($partial) || {}; my $ns_e_ver = $stack->ns_store_ver($partial) || {};
my $ns_e_type = $stack->ns_store_type($partial) || {}; my $ns_e_type = $stack->ns_store_type($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_virt = $stack->_ns_e_is_virtual(); my $is_virt = $stack->_ns_e_is_virtual();
my %ns_e_swver; my %ns_e_swver;
foreach my $iid (keys %$ns_e_type){ foreach my $iid ( keys %$ns_e_type ) {
my $type = $ns_e_type->{$iid}; my $type = $ns_e_type->{$iid};
next unless defined $type; next unless defined $type;
next unless $type =~ /(flash)/i; next unless $type =~ /(flash)/i;
my $ver = $ns_e_ver->{$iid}; my $ver = $ns_e_ver->{$iid};
next unless defined $ver; next unless defined $ver;
$iid =~ s/\.\d+$//; $iid =~ s/\.\d+$//;
if ($is_virt) { if ($is_virt) {
my ($grp, $idx, $pos) = split (/\./,$iid); my ( $grp, $idx, $pos ) = split( /\./, $iid );
my $enc = $ns_grp_enc->{$grp}; my $enc = $ns_grp_enc->{$grp};
$idx = $idx * $enc; $idx = $idx * $enc;
$iid = "3.$idx.$pos"; $iid = "3.$idx.$pos";
@@ -460,20 +469,20 @@ sub ns_e_parent {
my $stack = shift; my $stack = shift;
my $partial = shift; my $partial = shift;
my $ns_e_idx = $stack->ns_e_index($partial) || {}; my $ns_e_idx = $stack->ns_e_index($partial) || {};
my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {}; my $ns_grp_enc = $stack->s5ChasGrpEncodeFactor($partial) || {};
my $is_stack = $stack->_ns_e_is_stack(); my $is_stack = $stack->_ns_e_is_stack();
my $is_virtual = $stack->_ns_e_is_virtual(); my $is_virtual = $stack->_ns_e_is_virtual();
my %ns_e_parent; my %ns_e_parent;
foreach my $iid (keys %$ns_e_idx){ foreach my $iid ( keys %$ns_e_idx ) {
my $index = $ns_e_idx->{$iid}; my $index = $ns_e_idx->{$iid};
my ($grp, $idx, $pos) = split (/\./,$iid); my ( $grp, $idx, $pos ) = split( /\./, $iid );
next unless defined $grp; next unless defined $grp;
if ($grp == 8) { if ( $grp == 8 ) {
$ns_e_parent{$iid} = '0'; $ns_e_parent{$iid} = '0';
} }
if ($grp == 1) { if ( $grp == 1 ) {
if ($is_stack) { if ($is_stack) {
$ns_e_parent{$iid} = '0'; $ns_e_parent{$iid} = '0';
} }
@@ -481,27 +490,28 @@ sub ns_e_parent {
$ns_e_parent{$iid} = '080100'; $ns_e_parent{$iid} = '080100';
} }
} }
if ($grp == 3) { if ( $grp == 3 ) {
my $enc = $ns_grp_enc->{$grp}; my $enc = $ns_grp_enc->{$grp};
if ($idx % $enc) { if ( $idx % $enc ) {
my $npos = ($idx % $enc) * $enc; my $npos = ( $idx % $enc ) * $enc;
my @parent = ($grp, $npos, $pos); my @parent = ( $grp, $npos, $pos );
my $parent = join('',map { sprintf "%02d",$_ } @parent); my $parent = join( '', map { sprintf "%02d", $_ } @parent );
$ns_e_parent{$iid} = $parent; $ns_e_parent{$iid} = $parent;
} }
elsif ($is_stack) { elsif ($is_stack) {
$ns_e_parent{$iid} = '010100'; $ns_e_parent{$iid} = '010100';
} }
elsif ($is_virtual and !$is_stack) { elsif ( $is_virtual and !$is_stack ) {
$ns_e_parent{$iid} = 0; $ns_e_parent{$iid} = 0;
} }
elsif ($pos == 0) { elsif ( $pos == 0 ) {
$ns_e_parent{$iid} = '080100'; $ns_e_parent{$iid} = '080100';
} }
else { else {
my $parent = $iid; my $parent = $iid;
$parent =~ s/\.\d+$/\.00/; $parent =~ s/\.\d+$/\.00/;
$parent = join('',map { sprintf "%02d",$_ } split /\./, $parent); $parent = join( '', map { sprintf "%02d", $_ } split /\./,
$parent );
$ns_e_parent{$iid} = $parent; $ns_e_parent{$iid} = $parent;
} }
} }
@@ -514,19 +524,19 @@ sub munge_ns_grp_type {
my $oid = shift; my $oid = shift;
my %e_class = ( my %e_class = (
Sup => 'stack', Sup => 'stack',
Bkpl => 'backplane', Bkpl => 'backplane',
Brd => 'module', Brd => 'module',
Pwr => 'powerSupply', Pwr => 'powerSupply',
TmpSnr => 'sensor', TmpSnr => 'sensor',
Fan => 'fan', Fan => 'fan',
Clk => 'other', Clk => 'other',
Unit => 'chassis', Unit => 'chassis',
); );
my $name = &SNMP::translateObj($oid); my $name = &SNMP::translateObj($oid);
$name =~ s/s5ChasGrp//; $name =~ s/s5ChasGrp//;
if ((defined($name)) and (exists($e_class{$name}))) { if ( ( defined($name) ) and ( exists( $e_class{$name} ) ) ) {
$name = $e_class{$name}; $name = $e_class{$name};
} }
return $name if defined($name); return $name if defined($name);
@@ -712,8 +722,8 @@ server
=item $stack->ns_com_grp_idx() =item $stack->ns_com_grp_idx()
Returns reference to hash. Key: Table entry, Value: Index of the chassis level Returns reference to hash. Key: Table entry, Value: Index of the chassis
group which contains this component. level group which contains this component.
(C<s5ChasComGrpIndx>) (C<s5ChasComGrpIndx>)

View File

@@ -34,32 +34,32 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::PowerEthernet::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::PowerEthernet::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::PowerEthernet::EXPORT_OK = qw//; @SNMP::Info::PowerEthernet::EXPORT_OK = qw//;
use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/; use vars qw/$VERSION %MIBS %FUNCS %GLOBALS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ('POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus'); %MIBS = ( 'POWER-ETHERNET-MIB' => 'pethPsePortDetectionStatus' );
%GLOBALS = ( %GLOBALS = ();
);
%FUNCS = ( %FUNCS = (
# parts of pethPsePortTable
'peth_port_admin' => 'pethPsePortAdminEnable',
'peth_port_status' => 'pethPsePortDetectionStatus',
'peth_port_class' => 'pethPsePortPowerClassifications',
# pethMainPseTable
'peth_power_watts' => 'pethMainPsePower',
'peth_power_status' => 'pethMainPseOperStatus',
'peth_power_consumption' => 'pethMainPseConsumptionPower',
'peth_power_threshold' => 'pethMainPseUsageThreshold',
);
%MUNGE = ( # parts of pethPsePortTable
); 'peth_port_admin' => 'pethPsePortAdminEnable',
'peth_port_status' => 'pethPsePortDetectionStatus',
'peth_port_class' => 'pethPsePortPowerClassifications',
# pethMainPseTable
'peth_power_watts' => 'pethMainPsePower',
'peth_power_status' => 'pethMainPseOperStatus',
'peth_power_consumption' => 'pethMainPseConsumptionPower',
'peth_power_threshold' => 'pethMainPseUsageThreshold',
);
%MUNGE = ();
# POWER-ETHERNET-MIB doesn't define a mapping of its # POWER-ETHERNET-MIB doesn't define a mapping of its
# "module"/"port" index to ifIndex. Different vendors # "module"/"port" index to ifIndex. Different vendors
@@ -69,21 +69,22 @@ $VERSION = '1.09';
# If there is a module != 1, this heuristic doesn't work # If there is a module != 1, this heuristic doesn't work
# so returns undef. # so returns undef.
sub peth_port_ifindex { sub peth_port_ifindex {
my $peth = shift; my $peth = shift;
my $partial = shift; my $partial = shift;
my $peth_port_status = $peth->peth_port_status($partial); my $peth_port_status = $peth->peth_port_status($partial);
my $peth_port_ifindex; my $peth_port_ifindex;
foreach my $i (keys %$peth_port_status) { foreach my $i ( keys %$peth_port_status ) {
my ($module, $port) = split(/\./, $i); my ( $module, $port ) = split( /\./, $i );
if ($module != 1) { if ( $module != 1 ) {
# This heuristic won't work, so say that we got nothing.
# If you have this case, you have to write a device-specific # This heuristic won't work, so say that we got nothing.
# version of this function. # If you have this case, you have to write a device-specific
return; # version of this function.
} return;
$peth_port_ifindex->{$i} = $port; }
$peth_port_ifindex->{$i} = $port;
} }
return $peth_port_ifindex; return $peth_port_ifindex;
} }
@@ -122,7 +123,8 @@ F<POWER-ETHERNET-MIB> is used to describe PoE (IEEE 802.3af)
Create or use a device subclass that inherit this class. Do not use directly. Create or use a device subclass that inherit this class. Do not use directly.
For debugging purposes you can call this class directly as you would SNMP::Info For debugging purposes you can call this class directly as you would
SNMP::Info
my $poe = new SNMP::Info::PowerEthernet (...); my $poe = new SNMP::Info::PowerEthernet (...);

View File

@@ -34,120 +34,129 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::RapidCity::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::RapidCity::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::RapidCity::EXPORT_OK = qw//; @SNMP::Info::RapidCity::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = ( 'RAPID-CITY' => 'rapidCity', );
'RAPID-CITY' => 'rapidCity',
);
%GLOBALS = ( %GLOBALS = (
'rc_serial' => 'rcChasSerialNumber', 'rc_serial' => 'rcChasSerialNumber',
'chassis' => 'rcChasType', 'chassis' => 'rcChasType',
'slots' => 'rcChasNumSlots', 'slots' => 'rcChasNumSlots',
'tftp_host' => 'rcTftpHost', 'tftp_host' => 'rcTftpHost',
'tftp_file' => 'rcTftpFile', 'tftp_file' => 'rcTftpFile',
'tftp_action' => 'rcTftpAction', 'tftp_action' => 'rcTftpAction',
'tftp_result' => 'rcTftpResult', 'tftp_result' => 'rcTftpResult',
'rc_ch_rev' => 'rcChasHardwareRevision', 'rc_ch_rev' => 'rcChasHardwareRevision',
'rc_base_mac' => 'rc2kChassisBaseMacAddr', 'rc_base_mac' => 'rc2kChassisBaseMacAddr',
'rc_virt_ip' => 'rcSysVirtualIpAddr', 'rc_virt_ip' => 'rcSysVirtualIpAddr',
'rc_virt_mask' => 'rcSysVirtualNetMask', 'rc_virt_mask' => 'rcSysVirtualNetMask',
); );
%FUNCS = ( %FUNCS = (
# From RAPID-CITY::rcPortTable
'rc_index' => 'rcPortIndex', # From RAPID-CITY::rcPortTable
'rc_duplex' => 'rcPortOperDuplex', 'rc_index' => 'rcPortIndex',
'rc_duplex_admin' => 'rcPortAdminDuplex', 'rc_duplex' => 'rcPortOperDuplex',
'rc_speed_admin' => 'rcPortAdminSpeed', 'rc_duplex_admin' => 'rcPortAdminDuplex',
'rc_auto' => 'rcPortAutoNegotiate', 'rc_speed_admin' => 'rcPortAdminSpeed',
'rc_alias' => 'rcPortName', 'rc_auto' => 'rcPortAutoNegotiate',
# From RAPID-CITY::rc2kCpuEthernetPortTable 'rc_alias' => 'rcPortName',
'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex',
'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus', # From RAPID-CITY::rc2kCpuEthernetPortTable
'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus', 'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex',
'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr', 'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus',
'rc_cpu_mask' => 'rc2kCpuEthernetPortMask', 'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus',
'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate', 'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr',
'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex', 'rc_cpu_mask' => 'rc2kCpuEthernetPortMask',
'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex', 'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate',
'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed', 'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex',
'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed', 'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex',
'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr', 'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed',
# From RAPID-CITY::rcVlanPortTable 'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed',
'rc_i_vlan_if' => 'rcVlanPortIndex', 'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr',
'rc_i_vlan_num' => 'rcVlanPortNumVlanIds',
'rc_i_vlan' => 'rcVlanPortVlanIds', # From RAPID-CITY::rcVlanPortTable
'rc_i_vlan_type' => 'rcVlanPortType', 'rc_i_vlan_if' => 'rcVlanPortIndex',
'rc_i_vlan_pvid' => 'rcVlanPortDefaultVlanId', 'rc_i_vlan_num' => 'rcVlanPortNumVlanIds',
'rc_i_vlan_tag' => 'rcVlanPortPerformTagging', 'rc_i_vlan' => 'rcVlanPortVlanIds',
# From RAPID-CITY::rcVlanTable 'rc_i_vlan_type' => 'rcVlanPortType',
'rc_vlan_id' => 'rcVlanId', 'rc_i_vlan_pvid' => 'rcVlanPortDefaultVlanId',
'v_name' => 'rcVlanName', 'rc_i_vlan_tag' => 'rcVlanPortPerformTagging',
'rc_vlan_color' => 'rcVlanColor',
'rc_vlan_if' => 'rcVlanIfIndex', # From RAPID-CITY::rcVlanTable
'rc_vlan_stg' => 'rcVlanStgId', 'rc_vlan_id' => 'rcVlanId',
'rc_vlan_type' => 'rcVlanType', 'v_name' => 'rcVlanName',
'rc_vlan_members' => 'rcVlanPortMembers', 'rc_vlan_color' => 'rcVlanColor',
'rc_vlan_no_join' => 'rcVlanNotAllowToJoin', 'rc_vlan_if' => 'rcVlanIfIndex',
'rc_vlan_mac' => 'rcVlanMacAddress', 'rc_vlan_stg' => 'rcVlanStgId',
'rc_vlan_rstatus' => 'rcVlanRowStatus', 'rc_vlan_type' => 'rcVlanType',
# From RAPID-CITY::rcIpAddrTable 'rc_vlan_members' => 'rcVlanPortMembers',
'rc_ip_index' => 'rcIpAdEntIfIndex', 'rc_vlan_no_join' => 'rcVlanNotAllowToJoin',
'rc_ip_addr' => 'rcIpAdEntAddr', 'rc_vlan_mac' => 'rcVlanMacAddress',
'rc_ip_type' => 'rcIpAdEntIfType', 'rc_vlan_rstatus' => 'rcVlanRowStatus',
# From RAPID-CITY::rcChasFanTable
'rc_fan_op' => 'rcChasFanOperStatus', # From RAPID-CITY::rcIpAddrTable
# From RAPID-CITY::rcChasPowerSupplyTable 'rc_ip_index' => 'rcIpAdEntIfIndex',
'rc_ps_op' => 'rcChasPowerSupplyOperStatus', 'rc_ip_addr' => 'rcIpAdEntAddr',
# From RAPID-CITY::rcChasPowerSupplyDetailTable 'rc_ip_type' => 'rcIpAdEntIfType',
'rc_ps_type' => 'rcChasPowerSupplyDetailType',
'rc_ps_serial' => 'rcChasPowerSupplyDetailSerialNumber', # From RAPID-CITY::rcChasFanTable
'rc_ps_rev' => 'rcChasPowerSupplyDetailHardwareRevision', 'rc_fan_op' => 'rcChasFanOperStatus',
'rc_ps_part' => 'rcChasPowerSupplyDetailPartNumber',
'rc_ps_detail' => 'rcChasPowerSupplyDetailDescription', # From RAPID-CITY::rcChasPowerSupplyTable
# From RAPID-CITY::rcCardTable 'rc_ps_op' => 'rcChasPowerSupplyOperStatus',
'rc_c_type' => 'rcCardType',
'rc_c_serial' => 'rcCardSerialNumber', # From RAPID-CITY::rcChasPowerSupplyDetailTable
'rc_c_rev' => 'rcCardHardwareRevision', 'rc_ps_type' => 'rcChasPowerSupplyDetailType',
'rc_c_part' => 'rcCardPartNumber', 'rc_ps_serial' => 'rcChasPowerSupplyDetailSerialNumber',
# From RAPID-CITY::rc2kCardTable 'rc_ps_rev' => 'rcChasPowerSupplyDetailHardwareRevision',
'rc2k_c_ftype' => 'rc2kCardFrontType', 'rc_ps_part' => 'rcChasPowerSupplyDetailPartNumber',
'rc2k_c_fdesc' => 'rc2kCardFrontDescription', 'rc_ps_detail' => 'rcChasPowerSupplyDetailDescription',
'rc2k_c_fserial' => 'rc2kCardFrontSerialNum',
'rc2k_c_frev' => 'rc2kCardFrontHwVersion', # From RAPID-CITY::rcCardTable
'rc2k_c_fpart' => 'rc2kCardFrontPartNumber', 'rc_c_type' => 'rcCardType',
'rc2k_c_fdate' => 'rc2kCardFrontDateCode', 'rc_c_serial' => 'rcCardSerialNumber',
'rc2k_c_fdev' => 'rc2kCardFrontDeviations', 'rc_c_rev' => 'rcCardHardwareRevision',
'rc2k_c_btype' => 'rc2kCardBackType', 'rc_c_part' => 'rcCardPartNumber',
'rc2k_c_bdesc' => 'rc2kCardBackDescription',
'rc2k_c_bserial' => 'rc2kCardBackSerialNum', # From RAPID-CITY::rc2kCardTable
'rc2k_c_brev' => 'rc2kCardBackHwVersion', 'rc2k_c_ftype' => 'rc2kCardFrontType',
'rc2k_c_bpart' => 'rc2kCardBackPartNumber', 'rc2k_c_fdesc' => 'rc2kCardFrontDescription',
'rc2k_c_bdate' => 'rc2kCardBackDateCode', 'rc2k_c_fserial' => 'rc2kCardFrontSerialNum',
'rc2k_c_bdev' => 'rc2kCardBackDeviations', 'rc2k_c_frev' => 'rc2kCardFrontHwVersion',
# From RAPID-CITY::rc2kMdaCardTable 'rc2k_c_fpart' => 'rc2kCardFrontPartNumber',
'rc2k_mda_type' => 'rc2kMdaCardType', 'rc2k_c_fdate' => 'rc2kCardFrontDateCode',
'rc2k_mda_desc' => 'rc2kMdaCardDescription', 'rc2k_c_fdev' => 'rc2kCardFrontDeviations',
'rc2k_mda_serial' => 'rc2kMdaCardSerialNum', 'rc2k_c_btype' => 'rc2kCardBackType',
'rc2k_mda_rev' => 'rc2kMdaCardHwVersion', 'rc2k_c_bdesc' => 'rc2kCardBackDescription',
'rc2k_mda_part' => 'rc2kMdaCardPartNumber', 'rc2k_c_bserial' => 'rc2kCardBackSerialNum',
'rc2k_mda_date' => 'rc2kMdaCardDateCode', 'rc2k_c_brev' => 'rc2kCardBackHwVersion',
'rc2k_mda_dev' => 'rc2kMdaCardDeviations', 'rc2k_c_bpart' => 'rc2kCardBackPartNumber',
); 'rc2k_c_bdate' => 'rc2kCardBackDateCode',
'rc2k_c_bdev' => 'rc2kCardBackDeviations',
# From RAPID-CITY::rc2kMdaCardTable
'rc2k_mda_type' => 'rc2kMdaCardType',
'rc2k_mda_desc' => 'rc2kMdaCardDescription',
'rc2k_mda_serial' => 'rc2kMdaCardSerialNum',
'rc2k_mda_rev' => 'rc2kMdaCardHwVersion',
'rc2k_mda_part' => 'rc2kMdaCardPartNumber',
'rc2k_mda_date' => 'rc2kMdaCardDateCode',
'rc2k_mda_dev' => 'rc2kMdaCardDeviations',
);
%MUNGE = ( %MUNGE = (
'rc_base_mac' => \&SNMP::Info::munge_mac, 'rc_base_mac' => \&SNMP::Info::munge_mac,
'rc_vlan_mac' => \&SNMP::Info::munge_mac, 'rc_vlan_mac' => \&SNMP::Info::munge_mac,
'rc_cpu_mac' => \&SNMP::Info::munge_mac, 'rc_cpu_mac' => \&SNMP::Info::munge_mac,
'rc_vlan_members' => \&SNMP::Info::munge_port_list, 'rc_vlan_members' => \&SNMP::Info::munge_port_list,
'rc_vlan_no_join' => \&SNMP::Info::munge_port_list, 'rc_vlan_no_join' => \&SNMP::Info::munge_port_list,
); );
# Need to override here since overridden in Layer2 and Layer3 classes # Need to override here since overridden in Layer2 and Layer3 classes
sub serial { sub serial {
@@ -161,27 +170,27 @@ sub serial {
sub i_duplex { sub i_duplex {
my $rapidcity = shift; my $rapidcity = shift;
my $partial = shift; my $partial = shift;
my $rc_duplex = $rapidcity->rc_duplex($partial) || {}; my $rc_duplex = $rapidcity->rc_duplex($partial) || {};
my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex($partial) || {}; my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex($partial) || {};
my %i_duplex; my %i_duplex;
foreach my $if (keys %$rc_duplex){ foreach my $if ( keys %$rc_duplex ) {
my $duplex = $rc_duplex->{$if}; my $duplex = $rc_duplex->{$if};
next unless defined $duplex; next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i; $duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i; $duplex = 'full' if $duplex =~ /full/i;
$i_duplex{$if}=$duplex; $i_duplex{$if} = $duplex;
} }
# Get CPU Ethernet Interfaces for 8600 Series # Get CPU Ethernet Interfaces for 8600 Series
foreach my $iid (keys %$rc_cpu_duplex){ foreach my $iid ( keys %$rc_cpu_duplex ) {
my $c_duplex = $rc_cpu_duplex->{$iid}; my $c_duplex = $rc_cpu_duplex->{$iid};
next unless defined $c_duplex; next unless defined $c_duplex;
$i_duplex{$iid} = $c_duplex; $i_duplex{$iid} = $c_duplex;
} }
return \%i_duplex; return \%i_duplex;
@@ -189,39 +198,39 @@ sub i_duplex {
sub i_duplex_admin { sub i_duplex_admin {
my $rapidcity = shift; my $rapidcity = shift;
my $partial = shift; my $partial = shift;
my $rc_duplex_admin = $rapidcity->rc_duplex_admin() || {}; my $rc_duplex_admin = $rapidcity->rc_duplex_admin() || {};
my $rc_auto = $rapidcity->rc_auto($partial) || {}; my $rc_auto = $rapidcity->rc_auto($partial) || {};
my $rc_cpu_auto = $rapidcity->rc_cpu_auto($partial) || {}; my $rc_cpu_auto = $rapidcity->rc_cpu_auto($partial) || {};
my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin($partial) || {}; my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin($partial) || {};
my %i_duplex_admin; my %i_duplex_admin;
foreach my $if (keys %$rc_duplex_admin){ foreach my $if ( keys %$rc_duplex_admin ) {
my $duplex = $rc_duplex_admin->{$if}; my $duplex = $rc_duplex_admin->{$if};
next unless defined $duplex; next unless defined $duplex;
my $auto = $rc_auto->{$if}||'false'; my $auto = $rc_auto->{$if} || 'false';
my $string = 'other'; my $string = 'other';
$string = 'half' if ($duplex =~ /half/i and $auto =~ /false/i); $string = 'half' if ( $duplex =~ /half/i and $auto =~ /false/i );
$string = 'full' if ($duplex =~ /full/i and $auto =~ /false/i); $string = 'full' if ( $duplex =~ /full/i and $auto =~ /false/i );
$string = 'auto' if $auto =~ /true/i; $string = 'auto' if $auto =~ /true/i;
$i_duplex_admin{$if}=$string; $i_duplex_admin{$if} = $string;
} }
# Get CPU Ethernet Interfaces for 8600 Series # Get CPU Ethernet Interfaces for 8600 Series
foreach my $iid (keys %$rc_cpu_duplex_admin){ foreach my $iid ( keys %$rc_cpu_duplex_admin ) {
my $c_duplex = $rc_cpu_duplex_admin->{$iid}; my $c_duplex = $rc_cpu_duplex_admin->{$iid};
next unless defined $c_duplex; next unless defined $c_duplex;
my $c_auto = $rc_cpu_auto->{$iid}; my $c_auto = $rc_cpu_auto->{$iid};
my $string = 'other'; my $string = 'other';
$string = 'half' if ($c_duplex =~ /half/i and $c_auto =~ /false/i); $string = 'half' if ( $c_duplex =~ /half/i and $c_auto =~ /false/i );
$string = 'full' if ($c_duplex =~ /full/i and $c_auto =~ /false/i); $string = 'full' if ( $c_duplex =~ /full/i and $c_auto =~ /false/i );
$string = 'auto' if $c_auto =~ /true/i; $string = 'auto' if $c_auto =~ /true/i;
$i_duplex_admin{$iid} = $string; $i_duplex_admin{$iid} = $string;
} }
return \%i_duplex_admin; return \%i_duplex_admin;
@@ -229,61 +238,61 @@ sub i_duplex_admin {
sub set_i_duplex_admin { sub set_i_duplex_admin {
my $rapidcity = shift; my $rapidcity = shift;
my ($duplex, $iid) = @_; my ( $duplex, $iid ) = @_;
$duplex = lc($duplex); $duplex = lc($duplex);
return unless ($duplex =~ /(half|full|auto)/ and $iid =~ /\d+/); return unless ( $duplex =~ /(half|full|auto)/ and $iid =~ /\d+/ );
# map a textual duplex to an integer one the switch understands # map a textual duplex to an integer one the switch understands
my %duplexes = qw/full 2 half 1/; my %duplexes = qw/full 2 half 1/;
my $i_auto = $rapidcity->rc_auto($iid); my $i_auto = $rapidcity->rc_auto($iid);
if ($duplex eq "auto") { if ( $duplex eq "auto" ) {
return $rapidcity->set_rc_auto('1', $iid); return $rapidcity->set_rc_auto( '1', $iid );
} }
elsif (($duplex ne "auto") and ($i_auto->{$iid} eq "1")) { elsif ( ( $duplex ne "auto" ) and ( $i_auto->{$iid} eq "1" ) ) {
return unless ($rapidcity->set_rc_auto('2', $iid)); return unless ( $rapidcity->set_rc_auto( '2', $iid ) );
return $rapidcity->set_rc_duplex_admin($duplexes{$duplex}, $iid); return $rapidcity->set_rc_duplex_admin( $duplexes{$duplex}, $iid );
} }
else { else {
return $rapidcity->set_rc_duplex_admin($duplexes{$duplex}, $iid); return $rapidcity->set_rc_duplex_admin( $duplexes{$duplex}, $iid );
} }
return; return;
} }
sub set_i_speed_admin { sub set_i_speed_admin {
my $rapidcity = shift; my $rapidcity = shift;
my ($speed, $iid) = @_; my ( $speed, $iid ) = @_;
return unless ($speed =~ /(10|100|1000|auto)/i and $iid =~ /\d+/); return unless ( $speed =~ /(10|100|1000|auto)/i and $iid =~ /\d+/ );
# map a textual duplex to an integer one the switch understands # map a textual duplex to an integer one the switch understands
my %speeds = qw/10 1 100 2 1000 3/; my %speeds = qw/10 1 100 2 1000 3/;
my $i_auto = $rapidcity->rc_auto($iid); my $i_auto = $rapidcity->rc_auto($iid);
if ($speed eq "auto") { if ( $speed eq "auto" ) {
return $rapidcity->set_rc_auto('1', $iid); return $rapidcity->set_rc_auto( '1', $iid );
} }
elsif (($speed ne "auto") and ($i_auto->{$iid} eq "1")) { elsif ( ( $speed ne "auto" ) and ( $i_auto->{$iid} eq "1" ) ) {
return unless ($rapidcity->set_rc_auto('2', $iid)); return unless ( $rapidcity->set_rc_auto( '2', $iid ) );
return $rapidcity->set_rc_speed_admin($speeds{$speed}, $iid); return $rapidcity->set_rc_speed_admin( $speeds{$speed}, $iid );
} }
else { else {
return $rapidcity->set_rc_speed_admin($speeds{$speed}, $iid); return $rapidcity->set_rc_speed_admin( $speeds{$speed}, $iid );
} }
return; return;
} }
sub v_index { sub v_index {
my $rapidcity = shift; my $rapidcity = shift;
my $partial = shift; my $partial = shift;
return $rapidcity->rc_vlan_id($partial); return $rapidcity->rc_vlan_id($partial);
} }
sub i_vlan { sub i_vlan {
my $rapidcity = shift; my $rapidcity = shift;
my $partial = shift; my $partial = shift;
my $i_pvid = $rapidcity->rc_i_vlan_pvid($partial) || {}; my $i_pvid = $rapidcity->rc_i_vlan_pvid($partial) || {};
@@ -296,18 +305,18 @@ sub i_vlan_membership {
my $rc_v_ports = $rapidcity->rc_vlan_members(); my $rc_v_ports = $rapidcity->rc_vlan_members();
my $i_vlan_membership = {}; my $i_vlan_membership = {};
foreach my $vlan (keys %$rc_v_ports) { foreach my $vlan ( keys %$rc_v_ports ) {
my $portlist = $rc_v_ports->{$vlan}; my $portlist = $rc_v_ports->{$vlan};
my $ret = []; my $ret = [];
# Convert portlist bit array to ifIndex array # Convert portlist bit array to ifIndex array
for (my $i = 0; $i <= scalar(@$portlist); $i++) { for ( my $i = 0; $i <= scalar(@$portlist); $i++ ) {
push(@{$ret}, $i) if (@$portlist[$i]); push( @{$ret}, $i ) if ( @$portlist[$i] );
} }
#Create HoA ifIndex -> VLAN array #Create HoA ifIndex -> VLAN array
foreach my $port (@{$ret}) { foreach my $port ( @{$ret} ) {
push(@{$i_vlan_membership->{$port}}, $vlan); push( @{ $i_vlan_membership->{$port} }, $vlan );
} }
} }
return $i_vlan_membership; return $i_vlan_membership;
@@ -315,12 +324,13 @@ sub i_vlan_membership {
sub set_i_pvid { sub set_i_pvid {
my $rapidcity = shift; my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $rapidcity->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $rapidcity->_validate_vlan_param( $vlan_id, $ifindex ) );
unless ( $rapidcity->set_rc_i_vlan_pvid($vlan_id, $ifindex) ) { unless ( $rapidcity->set_rc_i_vlan_pvid( $vlan_id, $ifindex ) ) {
$rapidcity->error_throw("Unable to change PVID to $vlan_id on IfIndex: $ifindex"); $rapidcity->error_throw(
"Unable to change PVID to $vlan_id on IfIndex: $ifindex");
return; return;
} }
return 1; return 1;
@@ -328,9 +338,10 @@ sub set_i_pvid {
sub set_i_vlan { sub set_i_vlan {
my $rapidcity = shift; my $rapidcity = shift;
my ($new_vlan_id, $ifindex) = @_; my ( $new_vlan_id, $ifindex ) = @_;
return unless ( $rapidcity->_validate_vlan_param ($new_vlan_id, $ifindex) ); return
unless ( $rapidcity->_validate_vlan_param( $new_vlan_id, $ifindex ) );
my $vlan_p_type = $rapidcity->rc_i_vlan_type($ifindex); my $vlan_p_type = $rapidcity->rc_i_vlan_type($ifindex);
unless ( $vlan_p_type->{$ifindex} =~ /access/ ) { unless ( $vlan_p_type->{$ifindex} =~ /access/ ) {
@@ -342,9 +353,12 @@ sub set_i_vlan {
# Store current untagged VLAN to remove it from the port list later # Store current untagged VLAN to remove it from the port list later
my $old_vlan_id = $i_pvid->{$ifindex}; my $old_vlan_id = $i_pvid->{$ifindex};
# Check that haven't been given the same VLAN we are currently using # Check that haven't been given the same VLAN we are currently using
if ($old_vlan_id eq $new_vlan_id) { if ( $old_vlan_id eq $new_vlan_id ) {
$rapidcity->error_throw("Current PVID: $old_vlan_id and New VLAN: $new_vlan_id the same, no change."); $rapidcity->error_throw(
"Current PVID: $old_vlan_id and New VLAN: $new_vlan_id the same, no change."
);
return; return;
} }
@@ -353,107 +367,132 @@ sub set_i_vlan {
# Check if port in forbidden list for the VLAN, haven't seen this used, # Check if port in forbidden list for the VLAN, haven't seen this used,
# but we'll check anyway # but we'll check anyway
return unless return
($rapidcity->_check_forbidden_ports($new_vlan_id, $ifindex)); unless (
$rapidcity->_check_forbidden_ports( $new_vlan_id, $ifindex ) );
my $old_vlan_members = $rapidcity->rc_vlan_members($old_vlan_id); my $old_vlan_members = $rapidcity->rc_vlan_members($old_vlan_id);
my $new_vlan_members = $rapidcity->rc_vlan_members($new_vlan_id); my $new_vlan_members = $rapidcity->rc_vlan_members($new_vlan_id);
print "Modifying egress list for VLAN: $new_vlan_id \n" if $rapidcity->debug(); print "Modifying egress list for VLAN: $new_vlan_id \n"
my $new_egress = $rapidcity->modify_port_list($new_vlan_members->{$new_vlan_id},$ifindex,'1'); if $rapidcity->debug();
my $new_egress
= $rapidcity->modify_port_list( $new_vlan_members->{$new_vlan_id},
$ifindex, '1' );
print "Modifying egress list for VLAN: $old_vlan_id \n" if $rapidcity->debug(); print "Modifying egress list for VLAN: $old_vlan_id \n"
my $old_egress = $rapidcity->modify_port_list($old_vlan_members->{$old_vlan_id},$ifindex,'0'); if $rapidcity->debug();
my $old_egress
= $rapidcity->modify_port_list( $old_vlan_members->{$old_vlan_id},
$ifindex, '0' );
my $vlan_set = [ my $vlan_set = [
['rc_vlan_members',"$new_vlan_id","$new_egress"], [ 'rc_vlan_members', "$new_vlan_id", "$new_egress" ],
# ['rc_vlan_members',"$old_vlan_id","$old_egress"],
# ['rc_vlan_members',"$old_vlan_id","$old_egress"],
]; ];
return unless return
($rapidcity->set_multi($vlan_set)); unless ( $rapidcity->set_multi($vlan_set) );
my $vlan_set2 = [ my $vlan_set2 = [ [ 'rc_vlan_members', "$old_vlan_id", "$old_egress" ], ];
['rc_vlan_members',"$old_vlan_id","$old_egress"],
];
return unless return
($rapidcity->set_multi($vlan_set2)); unless ( $rapidcity->set_multi($vlan_set2) );
# Set new untagged / native VLAN # Set new untagged / native VLAN
# Some models/versions do this for us also, so check to see if we need to set # Some models/versions do this for us also, so check to see if we need to set
$i_pvid = $rapidcity->rc_i_vlan_pvid($ifindex); $i_pvid = $rapidcity->rc_i_vlan_pvid($ifindex);
my $cur_i_pvid = $i_pvid->{$ifindex}; my $cur_i_pvid = $i_pvid->{$ifindex};
print "Current PVID: $cur_i_pvid\n" if $rapidcity->debug(); print "Current PVID: $cur_i_pvid\n" if $rapidcity->debug();
unless ($cur_i_pvid eq $new_vlan_id) { unless ( $cur_i_pvid eq $new_vlan_id ) {
return unless ($rapidcity->set_i_pvid($new_vlan_id, $ifindex)); return unless ( $rapidcity->set_i_pvid( $new_vlan_id, $ifindex ) );
} }
print "Successfully changed VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n" if $rapidcity->debug(); print
"Successfully changed VLAN: $old_vlan_id to $new_vlan_id on IfIndex: $ifindex\n"
if $rapidcity->debug();
return 1; return 1;
} }
sub set_add_i_vlan_tagged { sub set_add_i_vlan_tagged {
my $rapidcity = shift; my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $rapidcity->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $rapidcity->_validate_vlan_param( $vlan_id, $ifindex ) );
print "Adding VLAN: $vlan_id to IfIndex: $ifindex\n" if $rapidcity->debug(); print "Adding VLAN: $vlan_id to IfIndex: $ifindex\n"
if $rapidcity->debug();
# Check if port in forbidden list for the VLAN, haven't seen this used, but we'll check anyway # Check if port in forbidden list for the VLAN, haven't seen this used, but we'll check anyway
return unless ($rapidcity->_check_forbidden_ports($vlan_id, $ifindex)); return
unless ( $rapidcity->_check_forbidden_ports( $vlan_id, $ifindex ) );
my $iv_members = $rapidcity->rc_vlan_members($vlan_id); my $iv_members = $rapidcity->rc_vlan_members($vlan_id);
print "Modifying egress list for VLAN: $vlan_id \n" if $rapidcity->debug(); print "Modifying egress list for VLAN: $vlan_id \n"
my $new_egress = $rapidcity->modify_port_list($iv_members->{$vlan_id},$ifindex,'1'); if $rapidcity->debug();
my $new_egress
= $rapidcity->modify_port_list( $iv_members->{$vlan_id}, $ifindex,
'1' );
unless ( $rapidcity->set_qb_v_egress($new_egress, $vlan_id) ) { unless ( $rapidcity->set_qb_v_egress( $new_egress, $vlan_id ) ) {
print "Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n" if $rapidcity->debug(); print
"Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n"
if $rapidcity->debug();
return; return;
} }
print "Successfully added IfIndex: $ifindex to VLAN: $vlan_id egress list\n" if $rapidcity->debug(); print
"Successfully added IfIndex: $ifindex to VLAN: $vlan_id egress list\n"
if $rapidcity->debug();
return 1; return 1;
} }
sub set_remove_i_vlan_tagged { sub set_remove_i_vlan_tagged {
my $rapidcity = shift; my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
return unless ( $rapidcity->_validate_vlan_param ($vlan_id, $ifindex) ); return unless ( $rapidcity->_validate_vlan_param( $vlan_id, $ifindex ) );
print "Removing VLAN: $vlan_id from IfIndex: $ifindex\n" if $rapidcity->debug(); print "Removing VLAN: $vlan_id from IfIndex: $ifindex\n"
if $rapidcity->debug();
my $iv_members = $rapidcity->rc_vlan_members($vlan_id); my $iv_members = $rapidcity->rc_vlan_members($vlan_id);
print "Modifying egress list for VLAN: $vlan_id \n" if $rapidcity->debug(); print "Modifying egress list for VLAN: $vlan_id \n"
my $new_egress = $rapidcity->modify_port_list($iv_members->{$vlan_id},$ifindex,'0'); if $rapidcity->debug();
my $new_egress
= $rapidcity->modify_port_list( $iv_members->{$vlan_id}, $ifindex,
'0' );
unless ( $rapidcity->set_qb_v_egress($new_egress, $vlan_id) ) { unless ( $rapidcity->set_qb_v_egress( $new_egress, $vlan_id ) ) {
print "Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n" if $rapidcity->debug(); print
"Error: Unable to add VLAN: $vlan_id to Index: $ifindex egress list.\n"
if $rapidcity->debug();
return; return;
} }
print "Successfully removed IfIndex: $ifindex from VLAN: $vlan_id egress list\n" if $rapidcity->debug(); print
"Successfully removed IfIndex: $ifindex from VLAN: $vlan_id egress list\n"
if $rapidcity->debug();
return 1; return 1;
} }
sub set_create_vlan { sub set_create_vlan {
my $rapidcity = shift; my $rapidcity = shift;
my ($name, $vlan_id) = @_; my ( $name, $vlan_id ) = @_;
return unless ($vlan_id =~ /\d+/); return unless ( $vlan_id =~ /\d+/ );
my $vlan_set = [ my $vlan_set = [
['v_name',"$vlan_id","$name"], [ 'v_name', "$vlan_id", "$name" ],
['rc_vlan_rstatus',"$vlan_id",4], [ 'rc_vlan_rstatus', "$vlan_id", 4 ],
]; ];
unless ($rapidcity->set_multi($vlan_set)){ unless ( $rapidcity->set_multi($vlan_set) ) {
print "Error: Unable to create VLAN: $vlan_id\n" if $rapidcity->debug(); print "Error: Unable to create VLAN: $vlan_id\n"
if $rapidcity->debug();
return; return;
} }
@@ -463,9 +502,9 @@ sub set_create_vlan {
sub set_delete_vlan { sub set_delete_vlan {
my $rapidcity = shift; my $rapidcity = shift;
my ($vlan_id) = shift; my ($vlan_id) = shift;
return unless ($vlan_id =~ /^\d+$/); return unless ( $vlan_id =~ /^\d+$/ );
unless ( $rapidcity->set_rc_vlan_rstatus('6', $vlan_id) ) { unless ( $rapidcity->set_rc_vlan_rstatus( '6', $vlan_id ) ) {
$rapidcity->error_throw("Unable to delete VLAN: $vlan_id"); $rapidcity->error_throw("Unable to delete VLAN: $vlan_id");
return; return;
} }
@@ -477,14 +516,19 @@ sub set_delete_vlan {
# #
sub _check_forbidden_ports { sub _check_forbidden_ports {
my $rapidcity = shift; my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
my $iv_forbidden = $rapidcity->rc_vlan_no_join($vlan_id); my $iv_forbidden = $rapidcity->rc_vlan_no_join($vlan_id);
my @forbidden_ports = split(//, unpack("B*", $iv_forbidden->{$vlan_id})); my @forbidden_ports
= split( //, unpack( "B*", $iv_forbidden->{$vlan_id} ) );
print "Forbidden ports: @forbidden_ports\n" if $rapidcity->debug(); print "Forbidden ports: @forbidden_ports\n" if $rapidcity->debug();
if ( defined($forbidden_ports[$ifindex]) and ($forbidden_ports[$ifindex] eq "1")) { if ( defined( $forbidden_ports[$ifindex] )
$rapidcity->error_throw("IfIndex: $ifindex in forbidden list for VLAN: $vlan_id unable to add"); and ( $forbidden_ports[$ifindex] eq "1" ) )
{
$rapidcity->error_throw(
"IfIndex: $ifindex in forbidden list for VLAN: $vlan_id unable to add"
);
return; return;
} }
return 1; return 1;
@@ -492,10 +536,14 @@ sub _check_forbidden_ports {
sub _validate_vlan_param { sub _validate_vlan_param {
my $rapidcity = shift; my $rapidcity = shift;
my ($vlan_id, $ifindex) = @_; my ( $vlan_id, $ifindex ) = @_;
# VID and ifIndex should both be numeric # VID and ifIndex should both be numeric
unless ( defined $vlan_id and defined $ifindex and $vlan_id =~ /^\d+$/ and $ifindex =~ /^\d+$/ ) { unless (defined $vlan_id
and defined $ifindex
and $vlan_id =~ /^\d+$/
and $ifindex =~ /^\d+$/ )
{
$rapidcity->error_throw("Invalid parameter"); $rapidcity->error_throw("Invalid parameter");
return; return;
} }
@@ -510,7 +558,8 @@ sub _validate_vlan_param {
#Check that VLAN exists on device #Check that VLAN exists on device
unless ( $rapidcity->rc_vlan_id($vlan_id) ) { unless ( $rapidcity->rc_vlan_id($vlan_id) ) {
$rapidcity->error_throw("VLAN $vlan_id does not exist or is not operational"); $rapidcity->error_throw(
"VLAN $vlan_id does not exist or is not operational");
return; return;
} }
@@ -1002,16 +1051,17 @@ Returns VLAN IDs
=head1 SET METHODS =head1 SET METHODS
These are methods that provide SNMP set functionality for overridden methods or These are methods that provide SNMP set functionality for overridden methods
provide a simpler interface to complex set operations. See or provide a simpler interface to complex set operations. See
L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set operations. L<SNMP::Info/"SETTING DATA VIA SNMP"> for general information on set
operations.
=over =over
=item $rapidcity->set_i_speed_admin(speed, ifIndex) =item $rapidcity->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port C<ifIndex>. Speed choices Sets port speed, must be supplied with speed and port C<ifIndex>. Speed
are 'auto', '10', '100', '1000'. choices are 'auto', '10', '100', '1000'.
Example: Example:
my %if_map = reverse %{$rapidcity->interfaces()}; my %if_map = reverse %{$rapidcity->interfaces()};
@@ -1031,9 +1081,9 @@ choices are 'auto', 'half', 'full'.
=item $rapidcity->set_i_vlan(vlan, ifIndex) =item $rapidcity->set_i_vlan(vlan, ifIndex)
Changes an access (untagged) port VLAN, must be supplied with the numeric Changes an access (untagged) port VLAN, must be supplied with the numeric
VLAN ID and port C<ifIndex>. This method will modify the port's VLAN membership VLAN ID and port C<ifIndex>. This method will modify the port's VLAN
and PVID (default VLAN). This method should only be used on end station membership and PVID (default VLAN). This method should only be used on end
(non-trunk) ports. station (non-trunk) ports.
Example: Example:
my %if_map = reverse %{$rapidcity->interfaces()}; my %if_map = reverse %{$rapidcity->interfaces()};
@@ -1053,8 +1103,8 @@ port C<ifIndex>. This method only changes the PVID, to modify an access
=item $rapidcity->set_add_i_vlan_tagged(vlan, ifIndex) =item $rapidcity->set_add_i_vlan_tagged(vlan, ifIndex)
Adds the port to the egress list of the VLAN, must be supplied with the numeric Adds the port to the egress list of the VLAN, must be supplied with the
VLAN ID and port C<ifIndex>. numeric VLAN ID and port C<ifIndex>.
Example: Example:
my %if_map = reverse %{$rapidcity->interfaces()}; my %if_map = reverse %{$rapidcity->interfaces()};

View File

@@ -34,37 +34,36 @@ use strict;
use Exporter; use Exporter;
use SNMP::Info; use SNMP::Info;
@SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/; @SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/;
@SNMP::Info::SONMP::EXPORT_OK = qw//; @SNMP::Info::SONMP::EXPORT_OK = qw//;
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE/;
$VERSION = '1.09'; $VERSION = '1.09';
%MIBS = ( %MIBS = (
'SYNOPTICS-ROOT-MIB' => 'synoptics', 'SYNOPTICS-ROOT-MIB' => 'synoptics',
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop', 'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop',
); );
%GLOBALS = ( %GLOBALS = (
'cdp_id' => 's5EnMsTopIpAddr', 'cdp_id' => 's5EnMsTopIpAddr',
'cdp_run' => 's5EnMsTopStatus', 'cdp_run' => 's5EnMsTopStatus',
); );
%FUNCS = ( %FUNCS = (
# From S5-ETH-MULTISEG-TOPOLOGY-MIB::TopNmmTable
'sonmp_topo_slot' => 's5EnMsTopNmmSlot',
'sonmp_topo_port' => 's5EnMsTopNmmPort',
'sonmp_topo_ip' => 's5EnMsTopNmmIpAddr',
'sonmp_topo_seg' => 's5EnMsTopNmmSegId',
'sonmp_topo_mac' => 's5EnMsTopNmmMacAddr',
'sonmp_topo_platform' => 's5EnMsTopNmmChassisType',
'sonmp_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
%MUNGE = ( # From S5-ETH-MULTISEG-TOPOLOGY-MIB::TopNmmTable
'sonmp_topo_mac' => \&SNMP::Info::munge_mac 'sonmp_topo_slot' => 's5EnMsTopNmmSlot',
); 'sonmp_topo_port' => 's5EnMsTopNmmPort',
'sonmp_topo_ip' => 's5EnMsTopNmmIpAddr',
'sonmp_topo_seg' => 's5EnMsTopNmmSegId',
'sonmp_topo_mac' => 's5EnMsTopNmmMacAddr',
'sonmp_topo_platform' => 's5EnMsTopNmmChassisType',
'sonmp_topo_localseg' => 's5EnMsTopNmmLocalSeg',
);
%MUNGE = ( 'sonmp_topo_mac' => \&SNMP::Info::munge_mac );
sub index_factor { sub index_factor {
return 32; return 32;
@@ -84,37 +83,40 @@ sub hasCDP {
} }
sub c_if { sub c_if {
my $sonmp = shift; my $sonmp = shift;
my $partial = shift; my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot($partial) || {}; my $sonmp_topo_slot = $sonmp->sonmp_topo_slot($partial) || {};
my $index_factor = $sonmp->index_factor(); my $index_factor = $sonmp->index_factor();
my $slot_offset = $sonmp->slot_offset(); my $slot_offset = $sonmp->slot_offset();
my $port_offset = $sonmp->port_offset(); my $port_offset = $sonmp->port_offset();
my $model = $sonmp->model(); my $model = $sonmp->model();
my %c_if; my %c_if;
foreach my $entry (keys %$sonmp_topo_port){ foreach my $entry ( keys %$sonmp_topo_port ) {
my $port = $sonmp_topo_port->{$entry}; my $port = $sonmp_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if $port == 0; next if $port == 0;
my $slot = $sonmp_topo_slot->{$entry} || 0; my $slot = $sonmp_topo_slot->{$entry} || 0;
if ($model eq 'Baystack Hub') { if ( $model eq 'Baystack Hub' ) {
my $comidx = $slot; my $comidx = $slot;
if (! ($comidx % 5)) { if ( !( $comidx % 5 ) ) {
$slot = ($slot / 5); $slot = ( $slot / 5 );
} elsif ($comidx =~ /[16]$/) { }
$slot = int($slot/5); elsif ( $comidx =~ /[16]$/ ) {
$port = 25; $slot = int( $slot / 5 );
} elsif ($comidx =~ /[27]$/) { $port = 25;
$slot = int($slot/5); }
$port = 26; elsif ( $comidx =~ /[27]$/ ) {
$slot = int( $slot / 5 );
$port = 26;
} }
} }
my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset); my $index = ( ( $slot - $slot_offset ) * $index_factor )
+ ( $port - $port_offset );
$c_if{$entry} = $index; $c_if{$entry} = $index;
} }
@@ -122,14 +124,14 @@ sub c_if {
} }
sub c_ip { sub c_ip {
my $sonmp = shift; my $sonmp = shift;
my $partial = shift; my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_ip = $sonmp->sonmp_topo_ip($partial) || {}; my $sonmp_topo_ip = $sonmp->sonmp_topo_ip($partial) || {};
my %c_ip; my %c_ip;
foreach my $entry (keys %$sonmp_topo_ip){ foreach my $entry ( keys %$sonmp_topo_ip ) {
my $port = $sonmp_topo_port->{$entry}; my $port = $sonmp_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if $port == 0; next if $port == 0;
@@ -141,54 +143,57 @@ sub c_ip {
} }
sub c_port { sub c_port {
my $sonmp = shift; my $sonmp = shift;
my $partial = shift; my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_seg = $sonmp->sonmp_topo_seg($partial) || {}; my $sonmp_topo_seg = $sonmp->sonmp_topo_seg($partial) || {};
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {}; my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {};
my %c_port; my %c_port;
foreach my $entry (keys %$sonmp_topo_seg){ foreach my $entry ( keys %$sonmp_topo_seg ) {
my $port = $sonmp_topo_port->{$entry}; my $port = $sonmp_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if $port == 0; next if $port == 0;
my $seg = $sonmp_topo_seg->{$entry}; my $seg = $sonmp_topo_seg->{$entry};
my $platform = $sonmp_topo_platform->{$entry}; my $platform = $sonmp_topo_platform->{$entry};
# AP-222x Series does not adhere to port numbering # AP-222x Series does not adhere to port numbering
if ($platform =~ /AccessPoint/i) { if ( $platform =~ /AccessPoint/i ) {
$c_port{$entry} = 'dp0'; $c_port{$entry} = 'dp0';
} }
# BayHubs send the lower three bytes of the MAC not the slot/port # BayHubs send the lower three bytes of the MAC not the slot/port
elsif ($seg > 4000) { elsif ( $seg > 4000 ) {
$c_port{$entry} = 'unknown'; $c_port{$entry} = 'unknown';
} }
else { else {
# Segment id is (256 * remote slot_num) + (remote_port) # Segment id is (256 * remote slot_num) + (remote_port)
my $remote_port = $seg % 256; my $remote_port = $seg % 256;
my $remote_slot = int($seg / 256); my $remote_slot = int( $seg / 256 );
$c_port{$entry} = "$remote_slot.$remote_port"; $c_port{$entry} = "$remote_slot.$remote_port";
} }
} }
return \%c_port; return \%c_port;
} }
sub c_platform { sub c_platform {
my $sonmp = shift; my $sonmp = shift;
my $partial = shift; my $partial = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {}; my $sonmp_topo_port = $sonmp->sonmp_topo_port($partial) || {};
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {}; my $sonmp_topo_platform = $sonmp->sonmp_topo_platform($partial) || {};
my %c_platform; my %c_platform;
foreach my $entry (keys %$sonmp_topo_platform){ foreach my $entry ( keys %$sonmp_topo_platform ) {
my $port = $sonmp_topo_port->{$entry}; my $port = $sonmp_topo_port->{$entry};
next unless defined $port; next unless defined $port;
next if $port == 0; next if $port == 0;
my $platform = $sonmp_topo_platform->{$entry}; my $platform = $sonmp_topo_platform->{$entry};
$c_platform{$entry} = $platform; $c_platform{$entry} = $platform;
} }
@@ -199,14 +204,15 @@ sub mac {
my $sonmp = shift; my $sonmp = shift;
my $sonmp_topo_port = $sonmp->sonmp_topo_port(); my $sonmp_topo_port = $sonmp->sonmp_topo_port();
my $sonmp_topo_mac = $sonmp->sonmp_topo_mac(); my $sonmp_topo_mac = $sonmp->sonmp_topo_mac();
foreach my $entry (keys %$sonmp_topo_port){ foreach my $entry ( keys %$sonmp_topo_port ) {
my $port = $sonmp_topo_port->{$entry}; my $port = $sonmp_topo_port->{$entry};
next unless $port == 0; next unless $port == 0;
my $mac = $sonmp_topo_mac->{$entry}; my $mac = $sonmp_topo_mac->{$entry};
return $mac; return $mac;
} }
# Topology turned off, not supported. # Topology turned off, not supported.
return; return;
} }
@@ -259,11 +265,13 @@ interface to the SynOptics Network Management Protocol (SONMP) information
through SNMP. through SNMP.
SONMP is a Layer 2 protocol that supplies topology information of devices that SONMP is a Layer 2 protocol that supplies topology information of devices that
also speak SONMP, mostly switches and hubs. SONMP is implemented in SynOptics, also speak SONMP, mostly switches and hubs. SONMP is implemented in
Bay, and Nortel devices. SONMP has been rebranded by Bay then Nortel and is SynOptics, Bay, and Nortel devices. SONMP has been rebranded by Bay then
know by several different names, most recently Nortel Discovery Protocol (NDP). Nortel and is know by several different names, most recently Nortel
Discovery Protocol (NDP).
Create or use a device subclass that inherits this class. Do not use directly. Create or use a device subclass that inherits this class. Do not use
directly.
Each device implements a subset of the global and cache entries. Each device implements a subset of the global and cache entries.
Check the return value to see if that data is held by the device. Check the return value to see if that data is held by the device.
@@ -340,7 +348,8 @@ Returns reference to hash. Key: Table entry, Value:slot number
=item $sonmp->sonmp_topo_port() =item $sonmp->sonmp_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<s5EnMsTopNmmPort>) (C<s5EnMsTopNmmPort>)
@@ -370,8 +379,8 @@ Returns reference to hash. Key: Table entry, Value:Remote Device Type
=item $sonmp->sonmp_topo_localseg =item $sonmp->sonmp_topo_localseg
Returns reference to hash. Key: Table entry, Value: Boolean, if bay_topo_seg() Returns reference to hash. Key: Table entry, Value: Boolean, if
is local. bay_topo_seg() is local.
(C<s5EnMsTopNmmLocalSeg>) (C<s5EnMsTopNmmLocalSeg>)
@@ -391,8 +400,8 @@ Returns reference to hash. Key: IID, Value: Local port (interfaces)
Returns reference to hash. Key: IID, Value: Remote IP address Returns reference to hash. Key: IID, Value: Remote IP address
If multiple entries exist with the same local port, c_if(), with different IPv4 If multiple entries exist with the same local port, c_if(), with different
addresses, c_ip(), there is either a non SONMP device in between two or IPv4 addresses, c_ip(), there is either a non SONMP device in between two or
more devices or multiple devices which are not directly connected. more devices or multiple devices which are not directly connected.
Use the data from the Layer2 Topology Table below to dig deeper. Use the data from the Layer2 Topology Table below to dig deeper.