mpcap

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 4 Imported by: 0

README

Implementation of PCAP Capture File Format

See https://www.ietf.org/archive/id/draft-gharris-opsawg-pcap-01.html

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter creates a new PCAP Writer that writes to the given io.Writer.

func (*Writer) WriteHeader

func (pw *Writer) WriteHeader(snaplen int) error

WriteHeader writes a global header block to the pcap file.

The global header block contains metadata about the capture, such as the timestamp format and the maximum packet length.

See https://wiki.wireshark.org/Development/LibpcapFileFormat for more information about the pcap file format.

func (*Writer) WritePacket

func (pw *Writer) WritePacket(timestamp time.Time, data []byte) error

WritePacket writes a packet to the pcap file.

The packet is written as a packet header plus the packet data. The timestamp is written as the number of seconds since the epoch, and the packet data is written as a sequence of bytes of the length specified in the packet header.

See https://wiki.wireshark.org/Development/LibpcapFileFormat for more information about the pcap file format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL