/[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 28 by dpavlin, Tue Apr 24 10:01:22 2007 UTC revision 31 by dpavlin, Tue Apr 24 15:44:20 2007 UTC
# Line 11  my $PORT  = '3235'; Line 11  my $PORT  = '3235';
11  my $debug = 0;  my $debug = 0;
12  my $quiet = 1;  my $quiet = 1;
13  my $verbose = 0;  my $verbose = 0;
14    my $credentials = 0;
15    
16  my $resend_search_delay = 3;  my $resend_search_delay = 3;
17  my $tftp_path = '/srv/tftp/';  my $tftp_path = '/srv/tftp/';
# Line 23  GetOptions( Line 24  GetOptions(
24          "verbose!"      => \$verbose,          "verbose!"      => \$verbose,
25          "search=i"      => \$resend_search_delay,          "search=i"      => \$resend_search_delay,
26          "tftp=s"        => \$tftp_path,          "tftp=s"        => \$tftp_path,
27            "credentials"   => \$credentials,
28  );  );
29    
30  $quiet = 0 if $verbose;  $quiet = 0 if $verbose;
# Line 38  if (-e $passwd_path) { Line 40  if (-e $passwd_path) {
40          while(<$fh>) {          while(<$fh>) {
41                  chomp;                  chomp;
42                  next if /^#/ || /^$/ || /^\s+$/;                  next if /^#/ || /^$/ || /^\s+$/;
43                  if (/^\S+\t\S+$/) {                  if (/^\S+\s\S+$/) {
44                          push @try_accounts, $_;                          push @try_accounts, $_;
45                  } else {                  } else {
46                          warn "invalid $passwd_path entry: $_\n";                          warn "invalid $passwd_path entry: $_\n";
# Line 156  sub once { Line 158  sub once {
158          print $m if ($once->{$m} == 1);          print $m if ($once->{$m} == 1);
159  }  }
160    
161    my $status = '';
162    
163    sub status {
164            my $m = join('', @_);
165            if ($m ne $status) {
166                    print $m;
167                    $status = $m;
168            }
169    }
170    
171  local $SIG{ALRM} = sub {  local $SIG{ALRM} = sub {
172          mdap_send("ANT-SEARCH MDAP/1.1\r\n");          mdap_send("ANT-SEARCH MDAP/1.1\r\n");
173          alarm( $resend_search_delay );          alarm( $resend_search_delay );
# Line 207  while (1) { Line 219  while (1) {
219                                  next;                                  next;
220                          } else {                          } else {
221                                  $ant_ok_password->{$ant}++;                                  $ant_ok_password->{$ant}++;
222                                    print "$ant credentials $user_id $user_pwd\n" if ($credentials && $ant_ok_password->{$ant} == 1);
223                          }                          }
224    
225                          my $board = $h->{'_BOARD_NAME'} || die "no _BOARD_NAME?";                          my $board = $h->{'_BOARD_NAME'} || die "no _BOARD_NAME?";
# Line 224  while (1) { Line 237  while (1) {
237                                                  "\n";                                                  "\n";
238                                          $ant_flashing->{$ant} = 0;                                          $ant_flashing->{$ant} = 0;
239                                          my $waiting = 0;                                          my $waiting = 0;
240                                            my $count = 0;
241                                          map {                                          map {
242                                                  $waiting++ if ($ant_flashing->{$_});                                                  $waiting++ if ($ant_flashing->{$_});
243                                                    $count++;
244                                          } keys %$ant_flashing;                                          } keys %$ant_flashing;
245                                          print "**** ALL ANTS FLASHED ****\n" if ($ant_flashing && $waiting == 0);                                          if ($waiting == 0) {
246                                                    status "ALL $count ANTS FLASHED to $build\n";
247                                                    $ant_flashing = undef;
248                                            } else {
249                                                    status "$waiting of $count ants still flasing upto $build\n";
250                                            }
251                                  }                                  }
252                          } else {                          } else {
253                                  once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n";                                  once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n";
254                          }                          }
255                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {
256                                  print "+ $ant bootp mode re-flash started\n";                                  print "+ $ant bootp mode re-flash started\n" if ($verbose);
257                                  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");
258                                  forget_ant( $ant );                                  forget_ant( $ant );
259                                  $ant_flashing->{$ant}++;                                  $ant_flashing->{$ant}++;

Legend:
Removed from v.28  
changed lines
  Added in v.31

  ViewVC Help
Powered by ViewVC 1.1.26