/[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 27 by dpavlin, Tue Apr 24 09:52:05 2007 UTC revision 30 by dpavlin, Tue Apr 24 14:53:04 2007 UTC
# Line 104  sub mdap_send { Line 104  sub mdap_send {
104  }  }
105    
106  my $ant_passwd;  my $ant_passwd;
107    my $ant_unknown_password;
108    my $ant_ok_password;
109    my $ant_flashing;
110    
111  sub ant_credentials {  sub ant_credentials {
112          my $ant = shift || die "no ant?";          my $ant = shift || die "no ant?";
# Line 113  sub ant_credentials { Line 116  sub ant_credentials {
116          return ($user_id,$user_pwd);          return ($user_id,$user_pwd);
117  }  }
118    
 my $ant_unknown_password;  
 my $ant_ok_password;  
   
119  sub ant_unknown_password {  sub ant_unknown_password {
120          my $ant = shift || die "no ant?";          my $ant = shift || die "no ant?";
121          if ( $ant_unknown_password->{$ant} ) {          if ( $ant_unknown_password->{$ant} ) {
# Line 128  sub ant_another_passwd { Line 128  sub ant_another_passwd {
128          my $ant = shift || die "no ant?";          my $ant = shift || die "no ant?";
129    
130          return 0 if ant_unknown_password( $ant );          return 0 if ant_unknown_password( $ant );
131            return 0 if $ant_ok_password->{$ant};
132    
133          $ant_passwd->{$ant}++;          $ant_passwd->{$ant}++;
134    
# Line 155  sub once { Line 156  sub once {
156          print $m if ($once->{$m} == 1);          print $m if ($once->{$m} == 1);
157  }  }
158    
159    my $status = '';
160    
161    sub status {
162            my $m = join('', @_);
163            if ($m ne $status) {
164                    print $m;
165                    $status = $m;
166            }
167    }
168    
169  local $SIG{ALRM} = sub {  local $SIG{ALRM} = sub {
170          mdap_send("ANT-SEARCH MDAP/1.1\r\n");          mdap_send("ANT-SEARCH MDAP/1.1\r\n");
171          alarm( $resend_search_delay );          alarm( $resend_search_delay );
# Line 221  while (1) { Line 232  while (1) {
232                                                  $ant_ok_password->{$ant} ? ' password protected' :                                                  $ant_ok_password->{$ant} ? ' password protected' :
233                                                  '',                                                  '',
234                                                  "\n";                                                  "\n";
235                                            $ant_flashing->{$ant} = 0;
236                                            my $waiting = 0;
237                                            my $count = 0;
238                                            map {
239                                                    $waiting++ if ($ant_flashing->{$_});
240                                                    $count++;
241                                            } keys %$ant_flashing;
242                                            if ($waiting == 0) {
243                                                    status "ALL $count ANTS FLASHED to $build\n";
244                                                    $ant_flashing = undef;
245                                            } else {
246                                                    status "$waiting of $count ants still flasing upto $build\n";
247                                            }
248                                  }                                  }
249                          } else {                          } else {
250                                  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";
251                          }                          }
252                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {
253                                  print "+ $ant bootp mode re-flash started\n";                                  print "+ $ant bootp mode re-flash started\n" if ($verbose);
254                                  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");
255                                  forget_ant( $ant );                                  forget_ant( $ant );
256                                    $ant_flashing->{$ant}++;
257                  } else {                  } else {
258                          print "!! reply ignored ", dump( $h ), $/;                          print "!! reply ignored ", dump( $h ), $/;
259                  }                  }

Legend:
Removed from v.27  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26