113 |
return ($user_id,$user_pwd); |
return ($user_id,$user_pwd); |
114 |
} |
} |
115 |
|
|
116 |
my $ant_password_protected; |
my $ant_unknown_password; |
117 |
|
my $ant_ok_password; |
118 |
|
|
119 |
|
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 |
|
|
132 |
$ant_passwd->{$ant}++; |
$ant_passwd->{$ant}++; |
133 |
|
|
134 |
if ( $ant_passwd->{$ant} > $#try_accounts ) { |
if ( $ant_passwd->{$ant} > $#try_accounts ) { |
135 |
print "$ant ant with unknown password\n"; |
print "$ant ant with unknown password\n"; |
136 |
$ant_password_protected->{$ant}++; |
$ant_unknown_password->{$ant} = 10; |
137 |
|
$ant_passwd->{$ant} = 0; |
138 |
return 0; |
return 0; |
139 |
} |
} |
140 |
return 1; |
return 1; |
141 |
} |
} |
142 |
|
|
143 |
|
sub forget_ant { |
144 |
|
my $ant = shift || die "no ant?"; |
145 |
|
delete $ant_unknown_password->{$ant}; |
146 |
|
delete $ant_passwd->{$ant}; |
147 |
|
delete $ant_ok_password->{$ant}; |
148 |
|
} |
149 |
|
|
150 |
my $once; |
my $once; |
151 |
|
|
152 |
sub once { |
sub once { |
186 |
next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# ); |
next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# ); |
187 |
|
|
188 |
my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h ); |
my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h ); |
189 |
|
my $seq_nr = $h->{'SEQ-NR'}; |
190 |
|
#warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr); |
191 |
|
|
192 |
my ($user_id,$user_pwd) = ant_credentials( $ant ); |
my ($user_id,$user_pwd) = ant_credentials( $ant ); |
193 |
|
|
194 |
if ($type eq 'REPLY-ANT-SEARCH') { |
if ($type eq 'REPLY-ANT-SEARCH') { |
195 |
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 ); |
196 |
} elsif ($type eq 'REPLY-INFO') { |
} elsif ($type eq 'REPLY-INFO') { |
197 |
|
|
198 |
if ($h->{'SEQ-NR'} < 0) { |
if ( $seq_nr < 0 ) { |
199 |
|
# if ( $ant_ok_password ) { |
200 |
|
# $ant_ok_password->{$ant} = 0; |
201 |
|
# } elsif ( ant_another_passwd( $ant ) ) { |
202 |
if ( ant_another_passwd( $ant ) ) { |
if ( ant_another_passwd( $ant ) ) { |
203 |
my ($user_id,$user_pwd) = ant_credentials( $ant ); |
($user_id,$user_pwd) = ant_credentials( $ant ); |
204 |
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"); |
205 |
} |
} |
206 |
next; |
next; |
207 |
|
} else { |
208 |
|
$ant_ok_password->{$ant}++; |
209 |
} |
} |
210 |
|
|
211 |
my $board = $h->{'_BOARD_NAME'} || die "no _BOARD_NAME?"; |
my $board = $h->{'_BOARD_NAME'} || die "no _BOARD_NAME?"; |
217 |
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"); |
218 |
} else { |
} else { |
219 |
once "$ant OK version $build", |
once "$ant OK version $build", |
220 |
$ant_password_protected->{$ant} ? '' : ' with password', |
$ant_unknown_password->{$ant} ? ' with unknown password' : |
221 |
|
$ant_ok_password->{$ant} ? ' password protected' : |
222 |
|
'', |
223 |
"\n"; |
"\n"; |
224 |
} |
} |
225 |
} else { |
} else { |
228 |
} elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) { |
} elsif ( $type eq 'REPLY-EXEC-CLI' && $h->{'SEQ-NR'} == 1 ) { |
229 |
print "+ $ant bootp mode re-flash started\n"; |
print "+ $ant bootp mode re-flash started\n"; |
230 |
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"); |
231 |
$ant_password_protected->{$ant} = 0; |
forget_ant( $ant ); |
232 |
} else { |
} else { |
233 |
print "!! reply ignored ", dump( $h ), $/; |
print "!! reply ignored ", dump( $h ), $/; |
234 |
} |
} |