Documentation ¶
Overview ¶
Package merger is the core logic of ddump. It handles extracting captured packets from an unlimitted number of readable input streams. The input streams are assumed to be in the "Linux cooked" (SLL) capture format. This format guarantees that captures from interfaces of various types like wlan and ethernet can be mixed in a single merged stream.
While the package is meant as the core of ddump, it is completely generic and only exposes standard types like io.Writer and io.ReadCloser making it suitable for inclusion in arbitrary packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PcapStreamMerger ¶
type PcapStreamMerger struct {
// contains filtered or unexported fields
}
PcapStreamMerger encapsultes the logic behind merging input streams
func NewPcapStreamMerger ¶
func NewPcapStreamMerger(outStream io.Writer) *PcapStreamMerger
NewPcapStreamMerger builds a new stream merger for writing merged streams to outStream. Initially, the stream merger does not contain any streams; use Add() to register new input streams.
func (*PcapStreamMerger) Add ¶
func (m *PcapStreamMerger) Add(inStream io.ReadCloser)
Add registers a new stream in the merger. Under the hood, this function starts to consume packets from the input stream.
The internal packet copy routine exits on error or when Close() has been called.
func (*PcapStreamMerger) Close ¶
func (m *PcapStreamMerger) Close()
Close signals the merger to stop its processing. The actual stop occures in the background. It will drain the any pending packets to avoid resource leaks. Then, the Start function will return.
func (*PcapStreamMerger) Start ¶
func (m *PcapStreamMerger) Start() error
Start writes the pcap "SLL" header to the configured output stream and then starts the fan-in of the packets provided by the input streams.
This function is synchronous and returns when all input streams have been merged or Close() has been called to request an early exit.