pcap-parser 91 packets ??

This commit is contained in:
Alon Levy
2023-12-29 01:15:52 +02:00
parent e15ec35ddd
commit 1716ed1924
3 changed files with 365 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
use std::fs::File;
use pcap_parser::traits::PcapReaderIterator;
use pcap_parser::*;
fn main() -> anyhow::Result<()> {
let file = File::open("in.pcap")?;
let mut cap = PcapNGReader::new(65535, file)?;
let mut i = 0;
let mut max_offset = 0;
while let Ok((offset, _packet)) = cap.next() {
i += 1;
max_offset = offset;
cap.consume(offset)
}
println!("found {} packets, {} last offset", i, max_offset);
Ok(())
}