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§

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.

Writes a PcapHeader to a writer.

Uses the endianness of the header.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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
};
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.