Struct packet_header_t

Struct Documentation

struct libnokogiri::pcap::packet_header_t

The packet header for normal unmodified pcap file packets.

This structure represents the header that is prior to each block of packet data.

The packet headers have the following structure

 0               1               2               3
 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Seconds                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Microseconds                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Captured Length                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Full Packet Length                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

  • Seconds - An unsigned 32-bit unix timestamp when the packet was captured. This can be adjusted to GMT with the timezone offset in the file header.

  • Microseconds - An unsigned 32-bit value representing either the microseconds when the packet was captured if standard, or the nanoseconds when captured if using the modified format.

  • Captured Length - An unsigned 32-bit value representing the number of octets captured that have been saved to the file.

  • Full Packet Length - An unsigned 32-bit value representing the total number of octets in the packet.

Due to resource limitations, it is possible for a packet capture to not have the complete contents of the packet, therefore the packet headers keep track of how big the packet was, as well as how much of that was actually written to the capture.

Public Functions

constexpr packet_header_t() noexcept
constexpr packet_header_t(std::uint32_t timestamp, std::uint32_t useconds, std::uint32_t pkt_len_have, std::uint32_t pkt_len_actual) noexcept
packet_header_t(const packet_header_t&) = delete
packet_header_t &operator=(const packet_header_t&) = delete
packet_header_t(packet_header_t&&) = default
packet_header_t &operator=(packet_header_t&&) = default
std::uint32_t timestamp() const noexcept

Retrieve the packets timestamp

void timestamp(const std::uint32_t timestamp) noexcept

Set the packet timestamp

std::uint32_t useconds() const noexcept

Retrieve the micro/nano second value for the packet

void useconds(const std::uint32_t useconds) noexcept

Set the micro/nano second value for the packet

std::uint32_t captured_len() const noexcept

Retrieve the captured length of the packet

void captured_len(const std::uint32_t captured_len) noexcept

Set the captured length of the packet

std::uint32_t actual_len() const noexcept

Retrieve the actual length of the packet

void actual_len(const std::uint32_t actual_len) noexcept

Set the actual length of the packet

bool full_packet() const noexcept

Checks if the packet represented by this header is a full packet