1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
2 |
|
|
3 |
|
use warnings; |
4 |
use strict; |
use strict; |
5 |
use IO::Socket::Multicast; |
use IO::Socket::Multicast; |
6 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
17 |
my $resend_search_delay = 3; |
my $resend_search_delay = 3; |
18 |
my $tftp_path = '/srv/tftp/'; |
my $tftp_path = '/srv/tftp/'; |
19 |
|
|
20 |
|
my $flashed_cmd = 'system config led=flash'; |
21 |
|
|
22 |
GetOptions( |
GetOptions( |
23 |
"port=i" => \$PORT, |
"port=i" => \$PORT, |
24 |
"group=s" => \$GROUP, |
"group=s" => \$GROUP, |
28 |
"search=i" => \$resend_search_delay, |
"search=i" => \$resend_search_delay, |
29 |
"tftp=s" => \$tftp_path, |
"tftp=s" => \$tftp_path, |
30 |
"credentials" => \$credentials, |
"credentials" => \$credentials, |
31 |
|
"exec=s" => \$flashed_cmd, |
32 |
); |
); |
33 |
|
|
34 |
$quiet = 0 if $verbose; |
$quiet = 0 if $verbose; |
45 |
while(<$fh>) { |
while(<$fh>) { |
46 |
chomp; |
chomp; |
47 |
next if /^#/ || /^$/ || /^\s+$/; |
next if /^#/ || /^$/ || /^\s+$/; |
48 |
if (/^\S+\s\S+$/) { |
if (/^\S+\s+\S+$/) { |
49 |
push @try_accounts, $_; |
push @try_accounts, $_; |
50 |
} else { |
} else { |
51 |
warn "invalid $passwd_path entry: $_\n"; |
warn "invalid $passwd_path entry: $_\n"; |
52 |
} |
} |
53 |
} |
} |
54 |
print "found ", $#try_accounts + 1, " accounts to try on password protected ants\n"; |
print "found ", $#try_accounts + 1, " accounts to try on password protected ants", |
55 |
|
$credentials ? " and display credentials" : "", "\n"; |
56 |
} |
} |
57 |
|
|
58 |
warn "search for ants every ${resend_search_delay}s\ntftp server path: $tftp_path\n"; |
warn "search for ants every ${resend_search_delay}s\ntftp server path: $tftp_path\nflashed to current version: $flashed_cmd\n"; |
59 |
|
|
60 |
sub fw { |
sub fw { |
61 |
my ($board, $offset,$len) = @_; |
my ($board, $offset,$len) = @_; |
245 |
|
|
246 |
$ant_flashing->{$ant} = 0; |
$ant_flashing->{$ant} = 0; |
247 |
# green|red|orange|flash|off |
# green|red|orange|flash|off |
248 |
mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:system config led=flash\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:$flashed_cmd\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n"); |
249 |
my $waiting = 0; |
my $waiting = 0; |
250 |
my $count = 0; |
my $count = 0; |
251 |
map { |
map { |
263 |
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"; |
264 |
} |
} |
265 |
} elsif ( $type eq 'REPLY-EXEC-CLI' ) { |
} elsif ( $type eq 'REPLY-EXEC-CLI' ) { |
266 |
print "+ $type ", dump( $data ), "\n" if ($verbose); |
print "+ $type\n$data\n" if ($verbose); |
267 |
if ( $seq_nr == 1 ) { |
if ( $seq_nr == 1 ) { |
268 |
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"); |
269 |
forget_ant( $ant ) if ( $ant_flashing->{$ant} ); |
forget_ant( $ant ) if ( $ant_flashing->{$ant} ); |
270 |
} |
} |
271 |
|
|
272 |
} else { |
} else { |
273 |
print "!! reply $type ignored ", dump( $h ), $/; |
print "!! reply $type ignored ", dump( $h ), $/; |
274 |
} |
} |