ExPcap.MagicNumber (expcap v0.1.2) View Source

This module represents a 'magic number' from a pcap header. The magic number not only contains a known value, but the value indicates the order in which bytes should be read AND whether or not datetimes use milliseconds or nanoseconds.

Link to this section Summary

Functions

Returns the number of bytes contained in the magic number.

Reads the magic number from the file passed in.

Returns a magic number that indicates that the bytes need to be reversed when read and that datetimes are in nanoseconds.

This reads the bytes of the magic number and matches them with the appropriate interpretation of the magic number.

Link to this section Types

Specs

t() :: %ExPcap.MagicNumber{
  magic: non_neg_integer(),
  nanos: boolean(),
  reverse_bytes: boolean()
}

Link to this section Functions

Specs

bytes_in_magic() :: non_neg_integer()

Returns the number of bytes contained in the magic number.

Specs

from_file(IO.device()) :: t()

Reads the magic number from the file passed in.

Link to this function

magic_number(int1, int2, int3, int4)

View Source

Specs

magic_number(212, 195, 178, 161) :: t()
magic_number(161, 178, 195, 212) :: t()
magic_number(161, 178, 60, 77) :: t()
magic_number(77, 60, 178, 161) :: t()

Returns a magic number that indicates that the bytes need to be reversed when read and that datetimes are in nanoseconds.

Specs

read_magic(binary()) :: t()

This reads the bytes of the magic number and matches them with the appropriate interpretation of the magic number.