7 |
use strict; |
use strict; |
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
|
|
10 |
my $path = shift @ARGV || '/srv/tftp/BANT-R'; # die "Usage: $0 firmware.bin\n"; |
my @images = @ARGV; |
11 |
|
push @images, '/srv/tftp/BANT-R' unless @images; |
12 |
|
|
13 |
my $magic = 'BLI223QH0'; |
my $magic = 'BLI223QH0'; |
14 |
|
|
15 |
open(my $fh, $path) || die "Can't open $path: $!"; |
for my $path ( @images ) { |
16 |
my $b; |
open(my $fh, $path) || die "Can't open $path: $!"; |
17 |
read($fh, $b, length($magic)); |
my $b; |
18 |
die "# $path not a firmware image\n" unless ($b eq $magic); |
read($fh, $b, length($magic)); |
19 |
seek($fh, 32, 0) || die "can't seek to 32: $!"; |
warn "# $path not a firmware image\n" unless ($b eq $magic); |
20 |
read($fh, $b, 4); |
seek($fh, 32, 0) || die "can't seek to 32: $!"; |
21 |
printf("%8s %s\n", join('.',unpack('CCCC', $b)), $path); |
read($fh, $b, 4); |
22 |
|
printf("%8s %s\n", join('.',unpack('CCCC', $b)), $path); |
23 |
|
} |