Struct pcap_parser::pcapng::EnhancedPacketBlock
source · [−]pub struct EnhancedPacketBlock<'a> {
pub block_type: u32,
pub block_len1: u32,
pub if_id: u32,
pub ts_high: u32,
pub ts_low: u32,
pub caplen: u32,
pub origlen: u32,
pub data: &'a [u8],
pub options: Vec<PcapNGOption<'a>>,
pub block_len2: u32,
}
Expand description
An Enhanced Packet Block (EPB) is the standard container for storing the packets coming from the network.
This struct is a thin abstraction layer, and stores the raw block data.
For ex the data
field is stored with the padding.
It implements the PcapNGPacketBlock
trait, which provides helper functions.
Examples
use pcap_parser::pcapng::parse_enhancedpacketblock_le;
use pcap_parser::traits::PcapNGPacketBlock;
let (i, epb) = parse_enhancedpacketblock_le(pcap_data).unwrap();
let packet_data = epb.packet_data();
if packet_data.len() < epb.orig_len() as usize {
// packet was truncated
} else {
// we have a full packet
}
Fields
block_type: u32
block_len1: u32
if_id: u32
ts_high: u32
ts_low: u32
caplen: u32
Captured packet length
origlen: u32
Original packet length
data: &'a [u8]
Raw data from packet (with padding)
options: Vec<PcapNGOption<'a>>
block_len2: u32
Implementations
sourceimpl<'a> EnhancedPacketBlock<'a>
impl<'a> EnhancedPacketBlock<'a>
sourcepub fn decode_ts(&self, ts_offset: u64, resolution: u64) -> (u32, u32)
pub fn decode_ts(&self, ts_offset: u64, resolution: u64) -> (u32, u32)
Decode the packet timestamp
To decode the timestamp, the raw values if_tsresol and if_tsoffset are required.
These values are stored as options in the InterfaceDescriptionBlock
matching the interface ID.
Return the timestamp seconds and fractional part (in resolution units)
sourcepub fn decode_ts_f64(&self, ts_offset: u64, resolution: u64) -> f64
pub fn decode_ts_f64(&self, ts_offset: u64, resolution: u64) -> f64
Decode the packet timestamp as f64
To decode the timestamp, the resolution and offset are required.
These values are stored as options in the InterfaceDescriptionBlock
matching the interface ID.
Trait Implementations
sourceimpl<'a> Debug for EnhancedPacketBlock<'a>
impl<'a> Debug for EnhancedPacketBlock<'a>
sourceimpl<'a> PcapNGPacketBlock for EnhancedPacketBlock<'a>
impl<'a> PcapNGPacketBlock for EnhancedPacketBlock<'a>
sourcefn big_endian(&self) -> bool
fn big_endian(&self) -> bool
Return true if block is encoded as big-endian
sourcefn truncated(&self) -> bool
fn truncated(&self) -> bool
Return true if block data was truncated (typically when snaplen < origlen)
sourceimpl<'a> ToVec for EnhancedPacketBlock<'a>
Available on crate feature serialize
only.
impl<'a> ToVec for EnhancedPacketBlock<'a>
serialize
only.Auto Trait Implementations
impl<'a> RefUnwindSafe for EnhancedPacketBlock<'a>
impl<'a> Send for EnhancedPacketBlock<'a>
impl<'a> Sync for EnhancedPacketBlock<'a>
impl<'a> Unpin for EnhancedPacketBlock<'a>
impl<'a> UnwindSafe for EnhancedPacketBlock<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more