![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Background capture worker responsible for PCAPNG serialization and sink I/O. More...
#include <dfx-pcapng/Worker.hpp>
Classes | |
| struct | QueueData |
| One capture item describing a message event and its context. More... | |
| struct | SinkData |
| Sink storage and "new sink" marker for hot swapping. More... | |
Public Types | |
| enum | SinkIndex : std::size_t { File , Pipe , Tcp , Count } |
| Index of supported sinks. More... | |
Public Member Functions | |
| Worker (bool getHwAndOsInfo) | |
| Construct and start the worker thread. | |
| ~Worker () | |
| Stop the worker thread and release all resources. Ensures the thread is terminated and the poller/timers are destroyed in a safe order. | |
| void | setFileSink (SinkPtr fileSink) |
| Install or replace the file sink. | |
| void | setPipeSink (SinkPtr pipeSink) |
| Install or replace the pipe sink. | |
| void | setTcpSink (SinkPtr tcpSink) |
| Install or replace the TCP sink. | |
| void | pushData (QueueData data) |
| Push a capture item into the worker queue. | |
| void | setUserAppInfo (std::string info) |
| Set application-specific information to embed into capture metadata. | |
| void | clearHwAndOsInfo () noexcept |
| Disable (or remove) hardware/OS metadata in the capture output. This only affects metadata emission; it does not stop the worker. | |
Background capture worker responsible for PCAPNG serialization and sink I/O.
Worker is the internal engine behind PCAPNG capture. It decouples hook callbacks (which may be invoked from runtime threads) from:
The worker owns a dedicated thread and an internal epoll-based poller. Producers push capture items via pushData(), and the worker thread drains and serializes them.
The worker maintains a map of "pending" items keyed by UUID. This enables deferred completion/cleanup behaviors (for example correlating parts of an event stream, or expiring items that did not complete in time).
| enum dfx::Pcapng::Worker::SinkIndex : std::size_t |
Index of supported sinks.
A worker can write to several sinks at once. Each sink is optional.
| Enumerator | |
|---|---|
| File | File output (offline capture). See FileSink. |
| Pipe | Pipe output (live capture into another process). See PipeSink. |
| Tcp | TCP output (stream capture to a remote consumer). See TcpSink. |
| Count | Number of sink slots. |
| dfx::Pcapng::Worker::Worker | ( | bool | getHwAndOsInfo | ) |
Construct and start the worker thread.
| getHwAndOsInfo | If true, hardware/OS information is collected and may be embedded in the capture output. |
| dfx::Pcapng::Worker::~Worker | ( | ) |
Stop the worker thread and release all resources. Ensures the thread is terminated and the poller/timers are destroyed in a safe order.
|
noexcept |
Disable (or remove) hardware/OS metadata in the capture output. This only affects metadata emission; it does not stop the worker.
| void dfx::Pcapng::Worker::pushData | ( | QueueData | data | ) |
Push a capture item into the worker queue.
Thread-safe producer API. Enqueues data and signals the worker so it can drain the queue promptly.
| data | Capture item to enqueue. |
| void dfx::Pcapng::Worker::setFileSink | ( | SinkPtr | fileSink | ) |
Install or replace the file sink.
Safe to call from any thread. The worker will detect the new sink and handle transition/initialization in its thread context.
| fileSink | New sink instance (may be null to disable). |
| void dfx::Pcapng::Worker::setPipeSink | ( | SinkPtr | pipeSink | ) |
Install or replace the pipe sink.
Safe to call from any thread. The worker will detect the new sink and handle transition/initialization in its thread context.
| pipeSink | New sink instance (may be null to disable). |
| void dfx::Pcapng::Worker::setTcpSink | ( | SinkPtr | tcpSink | ) |
Install or replace the TCP sink.
Safe to call from any thread. The worker will detect the new sink and handle transition/initialization in its thread context.
| tcpSink | New sink instance (may be null to disable). |
| void dfx::Pcapng::Worker::setUserAppInfo | ( | std::string | info | ) |
Set application-specific information to embed into capture metadata.
| info | Free-form string (scenario name, build id, test name, etc.). |