+jeneric's massive Nortel functionality patch. L2::Bay depricated

This commit is contained in:
Max Baker
2004-10-28 21:45:00 +00:00
parent bbd45f82ab
commit c1b7d7dfc0
15 changed files with 5683 additions and 28 deletions

468
Info/Layer3/AlteonAD.pm Normal file
View File

@@ -0,0 +1,468 @@
# SNMP::Info::Layer3::AlteonAD
# Eric Miller <eric@jeneric.org>
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::AlteonAD;
$VERSION = 0.9;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE /;
@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//;
$DEBUG=0;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
'ALTEON-TIGON-SWITCH-MIB' => 'agSoftwareVersion',
'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt',
'ALTEON-TS-NETWORK-MIB' => 'agPortTableMaxEnt',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
'sw_ver' => 'agSoftwareVersion',
'tftp_action' => 'agTftpAction',
'tftp_host' => 'agTftpServer',
'tftp_file' => 'agTftpCfgFileName',
'tftp_result' => 'agTftpLastActionStatus',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'bp_index_2' => 'dot1dBasePortIfIndex',
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# From agPortCurCfgTable
'ag_p_cfg_idx' => 'agPortCurCfgIndx',
'ag_p_cfg_pref' => 'agPortCurCfgPrefLink',
'ag_p_cfg_pvid' => 'agPortCurCfgPVID',
'ag_p_cfg_fe_auto' => 'agPortCurCfgFastEthAutoNeg',
'ag_p_cfg_fe_mode' => 'agPortCurCfgFastEthMode',
'ag_p_cfg_ge_auto' => 'agPortCurCfgGigEthAutoNeg',
'ag_p_cfg_name' => 'agPortCurCfgPortName',
# From portInfoTable
'p_info_idx' => 'portInfoIndx',
'p_info_mode' => 'portInfoMode',
# From portInfoTable
'ip_cfg_vlan' => 'ipCurCfgIntfVlan',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub model {
my $alteon = shift;
my $desc = $alteon->description();
return undef unless defined $desc;
return 'AD2' if ($desc =~ /AD2/);
return 'AD3' if ($desc =~ /AD3/);
return 'AD4' if ($desc =~ /AD4/);
return '180' if ($desc =~ /180/);
return '183' if ($desc =~ /183/);
return '184' if ($desc =~ /184/);
return $desc;
}
sub vendor {
return 'nortel';
}
sub os {
return 'webos';
}
sub os_ver {
my $alteon = shift;
my $version = $alteon->sw_ver();
return undef unless defined $version;
return $version;
}
sub interfaces {
my $alteon = shift;
my $interfaces = $alteon->i_index();
my $descriptions = $alteon->i_description();
my %interfaces = ();
foreach my $iid (keys %$interfaces){
my $desc = $descriptions->{$iid};
next unless defined $desc;
if ($desc =~ /(^net\d+)/) {
$desc = $1;
}
elsif (($iid > 256) and ($iid < 266)) {
$desc = ($iid % 256);
}
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_duplex {
my $alteon = shift;
my $p_mode = $alteon->p_info_mode();
my %i_duplex;
foreach my $if (keys %$p_mode){
my $duplex = $p_mode->{$if};
next unless defined $duplex;
$duplex = 'half' if $duplex =~ /half/i;
$duplex = 'full' if $duplex =~ /full/i;
my $idx = $if + 256;
$i_duplex{$idx}=$duplex;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $alteon = shift;
my $ag_pref = $alteon->ag_p_cfg_pref();
my $ag_fe_auto = $alteon->ag_p_cfg_fe_auto();
my $ag_fe_mode = $alteon->ag_p_cfg_fe_mode();
my $ag_ge_auto = $alteon->ag_p_cfg_ge_auto();
my %i_duplex_admin;
foreach my $if (keys %$ag_pref){
my $pref = $ag_pref->{$if};
next unless defined $pref;
my $string = 'other';
if ($pref =~ /gigabit/i) {
my $ge_auto = $ag_ge_auto->{$if};
$string = 'full' if ($ge_auto =~ /off/i);
$string = 'auto' if ($ge_auto =~ /on/i);
}
elsif ($pref =~ /fast/i) {
my $fe_auto = $ag_fe_auto->{$if};
my $fe_mode = $ag_fe_mode->{$if};
$string = 'half' 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;
}
my $idx = $if + 256;
$i_duplex_admin{$idx}=$string;
}
return \%i_duplex_admin;
}
sub i_vlan {
my $alteon = shift;
my $ag_vlans = $alteon->ag_p_cfg_pvid();
my $ip_vlans = $alteon->ip_cfg_vlan();
my %i_vlan;
foreach my $if (keys %$ip_vlans){
my $ip_vlanid = $ip_vlans->{$if};
next unless defined $ip_vlanid;
$i_vlan{$if}=$ip_vlanid;
}
foreach my $if (keys %$ag_vlans){
my $ag_vlanid = $ag_vlans->{$if};
next unless defined $ag_vlanid;
my $idx = $if + 256;
$i_vlan{$idx}=$ag_vlanid;
}
return \%i_vlan;
}
sub i_name {
my $alteon = shift;
my $p_name = $alteon->ag_p_cfg_name();
my %i_name;
foreach my $iid (keys %$p_name){
my $name = $p_name->{$iid};
next unless defined $name;
my $idx = $iid + 256;
$i_name{$idx} = $name;
}
return \%i_name;
}
# Bridge MIB does not map Bridge Port to ifIndex correctly
sub bp_index {
my $alteon = shift;
my $b_index = $alteon->bp_index_2();
my %bp_index;
foreach my $iid (keys %$b_index){
my $port = $b_index->{$iid};
next unless defined $port;
$port = $port + 256;
$bp_index{$iid} = $port;
}
return \%bp_index;
}
sub root_ip {
my $alteon = shift;
my $ip_table = $alteon->ip_table();
# Return First IP Address
foreach my $entry (keys %$ip_table){
my $router_ip = $ip_table->{$entry};
print " SNMP::Layer3::AlteonAD::root_ip() using $router_ip\n" if $DEBUG;
next unless $router_ip;
return $router_ip if ($router_ip ne '0.0.0.0');
}
return undef;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::AlteonAD - Perl5 Interface to Nortel Networks' Alteon Ace
Director Series Layer 2-7 Switches.
=head1 AUTHOR
Eric Miller (C<eric@jeneric.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $alteon = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $alteon->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Layer 2-7 load balancing switches running Nortel Networks'
Alteon Web OS Traffic Control Software.
For speed or debugging purposes you can call the subclass directly, but not after
determining a more specific class using the method above.
my $alteon = new SNMP::Info::Layer3::AlteonAD(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item ALTEON-TIGON-SWITCH-MIB
=item ALTEON-TS-PHYSICAL-MIB
=item ALTEON-TS-NETWORK-MIB
MIBs can be found on the CD that came with your product.
Or, they can be downloaded directly from Nortel Networks regardless of support
contract status. Go to http://www.nortelnetworks.com Techninal Support,
Browse Technical Support, Select by Product Families, Alteon,
Alteon Web OS Traffic Control Software, Software. Filter on mibs and download
the latest version's archive.
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $alteon->model()
Returns the model extracted from B<sysDescr>
=item $alteon->vendor()
Returns 'Nortel'
=item $alteon->os()
Returns 'WebOS'
=item $alteon->os_ver()
Returns the software version reported by B<agSoftwareVersion>
=item $alteon->root_ip()
Returns the primary IP used to communicate with the device. Currently returns
the first interfaces IP.
=item $alteon->tftp_action()
(B<agTftpAction>)
=item $alteon->tftp_host()
(B<agTftpServer>)
=item $alteon->tftp_file()
(B<agTftpCfgFileName>)
=item $alteon->tftp_result()
(B<agTftpLastActionStatus>)
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $alteon->interfaces()
Returns reference to the map between IID and physical port.
Utilizes description for network interfaces. Ports are determined by
formula (ifIndex mod 256).
=item $alteon->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs.
=item $alteon->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs.
=item $alteon->i_vlan()
Returns reference to hash. Maps port VLAN ID to IIDs.
=item $alteon->i_name()
Maps (B<agPortCurCfgPortName>) to port and returns the human set port name if exists.
=item $alteon->bp_index()
Returns a mapping between ifIndex and the Bridge Table.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $alteon->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $alteon->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $alteon->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=cut

551
Info/Layer3/BayRS.pm Normal file
View File

@@ -0,0 +1,551 @@
# SNMP::Info::Layer3::BayRS
# Eric Miller <eric@jeneric.org>
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::BayRS;
$VERSION = 0.9;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE %MODEL_MAP/;
@SNMP::Info::Layer3::BayRS::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
@SNMP::Info::Layer3::BayRS::EXPORT_OK = qw//;
$DEBUG=0;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
'Wellfleet-HARDWARE-MIB' => 'wfHwBpIdOpt',
'Wellfleet-OSPF-MIB' => 'wfOspfRouterId',
'Wellfleet-DOT1QTAG-CONFIG-MIB' => 'wfDot1qTagCfgVlanName',
'Wellfleet-CSMACD-MIB' => 'wfCSMACDCct',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
'bp_id' => 'wfHwBpIdOpt',
'bp_serial' => 'wfHwBpSerialNumber',
'ospf_rtr_id' => 'wfOspfRouterId',
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
# From Wellfleet-CSMACD-MIB::wfCSMACDTable
'wf_csmacd_cct' => 'wfCSMACDCct',
'wf_csmacd_slot' => 'wfCSMACDSlot',
'wf_csmacd_conn' => 'wfCSMACDConnector',
'wf_csmacd_mtu' => 'wfCSMACDMtu',
'wf_duplex' => 'wfCSMACDLineCapability',
'wf_csmacd_line' => 'wfCSMACDLineNumber',
# From Wellfleet-CSMACD-MIB::wfCSMACDAutoNegTable
'wf_auto' => 'wfCSMACDAutoNegSpeedSelect',
# From Wellfleet-DOT1QTAG-CONFIG-MIB::wfDot1qTagConfigTable
'wf_vlan_name' => 'wfDot1qTagCfgVlanName',
'wf_local_vlan_id' => 'wfDot1qTagCfgLocalVlanId',
'wf_global_vlan_id' => 'wfDot1qTagCfgGlobalVlanId',
'wf_vlan_port' => 'wfDot1qTagCfgPhysicalPortId',
# From Wellfleet-HARDWARE-MIB::wfHwTable
'wf_hw_slot' => 'wfHwSlot',
'wf_hw_mod_id' => 'wfHwModIdOpt',
'wf_hw_mod_rev' => 'wfHwModRev',
'wf_hw_mod_ser' => 'wfHwModSerialNumber',
'wf_hw_mobo_id' => 'wfHwMotherBdIdOpt ',
'wf_hw_mobo_rev' => 'wfHwMotherBdRev',
'wf_hw_mobo_ser' => 'wfHwMotherBdSerialNumber',
'wf_hw_diag' => 'wfHwDiagPromRev',
'wf_hw_boot' => 'wfHwBootPromRev',
'wf_hw_mobo_mem' => 'wfHwMotherBdMemorySize',
'wf_hw_cfg_time' => 'wfHwConfigDateAndTime ',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
%MODEL_MAP = (
'acefn' => 'FN',
'aceln' => 'LN',
'acecn' => 'CN',
'afn' => 'AFN',
'in' => 'IN',
'an' => 'AN',
'arn' => 'ARN',
'sys5000' => '5000',
'freln' => 'BLN',
'frecn' => 'BCN',
'frerbln' => 'BLN-2',
'asn' => 'ASN',
'asnzcable' => 'ASN-Z',
'asnbcable' => 'ASN-B',
);
sub model {
my $bayrs = shift;
my $bp_id = $bayrs->bp_id();
return defined $MODEL_MAP{$bp_id} ? $MODEL_MAP{$bp_id} : $bp_id;
}
sub vendor {
return 'nortel';
}
sub os {
return 'bayrs';
}
sub os_ver {
my $bayrs = shift;
my $descr = $bayrs->description();
return undef unless defined $descr;
if ($descr =~ m/rel\/(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub serial {
my $bayrs = shift;
my $serialnum = $bayrs->bp_serial();
$serialnum = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$serialnum)));
return $serialnum if defined $serialnum ;
return undef;
}
sub interfaces {
my $bayrs = shift;
my $description = $bayrs->i_description();
my $vlan_ids = $bayrs->wf_global_vlan_id();
my $vlan_idx = $bayrs->wf_local_vlan_id();
my %interfaces = ();
foreach my $iid (keys %$description){
my $desc = $description->{$iid};
next unless defined $desc;
$desc = $1 if $desc =~ /(^[A-Z]\d+)/;
$interfaces{$iid} = $desc;
}
foreach my $iid (keys %$vlan_ids){
my $vlan = $vlan_ids->{$iid};
next unless defined $vlan;
my $vlan_if = $vlan_idx->{$iid};
next unless defined $vlan_if;
my $desc = 'V' . $vlan;
$interfaces{$vlan_if} = $desc;
}
return \%interfaces;
}
sub i_name {
my $bayrs = shift;
my $i_index = $bayrs->i_index();
my $description = $bayrs->i_description();
my $v_name = $bayrs->wf_vlan_name();
my $vlan_idx = $bayrs->wf_local_vlan_id();
my %i_name;
foreach my $iid (keys %$description){
my $name = $description->{$iid};
next unless defined $name;
$i_name{$iid} = $name;
}
# Get VLAN Virtual Router Interfaces
foreach my $vid (keys %$v_name){
my $v_name = $v_name->{$vid};
next unless defined $v_name;
my $vlan_if = $vlan_idx->{$vid};
next unless defined $vlan_if;
$i_name{$vlan_if} = $v_name;
}
return \%i_name;
}
sub i_duplex {
my $bayrs = shift;
my $wf_cct = $bayrs->wf_csmacd_cct();
my $wf_duplex = $bayrs->wf_duplex();
my %i_duplex;
foreach my $if (keys %$wf_cct){
my $idx = $wf_cct->{$if};
next unless defined $idx;
my $duplex = $wf_duplex->{$if};
next unless defined $duplex;
my $string = 'half';
$string = 'full' if $duplex =~ /duplex/i;
$i_duplex{$idx}=$string;
}
return \%i_duplex;
}
sub i_duplex_admin {
my $bayrs = shift;
my $wf_cct = $bayrs->wf_csmacd_cct();
my $wf_duplex = $bayrs->wf_duplex();
my $wf_auto = $bayrs->wf_auto();
my $wf_slot = $bayrs->wf_csmacd_slot();
my $wf_conn = $bayrs->wf_csmacd_conn();
my %i_duplex_admin;
foreach my $if (keys %$wf_cct){
my $idx = $wf_cct->{$if};
next unless defined $idx;
my $duplex = $wf_duplex->{$if};
next unless defined $duplex;
my $slot = $wf_slot->{$if};
my $conn = $wf_conn->{$if};
my $auto_idx = "$slot.$conn";
my $auto = $wf_auto->{$auto_idx};
my $string = 'other';
if ($auto) {
$string = 'half';
$string = 'full' if $auto =~ /duplex/i;
$string = 'auto' if $auto =~ /nway/i;
}
elsif ($duplex) {
$string = 'half';
$string = 'full' if $duplex =~ /duplex/i;
}
$i_duplex_admin{$idx}=$string;
}
return \%i_duplex_admin;
}
sub i_vlan {
my $bayrs = shift;
my $wf_cct = $bayrs->wf_csmacd_cct();
my $wf_mtu = $bayrs->wf_csmacd_mtu();
my $wf_line = $bayrs->wf_csmacd_line();
my $wf_local_vid = $bayrs->wf_local_vlan_id();
my $wf_global_vid = $bayrs->wf_global_vlan_id();
my $wf_vport = $bayrs->wf_vlan_port();
my %i_vlan;
# Look for VLANs on Ethernet Interfaces
foreach my $if (keys %$wf_cct){
my $idx = $wf_cct->{$if};
next unless defined $idx;
# Check MTU size, if unable to carry VLAN tag skip.
my $mtu = $wf_mtu->{$if};
next if (($mtu =~ /default/i) or ($mtu < 1522));
my $line = $wf_line->{$if};
my @vlans = ();
foreach my $v_idx (keys %$wf_vport){
my $port = $wf_vport->{$v_idx};
next unless defined $port;
next if ($port != $line);
my $vlan = $wf_global_vid->{$v_idx};
push(@vlans, $vlan);
}
my $vlans = join (',', @vlans);
$i_vlan{$idx}=$vlans;
}
# Add VLAN on VLAN Interfaces
foreach my $idx (keys %$wf_global_vid){
my $v_if = $wf_local_vid->{$idx};
next unless defined $v_if;
my $vlan = $wf_global_vid->{$idx};
next unless defined $vlan;
$i_vlan{$v_if}=$vlan;
}
return \%i_vlan;
}
sub root_ip {
my $bayrs = shift;
my $ip_index = $bayrs->ip_index();
my $ip_table = $bayrs->ip_table();
# Check for CLIP
foreach my $entry (keys %$ip_index){
my $idx = $ip_index->{$entry};
next unless $idx == 0;
my $clip = $ip_table->{$entry};
next unless ((defined $clip) and ($clip eq '0.0.0.0'));
print " SNMP::Layer3::BayRS::root_ip() using $clip\n" if $DEBUG;
return $clip;
}
# Check for OSPF Router ID
my $ospf_ip = $bayrs->ospf_rtr_id();
if ((defined $ospf_ip) and ($ospf_ip ne '0.0.0.0')) {
print " SNMP::Layer3::BayRS::root_ip() using $ospf_ip\n" if $DEBUG;
return $ospf_ip;
}
# Else Return First IP Address
foreach my $entry (keys %$ip_table){
my $ip = $ip_table->{$entry};
print " SNMP::Layer3::BayRS::root_ip() using $ip\n" if $DEBUG;
next unless $ip;
return $ip if ($ip ne '0.0.0.0');
}
return undef;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::BayRS - Perl5 Interface to Nortel Networks' routers running BayRS.
=head1 AUTHOR
Eric Miller (C<eric@jeneric.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $bayrs = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $bayrs->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for routers running Nortel Networks' BayRS.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $bayrs = new SNMP::Info::Layer3::BayRS(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=back
=head2 Required MIBs
=over
=item Wellfleet-HARDWARE-MIB
=item Wellfleet-OSPF-MIB
=item Wellfleet-DOT1QTAG-CONFIG-MIB
=item Wellfleet-CSMACD-MIB
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
MIBs can be found on the CD that came with your product.
Or, they can be downloaded directly from Nortel Networks regardless of support
contract status. Go to http://www.nortelnetworks.com Techninal Support, Browse
Technical Support, Select by Product Families, BayRS Router Software,
Router Software v 15.x, Software. Filter on mibs and download the latest
version's archive.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $bayrs->model()
Returns the model of the BayRS router. Will translate between the MIB model and
the common model with this map :
%MODEL_MAP = (
'acefn' => 'FN',
'aceln' => 'LN',
'acecn' => 'CN',
'afn' => 'AFN',
'in' => 'IN',
'an' => 'AN',
'arn' => 'ARN',
'sys5000' => '5000',
'freln' => 'BLN',
'frecn' => 'BCN',
'frerbln' => 'BLN-2',
'asn' => 'ASN',
'asnzcable' => 'ASN-Z',
'asnbcable' => 'ASN-B',
);
=item $bayrs->vendor()
Returns 'Nortel'
=item $bayrs->os()
Returns 'BayRS'
=item $bayrs->os_ver()
Returns the software version extracted from B<sysDescr>
=item $bayrs->serial()
Returns (B<wfHwBpSerialNumber>) after conversion to ASCII decimal
=item $bayrs->root_ip()
Returns the primary IP used to communicate with the router.
Returns the first found: CLIP (CircuitLess IP), (B<wfOspfRouterId>), or the first
IP interface.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $bayrs->interfaces()
Returns reference to the map between IID and physical Port.
The physical port name is stripped to letter and numbers to signify
port type and slot port (S11) if the default platform naming was
maintained. Otherwise the port is the interface description.
=item $bayrs->i_name()
Returns (B<ifDescr>) along with VLAN name (B<wfDot1qTagCfgVlanName>) for VLAN
interfaces.
=item $bayrs->i_duplex()
Returns reference to hash. Maps port operational duplexes to IIDs for Ethernet
interfaces.
=item $bayrs->i_duplex_admin()
Returns reference to hash. Maps port admin duplexes to IIDs for Ethernet interfaces.
=item $bayrs->i_vlan()
Returns reference to hash. Maps port VLAN ID to IIDs.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $bayrs->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $bayrs->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $bayrs->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=cut

348
Info/Layer3/Contivity.pm Normal file
View File

@@ -0,0 +1,348 @@
# SNMP::Info::Layer3::Contivity
# Eric Miller <eric@jeneric.org>
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Contivity;
$VERSION = 0.9;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Entity;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::Contivity::ISA = qw/SNMP::Info SNMP::Info::Entity Exporter/;
@SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//;
$DEBUG=0;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Entity::MIBS,
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Entity::GLOBALS,
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Entity::FUNCS,
'i_name2' => 'ifName',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Entity::MUNGE,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub layers {
return '00000100';
}
sub vendor {
return 'nortel';
}
sub model {
my $contivity = shift;
my $e_model = $contivity->e_model() || {};
my $model = $e_model->{1} || undef;
return $1 if (defined $model and $model =~ /(CES\d+)/i);
return undef;
}
sub os {
return 'contivity';
}
sub os_ver {
my $contivity = shift;
my $descr = $contivity->description();
return undef unless defined $descr;
if ($descr =~ m/V(\d+_\d+\.\d+)/i){
return $1;
}
return undef;
}
sub mac {
my $contivity = shift;
my $i_mac = $contivity->i_mac();
# Return Interface MAC
foreach my $entry (keys %$i_mac){
my $sn = $i_mac->{$entry};
next unless $sn;
return $sn;
}
return undef;
}
sub serial {
my $contivity = shift;
my $e_serial = $contivity->e_serial() || {};
my $serial = $e_serial->{1} || undef;
return $1 if (defined $serial and $serial =~ /(\d+)/);
return undef;
}
sub interfaces {
my $contivity = shift;
my $description = $contivity->i_description();
my %interfaces = ();
foreach my $iid (keys %$description){
my $desc = $description->{$iid};
# Skip everything except Ethernet interfaces
next unless (defined $desc and $desc =~ /fe/i);
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub i_name {
my $contivity = shift;
my $i_name2 = $contivity->i_name2();
my %i_name;
foreach my $iid (keys %$i_name2){
my $name = $i_name2->{$iid};
#Skip everything except Ethernet interfaces
next unless (defined $name and $name =~ /fe/i);
$name = $1 if $name =~ /(fei\.\d+\.\d+)/;
$i_name{$iid} = $name;
}
return \%i_name;
}
sub root_ip {
my $contivity = shift;
my $ip_table = $contivity->ip_table();
# Return First IP Address
foreach my $entry (keys %$ip_table){
my $router_ip = $ip_table->{$entry};
print " SNMP::Layer3::Contivity::root_ip() using $router_ip\n" if $DEBUG;
next unless $router_ip;
return $router_ip if ($router_ip ne '0.0.0.0');
}
return undef;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Contivity - Perl5 Interface to Nortel Networks' Contivity
Extranet Switches (CES).
=head1 AUTHOR
Eric Miller (C<eric@jeneric.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $contivity = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $contivity->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Nortel Networks' Contivity Extranet Switch (CES).
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $contivity = new SNMP::Info::Layer3::Contivity(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Entity
=back
=head2 Required MIBs
=over
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Entity for its own MIB requirements.
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $contivity->vendor()
Returns 'Nortel'
=item $contivity->model()
Returns the chassis name.
(B<entPhysicalModelName.1>)
=item $contivity->os()
Returns 'CES'
=item $contivity->os_ver()
Returns the software version extracted from (B<sysDescr>).
=item $contivity->serial()
Returns the chassis serial number.
(B<entPhysicalSerialNum.1>)
=item $contivity->mac()
Returns the MAC address of the first Ethernet Interface.
=item $contivity->root_ip()
Returns the primary IP used to communicate with the router. Returns the first
IP interface.
=back
=head2 Overrides
=over
=item $contivity->layers()
Returns 00000100. Contivity does not support bridge MIB, so override reported
layers.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $contivity->interfaces()
Returns reference to the map between IID and physical Port. Skips loopback and
tunnel interfaces.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $contivity->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $contivity->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $contivity->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Table Methods imported from SNMP::Info::Entity
See documentation in SNMP::Info::Entity for details.
=cut

654
Info/Layer3/Passport.pm Normal file
View File

@@ -0,0 +1,654 @@
# SNMP::Info::Layer3::Passport
# Eric Miller <eric@jeneric.org>
#
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
#
# Copyright (c) 2002,2003 Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the University of California, Santa Cruz nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Passport;
$VERSION = 0.9;
use strict;
use Exporter;
use SNMP::Info;
use SNMP::Info::Bridge;
use SNMP::Info::SONMP;
use SNMP::Info::RapidCity;
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
@SNMP::Info::Layer3::Passport::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::RapidCity Exporter/;
@SNMP::Info::Layer3::Passport::EXPORT_OK = qw//;
$DEBUG=0;
# See SNMP::Info for the details of these data structures and
# the interworkings.
$INIT = 0;
%MIBS = (
%SNMP::Info::MIBS,
%SNMP::Info::Bridge::MIBS,
%SNMP::Info::SONMP::MIBS,
%SNMP::Info::RapidCity::MIBS,
'OSPF-MIB' => 'ospfRouterId',
);
%GLOBALS = (
%SNMP::Info::GLOBALS,
%SNMP::Info::Bridge::GLOBALS,
%SNMP::Info::SONMP::GLOBALS,
%SNMP::Info::RapidCity::GLOBALS,
'router_ip' => 'ospfRouterId'
);
%FUNCS = (
%SNMP::Info::FUNCS,
%SNMP::Info::Bridge::FUNCS,
%SNMP::Info::SONMP::FUNCS,
%SNMP::Info::RapidCity::FUNCS,
'i_index2' => 'ifIndex',
'i_mac2' => 'ifPhysAddress',
'i_description2' => 'ifDescr',
'i_name2' => 'ifName',
'ip_index2' => 'ipAdEntIfIndex',
# From RFC1213-MIB
'at_index' => 'ipNetToMediaIfIndex',
'at_paddr' => 'ipNetToMediaPhysAddress',
'at_netaddr' => 'ipNetToMediaNetAddress',
'i_name2' => 'ifName'
);
%MUNGE = (
%SNMP::Info::MUNGE,
%SNMP::Info::Bridge::MUNGE,
%SNMP::Info::SONMP::MUNGE,
%SNMP::Info::RapidCity::MUNGE,
'i_mac2' => \&SNMP::Info::munge_mac,
'at_paddr' => \&SNMP::Info::munge_mac,
);
sub model {
my $passport = shift;
my $desc = $passport->description();
return undef unless defined $desc;
return '8603' if ($desc =~ /8603/);
return '8606' if ($desc =~ /8606/);
return '8610co' if ($desc =~ /8610co/);
return '8610' if ($desc =~ /8610/);
return $desc;
}
sub vendor {
return 'nortel';
}
sub os {
return 'passport';
}
sub os_ver {
my $passport = shift;
my $descr = $passport->description();
return undef unless defined $descr;
if ($descr =~ m/(\d+\.\d+\.\d+\.\d+)/){
return $1;
}
return undef;
}
sub i_index {
my $passport = shift;
my $i_index = $passport->i_index2();
my $vlan_index = $passport->rc_vlan_if();
my $cpu_index = $passport->rc_cpu_ifindex();
my $virt_ip = $passport->rc_virt_ip();
my %if_index;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
$if_index{$iid} = $index;
}
# Get VLAN Virtual Router Interfaces
foreach my $vid (keys %$vlan_index){
my $v_index = $vlan_index->{$vid};
next unless defined $v_index;
next if $v_index == 0;
$if_index{$v_index} = $v_index;
}
# Get CPU Ethernet Interfaces
foreach my $cid (keys %$cpu_index){
my $c_index = $cpu_index->{$cid};
next unless defined $c_index;
next if $c_index == 0;
$if_index{$c_index} = $c_index;
}
# Check for Virtual Mgmt Interface
unless ($virt_ip eq '0.0.0.0') {
# Make up an index number, 1 is not reserved AFAIK
$if_index{1} = 1;
}
return \%if_index;
}
sub interfaces {
my $passport = shift;
my $i_index = $passport->i_index();
my $vlan_id = $passport->rc_vlan_id();
my $vlan_index = $passport->rc_vlan_if();
my $model = $passport->model();
my %reverse_vlan = reverse %$vlan_index;
my %if;
foreach my $iid (keys %$i_index){
my $index = $i_index->{$iid};
next unless defined $index;
if ($index == 1) {
$if{$index} = 'CPU.Virtual';
}
elsif (($index == 192) and ($model eq '8603')) {
$if{$index} = 'CPU3';
}
elsif ($index == 320) {
$if{$index} = 'CPU5';
}
elsif ($index == 384) {
$if{$index} = 'CPU6';
}
elsif ($index > 2000) {
my $vlan_index = $reverse_vlan{$iid};
my $v_id = $vlan_id->{$vlan_index};
next unless defined $v_id;
my $v_port = 'V'."$v_id";
$if{$index} = $v_port;
}
else {
my $port = ($index % 64) + 1;
my $slot = int($index / 64);
my $slotport = "$slot.$port";
$if{$iid} = $slotport;
}
}
return \%if;
}
sub i_mac {
my $passport = shift;
my $i_mac = $passport->i_mac2();
my $vlan_mac = $passport->rc_vlan_mac();
my $vlan_index = $passport->rc_vlan_if();
my $cpu_mac = $passport->rc_cpu_mac();
my $chassis_base_mac = $passport->rc_base_mac();
my $virt_ip = $passport->rc_virt_ip();
my %if_mac;
foreach my $iid (keys %$i_mac){
my $mac = $i_mac->{$iid};
next unless defined $mac;
$if_mac{$iid} = $mac;
}
# Get VLAN Virtual Router Interfaces
foreach my $iid (keys %$vlan_mac){
my $v_mac = $vlan_mac->{$iid};
my $v_id = $vlan_index->{$iid};
next unless defined $v_mac;
$if_mac{$v_id} = $v_mac;
}
# Get CPU Ethernet Interfaces
foreach my $iid (keys %$cpu_mac){
my $mac = $cpu_mac->{$iid};
next unless defined $mac;
$if_mac{$iid} = $mac;
}
# Check for Virtual Mgmt Interface
unless ($virt_ip eq '0.0.0.0'){
my @virt_mac = split /:/, $chassis_base_mac;
$virt_mac[0] = hex($virt_mac[0]);
$virt_mac[1] = hex($virt_mac[1]);
$virt_mac[2] = hex($virt_mac[2]);
$virt_mac[3] = hex($virt_mac[3]);
$virt_mac[4] = hex($virt_mac[4]) + 0x03;
$virt_mac[5] = hex($virt_mac[5]) + 0xF8;
my $mac = join(':',map { sprintf "%02x",$_ } @virt_mac);
$if_mac{1} = $mac;
}
return \%if_mac;
}
sub i_description {
my $passport = shift;
my $i_descr = $passport->i_description2();
my $v_descr = $passport->rc_vlan_name();
my $vlan_index = $passport->rc_vlan_if();
my %descr;
foreach my $iid (keys %$i_descr){
my $if_descr = $i_descr->{$iid};
next unless defined $if_descr;
$descr{$iid} = $if_descr;
}
# Get VLAN Virtual Router Interfaces
foreach my $vid (keys %$v_descr){
my $vl_descr = $v_descr->{$vid};
my $v_id = $vlan_index->{$vid};
next unless defined $vl_descr;
$descr{$v_id} = $vl_descr;
}
return \%descr;
}
sub i_name {
my $passport = shift;
my $i_index = $passport->i_index();
my $rc_alias = $passport->rc_alias();
my $i_name2 = $passport->i_name2();
my $v_name = $passport->rc_vlan_name();
my $vlan_index = $passport->rc_vlan_if();
my $model = $passport->model();
my %reverse_vlan = reverse %$vlan_index;
my %i_name;
foreach my $iid (keys %$i_index){
if ($iid == 1) {
$i_name{$iid} = 'CPU Virtual Management IP';
}
elsif (($iid == 192) and ($model eq '8603')) {
$i_name{$iid} = 'CPU 3 Ethernet Port';
}
elsif ($iid == 320) {
$i_name{$iid} = 'CPU 5 Ethernet Port';
}
elsif ($iid == 384) {
$i_name{$iid} = 'CPU 5 Ethernet Port';
}
elsif ($iid > 2000) {
my $vlan_index = $reverse_vlan{$iid};
my $vlan_name = $v_name->{$vlan_index};
next unless defined $vlan_name;
$i_name{$iid} = $vlan_name;
}
else {
my $name = $i_name2->{$iid};
my $alias = $rc_alias->{$iid};
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ?
$alias :
$name;
}
}
return \%i_name;
}
sub ip_index {
my $passport = shift;
my $ip_index = $passport->ip_index2();
my $cpu_ip = $passport->rc_cpu_ip();
my $virt_ip = $passport->rc_virt_ip();
my %ip_index;
foreach my $ip (keys %$ip_index){
my $iid = $ip_index->{$ip};
next unless defined $iid;
$ip_index{$ip} = $iid;
}
# Get CPU Ethernet IP
foreach my $cid (keys %$cpu_ip){
my $c_ip = $cpu_ip->{$cid};
next unless defined $c_ip;
$ip_index{$c_ip} = $cid;
}
# Get Virtual Mgmt IP
$ip_index{$virt_ip} = 1;
return \%ip_index;
}
sub root_ip {
my $passport = shift;
my $rc_ip_addr = $passport->rc_ip_addr();
my $rc_ip_type = $passport->rc_ip_type();
my $virt_ip = $passport->rc_virt_ip();
my $router_ip = $passport->router_ip();
my $sonmp_topo_port = $passport->sonmp_topo_port();
my $sonmp_topo_ip = $passport->sonmp_topo_ip();
# Return CLIP (CircuitLess IP)
foreach my $iid (keys %$rc_ip_type){
my $ip_type = $rc_ip_type->{$iid};
next unless ((defined $ip_type) and ($ip_type =~ /circuitLess/i));
my $ip = $rc_ip_addr->{$iid};
next unless defined $ip;
return $ip;
}
# Return Management Virtual IP address
return $virt_ip if ((defined $virt_ip) and ($virt_ip ne '0.0.0.0'));
# Return OSPF Router ID
return $router_ip if ((defined $router_ip) and ($router_ip ne '0.0.0.0'));
# Otherwise Return SONMP Advertised IP Address
foreach my $entry (keys %$sonmp_topo_port){
my $port = $sonmp_topo_port->{$entry};
next unless $port == 0;
my $ip = $sonmp_topo_ip->{$entry};
return $ip if ((defined $ip) and ($ip ne '0.0.0.0'));
}
return undef;
}
# Required for SNMP::Info::SONMP
sub index_factor {
return 64;
}
sub slot_offset {
return 0;
}
sub port_offset {
return 1;
}
1;
__END__
=head1 NAME
SNMP::Info::Layer3::Passport - Perl5 Interface to Nortel Networks' Passport
8600 Series Switches
=head1 AUTHOR
Eric Miller (C<eric@jeneric.org>)
=head1 SYNOPSIS
# Let SNMP::Info determine the correct subclass for you.
my $passport = new SNMP::Info(
AutoSpecify => 1,
Debug => 1,
# These arguments are passed directly on to SNMP::Session
DestHost => 'myswitch',
Community => 'public',
Version => 2
)
or die "Can't connect to DestHost.\n";
my $class = $passport->class();
print "SNMP::Info determined this device to fall under subclass : $class\n";
=head1 DESCRIPTION
Abstraction subclass for Nortel Networks' Passport 8600 Series Switches.
These devices run Passport OS but have some of the same charactersitics as the Baystack family.
For example, extended interface information is gleened from RAPID-CITY.
For speed or debugging purposes you can call the subclass directly, but not after determining
a more specific class using the method above.
my $passport = new SNMP::Info::Layer3::Passport(...);
=head2 Inherited Classes
=over
=item SNMP::Info
=item SNMP::Info::Bridge
=item SNMP::Info::SONMP
=item SNMP::Info::RapidCity
=back
=head2 Required MIBs
=over
=item OSPF-MIB
=item Inherited Classes' MIBs
See SNMP::Info for its own MIB requirements.
See SNMP::Info::Bridge for its own MIB requirements.
See SNMP::Info::SONMP for its own MIB requirements.
See SNMP::Info::RapidCity for its own MIB requirements.
OSPF-MIB is included in the archive at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
=back
=head1 GLOBALS
These are methods that return scalar value from SNMP
=over
=item $passport->model()
Returns the model extracted from B<sysDescr>
=item $passport->vendor()
Returns 'Nortel'
=item $passport->os()
Returns 'Passport'
=item $passport->os_ver()
Returns the software version extracted from B<sysDescr>
=item $passport->serial()
Returns (B<rcChasSerialNumber>)
=item $passport->root_ip()
Returns the primary IP used to communicate with the device. Returns the first
found: CLIP (CircuitLess IP), Management Virtual IP (B<rcSysVirtualIpAddr>),
OSPF Router ID (B<ospfRouterId>), SONMP Advertised IP Address.
=back
=head2 Overrides
=over
=item $passport->index_factor()
Required by SNMP::Info::SONMP. Returns 64.
=item $passport->port_offset()
Required by SNMP::Info::SONMP. Returns 1.
=item $passport->slot_offset()
Required by SNMP::Info::SONMP. Returns 0.
=back
=head2 Globals imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Globals imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Global Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
=head2 Global Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
=head1 TABLE ENTRIES
These are methods that return tables of information in the form of a reference
to a hash.
=head2 Overrides
=over
=item $passport->i_index()
Returns SNMP IID to Interface index. Extends (B<ifIndex>) by adding the index of
the CPU virtual management IP (if present), each CPU Ethernet port, and each VLAN
to ensure the virtual router ports are captured.
=item $passport->interfaces()
Returns reference to the map between IID and physical Port.
Slot and port numbers on the Passport switches are determined by the formula:
port = (ifIndex % 64) + 1, slot = int(ifIndex / 64).
The physical port name is returned as slot.port. CPU Ethernet ports are prefixed
with CPU and VLAN interfaces are returned as the VLAN ID prefixed with V.
=item $passport->i_mac()
MAC address of the interface. Note this is just the MAC of the port, not anything
connected to it.
=item $passport->i_description()
Description of the interface. Usually a little longer single word name that is both
human and machine friendly. Not always.
=item $passport->i_name()
Crosses rc_alias() (B<rcPortName>) with ifAlias() and returns the human set port
name if exists.
=item $passport->ip_index()
Maps the IP Table to the IID. Extends (B<ipAdEntIfIndex>) by adding the index of
the CPU virtual management IP (if present) and each CPU Ethernet port.
=back
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
=over
=item $passport->at_index()
Returns reference to hash. Maps ARP table entries to Interface IIDs
(B<ipNetToMediaIfIndex>)
=item $passport->at_paddr()
Returns reference to hash. Maps ARP table entries to MAC addresses.
(B<ipNetToMediaPhysAddress>)
=item $passport->at_netaddr()
Returns reference to hash. Maps ARP table entries to IPs
(B<ipNetToMediaNetAddress>)
=back
=head2 Table Methods imported from SNMP::Info
See documentation in SNMP::Info for details.
=head2 Table Methods imported from SNMP::Info::Bridge
See documentation in SNMP::Info::Bridge for details.
=head2 Table Methods imported from SNMP::Info::SONMP
See documentation in SNMP::Info::SONMP for details.
=head2 Table Methods imported from SNMP::Info::RapidCity
See documentation in SNMP::Info::RapidCity for details.
=cut