mod packet;
mod lib_version;
mod interf_desc;
mod data_link;
mod err;
use crate::traits::Library;
use crate::{wpcap, pcap, pfring};
use std::sync::Arc;
pub use self::lib_version::LibraryVersion;
pub use self::packet::{Packet, OwnedPacket, BorrowedPacket};
pub use self::interf_desc::InterfaceDescription;
pub use self::data_link::DataLink;
pub use self::err::Error;
pub fn open_best_library() -> Result<Box<dyn Library>, Error> {
if let Ok(l) = pfring::Library::open_default_paths() {
return Ok(Box::new(l));
}
if let Ok(l) = wpcap::Library::open_default_paths() {
return Ok(Box::new(l));
}
match pcap::Library::open_default_paths() {
Ok(l) => Ok(Box::new(l)),
Err(e) => Err(e)
}
}
pub fn open_best_library_arc() -> Result<Arc<dyn Library>, Error> {
if let Ok(l) = pfring::Library::open_default_paths() {
return Ok(Arc::new(l));
}
if let Ok(l) = wpcap::Library::open_default_paths() {
return Ok(Arc::new(l));
}
match pcap::Library::open_default_paths() {
Ok(l) => Ok(Arc::new(l)),
Err(e) => Err(e)
}
}
#[derive(Copy, Clone, Debug)]
pub struct Stats {
pub received: u64,
pub dropped: u64
}