1 |
#!/usr/bin/perl -w |
2 |
|
3 |
# fw-info.pl |
4 |
# |
5 |
# 04/22/07 16:33:13 CEST Dobrica Pavlinusic <dpavlin@rot13.org> |
6 |
|
7 |
use strict; |
8 |
use Data::Dump qw/dump/; |
9 |
|
10 |
my @images = @ARGV; |
11 |
push @images, '/srv/tftp/BANT-R' unless @images; |
12 |
|
13 |
my $magic = 'BLI223QH0'; |
14 |
|
15 |
for my $path ( @images ) { |
16 |
open(my $fh, $path) || die "Can't open $path: $!"; |
17 |
my $b; |
18 |
read($fh, $b, length($magic)); |
19 |
warn "# $path not a firmware image\n" unless ($b eq $magic); |
20 |
seek($fh, 32, 0) || die "can't seek to 32: $!"; |
21 |
read($fh, $b, 4); |
22 |
printf("%8s %s\n", join('.',unpack('CCCC', $b)), $path); |
23 |
} |