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§
Source§impl EnhancedPacketBlock<'_>
impl EnhancedPacketBlock<'_>
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.