[BACK]Return to Trango.pm CVS log [TXT][DIR] Up to [local] / trango / Net-Telnet-Trango / lib / Net / Telnet

Diff for /trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm between version 1.26 and 1.36

version 1.26, 2007/01/17 23:15:13 version 1.36, 2007/02/05 21:09:26
Line 1 
Line 1 
 package Net::Telnet::Trango;  package Net::Telnet::Trango;
 # $RedRiver: Trango.pm,v 1.25 2007/01/17 20:48:46 andrew Exp $  
 use strict;  # $RedRiver: Trango.pm,v 1.35 2007/02/05 21:03:40 andrew Exp $
 use warnings;  use strict;
 use base 'Net::Telnet';  use warnings;
   use base 'Net::Telnet';
 =pod  
   =pod
 =head1 NAME  
   =head1 NAME
 Net::Telnet::Trango  
 - Perl extension for accessing the Trango telnet interface  Net::Telnet::Trango
   - Perl extension for accessing the Trango telnet interface
 =head1 SYNOPSIS  
   =head1 SYNOPSIS
   use Net::Telnet::Trango;  
   my $t = new Net::Telnet::Trango ( Timeout => 5 );    use Net::Telnet::Trango;
     my $t = new Net::Telnet::Trango ( Timeout => 5 );
   $t->open( Host => $fox ) or die "Error connecting: $!";  
     $t->open( Host => $fox ) or die "Error connecting: $!";
   $t->login('password') or die "Couldn't log in: $!";  
     $t->login('password') or die "Couldn't log in: $!";
   # Do whatever  
     # Do whatever
   $t->exit;  
   $t->close;    $t->exit;
     $t->close;
 =head1 DESCRIPTION  
   =head1 DESCRIPTION
 Perl access to the telnet interface on Trango Foxes, SUs and APs.  
   Perl access to the telnet interface on Trango Foxes, SUs and APs.
 Another handy feature is that it will parse the output from certain  
 commands that is in the format "[key1] value1 [key2] value2" and put  Another handy feature is that it will parse the output from certain
 those in a hashref that is returned.  This makes using the output from  commands that is in the format "[key1] value1 [key2] value2" and put
 things like sysinfo very easy to do.  those in a hashref that is returned.  This makes using the output from
   things like sysinfo very easy to do.
 =head2 EXPORT  
   =head2 EXPORT
 None  
   None
 =head1 METHODS  
   =head1 METHODS
 =over  
   =cut
 =cut  
   our $VERSION = '0.01';
 our $VERSION = '0.01';  
   my %PRIVATE = (
 my %PRIVATE = (      is_connected => 0,
   is_connected => 0,      logged_in    => 0,
   logged_in => 0,  );
 );  
   =pod
 =pod  
   =head2 B<new>
 =item B<new>  - Creates a new Net::Telnet::Trango object.
   
 - Creates a new Net::Telnet::Trango object.      new([Options from Net::Telnet,]
           [Decode => 0,]);
         new([Options from Net::Telnet,]  
             [Decode => 0,]);  Same as new from L<Net::Telnet> but sets the default Trango Prompt:
   '/#> *$/'
 Same as new from L<Net::Telnet> but sets the default 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
 It also takes an optional parameter 'Decode'.  If not defined it  instead return a reference to an array of the lines that were returned
 defaults to 1, if it is set to 0, it will not decode the output and  from the command.
 instead return an array of the lines that were returned from the  
 command.  =cut
   
 =cut  sub new {
       my $class = shift;
 sub new  
 {      my %args;
   my $class = shift;      if ( @_ == 1 ) {
           $args{'Host'} = shift;
   my %args;      }
   if (@_ == 1) {      else {
     $args{'Host'} = shift;          %args = @_;
   } else {      }
     %args = @_;  
   }      $args{'Prompt'} ||= '/#> *$/';
   
   $args{'Prompt'}  ||= '/#> *$/';      foreach my $key ( keys %args ) {
           $PRIVATE{$key} = $args{$key};
   foreach my $key (keys %args) {      }
     $PRIVATE{$key} = $args{$key};      $PRIVATE{'Decode'} = 1 unless defined $PRIVATE{'Decode'};
   }      delete $args{'Decode'};
   $PRIVATE{'Decode'} = 1 unless defined $PRIVATE{'Decode'};  
   delete $args{'Decode'};      my $self = $class->SUPER::new(%args);
       bless $self if ref $self;
   my $self = $class->SUPER::new(%args);  
   bless $self if ref $self;      return $self;
   }
   return $self;  
 }  #  _password <new password> <new password>
   #  ? [command]
 #  _password <new password> <new password>  #  apsearch <secs> <ch#> <h|v> [<ch#> <h|v>]...
 #  ? [command]  #  arp -bcast <on|off>
 #  apsearch <secs> <ch#> <h|v> [<ch#> <h|v>]...  #  bcastscant <all|suid> <ch#> <h|v> [<ch#> <h|v> ...
 #  arp -bcast <on|off>  #  bye
 #  bcastscant <all|suid> <ch#> <h|v> [<ch#> <h|v> ...  #  cf2cf ap [default|<size>]
 #  bye  #  date
 #  cf2cf ap [default|<size>]  #  date <month> <day> <year>
 #  date  #  freq scantable
 #  date <month> <day> <year>  #  freq channeltable
 #  freq scantable  #  freq writescan [<ch#> <h|v>]
 #  freq channeltable  #  freq writechannel [<ch#> <freq>] ...
 #  freq writescan [<ch#> <h|v>]  #  freq <ch #> <h|v>
 #  freq writechannel [<ch#> <freq>] ...  #  help [command]
 #  freq <ch #> <h|v>  #  heater [<on temp> <off temp>]
 #  help [command]  #  ipconfig [<new ip> <new subnet mask> <new gateway>]
 #  heater [<on temp> <off temp>]  #  log [<# of entries, 1..179>]
 #  ipconfig [<new ip> <new subnet mask> <new gateway>]  #  log <sum> <# of entries, 1..179>
 #  log [<# of entries, 1..179>]  #  logout
 #  log <sum> <# of entries, 1..179>  #  opmode [ap [y]]
 #  logout  #  password
 #  opmode [ap [y]]  #  ping <ip addr>
 #  password  #  polar <h|v>
 #  ping <ip addr>  #  power <setism|setunii> <max|min|<dBm>>
 #  polar <h|v>  #  reboot
 #  power <setism|setunii> <max|min|<dBm>>  #  restart
 #  reboot  #  remarks [<str>]
 #  restart  #  rfrxthreshold [<ism|unii> <-90|-85|-80|-75|-70|-65>]
 #  remarks [<str>]  #  rfrxth [<ism|unii> <-90|-85|-80|-75|-70|-65>]
 #  rfrxthreshold [<ism|unii> <-90|-85|-80|-75|-70|-65>]  #  sysinfo
 #  rfrxth [<ism|unii> <-90|-85|-80|-75|-70|-65>]  #  set suid <id>
 #  sysinfo  #  set apid <id>
 #  set suid <id>  #  set baseid <id>
 #  set apid <id>  #  set defaultopmode [<ap|su> <min,0..10>]
 #  set baseid <id>  #  set defaultopmode off
 #  set defaultopmode [<ap|su> <min,0..10>]  #  set snmpcomm [<read | write | trap (id or setall)> <str>]
 #  set defaultopmode off  #  set mir [on|off]
 #  set snmpcomm [<read | write | trap (id or setall)> <str>]  #  set mir threshold <kbps>
 #  set mir [on|off]  #  set rssitarget [<ism|unii> <dBm>]
 #  set mir threshold <kbps>  #  set serviceradius [<ism | unii> <miles>]
 #  set rssitarget [<ism|unii> <dBm>]  #  ssrssi <ch #> <h|v>
 #  set serviceradius [<ism | unii> <miles>]  #  su [<suid>|all]
 #  ssrssi <ch #> <h|v>  #  su changechannel <all|suid> <ch#> <h|v>
 #  su [<suid>|all]  #  su ipconfig <suid> <new ip> <new subnet> <new gateway>
 #  su changechannel <all|suid> <ch#> <h|v>  #  su [live|poweroff|priority]
 #  su ipconfig <suid> <new ip> <new subnet> <new gateway>  #  su <ping|info|status> <suid>
 #  su [live|poweroff|priority]  #  su powerleveling <all|suid>
 #  su <ping|info|status> <suid>  #  su reboot <all|suid>
 #  su powerleveling <all|suid>  #  su restart <all|suid>
 #  su reboot <all|suid>  #  su testrflink <all|suid> [r]
 #  su restart <all|suid>  #  su testrflink <setlen> [64..1600]
 #  su testrflink <all|suid> [r]  #  su testrflink <aptx> [20..100]
 #  su testrflink <setlen> [64..1600]  #  su sw <suid|all> <sw #> <on|off>
 #  su testrflink <aptx> [20..100]  #  sudb [dload | view]
 #  su sw <suid|all> <sw #> <on|off>  #  sudb add <suid> pr <cir,kbps> <mir,kbps> <device id,hex>
 #  sudb [dload | view]  #  sudb add <suid> reg <cir,kbps> <mir,kbps> <device id,hex>
 #  sudb add <suid> pr <cir,kbps> <mir,kbps> <device id,hex>  #  sudb delete <all|<suid>>
 #  sudb add <suid> reg <cir,kbps> <mir,kbps> <device id,hex>  #  sudb modify <suid> <cir|mir> <kbps>
 #  sudb delete <all|<suid>>  #  sudb modify <suid> <su2su> <group id,hex>
 #  sudb modify <suid> <cir|mir> <kbps>  #  sudb view
 #  sudb modify <suid> <su2su> <group id,hex>  #  sulog [lastmins | sampleperiod <1..60>]
 #  sudb view  #  sulog [<# of entry,1..18>]
 #  sulog [lastmins | sampleperiod <1..60>]  #  survey <ism|unii> <time, sec> <h|v>
 #  sulog [<# of entry,1..18>]  #  sw [<sw #> <on|off>]
 #  survey <ism|unii> <time, sec> <h|v>  #  temp
 #  sw [<sw #> <on|off>]  #  tftpd [on|off]
 #  temp  #  time
 #  tftpd [on|off]  #  time <hour> <min> <sec>
 #  time  #  save <mainimage|fpgaimage> <current chksum> <new chksum>
 #  time <hour> <min> <sec>  #  save <systemsetting|sudb>
 #  save <mainimage|fpgaimage> <current chksum> <new chksum>  #  updateflash <mainimage|fpgaimage> <current chksum> <new chksum>
 #  save <systemsetting|sudb>  #  updateflash <systemsetting|sudb>
 #  updateflash <mainimage|fpgaimage> <current chksum> <new chksum>  
 #  updateflash <systemsetting|sudb>  =pod
   
 =pod  =head1 ACCESSORS
   
 =back  These are usually only set internally.
   
 =head2 ACCESSORS  =head2 B<firmware_version>
   - returns the firmware version
 These are usually only set internally.  
   Returns the firmware version if available, otherwise undef.
 =over  
   It should be available after a successful open().
 =item B<Host>  
   =head2 B<host_type>
 - returns the name of the host that you are accessing  - return the type of host you are connected to.
   
 =item B<firmware_version>  returns the type of host from the login banner for example M5830S or M5300S.  
   
 - returns the firmware version  Should be available after a successful open().
   
 Returns the firmware version if available, otherwise undef.  =head2 B<is_connected>
   - Status of the connection to host.
 It should be available after a successful open().  
   returns 1 when connected, undef otherwise.
 =item B<host_type>  
   =head2 B<logged_in>
 - return the type of host you are connected to.  - Status of being logged in to the host.
   
 returns the type of host from the login banner for example M5830S or M5300S.  returns 1 after a successful login(), 0 if it failed and undef if
   login() was never called.
 Should be available after a successful open().  
   =head2 B<login_banner>
 =item B<is_connected>  - The banner when first connecting to the host.
   
 - Status of the connection to host.  returns the banner that is displayed when first connected at login.  
   Only set after a successful open().
 returns 1 when connected, undef otherwise.  
   =head2 B<last_lines>
 =item B<logged_in>  - The last lines of output from the last cmd().
   
 - Status of being logged in to the host.  returns, as an array ref, the output from the last cmd() that was run.
   
 returns 1 after a successful login(), 0 if it failed and undef if  =head2 B<last_error>
 login() was never called.  - A text output of the last error that was encountered.
   
 =item B<login_banner>  returns the last error reported.  Probably contains the last entry in
   last_lines.
 - The banner when first connecting to the host.  
   =head1 ALIASES
 returns the banner that is displayed when first connected at login.  
 Only set after a successful open().  =head2 B<bye>
   - alias of exit()
 =item B<last_lines>  
   Does the same as exit()
 - The last lines of output from the last cmd().  
   =head2 B<restart>
 returns, as an array ref, the output from the last cmd() that was run.  - alias of reboot()
   
 =item B<last_error>  Does the same as reboot()
   
 - A text output of the last error that was encountered.  =head1 COMMANDS
   
 returns the last error reported.  Probably contains the last entry in  Most of these are just shortcuts to C<cmd(String =E<gt> METHOD)>,
 last_lines.  as such they accept the same options as C<cmd()>.  
   Specifically they take a named paramater "args", for example:
 =back  C<tftpd(args =E<gt> 'on')> would enable tftpd
   
 =head2 ALIASES  =head2 B<tftpd>
   - The output from the tftpd command
 =over  
   Returns a hash ref of the decoded output from the
 =item B<bye>  command.
   
 - alias of L<exit()>.  Also see enable_tftpd() and disable_tftpd() as those check that it was
   successfully changed.
 =item B<restart>  
   =head2 B<ver>
 - alias of L<reboot()>.  - The output from the ver command
   
 =back  Returns a hash ref of the decoded output from the
   command.
 =head2 COMMANDS  
   =head2 B<sysinfo>
 Most of these are just shortcuts to C<cmd(String =E<gt> METHOD)>,  - The output from the sysinfo command
 as such they accept the same options as C<cmd()>.  
 Specifically they take a named paramater "args", for example:  Returns a hash ref of the decoded output from the
 C<tftpd(args =E<gt> 'on')> would enable tftpd  command.
   
 =over  =head2 B<exit>
   - Exits the connection
 =item B<tftpd>  
   exits the command session with the Trango and closes
 - Returns a hash ref of the decoded output from the  the connection
 command.  
   =head2 B<reboot>
 Also see enable_tftpd() and disable_tftpd() as those check that it was  - Sends a reboot command
 successfully changed.  
   reboots the Trango and closes the connection
 =item B<ver>  
   =head2 B<remarks>
 - Returns a hash ref of the decoded output from the  - Set or retrieve the remarks.
 command.  
   Takes an optional argument, which sets the remarks.  
 =item B<sysinfo>  If there is no argument, returns the current remarks.
   
 - Returns a hash ref of the decoded output from the    my $old_remarks = $t->remarks();
 command.    $t->remarks($new_remarks);
   
 =item B<exit>  =head2 B<sulog>
   - The output from the sulog command
 - exits the command session with the Trango and closes  
 the connection  Returns an array ref of hashes containing each log
   line.
 =item B<reboot>  
   =head2 B<save_sudb>
 - reboots the Trango and closes the connection  - saves the sudb
   
 =item B<remarks>  Returns true on success, undef on failure
   
 - Set or retrieve the remarks.  =head2 B<syslog>
   - The output from the sulog command
 Takes an optional argument, which sets the remarks.  
 If there is no argument, returns the current remarks.  Returns a hashref of the output from the syslog command
   
   my $old_remarks = $t->remarks();  =head2 B<pipe>
   $t->remarks($new_remarks);  - the pipe command
   
 =item B<sulog>  Returns the output from the pipe command
   
 - returns an array ref of hashes containing each log  =head2 B<maclist>
 line.  - retrieves the maclist
   
 =item B<save_sudb>  Returns the output from the maclist command
   
 - returns true on success, undef on failure  =head2 B<maclist_reset>
   - resets the maclist.  
 =item B<syslog>  
   No useful output.
 - returns the output from the syslog command  
   =head2 B<eth_list>
 =item B<pipe>  - eth list command
   
 - returns the output from the pipe command  Returns the output from the eth list command
   
 =item B<maclist>  
   =head2 B<su_info>
 -  returns the output from the maclist command  - gets the su info
   
 =item B<maclist_reset>  Returns information about the SU.
   
 - resets the maclist.  You need to pass in the $suid and it will return the info for that suid.
   
 No useful output.    $t->su_info($suid);
   
 =item B<eth_list>  =head2 B<su_testrflink>
   - tests the RF Link to an su
 - returns the output from the eth list command  
     $t->su_testrflink($suid|'all');
 =item B<su_info>  
   =head2 B<save_ss>
 - returns information about the SU.  - saves the config.  
   
 You need to pass in the $suid and it will return the info for that suid.  Returns 1 on success, undef on failure.
   
   $t->su_info($suid);  =cut
   
 =item B<save_ss>  my $success  = 'Success\\.';
   my %COMMANDS = (
 - saves the config.      tftpd       => { decode    => 'all',       expect          => $success },
       ver         => { decode    => 'all' },
 Returns 1 on success, undef on failure.      sysinfo     => { decode    => 'all',       expect          => $success },
       updateflash => { decode    => 'all',       expect          => $success },
 =cut      sulog       => { decode    => 'sulog',     expect          => $success },
       'exit'      => { no_prompt => 1,           cmd_disconnects => 1 },
       reboot      => { no_prompt => 1,           cmd_disconnects => 1 },
 my $success = 'Success.';      remarks     => { decode    => 'all',       expect          => $success },
 my %COMMANDS = (      save_sudb   => { String    => 'save sudb', expect          => $success },
   tftpd       => { decode => 'all',   expect => $success },      syslog      => { expect    => $success },
   ver         => { decode => 'all' },      'pipe'      => {},                        # XXX needs a special decode
   sysinfo     => { decode => 'all',   expect => $success },      maclist     => { decode => 'maclist' },
   updateflash => { decode => 'all',   expect => $success },      maclist_reset => { String => 'maclist reset', expect       => 'done' },
   sulog       => { decode => 'sulog', expect => $success },      eth_link    => { String => 'eth link',     expect          => $success },
   'exit'      => { no_prompt => 1, cmd_disconnects => 1 },      su_info     =>
   reboot      => { no_prompt => 1, cmd_disconnects => 1 },        { String => 'su info',  decode => 'all', expect          => $success },
   remarks     => { decode => 'all', expect => $success },      su_testrflink =>
   save_sudb   => { String => 'save sudb', expect => $success },        { String => 'su testrflink', decode => 'each', expect    => $success },
   syslog      => { expect => $success },      save_ss     => { String => 'save ss',      expect          => $success },
   'pipe'      => { }, # XXX needs a special decode      opmode      => { decode => 'all',          expect          => $success },
   maclist     => { decode => 'maclist' },  );
   maclist_reset => { String => 'maclist reset', expect => 'done' },  
   eth_link    => { String => 'eth link', expect => $success },  my %ALIASES = (
   su_info     => { String => 'su info', decode => 'all', expect => $success },      bye     => 'exit',
   save_ss     => { String => 'save ss', expect => $success },      restart => 'reboot',
   opmode      => { decode => 'all',   expect => $success },      Host    => 'host',
   # eth r, w and reset???  );
   #su password???  
   #_bootloader  my %ACCESS = map { $_ => 1 } qw(
   #temp    firmware_version
   #heater    host_type
 );    is_connected
     logged_in
 my %ALIASES = (    login_banner
   bye     => 'exit',    Timeout
   restart => 'reboot',    last_lines
 );    last_vals
     last_error
 my %ACCESS = map { $_ => 1 } qw(    Decode
   firmware_version  );
   host_type  
   Host  sub AUTOLOAD {
   is_connected      my $self = shift;
   logged_in  
   login_banner      my ($method) = ( our $AUTOLOAD ) =~ /^.*::(\w+)$/
   Timeout        or die "Weird: $AUTOLOAD";
   last_lines  
   last_vals      if ( exists $ALIASES{$method} ) {
   last_error          $method = $ALIASES{$method};
 );          return $self->$method(@_);
       }
 sub AUTOLOAD  
 {      if ( exists $COMMANDS{$method} ) {
   my $self = shift;          my %cmd;
           foreach my $k ( keys %{ $COMMANDS{$method} } ) {
   my ($method) = (our $AUTOLOAD) =~ /^.*::(\w+)$/              $cmd{$k} = $COMMANDS{$method}{$k};
     or die "Weird: $AUTOLOAD";          }
           $cmd{'String'} ||= $method;
   if (exists $ALIASES{$method}) {          $cmd{'args'} .= ' ' . shift if ( @_ == 1 );
     $method = $ALIASES{$method};          return $self->cmd( %cmd, @_ );
     return $self->$method(@_);      }
   }  
       if ( exists $ACCESS{$method} ) {
   if (exists $COMMANDS{$method}) {          my $prev = $PRIVATE{$method};
     $COMMANDS{$method}{'String'} ||= $method;          ( $PRIVATE{$method} ) = @_ if @_;
     $COMMANDS{$method}{'args'} .= ' ' . shift if (@_ == 1);          return $prev;
     return $self->cmd(%{ $COMMANDS{$method} }, @_);      }
   }  
       $method = "SUPER::$method";
   if (exists $ACCESS{$method}) {      return $self->$method(@_);
     my $prev = $PRIVATE{$method};  }
     ($PRIVATE{$method}) = @_ if @_;  
     return $prev;  =pod
   }  
   =head2 B<open>
   $method = "SUPER::$method";  - Open a connection to a Trango AP.
   return $self->$method(@_);  
 }  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
 =pod  host_type() and firmware_version()
   
 =item B<open>  =cut
   
 - Open a connection to a Trango AP.  sub open {
       my $self = shift;
 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      unless ( $self->SUPER::open(@_) ) {
 host_type() and firmware_version()          $self->last_error( "Couldn't connect to " . $self->host . ":  $!" );
           return;
 =cut      }
   
 sub open      ## Get to login prompt
 {      unless (
   my $self = shift;          $self->waitfor(
               -match   => '/password: ?$/i',
   unless ( $self->SUPER::open(@_) ) {              -errmode => "return",
     $self->last_error("Couldn't connect to " . $self->Host . ":  $!");          )
     return undef;        )
   }      {
           $self->last_error( "problem connecting to host ("
   ## Get to login prompt                . $self->host . "): "
   unless ($self->waitfor(                . $self->lastline );
       -match => '/password: ?$/i',          return;
       -errmode => "return",      }
     ) ) {  
     $self->last_error("problem connecting to host (" . $self->Host . "): " .      $self->parse_login_banner( $self->lastline );
         $self->lastline);  
     return undef;      $self->is_connected(1);
   }  
       return $self->is_connected;
   $self->parse_login_banner($self->lastline);  }
   
   $self->is_connected(1);  =pod
   
   return $self->is_connected;  =head2 B<login>
 }  - Login to the AP.
   
 =pod  Calls open() if not already connected, then sends the password and sets
   logged_in() if successful
 =item B<login>  
   =cut
 - Login to the AP.  
   sub login {
 Calls open() if not already connected, then sends the password and sets      my $self = shift;
 logged_in() if successful  
       unless ( $self->is_connected ) {
 =cut          $self->open or return;
       }
 sub login  
 {      my $password = shift;
   my $self = shift;  
       $self->print($password);
   unless ($self->is_connected) {      unless (
     $self->open or return undef;          $self->waitfor(
   }              -match   => $self->prompt,
               -errmode => "return",
   my $password = shift;          )
         )
   $self->print($password);      {
   unless ($self->waitfor(          $self->last_error( "login ($self->host) failed: " . $self->lastline );
     -match => $self->prompt,          return;
     -errmode => "return",      }
   ) ) {  
     $self->last_error("login ($self->Host) failed: " . $self->lastline);      $self->logged_in(1);
     return undef;  
   }      return $self->logged_in;
   }
   $self->logged_in(1);  
   =pod
   return $self->logged_in;  
 }  =head2 B<parse_login_banner>
   - Converts the login_banner to some useful
 =pod  variables.
   
 =item B<parse_login_banner>  Takes a login banner (what you get when you first connect to the Trango)
   or reads what is already in login_banner() then parses it and sets
 - Converts the login_banner to some useful  host_type() and firmware_version() as well as login_banner()
 variables.  
   =cut
 Takes a login banner (what you get when you first connect to the Trango)  
 or reads what is already in login_banner() then parses it and sets  sub parse_login_banner {
 host_type() and firmware_version() as well as login_banner()      my $self = shift;
   
 =cut      if (@_) {
           $self->login_banner(@_);
 sub parse_login_banner      }
 {  
   my $self = shift;      my $banner = $self->login_banner;
   
   if (@_) {      my ( $type, $sep1, $subtype, $sep2, $ver ) =
     $self->login_banner(@_);        $banner =~
   }        /Welcome to Trango Broadband Wireless (\S+)([\s-]+)(\S+)([\s-]+)(.+)$/i;
   
   my $banner = $self->login_banner;      $type .= $sep1 . $subtype;
       $ver = $subtype . $sep2 . $ver;
   my ($type, $ver) = $banner =~  
     /Welcome to Trango Broadband Wireless (\S+)[\s-]+(.+)$/i;      $self->login_banner($banner);
       $self->host_type($type);
   $self->login_banner($banner);      $self->firmware_version($ver);
   $self->host_type($type);  
   $self->firmware_version($ver);      return 1;
   }
   return 1;  
 }  =pod
   
 =pod  =head2 B<su_password>
   - Set the password on SUs connected to the AP.
 =item B<su_password>  
   su_password('new_password'[, 'suid']) If no suid is specified,
 - Set the password on SUs connected to the AP.  the default is "all".
   
 su_password('new_password'[, 'suid']) If no suid is specified,    $t->su_password('good_pass', 5);
 the default is "all".  
   =cut
   $t->su_password('good_pass', 5);  
   sub su_password {
 =cut      my $self     = shift;
       my $new_pass = shift || '';
 sub su_password      my $su       = shift || 'all';
 {  
   my $self     = shift;      unless ( defined $new_pass ) {
   my $new_pass = shift || '';          $self->last_error("No new password");
   my $su       = shift || 'all';  
           #return;
   unless (defined $new_pass) {      }
     $self->last_error("No new password");  
     #return undef;      return $self->cmd(
   }          String => 'su password ' . $su . ' ' . $new_pass . ' ' . $new_pass,
           expect => $success,
   return $self->cmd(String => 'su password ' .      );
                      $su . ' ' .  }
                      $new_pass . ' ' .  
                      $new_pass,  =pod
                      expect => $success,  
                     );  =head2 B<su_ipconfig>
 }  - Change IP configuration on SUs connected to
   the AP.
 =pod  
   su_ipconfig( 'suid', 'new_ip', 'new_subnet', 'new_gateway' )
 =item B<su_ipconfig>  
     $t->su_ipconfig( 5, '10.0.1.5', '255.255.255.0', '10.0.1.1' );
 - Change IP configuration on SUs connected to  
 the AP.  =cut
   
 su_ipconfig( 'suid', 'new_ip', 'new_subnet', 'new_gateway' )  sub su_ipconfig {
       my $self = shift;
   $t->su_ipconfig( 5, '10.0.1.5', '255.255.255.0', '10.0.1.1' );  
       my $suid        = shift;
 =cut      my $new_ip      = shift;
       my $new_subnet  = shift;
 sub su_ipconfig      my $new_gateway = shift;
 {  
         my $self        = shift;      if ( $suid =~ /\D/ ) {
           $self->last_error("Invalid suid '$suid'");
         my $suid        = shift;          return;
         my $new_ip      = shift;      }
         my $new_subnet  = shift;      unless ($new_ip) {
         my $new_gateway = shift;          $self->last_error("no new_ip passed");
           return;
         if ($suid =~ /\D/) {      }
                 $self->last_error("Invalid suid '$suid'");      unless ($new_subnet) {
                 return undef;          $self->last_error("no new_subnet passed");
         }          return;
         unless ($new_ip) {      }
                 $self->last_error("no new_ip passed");      unless ($new_gateway) {
                 return undef;          $self->last_error("no new_gateway passed");
         }          return;
         unless ($new_subnet) {      }
                 $self->last_error("no new_subnet passed");  
                 return undef;      # su ipconfig <suid> <new ip> <new subnet> <new gateway>
         }      return $self->cmd(
         unless ($new_gateway) {          String => 'su ipconfig ' . $suid . ' ' . $new_ip . ' '
                 $self->last_error("no new_gateway passed");            . $new_subnet . ' '
                 return undef;            . $new_gateway,
         }          expect => $success,
       );
         # su ipconfig <suid> <new ip> <new subnet> <new gateway>  }
         return $self->cmd(String => 'su ipconfig ' .  
                      $suid       . ' ' .  =pod
                      $new_ip     . ' ' .  
                      $new_subnet . ' ' .  =head2 B<sudb_view>
                      $new_gateway,  - Returns the output from the sudb view command
                      expect => $success,  
                     );  returns a reference to an array of hashes each containing these keys
 }  'suid', 'type', 'cir', 'mir' and 'mac'
   
 =pod  =cut
   
 =item B<sudb_view>  sub sudb_view {
       my $self = shift;
 - Returns the output from the sudb view command  
       my $lines = $self->cmd( String => 'sudb view', expect => $success ) || [];
 returns a reference to an array of hashes each containing these keys  
 'suid', 'type', 'cir', 'mir' and 'mac'      return unless @{$lines};
   
 =cut      unless ( $PRIVATE{'Decode'} ) {
           return $lines;
 sub sudb_view      }
 {  
   my $self = shift;      my @sus;
       foreach ( @{$lines} ) {
   my @lines = $self->cmd( String => 'sudb view', expect => $success );          next unless $_;
           if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9A-Fa-f\s]+)$/) {
   return undef unless @lines;              my %s = (
                   suid => $1,
   unless ($PRIVATE{'Decode'}) {                  type => $2,
     return @lines;                  cir  => $3,
   }                  mir  => $4,
                   mac  => $5,
   my @sus;              );
   foreach (@lines) {  
     next unless $_;              $s{'mac'} =~ s/\s//g;
     if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9A-Fa-f\s]+)$/) {              $s{'mac'} = uc( $s{'mac'} );
       my %s = (  
         suid => $1,              push @sus, \%s;
         type => $2,          }
         cir  => $3,      }
         mir  => $4,  
         mac  => $5,      return \@sus;
       );  }
   
           $s{'mac'} =~ s/\s//g;  =pod
           $s{'mac'} = uc($s{'mac'});  
   =head2 B<sudb_add>
       push @sus, \%s;  
     }  Takes the following paramaters
   }  
       suid : numeric,
   return \@sus;      type : (reg|pr)
 }      cir  : numeric,
       mir  : numeric,
 =pod      mac  : Almost any format, it will be reformatted,
   
 =item B<sudb_add>  and returns true on success or undef otherwise.
   
 Takes the following paramaters    $t->sudb_add($suid, 'reg', $cir, $mir, $mac);
   
         suid : numeric,  You should save_sudb() after calling this, or your changes  will be lost
         type : (reg|pr)  when the AP is rebooted.
         cir  : numeric,  
         mir  : numeric,  =cut
         mac  : Almost any format, it will be reformatted,  
   sub sudb_add {
 and returns true on success or undef otherwise.      my $self = shift;
       my $suid = shift;
   $t->sudb_add($suid, 'reg', $cir, $mir, $mac);      my $type = shift;
       my $cir  = shift;
 You should save_sudb() after calling this, or your changes  will be lost      my $mir  = shift;
 when the AP is rebooted.      my $mac  = shift;
   
 =cut      if ( $suid =~ /\D/ ) {
           $self->last_error("Invalid suid '$suid'");
 sub sudb_add          return;
 {      }
         my $self = shift;  
         my $suid = shift;      unless ( lc($type) eq 'reg' || lc($type) eq 'pr' ) {
         my $type = shift;          $self->last_error("Invalid type '$type'");
         my $cir  = shift;          return;
         my $mir  = shift;      }
         my $mac  = shift;  
       if ( $cir =~ /\D/ ) {
         if ($suid =~ /\D/) {          $self->last_error("Invalid CIR '$cir'");
                 $self->last_error("Invalid suid '$suid'");          return;
                 return undef;      }
         }  
       if ( $mir =~ /\D/ ) {
         unless (lc($type) eq 'reg' || lc($type) eq 'pr') {          $self->last_error("Invalid MIR '$mir'");
                 $self->last_error("Invalid type '$type'");          return;
                 return undef;      }
         }  
       my $new_mac = $mac;
         if ($cir =~ /\D/) {      $new_mac =~ s/[^0-9A-Fa-f]//;
                 $self->last_error("Invalid CIR '$cir'");      unless ( length $new_mac == 12 ) {
                 return undef;          $self->last_error("Invalid MAC '$mac'");
         }          return;
       }
         if ($mir =~ /\D/) {      $new_mac = join ' ', $new_mac =~ /../g;
                 $self->last_error("Invalid MIR '$mir'");  
                 return undef;      my $string =
         }        'sudb add ' . $suid . ' ' . $type . ' ' . $cir . ' ' . $mir . ' '
         . $new_mac;
         my $new_mac = $mac;  
         $new_mac =~ s/[^0-9A-Fa-f]//;      return $self->cmd( String => $string, expect => $success );
         unless (length $new_mac == 12) {  }
                 $self->last_error("Invalid MAC '$mac'");  
                 return undef;  =pod
         }  
         $new_mac = join ' ', $new_mac =~ /../g;  =head2 B<sudb_delete>
   
         my $string = 'sudb add ' .  Takes either 'all' or the  suid of the su to delete
                 $suid . ' ' .  and returns true on success or undef otherwise.
                 $type . ' ' .  
                 $cir  . ' ' .    $t->sudb_delete($suid);
                 $mir  . ' ' .  
                 $new_mac;  You should save_sudb() after calling this, or your changes  will be lost
   when the AP is rebooted.
   
         return $self->cmd( String => $string, expect => $success );  =cut
 }  
   sub sudb_delete {
 =pod      my $self = shift;
       my $suid = shift;
 =item B<sudb_delete>  
       #if (lc($suid) ne 'all' || $suid =~ /\D/) {
 Takes either 'all' or the  suid of the su to delete      if ( $suid =~ /\D/ ) {
 and returns true on success or undef otherwise.          $self->last_error("Invalid suid '$suid'");
           return;
   $t->sudb_delete($suid);      }
   
 You should save_sudb() after calling this, or your changes  will be lost      return $self->cmd( String => 'sudb delete ' . $suid, expect => $success );
 when the AP is rebooted.  }
   
 =cut  =pod
   
 sub sudb_delete  =head2 B<sudb_modify>
 {  
         my $self = shift;  Takes either the  suid of the su to change
         my $suid = shift;  as well as what you are changing, either "cir, mir or su2su"
   and returns true on success or undef otherwise.
         #if (lc($suid) ne 'all' || $suid =~ /\D/) {  
         if ($suid =~ /\D/) {  cir and mir also take a value to set the cir/mir to.
                 $self->last_error("Invalid suid '$suid'");  
                 return undef;  su2su takes a group id parameter that is in hex.
         }  
     $t->sudb_modify($suid, 'cir', 512);
         return $self->cmd( String => 'sudb delete ' . $suid, expect => $success );  
 }  You should save_sudb() after calling this, or your changes  will be lost
   when the AP is rebooted.
 =pod  
   =cut
 =item B<sudb_modify>  
   sub sudb_modify {
 Takes either the  suid of the su to change      my $self  = shift;
 as well as what you are changing, either "cir, mir or su2su"      my $suid  = shift;
 and returns true on success or undef otherwise.      my $opt   = shift;
       my $value = shift;
 cir and mir also take a value to set the cir/mir to.  
       if ( $suid =~ /\D/ ) {
 su2su takes a group id parameter that is in hex.          $self->last_error("Invalid suid '$suid'");
           return;
   $t->sudb_modify($suid, 'cir', 512);      }
   
 You should save_sudb() after calling this, or your changes  will be lost      if ( lc($opt) eq 'cir' or lc($opt) eq 'mir' ) {
 when the AP is rebooted.          if ( $value =~ /\D/ ) {
               $self->last_error("Invalid $opt '$value'");
 =cut              return;
           }
 sub sudb_modify      }
 {      elsif ( lc($opt) eq 'su2su' ) {
         my $self  = shift;          if ( $value =~ /[^0-9A-Za-f]/ ) {
         my $suid  = shift;              $self->last_error("Invalid MAC '$value'");
         my $opt   = shift;              return;
         my $value = shift;          }
       }
         if ($suid =~ /\D/) {      else {
                 $self->last_error("Invalid suid '$suid'");          $self->last_error("Invalid option '$opt'");
                 return undef;          return;
         }      }
   
         if (lc($opt) eq 'cir' or lc($opt) eq 'mir') {      my $string = 'sudb modify ' . $suid . ' ' . $opt . ' ' . $value;
                 if ($value =~ /\D/) {  
                         $self->last_error("Invalid $opt '$value'");      return $self->cmd( String => $string, expect => $success );
                         return undef;  }
                 }  
         } elsif (lc($opt) eq 'su2su') {  =pod
                 if ($value =~ /[^0-9A-Za-f]/) {  
                         $self->last_error("Invalid MAC '$value'");  =head2 B<enable_tftpd>
                         return undef;  - enable the TFTP server
                 }  
         } else {  runs C<tftpd(args =E<gt> 'on')> and makes sure that Tftpd is now 'listen'ing
                 $self->last_error("Invalid option '$opt'");  
                 return undef;  =cut
         }  
   sub enable_tftpd {
         my $string = 'sudb modify ' . $suid . ' ' . $opt . ' ' . $value;      my $self = shift;
   
         return $self->cmd( String => $string, expect => $success );      my $vals = $self->tftpd( args => 'on' );
 }  
       if ( ref $vals eq 'HASH' && $vals->{'Tftpd'} eq 'listen' ) {
 =pod          return $vals;
       }
 =item B<enable_tftpd>      else {
           return;
 - enable the TFTP server      }
   }
 runs C<tftpd(args =E<gt> 'on')> and makes sure that Tftpd is now 'listen'ing  
   =pod
 =cut  
   =head2 B<disable_tftpd>
 sub enable_tftpd  - disable the TFTP server
 {  
   my $self = shift;  runs C<tftpd(args =E<gt> 'off')> and makes sure that Tftpd is now 'disabled'
   
   my $vals = $self->tftpd( args => 'on' );  =cut
   
   if ($vals->{'Tftpd'} eq 'listen') {  sub disable_tftpd {
     return $vals;      my $self = shift;
   } else {  
     return undef;      my $vals = $self->tftpd( args => 'off' );
   }  
 }      if ( ref $vals eq 'HASH' && $vals->{'Tftpd'} eq 'disabled' ) {
           return $vals;
 =pod      }
       else {
 =item B<disable_tftpd>          return;
       }
 - disable the TFTP server  }
   
 runs C<tftpd(args =E<gt> 'off')> and makes sure that Tftpd is now 'disabled'  =pod
   
 =cut  =head2 B<cmd> - runs a command on the AP.
   
 sub disable_tftpd  This does most of the work.  At the heart, it calls Net::Telnet::cmd()
 {  but it also does some special stuff for Trango.
   my $self = shift;  
   Normally returns the last lines from from the command
   my $vals = $self->tftpd( args => 'off' );  
   If you are using this, rather than one of the "easy" methods above,
   if (ref $vals eq 'HASH' && $vals->{'Tftpd'} eq 'disabled') {  you probably want to read through the source of this module to see how
     return $vals;  some of the other commands are called.
   } else {  
     return undef;  In addition to the Net::Telnet::cmd() options, it also accepts these:
   }  
 }  I<decode>
   - if this is true, then it will send the output lines to _decode_lines()
 =pod  and then returns the decoded output
   
 =item B<cmd>  I<no_prompt>
   - if this is true, it does not wait for a prompt, so you are not stuck
 - runs a command on the AP.  waiting for something that will never happen.
   
 This does most of the work.  At the heart, it calls Net::Telnet::cmd()  I<cmd_disconnects>
 but it also does some special stuff for Trango.  - if this is true, it then sets logged_in() to false, then it will
   close() the connection and set is_connected() to false
 Normally returns the last lines from from the command  
   I<expect>
 If you are using this, rather than one of the "easy" methods above,  - if this is set (usually to 'Success.') it will check for that in the
 you probably want to read through the source of this module to see how  last line of output and if it does not, will return undef because the
 some of the other commands are called.  command probably failed
   
 In addition to the Net::Telnet::cmd() options, it also accepts these:  I<args>
   - a string containing the command line options that are passed to the
 I<decode>  command
   
 - if this is true, then it will send the output lines to _decode_lines()      $t->cmd( String => 'exit', no_prompt => 1, cmd_disconnects => 1 );
 and then returns the decoded output  
   =cut
 I<no_prompt>  
   sub cmd {
 - if this is true, it does not wait for a prompt, so you are not stuck      my $self = shift;
 waiting for something that will never happen.  
       my @valid_net_telnet_opts = qw(
 I<cmd_disconnects>        String
         Output
 - if this is true, it then sets logged_in() to false, then it will        Cmd_remove_mode
 close() the connection and set is_connected() to false        Errmode
         Input_record_separator
 I<expect>        Ors
         Output_record_separator
 - if this is set (usually to 'Success.') it will check for that in the        Prompt
 last line of output and if it does not, will return undef because the        Rs
 command probably failed        Timeout
       );
 I<args>  
       my %cfg;
 - a string containing the command line options that are passed to the      if ( @_ == 1 ) {
 command          $cfg{'String'} = shift;
       }
         $t->cmd( String => 'exit', no_prompt => 1, cmd_disconnects => 1 );      elsif ( @_ > 1 ) {
           %cfg = @_;
 =cut      }
   
 sub cmd      $cfg{'Timeout'} ||= $self->Timeout;
 {  
   my $self = shift;      unless ( $cfg{'String'} ) {
           $self->last_error("No command passed");
   my @valid_net_telnet_opts = qw(          return;
     String      }
     Output  
     Cmd_remove_mode      unless ( $self->is_connected ) {
     Errmode          $self->last_error("Not connected");
     Input_record_separator          return;
     Ors      }
     Output_record_separator  
     Prompt      unless ( $self->logged_in ) {
     Rs          $self->last_error("Not logged in");
     Timeout          return;
   );      }
   
   my %cfg;      my %cmd;
   if (@_ == 1) {      foreach (@valid_net_telnet_opts) {
     $cfg{'String'} = shift;          if ( exists $cfg{$_} ) {
   } elsif (@_ > 1) {              $cmd{$_} = $cfg{$_};
     %cfg = @_;          }
   }      }
       if ( $cfg{'args'} ) {
   $cfg{'Timeout'} ||= $self->Timeout;          $cmd{'String'} .= ' ' . $cfg{'args'};
       }
   unless ($cfg{'String'}) {  
     $self->last_error("No command passed");      my @lines;
     return undef;      if ( $cfg{'no_prompt'} ) {
   }          $self->print( $cmd{'String'} );
           @lines = $self->lastline;
   unless ($self->is_connected) {      }
     $self->last_error("Not connected");      else {
     return undef;          @lines = $self->SUPER::cmd(%cmd);
   }      }
   
   unless ($self->logged_in) {      $self->last_lines( \@lines );
     $self->last_error("Not logged in");  
     return undef;      my $vals = 1;
   }      if ( $PRIVATE{'Decode'} && $cfg{'decode'} ) {
           if ( $cfg{'decode'} eq 'each' ) {
               $vals = _decode_each_line(@lines);
   my %cmd;          }
   foreach (@valid_net_telnet_opts) {          elsif ( $cfg{'decode'} eq 'sulog' ) {
     if (exists $cfg{$_}) {              $vals = _decode_sulog(@lines);
       $cmd{$_} = $cfg{$_};          }
     }          elsif ( $cfg{'decode'} eq 'maclist' ) {
   }              $vals = _decode_maclist(@lines);
   if ($cfg{'args'}) {          }
     $cmd{'String'} .= ' ' . $cfg{'args'};          else {
   }              $vals = _decode_lines(@lines);
   my @lines;          }
   unless ($cfg{'no_prompt'}) {      }
     @lines = $self->SUPER::cmd(%cmd);  
   } else {      $self->last_vals($vals);
     $self->print($cmd{'String'});  
     @lines = $self->lastline;      my $last = $self->lastline;
   }  
       if ( ( not $cfg{'expect'} ) || $last =~ /$cfg{'expect'}$/ ) {
   $self->last_lines(\@lines);          if ( $cfg{'cmd_disconnects'} ) {
               $self->logged_in(0);
   my $vals = 1;              $self->close;
   if ($PRIVATE{'Decode'} && $cfg{'decode'}) {              $self->is_connected(0);
     if ($cfg{'decode'} eq 'each') {          }
       $vals = _decode_each_line(@lines);  
     } elsif ($cfg{'decode'} eq 'sulog') {          if ( $PRIVATE{'Decode'} && $cfg{'decode'} ) {
       $vals = _decode_sulog(@lines);              return $vals;
     } elsif ($cfg{'decode'} eq 'maclist') {          }
       $vals = _decode_maclist(@lines);          else {
     } else {              return \@lines;
       $vals = _decode_lines(@lines);          }
     }      }
   }      else {
           $self->last_error("Error with command ($cfg{'String'}): $last");
   $self->last_vals($vals);          return;
       }
   }
   my $last = $self->lastline;  
   #=item _decode_lines
   if ((not $cfg{'expect'}) || $last =~ /$cfg{'expect'}$/) {  
     if ($cfg{'cmd_disconnects'}) {  sub _decode_lines {
       $self->logged_in(0);      my @lines = @_;
       $self->close;  
       $self->is_connected(0);      my %conf;
     }  
       my $key = '';
     if ($PRIVATE{'Decode'} && $cfg{'decode'}) {      my $val = undef;
       return $vals;      my @vals;
     } else {      my $in_key = 0;
       return @lines;      my $in_val = 1;
     }  
   } else {      foreach my $line (@lines) {
     $self->last_error("Error with command ($cfg{'String'}): $last");          next if $line =~ /$success$/;
     return undef;  
   }          my @chars = split //, $line;
 }  
           my $last_key = '';
 #=item _decode_lines          foreach my $c (@chars) {
   
 sub _decode_lines              if ( $c eq '[' || $c eq "\r" || $c eq "\n" ) {
 {                  if ( $c eq '[' ) {
   my @lines = @_;                      $in_key = 1;
                       $in_val = 0;
   my %conf;                  }
                   else {
   my $key = '';                      $in_key = 0;
   my $val = undef;                      $in_val = 1;
   my $in_key = 0;                  }
   my $in_val = 1;  
                   if ($key) {
   foreach my $line (@lines) {                      $key =~ s/^\s+//;
     next if $line =~ /$success$/;                      $key =~ s/\s+$//;
   
     my @chars = split //, $line;                      if ($val) {
                           $val =~ s/^\s+//;
     my $last_key = '';                          $val =~ s/\s+$//;
     foreach my $c (@chars) {                      }
   
       if ($c eq '[' || $c eq "\r" || $c eq "\n") {                      if ( $key eq 'Checksum' && $last_key ) {
         if ($c eq '[') {  
           $in_key = 1;                          # Special case for these bastids.
           $in_val = 0;                          my $new = $last_key;
         } else {                          $new =~ s/\s+\S+$//;
           $in_key = 0;                          $key = $new . " " . $key;
           $in_val = 1;                      }
         }  
                       $conf{$key} = $val;
         if ($key) {                      $last_key   = $key;
           $key =~ s/^\s+//;                      $key        = '';
           $key =~ s/\s+$//;                  }
                   elsif ($val) {
           if (defined $val) {                      push @vals, $val;
             $val =~ s/^\s+//;                  }
             $val =~ s/\s+$//;                  $val = '';
           }  
               }
           if ($key eq 'Checksum' && $last_key) {              elsif ( $c eq ']' ) {
             # Special case for these bastids.                  $in_val = 1;
             my $new = $last_key;                  $in_key = 0;
             $new =~ s/\s+\S+$//;                  $c      = shift @chars;
             $key = $new . " " . $key;  
           }              }
               elsif ($in_key) {
           $last_key = $key;                  $key .= $c;
           $conf{$key} = $val;  
           $key = '';              }
           $val = '';              elsif ($in_val) {
         }                  $val .= $c;
               }
       } elsif ($c eq ']') {          }
         $in_val = 1;      }
         $in_key = 0;  
         $c = shift @chars;      unless ($key) {
           push @vals, $val;
       } elsif ($in_key) {      }
         $key .= $c;  
       if ( @vals == 1 ) {
       } elsif ($in_val) {          $val = $vals[0];
         $val .= $c;      }
       }      elsif (@vals) {
     }          $val = \@vals;
   }      }
       else {
   if (%conf) {          $val = undef;
     return \%conf;      }
   } else {  
     return $val;      if (%conf) {
   }          $conf{_pre} = $val if $val;
 }          return \%conf;
       }
 #=item _decode_each_line      else {
           return $val;
 sub _decode_each_line      }
 {  }
   my @lines = @_;  
   my @decoded;  #=item _decode_each_line
   foreach my $line (@lines) {  
     my $decoded = _decode_lines($line);  sub _decode_each_line {
     push @decoded, $decoded if defined $decoded;      my @lines = @_;
   }      my @decoded;
   return \@decoded;      foreach my $line (@lines) {
 }          my $decoded = _decode_lines($line);
           push @decoded, $decoded if defined $decoded;
 #=item _decode_sulog      }
       return \@decoded;
 sub _decode_sulog  }
 {  
   my @lines = @_;  #=item _decode_sulog
   my @decoded;  
   my $last_tm;  sub _decode_sulog {
   foreach my $line (@lines) {      my @lines = @_;
     my $decoded = _decode_lines($line);      my @decoded;
       my $last_tm;
     if (defined $decoded) {      foreach my $line (@lines) {
       if ($decoded->{'tm'}) {          my $decoded = _decode_lines($line);
         $last_tm = $decoded->{'tm'};  
         next;          if ( defined $decoded ) {
       } else {              if ( $decoded->{'tm'} ) {
         $decoded->{'tm'} = $last_tm;                  $last_tm = $decoded->{'tm'};
       }                  next;
       next unless $last_tm;              }
               else {
       push @decoded, $decoded if defined $decoded;                  $decoded->{'tm'} = $last_tm;
     }              }
   }              next unless $last_tm;
   return \@decoded;  
 }              push @decoded, $decoded if defined $decoded;
           }
 #=item _decode_maclist      }
       return \@decoded;
 sub _decode_maclist  }
 {  
         my @lines = @_;  #=item _decode_maclist
         my @decoded;  
         my $total_entries = 0;  sub _decode_maclist {
         my $current_tm = 0;      my @lines = @_;
         foreach my $line (@lines) {      my @decoded;
                 $line =~ s/\r?\n$//;      my $total_entries = 0;
                 my ($mac, $loc, $tm) = $line =~ /      my $current_tm    = 0;
                         ([0-9a-fA-F ]{17})\s+      foreach my $line (@lines) {
                         (.*)\s+          $line =~ s/\r?\n$//;
                         tm\s+          my ( $mac, $loc, $tm ) = $line =~ /
                         (\d+)              ([0-9a-fA-F ]{17})\s+
                 /x;              (.*)\s+
               tm\s+
                 if ($mac) {              (\d+)
                         $mac =~ s/\s+//g;          /x;
                         $loc =~ s/^\s+//;  
                         $loc =~ s/\s+$//;          if ($mac) {
               $mac =~ s/\s+//g;
                         my $suid = undef;              $loc =~ s/^\s+//;
                         if ($loc =~ /suid\s+=\s+(\d+)/) {              $loc =~ s/\s+$//;
                                 $suid = $1;  
                                 $loc = undef;              my $suid = undef;
                         }              if ( $loc =~ /suid\s+=\s+(\d+)/ ) {
                   $suid = $1;
                         push @decoded, {                  $loc  = undef;
                                 mac  => $mac,              }
                                 loc  => $loc,  
                                 tm   => $tm,              push @decoded,
                                 suid => $suid,                {
                         };                  mac  => $mac,
                 } elsif ($line =~ /(\d+)\s+entries/) {                  loc  => $loc,
                         $total_entries = $1;                  tm   => $tm,
                 } elsif ($line =~ /current tm = (\d+)\s+sec/) {                  suid => $suid,
                         $current_tm = $1                };
                 }          }
         }          elsif ( $line =~ /(\d+)\s+entries/ ) {
               $total_entries = $1;
         map { $_->{'cur_tm'} = $current_tm } @decoded;          }
           elsif ( $line =~ /current tm = (\d+)\s+sec/ ) {
         if (scalar @decoded == $total_entries) {              $current_tm = $1;
                 return \@decoded;          }
         } else {      }
                 # XXX we should have a way to set last error, not sure why we don't  
                 return undef;      map { $_->{'cur_tm'} = $current_tm } @decoded;
         }  
 }      if ( scalar @decoded == $total_entries ) {
           return \@decoded;
 1;      }
 __END__      else {
   
 =back          # XXX we should have a way to set last error, not sure why we don't
           return;
 =head1 SEE ALSO      }
   }
 Trango Documentation - http://www.trangobroadband.com/support/product_docs.htm  
   1;    # End of Net::Telnet::Trango
 L<Net::Telnet>  __END__
   
 =head1 TODO  =head1 SEE ALSO
   
 There are still a lot of commands that are not accessed directly.  If  Trango Documentation -
 you call them (as cmd("command + args") or whatever) and it works,  L<http://www.trangobroadband.com/support/product_docs.htm>
 please send me examples that work and I will try to get it incorporated  
 into the next version of the script.  L<Net::Telnet>
   
 I also want to be able to parse the different types of output from  =head1 TODO
 commands like su, sudb all and anything else that would be better  
 available as a perl datastructure.  There are still a lot of commands that are not accessed directly.  If
   you call them (as cmd("command + args") or whatever) and it works,
 =head1 AUTHOR  please send me examples that work and I will try to get it incorporated
   into the next version of the script.
 Andrew Fresh E<lt>andrew@rraz.netE<gt>  
   I also want to be able to parse the different types of output from
 =head1 COPYRIGHT AND LICENSE  commands like su, sudb all and anything else that would be better
   available as a perl datastructure.
 Copyright (C) 2005,2006,2007 by Andrew Fresh  
   =head1 AUTHOR
 This library is free software; you can redistribute it and/or modify  
 it under the same terms as Perl itself, either Perl version 5.8.7 or,  Andrew Fresh E<lt>andrew@rraz.netE<gt>
 at your option, any later version of Perl 5 you may have available.  
   =head1 SUPPORT
 =cut  
   You can find documentation for this module with the perldoc command.
   
       perldoc Net::Telnet::Trango
   
   You can also look for information at:
   
   =over 4
   
   =item * AnnoCPAN: Annotated CPAN documentation
   
   L<http://annocpan.org/dist/Net-Telnet-Trango>
   
   =item * CPAN Ratings
   
   L<http://cpanratings.perl.org/d/Net-Telnet-Trango>
   
   =item * RT: CPAN's request tracker
   
   L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Telnet-Trango>
   
   =item * Search CPAN
   
   L<http://search.cpan.org/dist/Net-Telnet-Trango>
   
   =back
   
   =head1 COPYRIGHT AND LICENSE
   
   Copyright (C) 2005,2006,2007 by Andrew Fresh
   
   This program is free software; you can redistribute it and/or modify it
   under the same terms as Perl itself.
   
   =cut

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.36

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>