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

Link to this function

from_file(f, magic_number)

View Source

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.

Link to this function

read_forward(data, magic_number)

View Source

Specs

read_forward(binary(), ExPcap.MagicNumber.t()) :: t()

Reads a global header from a binary containing a pcap header (after the magic number)

Link to this function

read_reversed(data, magic_number)

View Source

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.

Link to this function

reverse_bytes?(global_header)

View Source

Specs

reverse_bytes?(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