Commit 070d4a56 authored by Mac Newbold's avatar Mac Newbold
Browse files

Small set of changes to make snmpit work correctly for the control router. I...

Small set of changes to make snmpit work correctly for the control router. I also added entries in the database for ports that are in vlans (other than the default #1) that aren't connected to a node in the database. So, from now on, when an empty port is in a vlan, we need to put an entry in the wires table that says its connected to node 'empty' on some unused port number.
parent 87c88fa4
...@@ -13,6 +13,23 @@ ...@@ -13,6 +13,23 @@
my $TB = "@prefix@"; my $TB = "@prefix@";
my $DBNAME = "@TBDBNAME@"; my $DBNAME = "@TBDBNAME@";
# snmpit uses modules that implement the interface to a given switch
# model. These modules should support these actions:
#
# new Needs to take IP, and initialize snmp session
# portControl (cmd,ports)
# cmd = {enable, disable, 10mbit, 100mbit, full, half,
# auto, manual}
# ports = list of "pcX:Y"
# showPorts print settings of all ports
# getStats print various stats
# vlanLock Get a vlan editing lock/token/buffer, and
# vlanUnlock Release it when done
# setupVlan (ports) - takes a list of ports, and vlans them
# removeVlan (vlans) - takes a list of vlan numbers
# listVlans returns a list of entries, with each entry having an
# ID, a name, and a list of members (pcX:Y)
# #
# Source Code Map # Source Code Map
# =============== # ===============
...@@ -770,10 +787,10 @@ sub num { $a <=> $b; } ...@@ -770,10 +787,10 @@ sub num { $a <=> $b; }
sub alphanum { sub alphanum {
$a =~ /^([a-z]*)([0-9]*)/; $a =~ /^([a-z]*)([0-9]*)/;
$a_let = $1; $a_let = $1;
$a_num = $2; $a_num = ($2 || 0);
$b =~ /^([a-z]*)([0-9]*)/; $b =~ /^([a-z]*)([0-9]*)/;
$b_let = $1; $b_let = $1;
$b_num = $2; $b_num = ($2 || 0);
if ($a_let eq $b_let) { if ($a_let eq $b_let) {
return $a_num <=> $b_num; return $a_num <=> $b_num;
} else { } else {
...@@ -851,9 +868,9 @@ sub ListVLANs { ...@@ -851,9 +868,9 @@ sub ListVLANs {
my @vlan=(); my @vlan=();
if (defined (@{$Members{$data[2]}})) { @vlan =@{$Members{$data[2]}}; } if (defined (@{$Members{$data[2]}})) { @vlan =@{$Members{$data[2]}}; }
print "('$data[1]' " if $debug; print "('$data[1]' " if $debug;
$node = $Ports{"$i:$data[1]"}; ($node = $Ports{"$i:$data[1]"}) || ($node = "???");
print "== $node)\n" if $debug; print "== $node)\n" if $debug;
push(@vlan, $node); push(@vlan, $node) unless ($node =~ /^empty:/);
$Members{$data[2]} = \@vlan; $Members{$data[2]} = \@vlan;
#do the getnext at the end, because if we're on the last, the next #do the getnext at the end, because if we're on the last, the next
#one is junk to all the processing instructions... #one is junk to all the processing instructions...
...@@ -861,7 +878,7 @@ sub ListVLANs { ...@@ -861,7 +878,7 @@ sub ListVLANs {
$RetVal = $sess->getnext($VlanPortVlan); $RetVal = $sess->getnext($VlanPortVlan);
@data = @{$VlanPortVlan}; @data = @{$VlanPortVlan};
} while ( $data[0] =~ /^vlanPortVlan/ ) ; } while ( $data[0] =~ /^vlanPortVlan/ ) ;
} else { } else {
die("Invalid option 'list VLANs' for device of type $device.\n"); die("Invalid option 'list VLANs' for device of type $device.\n");
} }
...@@ -870,7 +887,7 @@ sub ListVLANs { ...@@ -870,7 +887,7 @@ sub ListVLANs {
my $id; my $id;
# I'm trying out using formats. See perldoc perlform for details. # I'm trying out using formats. See perldoc perlform for details.
format = format =
@<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
($id),($Names{$id}),(defined(@{$Members{$id}})?join(" ",sort alphanum (@{$Members{$id}})):"") ($id),($Names{$id}),(defined(@{$Members{$id}})?join(" ",sort alphanum (@{$Members{$id}})):"")
. .
foreach $id ( sort num keys (%Names) ) { foreach $id ( sort num keys (%Names) ) {
......
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