Commit 5b32d198 authored by Robert Ricci's avatar Robert Ricci

The setVlanOnTrunk function can now take more than one VLAN number

(and so, has been renamed setVlansOnTrunk). Part of the work necessary
to get the stack-level setVlanOnTrunks function to accept multiple
VLANs in one call.
parent efb2d38e
......@@ -978,15 +978,15 @@ sub getStats ($) {
#
# Enable, or disable, port on a trunk
#
# usage: removeVlan(self, vlan_number, modport, value)
# vlan_number: The cisco-native VLAN top operate on
# usage: setVlansOnTrunk(self, modport, value, vlan_numbers)
# modport: module.port of the trunk to operate on
# value: 0 to disallow the VLAN on the trunk, 1 to allow it
# vlan_numbers: An array of cisco-native VLAN numbers operate on
# Returns 1 on success, 0 otherwise
#
sub setVlanOnTrunk($$$$) {
sub setVlansOnTrunk($$$$) {
my $self = shift;
my ($vlan_number, $modport, $value) = @_;
my ($modport, $value, @vlan_numbers) = @_;
#
# Some error checking
......@@ -994,7 +994,7 @@ sub setVlanOnTrunk($$$$) {
if (($value != 1) && ($value != 0)) {
die "Invalid value $value passed to setVlanOnTrunk\n";
}
if ($vlan_number == 1) {
if (grep(/^1$/,@vlan_numbers)) {
die "VLAN 1 passed to setVlanOnTrunk\n"
}
......@@ -1021,8 +1021,10 @@ sub setVlanOnTrunk($$$$) {
# Put this into an array of 1s and 0s for easy manipulation
my @bits = split //,$unpacked;
# Just set the bit of the one we want to change
$bits[$vlan_number] = $value;
# Just set the bit of the ones we want to change
foreach my $vlan_number (@vlan_numbers) {
$bits[$vlan_number] = $value;
}
# Pack it back up...
$unpacked = join('',@bits);
......
......@@ -497,8 +497,8 @@ sub setVlanOnTrunks($$$;@) {
# first
#
my $modport = $trunks{$src}{$dst}[0];
$errors += !($self->{DEVICES}{$src}->setVlanOnTrunk($vlan_number,
$modport,$value));
$errors += !($self->{DEVICES}{$src}->setVlansOnTrunk($modport,
$value,$vlan_number));
}
if (!$self->{DEVICES}{$dst}) {
warn "ERROR - Bad device $dst found in setVlanOnTrunks!\n";
......@@ -509,8 +509,8 @@ sub setVlanOnTrunks($$$;@) {
# first
#
my $modport = $trunks{$dst}{$src}[0];
$errors += !($self->{DEVICES}{$dst}->setVlanOnTrunk($vlan_number,
$modport,$value));
$errors += !($self->{DEVICES}{$dst}->setVlanOnTrunk($modport,
$value,$vlan_number));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment