| version 1.3, 2005/12/30 19:26:06 |
version 1.4, 2005/12/30 20:26:41 |
|
|
| package Net::Telnet::Trango;
|
package Net::Telnet::Trango;
|
| # $RedRiver: Trango.pm,v 1.2 2005/12/30 01:02:41 andrew Exp $
|
# $RedRiver: Trango.pm,v 1.3 2005/12/30 19:26:06 andrew Exp $
|
| use strict;
|
use strict;
|
| use warnings;
|
use warnings;
|
| use base 'Net::Telnet';
|
use base 'Net::Telnet';
|
|
|
|
|
|
| =pod
|
=pod
|
|
|
|
| |
=item new
|
| |
|
| |
Same as new from L<Net::Telnet> but has defaults for the trango 'Prompt'
|
| |
|
| |
=cut
|
| |
|
| |
sub new
|
| |
{
|
| |
my $class = shift;
|
| |
|
| |
my %args;
|
| |
if (@_ == 1) {
|
| |
$args{'Host'} = shift;
|
| |
} else {
|
| |
%args = @_;
|
| |
}
|
| |
|
| |
$args{'Prompt'} ||= '/#> *$/';
|
| |
|
| |
foreach my $key (keys %args) {
|
| |
$PRIVATE{$key} = $args{$key};
|
| |
}
|
| |
|
| |
my $self = $class->SUPER::new(%args);
|
| |
bless $self if ref $self;
|
| |
|
| |
return $self;
|
| |
}
|
| |
|
| |
# _password <new password> <new password>
|
| |
# ? [command]
|
| |
# apsearch <secs> <ch#> <h|v> [<ch#> <h|v>]...
|
| |
# arp -bcast <on|off>
|
| |
# bcastscant <all|suid> <ch#> <h|v> [<ch#> <h|v> ...
|
| |
# bye
|
| |
# cf2cf ap [default|<size>]
|
| |
# date
|
| |
# date <month> <day> <year>
|
| |
# freq scantable
|
| |
# freq channeltable
|
| |
# freq writescan [<ch#> <h|v>]
|
| |
# freq writechannel [<ch#> <freq>] ...
|
| |
# freq <ch #> <h|v>
|
| |
# help [command]
|
| |
# heater [<on temp> <off temp>]
|
| |
# ipconfig [<new ip> <new subnet mask> <new gateway>]
|
| |
# log [<# of entries, 1..179>]
|
| |
# log <sum> <# of entries, 1..179>
|
| |
# logout
|
| |
# opmode [ap [y]]
|
| |
# password
|
| |
# ping <ip addr>
|
| |
# polar <h|v>
|
| |
# power <setism|setunii> <max|min|<dBm>>
|
| |
# reboot
|
| |
# restart
|
| |
# remarks [<str>]
|
| |
# rfrxthreshold [<ism|unii> <-90|-85|-80|-75|-70|-65>]
|
| |
# rfrxth [<ism|unii> <-90|-85|-80|-75|-70|-65>]
|
| |
# sysinfo
|
| |
# set suid <id>
|
| |
# set apid <id>
|
| |
# set baseid <id>
|
| |
# set defaultopmode [<ap|su> <min,0..10>]
|
| |
# set defaultopmode off
|
| |
# set snmpcomm [<read | write | trap (id or setall)> <str>]
|
| |
# set mir [on|off]
|
| |
# set mir threshold <kbps>
|
| |
# set rssitarget [<ism|unii> <dBm>]
|
| |
# set serviceradius [<ism | unii> <miles>]
|
| |
# ssrssi <ch #> <h|v>
|
| |
# su [<suid>|all]
|
| |
# su changechannel <all|suid> <ch#> <h|v>
|
| |
# su ipconfig <suid> <new ip> <new subnet> <new gateway>
|
| |
# su [live|poweroff|priority]
|
| |
# su <ping|info|status> <suid>
|
| |
# su powerleveling <all|suid>
|
| |
# su reboot <all|suid>
|
| |
# su restart <all|suid>
|
| |
# su testrflink <all|suid> [r]
|
| |
# su testrflink <setlen> [64..1600]
|
| |
# su testrflink <aptx> [20..100]
|
| |
# su sw <suid|all> <sw #> <on|off>
|
| |
# sudb [dload | view]
|
| |
# sudb add <suid> pr <cir,kbps> <mir,kbps> <device id,hex>
|
| |
# sudb add <suid> reg <cir,kbps> <mir,kbps> <device id,hex>
|
| |
# sudb delete <all|<suid>>
|
| |
# sudb modify <suid> <cir|mir> <kbps>
|
| |
# sudb modify <suid> <su2su> <group id,hex>
|
| |
# sudb view
|
| |
# sulog [lastmins | sampleperiod <1..60>]
|
| |
# sulog [<# of entry,1..18>]
|
| |
# survey <ism|unii> <time, sec> <h|v>
|
| |
# sw [<sw #> <on|off>]
|
| |
# temp
|
| |
# tftpd [on|off]
|
| |
# time
|
| |
# time <hour> <min> <sec>
|
| |
# save <mainimage|fpgaimage> <current chksum> <new chksum>
|
| |
# save <systemsetting|sudb>
|
| |
# updateflash <mainimage|fpgaimage> <current chksum> <new chksum>
|
| |
# updateflash <systemsetting|sudb>
|
| |
|
| |
=pod
|
| |
|
| =head1 METHODS
|
=head1 METHODS
|
|
|
|
| =head2 ACCESSORS
|
=head2 ACCESSORS
|
|
|
|
|
|
| reboots the trango and closes the connection
|
reboots the trango and closes the connection
|
|
|
|
| =cut
|
=item sulog
|
|
|
|
| # _password <new password> <new password>
|
returns an array ref of hashes containing each log line.
|
| # ? [command]
|
|
| # apsearch <secs> <ch#> <h|v> [<ch#> <h|v>]...
|
|
| # arp -bcast <on|off>
|
|
| # bcastscant <all|suid> <ch#> <h|v> [<ch#> <h|v> ...
|
|
| # bye
|
|
| # cf2cf ap [default|<size>]
|
|
| # date
|
|
| # date <month> <day> <year>
|
|
| # freq scantable
|
|
| # freq channeltable
|
|
| # freq writescan [<ch#> <h|v>]
|
|
| # freq writechannel [<ch#> <freq>] ...
|
|
| # freq <ch #> <h|v>
|
|
| # help [command]
|
|
| # heater [<on temp> <off temp>]
|
|
| # ipconfig [<new ip> <new subnet mask> <new gateway>]
|
|
| # log [<# of entries, 1..179>]
|
|
| # log <sum> <# of entries, 1..179>
|
|
| # logout
|
|
| # opmode [ap [y]]
|
|
| # password
|
|
| # ping <ip addr>
|
|
| # polar <h|v>
|
|
| # power <setism|setunii> <max|min|<dBm>>
|
|
| # reboot
|
|
| # restart
|
|
| # remarks [<str>]
|
|
| # rfrxthreshold [<ism|unii> <-90|-85|-80|-75|-70|-65>]
|
|
| # rfrxth [<ism|unii> <-90|-85|-80|-75|-70|-65>]
|
|
| # sysinfo
|
|
| # set suid <id>
|
|
| # set apid <id>
|
|
| # set baseid <id>
|
|
| # set defaultopmode [<ap|su> <min,0..10>]
|
|
| # set defaultopmode off
|
|
| # set snmpcomm [<read | write | trap (id or setall)> <str>]
|
|
| # set mir [on|off]
|
|
| # set mir threshold <kbps>
|
|
| # set rssitarget [<ism|unii> <dBm>]
|
|
| # set serviceradius [<ism | unii> <miles>]
|
|
| # ssrssi <ch #> <h|v>
|
|
| # su [<suid>|all]
|
|
| # su changechannel <all|suid> <ch#> <h|v>
|
|
| # su ipconfig <suid> <new ip> <new subnet> <new gateway>
|
|
| # su [live|poweroff|priority]
|
|
| # su <ping|info|status> <suid>
|
|
| # su powerleveling <all|suid>
|
|
| # su reboot <all|suid>
|
|
| # su restart <all|suid>
|
|
| # su testrflink <all|suid> [r]
|
|
| # su testrflink <setlen> [64..1600]
|
|
| # su testrflink <aptx> [20..100]
|
|
| # su sw <suid|all> <sw #> <on|off>
|
|
| # sudb [dload | view]
|
|
| # sudb add <suid> pr <cir,kbps> <mir,kbps> <device id,hex>
|
|
| # sudb add <suid> reg <cir,kbps> <mir,kbps> <device id,hex>
|
|
| # sudb delete <all|<suid>>
|
|
| # sudb modify <suid> <cir|mir> <kbps>
|
|
| # sudb modify <suid> <su2su> <group id,hex>
|
|
| # sudb view
|
|
| # sulog [lastmins | sampleperiod <1..60>]
|
|
| # sulog [<# of entry,1..18>]
|
|
| # survey <ism|unii> <time, sec> <h|v>
|
|
| # sw [<sw #> <on|off>]
|
|
| # temp
|
|
| # tftpd [on|off]
|
|
| # time
|
|
| # time <hour> <min> <sec>
|
|
| # save <mainimage|fpgaimage> <current chksum> <new chksum>
|
|
| # save <systemsetting|sudb>
|
|
| # updateflash <mainimage|fpgaimage> <current chksum> <new chksum>
|
|
| # updateflash <systemsetting|sudb>
|
|
|
|
|
| |
=cut
|
|
|
|
| |
|
| my $success = 'Success.';
|
my $success = 'Success.';
|
| my %COMMANDS = (
|
my %COMMANDS = (
|
| tftpd => { decode => 1, expect => $success },
|
tftpd => { decode => 'all', expect => $success },
|
| ver => { decode => 1 },
|
ver => { decode => 'all' },
|
| sysinfo => { decode => 1, expect => $success },
|
sysinfo => { decode => 'all', expect => $success },
|
| updateflash => { decode => 1, expect => $success },
|
updateflash => { decode => 'all', expect => $success },
|
| |
sulog => { decode => 'sulog', expect => $success },
|
| 'exit' => { Prompt => '//', cmd_disconnects => 1 },
|
'exit' => { Prompt => '//', cmd_disconnects => 1 },
|
| reboot => { Prompt => '//', cmd_disconnects => 1 },
|
reboot => { Prompt => '//', cmd_disconnects => 1 },
|
| #su password???
|
#su password???
|
|
|
|
|
|
| =pod
|
=pod
|
|
|
|
| =item new
|
|
|
|
|
| Same as new from L<Net::Telnet> but has defaults for the trango 'Prompt'
|
|
|
|
|
| =cut
|
|
|
|
|
| sub new
|
|
| {
|
|
| my $class = shift;
|
|
|
|
|
| my %args;
|
|
| if (@_ == 1) {
|
|
| $args{'Host'} = shift;
|
|
| } else {
|
|
| %args = @_;
|
|
| }
|
|
|
|
|
| $args{'Prompt'} ||= '/#> *$/';
|
|
|
|
|
| foreach my $key (keys %args) {
|
|
| $PRIVATE{$key} = $args{$key};
|
|
| }
|
|
|
|
|
| my $self = $class->SUPER::new(%args);
|
|
| bless $self if ref $self;
|
|
|
|
|
| return $self;
|
|
| }
|
|
|
|
|
| =pod
|
|
|
|
|
| =item open
|
=item open
|
|
|
|
| Calls Net::Telnet::open() then makes sure you get a password prompt so you are ready to login() and parses the login banner so you can get host_type() and firmware_version()
|
Calls Net::Telnet::open() then makes sure you get a password prompt so you are ready to login() and parses the login banner so you can get host_type() and firmware_version()
|
|
|
|
|
|
| my $vals = 1;
|
my $vals = 1;
|
| if ($cfg{'decode'}) {
|
if ($cfg{'decode'}) {
|
| $vals = _decode_lines(@lines);
|
if ($cfg{'decode'} eq 'each') {
|
| |
$vals = _decode_each_line(@lines);
|
| |
} elsif ($cfg{'decode'} eq 'sulog') {
|
| |
$vals = _decode_sulog(@lines);
|
| |
} else {
|
| |
$vals = _decode_lines(@lines);
|
| |
}
|
| }
|
}
|
|
|
|
|
|
|
|
|
| my $in_val = 0;
|
my $in_val = 0;
|
|
|
|
| foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
| |
next if $line =~ /$success$/;
|
| |
|
| my @chars = split //, $line;
|
my @chars = split //, $line;
|
|
|
|
| my $last_key = '';
|
my $last_key = '';
|
|
|
| if (%conf) {
|
if (%conf) {
|
| return \%conf;
|
return \%conf;
|
| } else {
|
} else {
|
| return \@lines;
|
return undef;
|
| }
|
}
|
| |
}
|
| |
|
| |
#=item _decode_each_line
|
| |
|
| |
sub _decode_each_line
|
| |
{
|
| |
my @lines = @_;
|
| |
my @decoded;
|
| |
foreach my $line (@lines) {
|
| |
my $decoded = _decode_lines($line);
|
| |
push @decoded, $decoded if defined $decoded;
|
| |
}
|
| |
return \@decoded;
|
| |
}
|
| |
|
| |
#=item _decode_sulog
|
| |
|
| |
sub _decode_sulog
|
| |
{
|
| |
my @lines = @_;
|
| |
my @decoded;
|
| |
my $last_tm;
|
| |
foreach my $line (@lines) {
|
| |
my $decoded = _decode_lines($line);
|
| |
|
| |
if (defined $decoded) {
|
| |
if ($decoded->{'tm'}) {
|
| |
$last_tm = $decoded->{'tm'};
|
| |
next;
|
| |
} else {
|
| |
$decoded->{'tm'} = $last_tm;
|
| |
}
|
| |
next unless $last_tm;
|
| |
|
| |
push @decoded, $decoded if defined $decoded;
|
| |
}
|
| |
}
|
| |
return \@decoded;
|
| }
|
}
|
|
|
|
| 1;
|
1;
|