![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
PCAPNG sink that writes capture bytes to a file. More...
#include <dfx-pcapng/sinks/FileSink.hpp>
Public Member Functions | |
| FileSink (fs::path const &path, bool truncate=true) | |
Create a file sink targeting path. | |
| void | init (std::vector< uint8_t > initialHeader) override |
| Initialize the sink by writing the initial PCAPNG header. | |
| void | write (std::vector< uint8_t > data) override |
| Append serialized PCAPNG bytes to the output file. | |
| Public Member Functions inherited from dfx::Pcapng::Sink | |
| 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. | |
| void | setPoller (FdWatch::Poller *poller) |
| Provide a poller that the sink may use for event-driven I/O. | |
Additional Inherited Members | |
| Protected Attributes inherited from dfx::Pcapng::Sink | |
| FdWatch::Poller * | _poller = nullptr |
| Borrowed poller pointer for event-driven sink implementations. | |
PCAPNG sink that writes capture bytes to a file.
FileSink is a concrete Sink implementation that persists a PCAPNG capture stream to a filesystem path using a binary std::ofstream.
A more optimal solution than std::ofstream may be implemented in a future revision.
Key behaviors:
This sink does not rely on FdWatch::Poller; it performs synchronous writes from the capture worker thread.
| dfx::Pcapng::FileSink::FileSink | ( | fs::path const & | path, |
| bool | truncate = true ) |
Create a file sink targeting path.
| path | Output file path. |
| truncate | If true, truncate/overwrite the file. If false, append. |
| dfx::Utils::Exception | Thrown if parent directory creation fails or if the file cannot be opened. |
|
overridevirtual |
Initialize the sink by writing the initial PCAPNG header.
FileSink implements initialization by immediately writing initialHeader to the output stream.
| initialHeader | Serialized PCAPNG header bytes to write first. |
Implements dfx::Pcapng::Sink.
|
overridevirtual |
Append serialized PCAPNG bytes to the output file.
Writes data to the underlying file stream as raw bytes.
| data | Bytes to write. |
Implements dfx::Pcapng::Sink.