version 1.7, 2006/06/28 23:33:18 |
version 1.10, 2006/07/31 23:16:52 |
|
|
package Net::Telnet::Trango;
|
package Net::Telnet::Trango;
|
# $RedRiver: Trango.pm,v 1.6 2006/06/28 22:00:15 andrew Exp $
|
# $RedRiver: Trango.pm,v 1.9 2006/07/14 01:17:29 andrew Exp $
|
use strict;
|
use strict;
|
use warnings;
|
use warnings;
|
use base 'Net::Telnet';
|
use base 'Net::Telnet';
|
|
|
|
|
Same as new from L<Net::Telnet> but has defaults for the trango 'Prompt'
|
Same as new from L<Net::Telnet> but has defaults for the trango 'Prompt'
|
|
|
|
It also takes an optional parameter 'Decode'. If not defined it
|
|
defaults to 1, if it is set to 0, it will not decode the output and
|
|
instead return an array of the lines that were returned from the
|
|
command.
|
|
|
=cut
|
=cut
|
|
|
sub new
|
sub new
|
|
|
foreach my $key (keys %args) {
|
foreach my $key (keys %args) {
|
$PRIVATE{$key} = $args{$key};
|
$PRIVATE{$key} = $args{$key};
|
}
|
}
|
|
$PRIVATE{'Decode'} = 1 unless defined $PRIVATE{'Decode'};
|
|
delete $args{'Decode'};
|
|
|
my $self = $class->SUPER::new(%args);
|
my $self = $class->SUPER::new(%args);
|
bless $self if ref $self;
|
bless $self if ref $self;
|
|
|
|
|
returns an array ref of hashes containing each log line.
|
returns an array ref of hashes containing each log line.
|
|
|
|
=item save_sudb
|
|
|
|
returns true on success, undef on failure
|
|
|
|
=item syslog
|
|
|
|
returns the output from the syslog command
|
|
|
|
=item pipe
|
|
|
|
returns the output from the pipe command
|
|
|
|
=item maclist
|
|
|
|
returns the output from the maclist command
|
|
|
|
=item maclist_reset
|
|
|
|
resets the maclist. No useful output.
|
|
|
|
=item eth_list
|
|
|
|
returns the output from the eth list command
|
|
|
=cut
|
=cut
|
|
|
|
|
|
|
sulog => { decode => 'sulog', expect => $success },
|
sulog => { decode => 'sulog', expect => $success },
|
'exit' => { no_prompt => 1, cmd_disconnects => 1 },
|
'exit' => { no_prompt => 1, cmd_disconnects => 1 },
|
reboot => { no_prompt => 1, cmd_disconnects => 1 },
|
reboot => { no_prompt => 1, cmd_disconnects => 1 },
|
sudb_save => { String => "sudb save", expect => $success },
|
save_sudb => { String => 'save sudb', expect => $success },
|
|
syslog => { expect => $success },
|
|
'pipe' => { }, # XXX needs a special decode
|
|
maclist => { }, # XXX needs a special decode and a special expect
|
|
maclist_reset => { String => 'maclist reset', expect => 'done' },
|
|
eth_link => { String => 'eth link', expect => $success },
|
|
# eth r, w and reset???
|
#su password???
|
#su password???
|
#_bootloader
|
#_bootloader
|
#temp
|
#temp
|
|
|
);
|
);
|
}
|
}
|
|
|
|
|
=pod
|
=pod
|
|
|
=item sudb_view
|
=item sudb_view
|
|
|
|
|
return undef unless @lines;
|
return undef unless @lines;
|
|
|
|
unless ($PRIVATE{'Decode'}) {
|
|
return @lines;
|
|
}
|
|
|
my @sus;
|
my @sus;
|
foreach (@lines) {
|
foreach (@lines) {
|
|
next unless $_;
|
if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9A-Fa-f\s]+)$/) {
|
if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9A-Fa-f\s]+)$/) {
|
my %s = (
|
my %s = (
|
suid => $1,
|
suid => $1,
|
|
|
|
|
and returns true on success or undef otherwise.
|
and returns true on success or undef otherwise.
|
|
|
You should sudb_save() after calling this, or your changes will be lost
|
You should save_sudb() after calling this, or your changes will be lost
|
when the AP is rebooted.
|
when the AP is rebooted.
|
|
|
=cut
|
=cut
|
|
|
Takes either 'all' or the suid of the su to delete
|
Takes either 'all' or the suid of the su to delete
|
and returns true on success or undef otherwise.
|
and returns true on success or undef otherwise.
|
|
|
You should sudb_save() after calling this, or your changes will be lost
|
You should save_sudb() after calling this, or your changes will be lost
|
when the AP is rebooted.
|
when the AP is rebooted.
|
|
|
=cut
|
=cut
|
|
|
return $self->cmd( String => 'sudb delete ' . $suid, expect => $success );
|
return $self->cmd( String => 'sudb delete ' . $suid, expect => $success );
|
}
|
}
|
|
|
|
|
=pod
|
=pod
|
|
|
=item sudb_modify
|
=item sudb_modify
|
|
|
|
|
su2su takes a group id parameter that is in hex.
|
su2su takes a group id parameter that is in hex.
|
|
|
You should sudb_save() after calling this, or your changes will be lost
|
You should save_sudb() after calling this, or your changes will be lost
|
when the AP is rebooted.
|
when the AP is rebooted.
|
|
|
=cut
|
=cut
|
|
|
);
|
);
|
|
|
my %cfg;
|
my %cfg;
|
if (@_ == 2) {
|
if (@_ == 1) {
|
$cfg{'String'} = shift;
|
$cfg{'String'} = shift;
|
} elsif (@_ > 2) {
|
} elsif (@_ > 1) {
|
%cfg = @_;
|
%cfg = @_;
|
}
|
}
|
|
|
|
|
$self->last_lines(\@lines);
|
$self->last_lines(\@lines);
|
|
|
my $vals = 1;
|
my $vals = 1;
|
if ($cfg{'decode'}) {
|
if ($PRIVATE{'Decode'} && $cfg{'decode'}) {
|
if ($cfg{'decode'} eq 'each') {
|
if ($cfg{'decode'} eq 'each') {
|
$vals = _decode_each_line(@lines);
|
$vals = _decode_each_line(@lines);
|
} elsif ($cfg{'decode'} eq 'sulog') {
|
} elsif ($cfg{'decode'} eq 'sulog') {
|
|
|
$self->is_connected(0);
|
$self->is_connected(0);
|
}
|
}
|
|
|
if ($cfg{'decode'}) {
|
if ($PRIVATE{'Decode'} && $cfg{'decode'}) {
|
return $vals;
|
return $vals;
|
} else {
|
} else {
|
return @lines;
|
return @lines;
|