parses all packets, forgot to account for partial
This commit is contained in:
parent
1716ed1924
commit
2e4e7c7c07
|
@ -7,12 +7,24 @@ fn main() -> anyhow::Result<()> {
|
||||||
let file = File::open("in.pcap")?;
|
let file = File::open("in.pcap")?;
|
||||||
let mut cap = PcapNGReader::new(65535, file)?;
|
let mut cap = PcapNGReader::new(65535, file)?;
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
let mut max_offset = 0;
|
let mut size = 0;
|
||||||
while let Ok((offset, _packet)) = cap.next() {
|
loop {
|
||||||
|
match cap.next() {
|
||||||
|
Ok((offset, _packet)) => {
|
||||||
i += 1;
|
i += 1;
|
||||||
max_offset = offset;
|
size += offset;
|
||||||
cap.consume(offset)
|
cap.consume(offset)
|
||||||
}
|
}
|
||||||
println!("found {} packets, {} last offset", i, max_offset);
|
Err(PcapError::Eof) => break,
|
||||||
|
Err(PcapError::Incomplete) => {
|
||||||
|
cap.refill().unwrap();
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
println!("unexpected error");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("found {} packets, {} size", i, size);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user