Update of /cvsroot/netpass/NetPass/lib/NetPass
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32033/lib/NetPass
Modified Files:
DB.pm
Log Message:
various changes to reporting, nothing major
Index: DB.pm
===================================================================
RCS file: /cvsroot/netpass/NetPass/lib/NetPass/DB.pm,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- DB.pm 1 Sep 2005 18:27:20 -0000 1.56
+++ DB.pm 5 Jan 2006 21:02:35 -0000 1.57
@@ -300,7 +300,7 @@
return 0;
}
-=head2 $rv = getRegisterInfo(-mac => mac, -macs => [], -ip => ip, -ips => [])
+=head2 $rv = getRegisterInfo(-mac => mac, -macs => [], -ip => ip, -ips => [], -switch => ip, -port => number)
This routine will get the registered info on an already registered MAC. Returns:
@@ -308,11 +308,17 @@
=item C<HASHREF>
-containing keys that correspond to the macAddresses given.
-values of C<HASHREF> are C<HASHREF>s containing keys: ipAddress, lastSeen,
-registeredOn, status, message, username, OS, switchIP, switchPort, uqlinkup.
+keys in the hash contain either macAddresses or IP Addresses.
+If you specify the B<mac>, B<macs> or B<switch>/B<port> parameters
+then the keys are mac addresses. If you specify the B<ip> or
+B<ips> parameters, then the keys are IP Addresses.
-If the Mac is not registered, it won't be in the HASHREF returned.
+values of C<HASHREF> are themselves C<HASHREF>s containing
+keys: ipAddress, lastSeen, registeredOn, status, message,
+username, OS, switchIP, switchPort, uqlinkup.
+
+If no matches are found (e.g. the Mac is not registered),
+the HASREF will be empty.
on success
@@ -336,19 +342,23 @@
my $parms = parse_parms({
-parms => \@_,
- -legal => [ qw(-mac -macs -ip -ips) ],
- -defaults => { -mac => '',
- -macs => [],
- -ip => '',
- -ips => []
+ -legal => [ qw(-mac -macs -ip -ips -switch -port) ],
+ -defaults => { -mac => '',
+ -macs => [],
+ -ip => '',
+ -ips => [],
+ -switch => '',
+ -port => ''
}
}
);
return "invalid params\n".Carp::longmess(Class::ParmList->error) if (!defined($parms));
- my ($mac, $macs, $ip, $ips) = $parms->get('-mac', '-macs',
- '-ip', '-ips');
+ my ($mac, $macs, $ip, $ips, $switch, $port) =
+ $parms->get('-mac', '-macs',
+ '-ip', '-ips',
+ '-switch', '-port');
my $sql = "SELECT macAddress, ipAddress, lastSeen, registeredOn, status, username, OS, switchIP, switchPort, uqlinkup FROM register WHERE ";
if ($mac ne "") {
@@ -359,6 +369,11 @@
$sql .= " ipAddress = ".$self->dbh->quote($ip);
$kfield = "ipAddress";
}
+ elsif ($switch ne "" && $port ne "") {
+ $sql .= " ( switchIP = ".$self->dbh->quote($switch) .
+ " AND switchPort = ".$self->dbh->quote($port) . " ) ";
+ $kfield = "macAddress";
+ }
elsif ($#{$macs} > -1) {
$sql .= join (" OR ", (map (" macAddress = ".$self->dbh->quote($_), @{$macs})));
$kfield = "macAddress";
@@ -367,13 +382,16 @@
$sql .= join (" OR ", (map (" ipAddress = ".$self->dbh->quote($_), @{$ip})));
$kfield = "ipAddress";
}
+ elsif (($switch && !$port) || (!$switch && $port)) {
+ return "invalid parameters";
+ }
my $a = $self->{'dbh'}->selectall_hashref($sql, $kfield);
return $a if (defined($a) && (ref($a) eq "HASH"));
_log "ERROR", "select failed: ".$self->{'dbh'}->errstr."\n";
- return undef;
+ return "db failure ". $self->{'dbh'}->errstr;
}
=head2 $msg = getPageList(-name => $name, -group => '')
|