![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Abstract output destination for PCAPNG capture data. More...
#include <dfx-pcapng/sinks/Sink.hpp>
Public Member Functions | |
| Sink () noexcept=default | |
| Construct a sink. | |
| DISABLE_COPY_AND_MOVE (Sink) | |
| Sinks are not copyable and not movable. | |
| virtual | ~Sink ()=default |
| Virtual destructor for polymorphic use. | |
| virtual void | init (std::vector< uint8_t > initialHeader)=0 |
| Initialize the sink and write the initial PCAPNG header. | |
| void | setPoller (FdWatch::Poller *poller) |
| Provide a poller that the sink may use for event-driven I/O. | |
| virtual void | write (std::vector< uint8_t > data)=0 |
| Write serialized PCAPNG bytes to the sink. | |
Protected Attributes | |
| FdWatch::Poller * | _poller = nullptr |
| Borrowed poller pointer for event-driven sink implementations. | |
Abstract output destination for PCAPNG capture data.
Sink is the output abstraction used by the PCAPNG capture subsystem. A sink receives already-serialized PCAPNG bytes (produced by the capture writer/worker) and is responsible for delivering them to a destination such as:
Unlike a simple file-like API, a Sink may optionally integrate with the runtime I/O model through a FdWatch::Poller :
Replacing a sink typically means destroying the old sink and installing a new one, which will receive a fresh init() call with a fresh header.
|
defaultnoexcept |
Construct a sink.
The poller pointer is always null immediately after construction. It is only set later via setPoller().
|
virtualdefault |
Virtual destructor for polymorphic use.
| dfx::Pcapng::Sink::DISABLE_COPY_AND_MOVE | ( | Sink | ) |
Sinks are not copyable and not movable.
|
pure virtual |
Initialize the sink and write the initial PCAPNG header.
This method is called by the capture worker when the sink becomes active.
Important points:
| initialHeader | Serialized bytes that must be emitted first in the output stream (typically the Section Header Block and related initial blocks). |
Implemented in dfx::Pcapng::FileSink, dfx::Pcapng::PipeSink, and dfx::Pcapng::TcpSink.
|
inline |
Provide a poller that the sink may use for event-driven I/O.
Sinks that need non-blocking I/O can use this poller to register their own file descriptors for readiness notification.
| poller | Poller to use (borrowed). |
|
pure virtual |
Write serialized PCAPNG bytes to the sink.
| data | Serialized bytes to append to the capture stream. |
Called repeatedly after init().
The sink receives already-formed PCAPNG bytes (blocks or sequences of blocks) and must deliver them to the underlying destination.
Implementations may choose to:
Implemented in dfx::Pcapng::FileSink, dfx::Pcapng::PipeSink, and dfx::Pcapng::TcpSink.
|
protected |
Borrowed poller pointer for event-driven sink implementations.
Set by setPoller(). The pointer is null by default but will be non-null by the time init() / write() is called.