final rftest2pcap script
Signed-off-by: Mariano Alvira <mar@devl.org>
This commit is contained in:
parent
56a75f637f
commit
400ea36fce
|
@ -53,28 +53,32 @@ while(1) {
|
||||||
if (defined($count) && ($count != 0)) {
|
if (defined($count) && ($count != 0)) {
|
||||||
$str .= $c;
|
$str .= $c;
|
||||||
# match if ends in \n or \r and process line
|
# match if ends in \n or \r and process line
|
||||||
if(($str =~ /\n\r$/) ||
|
if(($str =~ /\n$/) ||
|
||||||
($str =~ /\r\n$/)) {
|
($str =~ /\r$/)) {
|
||||||
if($str =~ /^rftest/) {
|
if($str =~ /^rftest/) {
|
||||||
#new packet
|
#new packet
|
||||||
($sec, $usec) = gettimeofday;
|
($sec, $usec) = gettimeofday;
|
||||||
# print "rftestline: $sec $usec $str\n\r";
|
print STDERR "rftestline: $sec $usec $str";
|
||||||
} elsif($str =~ /^\s*data/) {
|
} elsif($str =~ /^\s*data/) {
|
||||||
#packet payload
|
#packet payload
|
||||||
|
print STDERR "dataline: ";
|
||||||
|
print STDERR $str;
|
||||||
$str =~ /data: 0x\d+ (.+)/;
|
$str =~ /data: 0x\d+ (.+)/;
|
||||||
my @data = split(' ',$1);
|
my @data = split(' ',$1);
|
||||||
# print "dataline: ";
|
|
||||||
($len, @data) = @data;
|
($len, @data) = @data;
|
||||||
# print "\n\r";
|
|
||||||
#write out pcap entry
|
#write out pcap entry
|
||||||
print pack('LLLL',($sec,$usec,scalar(@data),scalar(@data)+2));
|
print pack('LLLL',($sec,$usec,scalar(@data),scalar(@data)+2));
|
||||||
|
print STDERR "new packet: $sec $usec " . scalar(@data) . " " . (scalar(@data)+2) . "\n\r";
|
||||||
@frame = @data[0,1];
|
@frame = @data[0,1];
|
||||||
print pack ('CC',($frame[1],$frame[0]));
|
print pack ('CC',(hex($frame[0]),hex($frame[1])));
|
||||||
|
print STDERR "$frame[0] $frame[1] ";
|
||||||
foreach my $data (@data[2..scalar(@data)-1]) {
|
foreach my $data (@data[2..scalar(@data)-1]) {
|
||||||
print pack ('C',hex($data));
|
print pack ('C',hex($data));
|
||||||
|
print STDERR "$data ";
|
||||||
}
|
}
|
||||||
|
print STDERR "\n\r";
|
||||||
}
|
}
|
||||||
|
print STDERR "\n\r";
|
||||||
$str = '';
|
$str = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue