Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadPcapFile ¶
func ReadPcapFile(filename string) (reader gopacket.PacketDataSource, ioReader io.ReadCloser, deleteFile bool, deleteFileName string)
ReadPcapFile reads a pcap/pcapng file from filename. This file can optionally be zipped.
Returns an instance of NgReader to read the pcap. Also returns an io.ReadCloser which must be closed after the file has been read. file is not nil for zipped file. If it is not nil, the caller must close it.
Types ¶
type PacketReader ¶
type PacketReader struct { PacketIdx int64 FirstPacketTimestamp int64 LastPacketTimestamp int64 // contains filtered or unexported fields }
PacketReader reads from a source. Is responsible for forwarding packets to the parser, as well as keeping track of the number of Packet, as well as flushing the pool in regular intervals.
func NewPacketReader ¶
func NewPacketReader(pools *pool.Pools, packetParser *parser.Parser) *PacketReader
NewPacketReader creates a new PacketReader.
func (*PacketReader) Read ¶
func (p *PacketReader) Read(packetStop, flushRate int64, packetDataSource gopacket.PacketDataSource) bool
Read more packets from the provided source. Will stop either when the source is depleted or when the specified number of packets have been read. Use first return value of ReadPCAPFile to read a pcap file. flushRate specifies the time in nanoseconds after which pools will be flushed. Flushing the pool is necessary to remove timedout flows from the pool and to keep memory footprint low.
Returns whether the specified number of packets have been read