Documentation
¶
Overview ¶
Package pcap implements reader and writer for the pcap file format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct { // SnapLen is the snapshot length used for capturing each packet. // The Packet.Data length must not exceed this value. SnapLen int // LinkType specifies the type of each Packet.Data. LinkType LinkType }
Header contains information from the pcap stream header.
type Packet ¶
type Packet struct { // Timestamp is the timestamp of the packet. Timestamp time.Time // OrigLen is the original packet length. // Due to a smaller Header.SnapLen, the Data may be truncated. OrigLen int // Data is the captured contents of the packet, // where the type is determined by Header.LinkType. // Its length may be less than OrigLen if truncated and // must not exceed Header.SnapLen. Data []byte }
Packet describes a captured packet.
type Reader ¶
type Reader struct { Header // must not be modified // contains filtered or unexported fields }
Reader implements a streaming pcap reader.
func NewReader ¶
NewReader parses the pcap header and returns a Reader that parses each subsequent packet after the header.
The first call to Reader.ReadNext allocates a buffer proportional to Header.SnapLen, which may be arbitrarily large. It is the caller's responsibility to check whether the amount of memory needed is reasonable.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements a streaming pcap writer.
Click to show internal directories.
Click to hide internal directories.