version 1.11, 2006/08/23 01:37:20 |
version 1.13, 2006/09/07 03:39:36 |
|
|
package Net::Telnet::Trango;
|
package Net::Telnet::Trango;
|
# $RedRiver: Trango.pm,v 1.10 2006/07/31 22:16:52 andrew Exp $
|
# $RedRiver: Trango.pm,v 1.12 2006/08/31 21:29:53 andrew Exp $
|
use strict;
|
use strict;
|
use warnings;
|
use warnings;
|
use base 'Net::Telnet';
|
use base 'Net::Telnet';
|
|
|
|
|
=pod
|
=pod
|
|
|
|
=item su_ipconfig
|
|
|
|
C<su_ipconfig( 'suid', 'new_ip', 'new_subnet', 'new_gateway' )>
|
|
|
|
=cut
|
|
|
|
sub su_ipconfig
|
|
{
|
|
my $self = shift;
|
|
|
|
my $suid = shift;
|
|
my $new_ip = shift;
|
|
my $new_subnet = shift;
|
|
my $new_gateway = shift;
|
|
|
|
return undef unless $suid =~ /^\d+$/;
|
|
return undef unless $new_ip;
|
|
return undef unless $new_subnet;
|
|
return undef unless $new_gateway;
|
|
|
|
# su ipconfig <suid> <new ip> <new subnet> <new gateway>
|
|
return $self->cmd(String => 'su ipconfig ' .
|
|
$suid . ' ' .
|
|
$new_ip . ' ' .
|
|
$new_subnet . ' ' .
|
|
$new_gateway,
|
|
expect => $success,
|
|
);
|
|
}
|
|
|
|
=pod
|
|
|
=item sudb_view
|
=item sudb_view
|
|
|
returns a reference to an array of hashes each containing:
|
returns a reference to an array of hashes each containing:
|
|
|
my @lines = @_;
|
my @lines = @_;
|
my @decoded;
|
my @decoded;
|
my $total_entries = 0;
|
my $total_entries = 0;
|
|
my $current_tm = 0;
|
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
$line =~ s/\r?\n$//;
|
$line =~ s/\r?\n$//;
|
my ($mac, $loc, $tm) = $line =~ /
|
my ($mac, $loc, $tm) = $line =~ /
|
|
|
loc => $loc,
|
loc => $loc,
|
tm => $tm,
|
tm => $tm,
|
suid => $suid,
|
suid => $suid,
|
|
cur_tm => \$current_tm,
|
};
|
};
|
} elsif ($line =~ /(\d+)\s+entries/) {
|
} elsif ($line =~ /(\d+)\s+entries/) {
|
$total_entries = $1;
|
$total_entries = $1;
|
|
} elsif ($line =~ /current tm = (\d+)\s+sec/) {
|
|
$current_tm = $1
|
}
|
}
|
}
|
}
|
if (scalar @decoded == $total_entries) {
|
if (scalar @decoded == $total_entries) {
|