Justin Hunter's patch, SF ID 1341140, add set_i_duplex_admin and set_i_speed_admin methods

This commit is contained in:
Eric Miller
2005-11-13 04:18:33 +00:00
parent 3a1d04eb38
commit f5dba96839

View File

@@ -136,6 +136,54 @@ sub i_duplex_admin {
return \%i_duplex_admin;
}
### we want to be able to set speed on 2900 class switches
###
### $info->set_i_speed_admin("100", ifIndex);
### speed choices are 'auto', '10', '100'
###
sub set_i_speed_admin {
# map speeds to those the switch will understand
my %speeds = qw/auto 1 10 10000000 100 100000000/;
my $c2900 = shift;
my ($speed, $iid) = @_;
my $c2900_p_index = $c2900->c2900_p_index();
my %reverse_2900 = reverse %$c2900_p_index;
$speed = lc($speed);
return 0 unless defined $speeds{$speed};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_speed_admin($speeds{$speed}, $iid);
}
### we want to be able to set duplex on 2900 class switches
###
### $info->set_i_duplex_admin("half", ifIndex);
### duplex choices are 'auto', 'half', 'full'
###
sub set_i_duplex_admin {
# map a textual duplex to an integer one the switch understands
my %duplexes = qw/full 1 half 2 auto 3/;
my $c2900 = shift;
my ($duplex, $iid) = @_;
my $c2900_p_index = $c2900->c2900_p_index();
my %reverse_2900 = reverse %$c2900_p_index;
$duplex = lc($duplex);
return 0 unless defined $duplexes{$duplex};
# account for weirdness of c2900 mib
$iid = $reverse_2900{$iid};
return $c2900->set_c2900_p_duplex_admin($duplexes{$duplex}, $iid);
}
# Use i_descritption for port key, cuz i_name can be manually entered.
sub interfaces {
my $c2900 = shift;
@@ -273,7 +321,34 @@ to a hash.
Returns reference to hash of IIDs to admin duplex setting
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin;
=item $c2900->set_i_speed_admin(speed, ifIndex)
Sets port speed, must be supplied with speed and port ifIndex
Speed choices are 'auto', '10', '100'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin to
utilize port ifIndex.
Example:
my %if_map = reverse %{$info->interfaces()};
$info->set_i_up_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port speed. ",$info->error(1);
=item $c2900->set_i_duplex_admin(duplex, ifIndex)
Sets port duplex, must be supplied with duplex and port ifIndex
Speed choices are 'auto', 'half', 'full'
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin to
utilize port ifIndex.
Example:
my %if_map = reverse %{$info->interfaces()};
$info->set_i_up_admin('auto', $if_map{'FastEthernet0/1'})
or die "Couldn't change port duplex. ",$info->error(1);
=back