/[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 19 by dpavlin, Mon Apr 23 19:06:18 2007 UTC revision 20 by dpavlin, Mon Apr 23 19:40:57 2007 UTC
# Line 103  sub mdap_send { Line 103  sub mdap_send {
103          }          }
104  }  }
105    
106  my $ant_passwd_try;  my $ant_passwd;
107    
108  sub ant_credentials {  sub ant_credentials {
109          my $ant = shift || die "no ant?";          my $ant = shift || die "no ant?";
110          my $i = $ant_passwd_try->{$ant} || 0;          my $i = $ant_passwd->{$ant} || 0;
111          my ($user_id,$user_pwd) = split(/\t/, $try_accounts[$i]);          my ($user_id,$user_pwd) = split(/\t/, $try_accounts[$i]);
112          #warn "ant $ant as [$i] $user_id / $user_pwd\n";          #warn "ant $ant as [$i] $user_id / $user_pwd\n";
113          return ($user_id,$user_pwd);          return ($user_id,$user_pwd);
114  }  }
115    
116    my $ant_password_protected;
117    
118  sub ant_another_passwd {  sub ant_another_passwd {
119          my $ant = shift || die "no ant?";          my $ant = shift || die "no ant?";
120          $ant_passwd_try->{$ant}++;          return if ( $ant_password_protected->{$ant} );
121          $ant_passwd_try->{$ant} = 0 if ( $ant_passwd_try->{$ant} > $#try_accounts );  
122            $ant_passwd->{$ant}++;
123    
124            if ( $ant_passwd->{$ant} > $#try_accounts ) {
125                    print "!! ant $ant password protected\n";
126                    $ant_password_protected->{$ant}++;
127                    return 0;
128            }
129            return 1;
130    }
131    
132    my $once;
133    
134    sub once {
135            my $m = join(" ", @_);
136            $once->{$m}++;
137            print $m if ($once->{$m} == 1);
138  }  }
139    
140  local $SIG{ALRM} = sub {  local $SIG{ALRM} = sub {
# Line 154  while (1) { Line 172  while (1) {
172                  my ($user_id,$user_pwd) = ant_credentials( $ant );                  my ($user_id,$user_pwd) = ant_credentials( $ant );
173    
174                  if ($type eq 'REPLY-ANT-SEARCH') {                  if ($type eq 'REPLY-ANT-SEARCH') {
175                          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") unless ( $ant_password_protected->{$ant} );
176                  } elsif ($type eq 'REPLY-INFO') {                  } elsif ($type eq 'REPLY-INFO') {
177    
178                          if ($h->{'SEQ-NR'} < 0) {                          if ($h->{'SEQ-NR'} < 0) {
179                                  warn "!! password protected ant $ant, skipping\n";                                  if ( ant_another_passwd( $ant ) ) {
180                                  ant_another_passwd( $ant );                                          my ($user_id,$user_pwd) = ant_credentials( $ant );
181                                            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");
182                                    }
183                                  next;                                  next;
184                          }                          }
185    
# Line 171  while (1) { Line 191  while (1) {
191                                          print "UPDATE STEP 1 on ant $ant version $build -> $new_build\n";                                          print "UPDATE STEP 1 on ant $ant version $build -> $new_build\n";
192                                          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");
193                                  } else {                                  } else {
194                                          print "OK ant $ant allready updated...\n";                                          once "OK ant $ant has $build\n";
195                                  }                                  }
196                          } else {                          } else {
197                                  print "!! 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";
198                          }                          }
199                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) {
200                                  print "UPDATE STEP 2 on ant $ant\n";                                  print "UPDATE STEP 2 on ant $ant\n";

Legend:
Removed from v.19  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26