ExPcap.GlobalHeader (expcap v0.1.2) View Source
This module represents the global header of a pcap file.
Link to this section Summary
Functions
Reads the pcap global header (the bits after the magic number) and returns a struct containing the global header values. The code reads the bytes according to the order specified by the magic header.
Reads a global header from a binary containing a pcap header (after the magic number)
Reads a global header from a binary containing a pcap header (after the magic number) but it does so by reading the bytes in reverse order for each value. The magic number indicates the byte order for reading.
Returns true if the global header indicates that the bytes need to be reversed.
Link to this section Types
Specs
t() :: %ExPcap.GlobalHeader{ magic_number: ExPcap.MagicNumber.t(), network: non_neg_integer(), sigfigs: non_neg_integer(), snaplen: non_neg_integer(), thiszone: integer(), version_major: non_neg_integer(), version_minor: non_neg_integer() }
Link to this section Functions
Specs
from_file(IO.device(), ExPcap.MagicNumber.t()) :: t()
Reads the pcap global header (the bits after the magic number) and returns a struct containing the global header values. The code reads the bytes according to the order specified by the magic header.
Specs
read_forward(binary(), ExPcap.MagicNumber.t()) :: t()
Reads a global header from a binary containing a pcap header (after the magic number)
Specs
read_reversed(binary(), ExPcap.MagicNumber.t()) :: t()
Reads a global header from a binary containing a pcap header (after the magic number) but it does so by reading the bytes in reverse order for each value. The magic number indicates the byte order for reading.
Specs
Returns true if the global header indicates that the bytes need to be reversed.
Examples
iex> ExPcap.GlobalHeader.reverse_bytes?( %ExPcap.GlobalHeader{magic_number: %ExPcap.MagicNumber{reverse_bytes: false}})
false
iex> ExPcap.GlobalHeader.reverse_bytes?( %ExPcap.GlobalHeader{magic_number: %ExPcap.MagicNumber{reverse_bytes: true}})
true