/[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 23 by dpavlin, Mon Apr 23 21:26:08 2007 UTC revision 28 by dpavlin, Tue Apr 24 10:01:22 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    
119  my $ant_password_protected;  sub ant_unknown_password {
120            my $ant = shift || die "no ant?";
121            if ( $ant_unknown_password->{$ant} ) {
122                    $ant_unknown_password->{$ant}--;
123            }
124            return $ant_unknown_password->{$ant};
125    }
126    
127  sub ant_another_passwd {  sub ant_another_passwd {
128          my $ant = shift || die "no ant?";          my $ant = shift || die "no ant?";
129          return if ( $ant_password_protected->{$ant} );  
130            return 0 if ant_unknown_password( $ant );
131            return 0 if $ant_ok_password->{$ant};
132    
133          $ant_passwd->{$ant}++;          $ant_passwd->{$ant}++;
134    
135          if ( $ant_passwd->{$ant} > $#try_accounts ) {          if ( $ant_passwd->{$ant} > $#try_accounts ) {
136                  print "$ant ant with unknown password\n";                  print "$ant ant with unknown password\n";
137                  $ant_password_protected->{$ant}++;                  $ant_unknown_password->{$ant} = 10;
138                    $ant_passwd->{$ant} = 0;
139                  return 0;                  return 0;
140          }          }
141          return 1;          return 1;
142  }  }
143    
144    sub forget_ant {
145            my $ant = shift || die "no ant?";
146            delete $ant_unknown_password->{$ant};
147            delete $ant_passwd->{$ant};
148            delete $ant_ok_password->{$ant};
149    }
150    
151  my $once;  my $once;
152    
153  sub once {  sub once {
# Line 168  while (1) { Line 187  while (1) {
187                  next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# );                  next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# );
188    
189                  my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h );                  my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h );
190                    my $seq_nr = $h->{'SEQ-NR'};
191                    #warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr);
192    
193                  my ($user_id,$user_pwd) = ant_credentials( $ant );                  my ($user_id,$user_pwd) = ant_credentials( $ant );
194    
195                  if ($type eq 'REPLY-ANT-SEARCH') {                  if ($type eq 'REPLY-ANT-SEARCH') {
196                          mdap_send("INFO MDAP/$mdap_ver\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n") unless ( $ant_password_protected->{$ant} );                          mdap_send("INFO MDAP/$mdap_ver\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n") unless ant_unknown_password( $ant );
197                  } elsif ($type eq 'REPLY-INFO') {                  } elsif ($type eq 'REPLY-INFO') {
198    
199                          if ($h->{'SEQ-NR'} < 0) {                          if ( $seq_nr < 0 ) {
200    #                               if ( $ant_ok_password ) {
201    #                                       $ant_ok_password->{$ant} = 0;
202    #                               } elsif ( ant_another_passwd( $ant ) ) {
203                                  if ( ant_another_passwd( $ant ) ) {                                  if ( ant_another_passwd( $ant ) ) {
204                                          my ($user_id,$user_pwd) = ant_credentials( $ant );                                          ($user_id,$user_pwd) = ant_credentials( $ant );
205                                          mdap_send("INFO MDAP/$mdap_ver\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");                                          mdap_send("INFO MDAP/$mdap_ver\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");
206                                  }                                  }
207                                  next;                                  next;
208                            } else {
209                                    $ant_ok_password->{$ant}++;
210                          }                          }
211    
212                          my $board = $h->{'_BOARD_NAME'} || die "no _BOARD_NAME?";                          my $board = $h->{'_BOARD_NAME'} || die "no _BOARD_NAME?";
# Line 192  while (1) { Line 218  while (1) {
218                                          mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:software upgrade\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");                                          mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:software upgrade\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n");
219                                  } else {                                  } else {
220                                          once "$ant OK version $build",                                          once "$ant OK version $build",
221                                                  $ant_password_protected->{$ant} ? '' : ' with password',                                                  $ant_unknown_password->{$ant} ? ' with unknown password' :
222                                                    $ant_ok_password->{$ant} ? ' password protected' :
223                                                    '',
224                                                  "\n";                                                  "\n";
225                                            $ant_flashing->{$ant} = 0;
226                                            my $waiting = 0;
227                                            map {
228                                                    $waiting++ if ($ant_flashing->{$_});
229                                            } keys %$ant_flashing;
230                                            print "**** ALL ANTS FLASHED ****\n" if ($ant_flashing && $waiting == 0);
231                                  }                                  }
232                          } else {                          } else {
233                                  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";
# Line 201  while (1) { Line 235  while (1) {
235                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {
236                                  print "+ $ant bootp mode re-flash started\n";                                  print "+ $ant bootp mode re-flash started\n";
237                                  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");
238                                  $ant_password_protected->{$ant} = 0;                                  forget_ant( $ant );
239                                    $ant_flashing->{$ant}++;
240                  } else {                  } else {
241                          print "!! reply ignored ", dump( $h ), $/;                          print "!! reply ignored ", dump( $h ), $/;
242                  }                  }

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

  ViewVC Help
Powered by ViewVC 1.1.26