pub struct PcapDataEngine<A: PcapAnalyzer> { /* private fields */ }Expand description
pcap/pcap-ng data analyzer engine
PcapDataEngine iterates over a pcap input, parses data and abstracts the
format (pcap datalink, endianness etc.) for the analysis.
PcapDataEngine stores a PcapAnalyzer instance, and wraps it to receive parsed data blocks.
Internally, it is an abstraction over a BlockEngine.
§example
use pako_tools::{Config, Error, Packet, ParseContext, PcapAnalyzer, PcapDataEngine, PcapEngine};
#[derive(Default)]
pub struct ExampleAnalyzer {
packet_count: usize,
}
impl PcapAnalyzer for ExampleAnalyzer {
fn handle_packet(&mut self, packet: &Packet, ctx: &ParseContext) -> Result<(), Error> {
Ok(())
}
}
let config = Config::default();
let analyzer = ExampleAnalyzer::default();
let mut engine = PcapDataEngine::new(analyzer, &config);
// `engine.run()` can take any `mut Read` as input
// Here, we use a cursor as an example
use std::io::Cursor;
let mut input = Cursor::new(vec![1, 2, 3, 4, 5]);
let res = engine.run(&mut input);Implementations§
Source§impl<A: PcapAnalyzer> PcapDataEngine<A>
impl<A: PcapAnalyzer> PcapDataEngine<A>
pub fn new(data_analyzer: A, config: &Config) -> Self
pub fn data_analyzer(&self) -> &A
pub fn data_analyzer_mut(&mut self) -> &mut A
Trait Implementations§
Source§impl<A: PcapAnalyzer> PcapEngine for PcapDataEngine<A>
impl<A: PcapAnalyzer> PcapEngine for PcapDataEngine<A>
Auto Trait Implementations§
impl<A> Freeze for PcapDataEngine<A>where
A: Freeze,
impl<A> RefUnwindSafe for PcapDataEngine<A>where
A: RefUnwindSafe,
impl<A> Send for PcapDataEngine<A>where
A: Send,
impl<A> Sync for PcapDataEngine<A>where
A: Sync,
impl<A> Unpin for PcapDataEngine<A>where
A: Unpin,
impl<A> UnwindSafe for PcapDataEngine<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more