ExPcap.GlobalHeader
This module represents the global header of a pcap file.
Summary↑
from_file(f, magic_number) | 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 |
read_forward(data, magic_number) | Reads a global header from a binary containing a pcap header (after the magic number) |
read_reversed(data, 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 |
reverse_bytes?(global_header) | Returns true if the global header indicates that the bytes need to be reversed |
Types ↑
t :: %ExPcap.GlobalHeader{magic_number: ExPcap.MagicNumber.t, version_major: non_neg_integer, version_minor: non_neg_integer, thiszone: integer, sigfigs: non_neg_integer, snaplen: non_neg_integer, network: non_neg_integer}
Functions
Specs:
- from_file(IO.device, ExPcap.MagicNumber.t) :: ExPcap.GlobalHeader.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) :: ExPcap.GlobalHeader.t
Reads a global header from a binary containing a pcap header (after the magic number)
Specs:
- read_reversed(binary, ExPcap.MagicNumber.t) :: ExPcap.GlobalHeader.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:
- reverse_bytes?(ExPcap.GlobalHeader.t) :: boolean
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