ExPcap.GlobalHeader

This module represents the global header of a pcap file.

Source

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

from_file(f, magic_number)

Specs:

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.

Source
read_forward(data, magic_number)

Specs:

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

Source
read_reversed(data, magic_number)

Specs:

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.

Source
reverse_bytes?(global_header)

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
Source