/[mdap]/mdap-server.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /mdap-server.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 47 by dpavlin, Fri Nov 16 14:59:30 2007 UTC revision 64 by dpavlin, Sun Nov 18 00:55:43 2007 UTC
# Line 7  use Data::Dump qw/dump/; Line 7  use Data::Dump qw/dump/;
7  use Getopt::Long;  use Getopt::Long;
8    
9  use lib './lib';  use lib './lib';
10  use MDAP::ChangeIP;  use MDAP;
11    
12  my $GROUP = '224.0.0.103';  my $GROUP = '224.0.0.103';
13  my $PORT  = '3235';  my $PORT  = '3235';
14    
15  my $debug = 0;  #my $debug = 0; # from MDAP
16  my $quiet = 1;  my $quiet = 1;
17  my $verbose = 0;  my $verbose = 0;
18  my $credentials = 0;  my $credentials = 0;
19    
20    my $plugins = 1;
21    
22  my $resend_search_delay = 3;  my $resend_search_delay = 3;
23  my $tftp_path = '/srv/tftp/';  my $tftp_path = '/srv/tftp/';
24    
# Line 32  GetOptions( Line 34  GetOptions(
34          "tftp=s"        => \$tftp_path,          "tftp=s"        => \$tftp_path,
35          "credentials"   => \$credentials,          "credentials"   => \$credentials,
36          "exec=s"        => \$flashed_cmd,          "exec=s"        => \$flashed_cmd,
37            'plugins!'      => \$plugins,
38  );  );
39    
40  $quiet = 0 if $verbose;  $quiet = 0 if $verbose;
# Line 159  sub forget_ant { Line 162  sub forget_ant {
162          delete $ant_ok_password->{$ant};          delete $ant_ok_password->{$ant};
163  }  }
164    
 my $once;  
   
 sub once {  
         my $m = join('', @_);  
         $once->{$m}++;  
         print $m if ($once->{$m} == 1);  
 }  
   
165  my $status = '';  my $status = '';
166    
167  sub status {  sub status {
# Line 243  while (1) { Line 238  while (1) {
238                                          once "$ant OK version $build",                                          once "$ant OK version $build",
239                                                  $ant_unknown_password->{$ant} ? ' with unknown password' :                                                  $ant_unknown_password->{$ant} ? ' with unknown password' :
240                                                  $ant_passwd->{$ant} ? ' password protected' :                                                  $ant_passwd->{$ant} ? ' password protected' :
241                                                  '',                                                  '';
                                                 "\n";  
242    
243                                          $ant_flashing->{$ant} = 0;                                          $ant_flashing->{$ant} = 0;
244                                          # green|red|orange|flash|off                                          # green|red|orange|flash|off
# Line 262  while (1) { Line 256  while (1) {
256                                                  status "$waiting of $count ants still flasing upto $build\n";                                                  status "$waiting of $count ants still flasing upto $build\n";
257                                          }                                          }
258                                  }                                  }
                         } else {  
                                 once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n";  
                         }  
259    
260                          if ( my $command = CWMP::ChangeIP::check( $h ) ) {                                  if ( $plugins ) {
261                                  warn "## sending $command to $ant\n";                                          foreach my $plugin ( MDAP->plugins ) {
262                                  mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:$command\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");                                                  warn "## calling $plugin\n" if $debug;
263                                                    if ( my $command = $plugin->check( $h ) ) {
264    
265                                                            warn ">> $plugin $ant ",
266                                                                    $h->{'ANT-NAME'}, " ",
267                                                                    $h->{'_BUILD'}, " ",
268                                                                    "\t:$command\n";
269                    
270                                                            mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:$command\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");
271                                                            last;
272                                                    }
273                                            }
274                                    }
275    
276                            } else {
277                                    once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update";
278                          }                          }
279    
280                  } elsif ( $type eq 'REPLY-EXEC-CLI' ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' ) {
281                          print "+ $type\n$data\n" if ($verbose);                          print "##<< $type\n$data\n" if $debug;
282                          if ( $seq_nr == 1 ) {                          if ( $seq_nr == 1 ) {
283                                  mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nSEQ-NR:2\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");                                  mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nSEQ-NR:2\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");
284                                  forget_ant( $ant ) if ( $ant_flashing->{$ant} );                                  forget_ant( $ant ) if ( $ant_flashing->{$ant} );
285                          } elsif ( $seq_nr < 0 ) {                          } elsif ( $seq_nr < 0 ) {
286                                  warn "EXEC-CLI failed\n";                                  warn "EXEC-CLI failed: $data\n";
287                          }                          }
288    
289                  } else {                  } else {

Legend:
Removed from v.47  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC 1.1.26