[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.22 and 1.37

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

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