Add i_speed_high(), which i_speed() uses if needed to support

interfaces >4Gbps
This commit is contained in:
Bill Fenner
2006-04-06 20:50:46 +00:00
parent 3db7164f9f
commit 3c4b8911f5
2 changed files with 63 additions and 2 deletions

View File

@@ -30,6 +30,10 @@ version 1.0 ()
+ Added set_i_duplex_admin() and set_i_speed_admin() to CiscoStack class + Added set_i_duplex_admin() and set_i_speed_admin() to CiscoStack class
+ CDP added to Aironet class + CDP added to Aironet class
+ Added Juniper class + Added Juniper class
+ Added support for Catalyst 4000 and 4500, get admin. duplex
and speed properly
+ Added i_speed_high(), which i_speed() uses if needed to support
interfaces >4Gbps
* More error checking in _load_attr() around bulkwalk code * More error checking in _load_attr() around bulkwalk code
* Minor warning fix in L3::Aironet::os_ver() * Minor warning fix in L3::Aironet::os_ver()
@@ -52,6 +56,8 @@ version 1.0 ()
* Check root ip for reachability before assignment * Check root ip for reachability before assignment
* HP class should recognize more models * HP class should recognize more models
* Fix in HP class for models not returning full bp_index * Fix in HP class for models not returning full bp_index
* [ 1436103 ] L2::Aironet devices weren't getting their model
translated properly
verison 0.9 (11/15/04) verison 0.9 (11/15/04)
+ ** Added full Nortel/Bay/BayStack support + ** Added full Nortel/Bay/BayStack support

59
Info.pm
View File

@@ -1220,7 +1220,30 @@ INTEGER. Interface MTU value.
Speed of the link, human format. See munge_speed() later in document for details. Speed of the link, human format. See munge_speed() later in document for details.
(B<ifSpeed>) (B<ifSpeed>, B<ifHighSpeed> if necessary)
=cut
sub i_speed {
my $l3 = shift;
my $i_speed = $l3->orig_i_speed();
my $i_speed_high = undef;
foreach my $i (keys %$i_speed) {
if ($i_speed->{$i} eq "4294967295") {
$i_speed_high = $l3->i_speed_high() unless defined($i_speed_high);
$i_speed->{$i} = $i_speed_high->{$i} if ($i_speed_high->{$i});
}
}
return $i_speed;
}
=item $info->i_speed_high()
Speed of a high-speed link, human format. See munge_highspeed() later in
document for details. You should not need to call this directly, as
i_speed() will call it if it needs to.
(B<ifHighSpeed>)
=item $info->i_mac() =item $info->i_mac()
@@ -1244,7 +1267,7 @@ Administrative status of the port. Typical values are 'enabled' and 'disabled'.
The value of sysUpTime when this port last changed states (up,down). The value of sysUpTime when this port last changed states (up,down).
(B<IfLastChange>) (B<ifLastChange>)
=item $info->i_name() =item $info->i_name()
@@ -1619,6 +1642,7 @@ These are table entries, such as the IfIndex
'ip_netmask' => 'ipAdEntNetMask', 'ip_netmask' => 'ipAdEntNetMask',
'ip_broadcast' => 'ipAdEntBcastAddr', 'ip_broadcast' => 'ipAdEntBcastAddr',
# ifXTable - Extension Table # ifXTable - Extension Table
'i_speed_high' => 'ifHighSpeed',
'i_pkts_multi_in' => 'ifInMulticastPkts', 'i_pkts_multi_in' => 'ifInMulticastPkts',
'i_pkts_multi_out' => 'ifOutMulticastPkts', 'i_pkts_multi_out' => 'ifOutMulticastPkts',
'i_pkts_bcast_in' => 'ifInBroadcastPkts', 'i_pkts_bcast_in' => 'ifInBroadcastPkts',
@@ -1685,6 +1709,7 @@ Sample %MUNGE:
'i_mac' => \&munge_mac, 'i_mac' => \&munge_mac,
'layers' => \&munge_dec2bin, 'layers' => \&munge_dec2bin,
'i_speed' => \&munge_speed, 'i_speed' => \&munge_speed,
'i_speed_high' => \&munge_highspeed,
'i_octet_in64' => \&munge_counter64, 'i_octet_in64' => \&munge_counter64,
'i_octet_out64' => \&munge_counter64, 'i_octet_out64' => \&munge_counter64,
'i_pkts_ucast_in64' => \&munge_counter64, 'i_pkts_ucast_in64' => \&munge_counter64,
@@ -1857,6 +1882,7 @@ Makes human friendly speed ratings using %SPEED_MAP
%SPEED_MAP = ( %SPEED_MAP = (
'56000' => '56 kbps', '56000' => '56 kbps',
'64000' => '64 kbps', '64000' => '64 kbps',
'115000' => '115 kpbs',
'1500000' => '1.5 Mbps', '1500000' => '1.5 Mbps',
'1536000' => 'T1', '1536000' => 'T1',
'1544000' => 'T1', '1544000' => 'T1',
@@ -1875,6 +1901,8 @@ Makes human friendly speed ratings using %SPEED_MAP
'45000000' => '45 Mbps', '45000000' => '45 Mbps',
'45045000' => 'DS3', '45045000' => 'DS3',
'46359642' => 'DS3', '46359642' => 'DS3',
'51850000' => 'OC-1',
'54000000' => '54 Mbps',
'64000000' => '64 Mbps', '64000000' => '64 Mbps',
'100000000' => '100 Mbps', '100000000' => '100 Mbps',
'149760000' => 'ATM on OC-3', '149760000' => 'ATM on OC-3',
@@ -1913,6 +1941,7 @@ Makes human friendly speed ratings using %SPEED_MAP
'45045000' => 'DS3', '45045000' => 'DS3',
'46359642' => 'DS3', '46359642' => 'DS3',
'51850000' => 'OC-1', '51850000' => 'OC-1',
'54000000' => '54 Mbps',
'64000000' => '64 Mbps', '64000000' => '64 Mbps',
'100000000' => '100 Mbps', '100000000' => '100 Mbps',
'149760000' => 'ATM on OC-3', '149760000' => 'ATM on OC-3',
@@ -1934,6 +1963,32 @@ sub munge_speed {
return $map || $speed; return $map || $speed;
} }
=item munge_highspeed()
Makes human friendly speed ratings for ifHighSpeed
=cut
sub munge_highspeed {
my $speed = shift;
my $fmt = "%d Mbps";
if ($speed > 9999999) {
$fmt = "%d Tbps";
$speed /= 1000000;
} elsif ($speed > 999999) {
$fmt = "%.1f Tbps";
$speed /= 1000000.0;
} elsif ($speed > 9999) {
$fmt = "%d Gbps";
$speed /= 1000;
} elsif ($speed > 999) {
$fmt = "%.1f Gbps";
$speed /= 1000.0;
}
return sprintf($fmt, $speed);
}
=item munge_ip() =item munge_ip()
Takes a binary IP and makes it dotted ASCII Takes a binary IP and makes it dotted ASCII