Able to replay an entire DEEP file!

This commit is contained in:
2019-08-24 23:58:24 -04:00
parent 5ce7ce740b
commit ac9914be3c
3 changed files with 113 additions and 48 deletions

View File

@ -3,9 +3,8 @@ use std::io::Read;
use std::path::Path;
use clap::{App, Arg};
use nom::sequence::tuple;
use parsers::Block;
use crate::iex::IexParser;
// Cap'n'Proto and Flatbuffers typically ask that you generate code on the fly to match
// the schemas. For purposes of auto-complete and easy browsing in the repository,
@ -35,16 +34,7 @@ fn main() {
let mut buf = Vec::new();
file.read_to_end(&mut buf).expect(&format!("Unable to read file={}", path.display()));
let mut rem = &buf[..];
while let Ok((unparsed, block)) = parsers::read_block(rem) {
let offset = (unparsed.as_ptr() as usize) - (buf.as_ptr() as usize);
rem = unparsed;
match block {
Block::SectionHeader(sh) => println!("{:?}, next offset={}", sh, offset),
Block::InterfaceDescription(id) => println!("{:?}, next offset={}", id, offset),
Block::EnhancedPacket(epb) => println!("EnhancedPacketBlock {{ block_len: {}, packet_len: {} }}, next offset={}", epb.block_len, epb.packet_data.len(), offset)
}
for _payload in IexParser::new(&buf[..]) {
//dbg!(payload);
}
println!("Remaining unparsed len={}", rem.len());
}