Documentation ¶
Overview ¶
Package pcapng provides support for reading packets from PCAP-NG file. See https://github.com/pcapng/pcapng for information of the file format.
Made to be compatible with https://github.com/google/gopacket/pcapgo
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPerPacketEncap = errors.New("doesn't support per-packet encapsulations")
ErrPerPacketEncap is the error returned by ReadPacketData when packets have different link types (link type of current packet is different from previous packets)
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps io.Reader to read packet data in PCAPNG format. If the PCAPNG data is gzip compressed it is transparently uncompressed by wrapping the given io.Reader with a gzip.Reader.
func NewReader ¶
NewReader returns a new reader object, for reading packet data from the given reader. The reader must be open and must contain as first block - Section Header Block and Interface Description Block before any packet block. If the file format is not supported an error is returned
// Create new reader: f, _ := os.Open("file.pcapng") defer f.Close() r, err := NewReader(f) data, ci, err := r.ReadPacketData()
func (*Reader) ReadPacketData ¶
func (r *Reader) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error)
ReadPacketData read until get packet block (any of EPB, SPB or PB). If get SHB or IDB, process it and continue to read. Skip any other block types. If packets have different link type return error ErrPerPacketEncap.