Struct pcap_file::pcap::PcapHeader
source · pub struct PcapHeader {
pub version_major: u16,
pub version_minor: u16,
pub ts_correction: i32,
pub ts_accuracy: u32,
pub snaplen: u32,
pub datalink: DataLink,
pub ts_resolution: TsResolution,
pub endianness: Endianness,
}
Expand description
Pcap Global Header
Fields§
§version_major: u16
Major version number
version_minor: u16
Minor version number
ts_correction: i32
GMT to local timezone correction, should always be 0
ts_accuracy: u32
Timestamp accuracy, should always be 0
snaplen: u32
Max length of captured packet, typically 65535
datalink: DataLink
DataLink type (first layer in the packet)
ts_resolution: TsResolution
Timestamp resolution of the pcap (microsecond or nanosecond)
endianness: Endianness
Endianness of the pcap (excluding the packet data)
Implementations§
source§impl PcapHeader
impl PcapHeader
sourcepub fn from_slice(slice: &[u8]) -> PcapResult<(&[u8], PcapHeader)>
pub fn from_slice(slice: &[u8]) -> PcapResult<(&[u8], PcapHeader)>
Creates a new PcapHeader
from a slice of bytes.
Returns an error if the reader doesn’t contain a valid pcap or if there is a reading error.
PcapError::IncompleteBuffer
indicates that there is not enough data in the buffer.
sourcepub fn write_to<W: Write>(&self, writer: &mut W) -> PcapResult<usize>
pub fn write_to<W: Write>(&self, writer: &mut W) -> PcapResult<usize>
Writes a PcapHeader
to a writer.
Uses the endianness of the header.
Trait Implementations§
source§impl Clone for PcapHeader
impl Clone for PcapHeader
source§fn clone(&self) -> PcapHeader
fn clone(&self) -> PcapHeader
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PcapHeader
impl Debug for PcapHeader
source§impl Default for PcapHeader
impl Default for PcapHeader
Creates a new PcapHeader
with these parameters:
ⓘ
PcapHeader {
version_major: 2,
version_minor: 4,
ts_correction: 0,
ts_accuracy: 0,
snaplen: 65535,
datalink: DataLink::ETHERNET,
ts_resolution: TsResolution::MicroSecond,
endianness: Endianness::Big
};
source§impl PartialEq<PcapHeader> for PcapHeader
impl PartialEq<PcapHeader> for PcapHeader
source§fn eq(&self, other: &PcapHeader) -> bool
fn eq(&self, other: &PcapHeader) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.